Skip to content

Commit e92fca6

Browse files
Merge pull request #358 from ZEISS/bugfix/357-iconlink-color-style
Bugfix/357 Fix `IconLink` without label color style
2 parents 528222a + 69476e7 commit e92fca6

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 2.1.4
44

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

78
## 2.1.3
89

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ A complete opinionated React component library with minimal dependencies powered
1212

1313
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.
1414

15-
See [https://precise-ui.io](https://precise-ui.io) for our kitchen sink (i.e., demo page illustrating all the components incl. their documentation).
15+
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).
1616

1717
## Getting Started
1818

@@ -50,7 +50,7 @@ import { TextField } from 'precise-ui';
5050
<TextField label="Label" />
5151
```
5252

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

5555
## Contributing
5656

492 Bytes
Loading

src/components/IconLink/Example.md

+8
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ const { IconLink } = require('precise-ui');
2525
This link is <IconLink block icon="Cached">Refresh</IconLink> displayed as a block and this is <IconLink disabled icon="VisibilityOff">disabled</IconLink>
2626
</div>
2727
```
28+
29+
`IconLink` can be also displayed as an interactive component.
30+
31+
```jsx
32+
const { IconLink } = require('precise-ui');
33+
34+
<IconLink icon="Add" href="#🎩" isInteractiveIcon={true}/>
35+
```

src/components/IconLink/index.tsx

+23-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ export interface IconLinkProps extends AnchorProps {
1515
* The name of the icon to display.
1616
*/
1717
icon: IconName;
18+
/**
19+
* Controls the icon's color style.
20+
* If `true`, the icon will be colored with the theme's `ui0` color.
21+
* Otherwise, it will be colored in `ui0` only if the `IconLink` has children.
22+
* If set to `false` and the `IconLink` has no children, the icon will be colored in `ui5`.
23+
*/
24+
isInteractiveIcon?: boolean;
1825
}
1926

2027
export interface StyledAnchorProps {
@@ -70,11 +77,25 @@ const AnchorText = styled.span`
7077
/**
7178
* The icon link component shows an icon with optional text.
7279
*/
73-
export const IconLink: React.SFC<IconLinkProps> = ({ icon, theme, disabled, children, block, ...other }) => {
80+
export const IconLink: React.SFC<IconLinkProps> = ({
81+
icon,
82+
theme,
83+
disabled,
84+
children,
85+
block,
86+
isInteractiveIcon,
87+
...other
88+
}) => {
7489
return (
7590
<StyledAnchor disabled={disabled} display={block ? 'block' : 'inline-block'} {...other}>
7691
{icon && (
77-
<StyledIcon disabled={disabled} iconOnly={children ? false : true} name={icon} theme={theme} size={'22px'} />
92+
<StyledIcon
93+
disabled={disabled}
94+
iconOnly={isInteractiveIcon ? false : !children}
95+
name={icon}
96+
theme={theme}
97+
size={'22px'}
98+
/>
7899
)}
79100
{children && <AnchorText>{children}</AnchorText>}
80101
</StyledAnchor>

0 commit comments

Comments
 (0)