diff --git a/playwright/visual.test.ts-snapshots/Link-Small-1-chromium-linux.png b/playwright/visual.test.ts-snapshots/Link-Small-1-chromium-linux.png new file mode 100644 index 00000000..49f4952a Binary files /dev/null and b/playwright/visual.test.ts-snapshots/Link-Small-1-chromium-linux.png differ diff --git a/src/components/Link/Link.module.css b/src/components/Link/Link.module.css index d33b56e6..07af097c 100644 --- a/src/components/Link/Link.module.css +++ b/src/components/Link/Link.module.css @@ -52,3 +52,7 @@ limitations under the License. .link[data-kind="critical"]:active { background: var(--cpd-color-text-critical-primary); } + +.link[data-size="small"] { + font-size: var(--cpd-font-size-body-sm); +} diff --git a/src/components/Link/Link.stories.tsx b/src/components/Link/Link.stories.tsx index 6f67db7b..c32c62d0 100644 --- a/src/components/Link/Link.stories.tsx +++ b/src/components/Link/Link.stories.tsx @@ -24,7 +24,9 @@ export default { component: LinkComponent, tags: ["autodocs"], argTypes: {}, - args: {}, + args: { + size: "medium", + }, } as Meta; const Template: StoryFn = (args) => ( @@ -33,3 +35,8 @@ const Template: StoryFn = (args) => ( export const Round = Template.bind({}); Round.args = {}; + +export const Small = Template.bind({}); +Small.args = { + size: "small", +}; diff --git a/src/components/Link/Link.test.tsx b/src/components/Link/Link.test.tsx index 139f5db9..465b149f 100644 --- a/src/components/Link/Link.test.tsx +++ b/src/components/Link/Link.test.tsx @@ -25,4 +25,9 @@ describe("Link", () => { const { asFragment } = render(); expect(asFragment()).toMatchSnapshot(); }); + + it("renders width a small size", () => { + const { asFragment } = render(); + expect(asFragment()).toMatchSnapshot(); + }); }); diff --git a/src/components/Link/Link.tsx b/src/components/Link/Link.tsx index 3aae73b9..34bb78c1 100644 --- a/src/components/Link/Link.tsx +++ b/src/components/Link/Link.tsx @@ -25,15 +25,24 @@ type LinkProps = { className?: string; /** * The type of link. + * @default "primary" */ kind?: "primary" | "critical"; -} & Omit, "rel">; + /** + * The size of link. + * @default "medium" + */ + size?: "small" | "medium"; +} & Omit, "rel" | "size">; /** * A link component. */ export const Link = forwardRef>( - function Link({ children, className, kind = "primary", ...props }, ref) { + function Link( + { children, className, kind = "primary", size = "medium", ...props }, + ref, + ) { return ( >( rel="noreferrer noopener" className={classNames(styles.link, className)} data-kind={kind} + data-size={size} > {children} diff --git a/src/components/Link/__snapshots__/Link.test.tsx.snap b/src/components/Link/__snapshots__/Link.test.tsx.snap index 06ecc854..0a4d3c59 100644 --- a/src/components/Link/__snapshots__/Link.test.tsx.snap +++ b/src/components/Link/__snapshots__/Link.test.tsx.snap @@ -5,6 +5,18 @@ exports[`Link > renders 1`] = ` + +`; + +exports[`Link > renders width a small size 1`] = ` + +