Skip to content

Commit 20cd7a4

Browse files
authored
fix(link): apply underlined styles (#911)
1 parent 2790042 commit 20cd7a4

File tree

5 files changed

+31
-9
lines changed

5 files changed

+31
-9
lines changed

.size-snapshot.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"dist/ui-kit.esm.js": {
3-
"bundled": 874809,
4-
"minified": 600844,
5-
"gzipped": 122315,
3+
"bundled": 882007,
4+
"minified": 604581,
5+
"gzipped": 123515,
66
"treeshaked": {
77
"rollup": {
8-
"code": 428635,
8+
"code": 431686,
99
"import_statements": 893
1010
},
1111
"webpack": {
12-
"code": 455406
12+
"code": 458492
1313
}
1414
}
1515
}

src/components/links/link/README.md

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,11 @@ Links are used either to link to other ui routes, or to link to external pages.
2626

2727
#### Properties
2828

29-
| Props | Type | Required | Values | Default | Description |
30-
| ------------ | ----------------------------------------------------------------- | :------: | ------ | ------- | --------------------------------------------------------------------------- |
31-
| `to` | `string` or `{ pathname: String, search: String, query: Object }` || - | - | The URL that the Link should point to |
32-
| `isExternal` | `boolean` | - | - | false | If true, a regular <a> is rendered instead of the default React Router Link |
29+
| Props | Type | Required | Values | Default | Description |
30+
| -------------- | ----------------------------------------------------------------- | :------: | ------ | ------- | --------------------------------------------------------------------------- |
31+
| `to` | `string` or `{ pathname: String, search: String, query: Object }` || - | - | The URL that the Link should point to |
32+
| `isExternal` | `boolean` | - | - | false | If true, a regular <a> is rendered instead of the default React Router Link |
33+
| `hasUnderline` | `boolean` | - | - | true | Either sets text-decoration to none or to underline |
3334

3435
The component further forwards all remaining props to the underlying component. The external link includes `target="_blank"` and `rel="noopener noreferrer"` by default.
3536

src/components/links/link/link.js

+4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ const getLinkStyles = (props, theme) => {
1111
...vars,
1212
...theme,
1313
};
14+
1415
return css`
1516
font-family: ${overwrittenVars.fontFamilyDefault};
1617
color: ${overwrittenVars.colorPrimary};
1718
font-size: ${overwrittenVars.fontSizeDefault};
19+
text-decoration: ${props.hasUnderline ? 'underline' : 'none'};
1820
1921
&:hover,
2022
&:focus,
@@ -53,6 +55,7 @@ const Link = props => {
5355
Link.displayName = 'Link';
5456

5557
Link.propTypes = {
58+
hasUnderline: PropTypes.bool.isRequired,
5659
isExternal: PropTypes.bool.isRequired,
5760
to: requiredIf(
5861
PropTypes.oneOfType([
@@ -69,6 +72,7 @@ Link.propTypes = {
6972
};
7073

7174
Link.defaultProps = {
75+
hasUnderline: true,
7276
isExternal: false,
7377
};
7478

src/components/links/link/link.story.js

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ storiesOf('Components|Links', module)
1919
<Section>
2020
<Link
2121
to={text('to', '/foo/bar')}
22+
hasUnderline={boolean('hasUnderline', true)}
2223
isExternal={boolean('isExternal', false)}
2324
>
2425
{text('label', 'Accessibility text')}

src/components/links/link/link.visualroute.js

+16
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import React from 'react';
22
import { Link } from 'ui-kit';
3+
import { ThemeProvider } from 'emotion-theming';
34
import { Suite, Spec } from '../../../../test/percy';
45

56
export const routePath = '/link';
67

8+
const purpleTheme = {
9+
colorPrimary: 'purple',
10+
colorPrimary25: 'deeppurple',
11+
};
12+
713
export const component = () => (
814
<Suite>
915
<Spec label="regular">
@@ -14,5 +20,15 @@ export const component = () => (
1420
A label text
1521
</Link>
1622
</Spec>
23+
<Spec label="without underline">
24+
<Link to="/" hasUnderline={false}>
25+
A label text
26+
</Link>
27+
</Spec>
28+
<ThemeProvider theme={purpleTheme}>
29+
<Spec label="with custom theme">
30+
<Link to="/">A label text</Link>
31+
</Spec>
32+
</ThemeProvider>
1733
</Suite>
1834
);

0 commit comments

Comments
 (0)