Skip to content

Commit c71dadb

Browse files
authored
Merge pull request #27 from input-output-hk/feat/lw-10645-improve-text-link-component
feat: add limited px prop to text link component [LW-10645]
2 parents 53c63db + f9150cf commit c71dadb

File tree

3 files changed

+41
-29
lines changed

3 files changed

+41
-29
lines changed

src/design-system/text-link/text-link.component.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22

33
import classNames from 'classnames';
44

5+
import { spacing } from '../../design-tokens';
56
import { Flex } from '../flex';
67
import { Text } from '../text';
78

@@ -12,10 +13,12 @@ import type { OmitClassName } from '../../types';
1213
export type Props = OmitClassName<'a'> & {
1314
disabled?: boolean;
1415
label?: string;
16+
px?: keyof typeof spacing;
1517
};
1618

1719
export const TextLink = ({
1820
disabled = false,
21+
px = '$8',
1922
label,
2023
...props
2124
}: Readonly<Props>): JSX.Element => {
@@ -26,6 +29,7 @@ export const TextLink = ({
2629
className={classNames(cx.button, cx.container)}
2730
alignItems="center"
2831
justifyContent="center"
32+
px={px}
2933
>
3034
<Flex alignItems="center" justifyContent="center">
3135
<Text.Button

src/design-system/text-link/text-link.css.ts

+22-27
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1-
import { sx, style, vars, createVar, globalStyle } from '../../design-tokens';
1+
import { style, vars, createVar, globalStyle } from '../../design-tokens';
22

33
export const button = style({});
44

55
export const borderGap = createVar();
66

7-
export const container = style([
8-
sx({
9-
px: '$8',
10-
}),
11-
{
12-
border: 'none',
13-
outline: 'none',
14-
position: 'relative',
15-
zIndex: 1,
16-
cursor: 'pointer',
17-
display: 'inline-flex',
18-
19-
vars: {
20-
[borderGap]: '2px',
21-
},
7+
export const container = style({
8+
border: 'none',
9+
outline: 'none',
10+
position: 'relative',
11+
zIndex: 1,
12+
cursor: 'pointer',
13+
display: 'inline-flex',
2214

23-
selectors: {
24-
'&[aria-disabled="true"]': {
25-
opacity: vars.opacities.$0_24,
26-
},
15+
vars: {
16+
[borderGap]: '2px',
17+
},
2718

28-
'&:focus:not(:active)': {
29-
outlineColor: `${vars.colors.$buttons_secondary_container_outlineColor}`,
30-
outlineWidth: vars.spacing.$4,
31-
outlineStyle: 'solid',
32-
borderRadius: vars.spacing.$4,
33-
},
19+
selectors: {
20+
'&[aria-disabled="true"]': {
21+
opacity: vars.opacities.$0_24,
22+
},
23+
24+
'&:focus:not(:active)': {
25+
outlineColor: `${vars.colors.$buttons_secondary_container_outlineColor}`,
26+
outlineWidth: vars.spacing.$4,
27+
outlineStyle: 'solid',
28+
borderRadius: vars.spacing.$4,
3429
},
3530
},
36-
]);
31+
});
3732

3833
export const label = style([
3934
{

src/design-system/text-link/text-link.stories.tsx

+15-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { Meta } from '@storybook/react';
44

55
import { Variants, Section, page, UIStateTable } from '../decorators';
66
import { Grid, Cell } from '../grid';
7+
import { Text } from '../text';
78

89
import { TextLink } from './text-link.component';
910

@@ -15,7 +16,7 @@ export default {
1516
decorators: [page({ title: 'Text Link', subtitle })],
1617
} as Meta;
1718

18-
const Buttons = (): JSX.Element => (
19+
const TextLinkExamples = (): JSX.Element => (
1920
<>
2021
<Variants.Row>
2122
<Variants.Cell>
@@ -69,10 +70,22 @@ export const Overview = (): JSX.Element => (
6970
<Cell>
7071
<Section title="Main components">
7172
<UIStateTable>
72-
<Buttons />
73+
<TextLinkExamples />
7374
</UIStateTable>
7475
</Section>
7576
</Cell>
77+
<Cell>
78+
<Section title="Usage Examples">
79+
<Text.Body.Normal>
80+
This is an example of a text link in the
81+
<TextLink px="$4" label="middle" />
82+
of a text using horizontal padding (default).
83+
</Text.Body.Normal>
84+
</Section>
85+
</Cell>
86+
<Cell>
87+
<TextLink px="$0" label="Example without horizontal padding" />
88+
</Cell>
7689
</Grid>
7790
);
7891

0 commit comments

Comments
 (0)