Skip to content

Commit

Permalink
Merge pull request #358 from ZEISS/bugfix/357-iconlink-color-style
Browse files Browse the repository at this point in the history
Bugfix/357 Fix `IconLink` without label color style
  • Loading branch information
klaidigorishti authored Jan 24, 2022
2 parents 528222a + 69476e7 commit e92fca6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 2.1.4

- Updated `Highlight` component to have optional highlight prop (#280)
- Fix `IconLink` without label color style (#357)

## 2.1.3

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A complete opinionated React component library with minimal dependencies powered

The UI component library contains both, very low-level design elements as well as combined high-level design elements. In general, the intention of the library is to simplify development by exposing components that satisfy design specifications and provide ease of programming. Repeatable UI designs should therefore only take minutes instead of hours.

See [https://precise-ui.io](https://precise-ui.io) for our kitchen sink (i.e., demo page illustrating all the components incl. their documentation).
See [https://precise-ui.io](https://www.precise-ui.io) for our kitchen sink (i.e., demo page illustrating all the components incl. their documentation).

## Getting Started

Expand Down Expand Up @@ -50,7 +50,7 @@ import { TextField } from 'precise-ui';
<TextField label="Label" />
```

You can see a list of all available components on our [website](https://precise-ui.io/).
You can see a list of all available components on our [website](https://www.precise-ui.io/).

## Contributing

Expand Down
Binary file added integration/__image_snapshots__/IconLink_7-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/components/IconLink/Example.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ const { IconLink } = require('precise-ui');
This link is <IconLink block icon="Cached">Refresh</IconLink> displayed as a block and this is <IconLink disabled icon="VisibilityOff">disabled</IconLink>
</div>
```

`IconLink` can be also displayed as an interactive component.

```jsx
const { IconLink } = require('precise-ui');

<IconLink icon="Add" href="#🎩" isInteractiveIcon={true}/>
```
25 changes: 23 additions & 2 deletions src/components/IconLink/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ export interface IconLinkProps extends AnchorProps {
* The name of the icon to display.
*/
icon: IconName;
/**
* Controls the icon's color style.
* If `true`, the icon will be colored with the theme's `ui0` color.
* Otherwise, it will be colored in `ui0` only if the `IconLink` has children.
* If set to `false` and the `IconLink` has no children, the icon will be colored in `ui5`.
*/
isInteractiveIcon?: boolean;
}

export interface StyledAnchorProps {
Expand Down Expand Up @@ -70,11 +77,25 @@ const AnchorText = styled.span`
/**
* The icon link component shows an icon with optional text.
*/
export const IconLink: React.SFC<IconLinkProps> = ({ icon, theme, disabled, children, block, ...other }) => {
export const IconLink: React.SFC<IconLinkProps> = ({
icon,
theme,
disabled,
children,
block,
isInteractiveIcon,
...other
}) => {
return (
<StyledAnchor disabled={disabled} display={block ? 'block' : 'inline-block'} {...other}>
{icon && (
<StyledIcon disabled={disabled} iconOnly={children ? false : true} name={icon} theme={theme} size={'22px'} />
<StyledIcon
disabled={disabled}
iconOnly={isInteractiveIcon ? false : !children}
name={icon}
theme={theme}
size={'22px'}
/>
)}
{children && <AnchorText>{children}</AnchorText>}
</StyledAnchor>
Expand Down

0 comments on commit e92fca6

Please sign in to comment.