diff --git a/libs/pxweb2-ui/src/lib/components/Link/Link.module.scss b/libs/pxweb2-ui/src/lib/components/Link/Link.module.scss index ece73ef7..1b26eac0 100644 --- a/libs/pxweb2-ui/src/lib/components/Link/Link.module.scss +++ b/libs/pxweb2-ui/src/lib/components/Link/Link.module.scss @@ -1,12 +1,69 @@ +@use '../../../../style-dictionary/dist/scss/fixed-variables.scss' as fixvar; + .link { - font-family: 'Roboto', sans-serif; + text-decoration-line: underline; color: var(--px-color-text-action); + display: inline-flex; + align-items: flex-start; + gap: 4px; + padding-top: 12px; + padding-bottom: 12px; + align-items: center; + &:hover { text-decoration: none; + background-color: var(--px-color-surface-subtle-hover); } &:focus { + text-decoration-line: none; + color: var(--px-color-text-on-action-subtle); + background-color: var(--px-color-surface-subtle-active); + } + + &:focus-visible { + text-decoration-line: none; + color: var(--px-color-text-on-action-subtle); + background-color: var(--px-color-surface-subtle-active); + } + + &:active { + text-decoration-line: none; color: var(--px-color-text-on-action-subtle); background-color: var(--px-color-surface-subtle-active); } } +.no_underline { + text-decoration-line: none; +} +.inline { + display: inline-flex; + gap: 0px; + padding: 0px; +} + +.padding-small { + padding-top: 10px; + padding-bottom: 10px; +} + +.padding-medium { + padding-top: 8px; + padding-bottom: 8px; +} + +.bodylong-small { + font-family: PxWeb-font-400; + font-style: normal; + font-weight: 400; + font-size: 0.875rem; + line-height: 1.5rem; +} + +.bodylong-medium { + font-family: PxWeb-font-400; + font-style: normal; + font-weight: 400; + font-size: 1rem; + line-height: 1.75rem; +} diff --git a/libs/pxweb2-ui/src/lib/components/Link/Link.stories.tsx b/libs/pxweb2-ui/src/lib/components/Link/Link.stories.tsx index f5bbd75e..9d0a4da0 100644 --- a/libs/pxweb2-ui/src/lib/components/Link/Link.stories.tsx +++ b/libs/pxweb2-ui/src/lib/components/Link/Link.stories.tsx @@ -1,8 +1,7 @@ -import type { Meta } from '@storybook/react'; -import { Link } from './Link'; +import type { Meta, StoryObj, StoryFn } from '@storybook/react'; -/* import { within } from '@storybook/testing-library'; -import { expect } from '@storybook/jest'; */ +import { Link } from './Link'; +import { BodyLong } from '../Typography/BodyLong/BodyLong'; const meta: Meta = { component: Link, @@ -10,9 +9,98 @@ const meta: Meta = { }; export default meta; -export const Primary = { +type Story = StoryObj; + +export const variants: Story = { args: { href: '#', children: 'En godt skrevet lenketekst', + size: 'medium', }, }; + +export const inlineAndStandalone: StoryFn = () => { + return ( + <> +

Inline link in BodyLong

+ +

medium without icon:

+ + This is a story about Little Red Ridinghood. One day she went into the + wood to visit her grandmother. The day after too, She visited her every + day, every week, every month, every year. She never saw a wolf, no even + a little fox. Go to{' '} + + Statistikkbanken + {' '} + to read more. This is a story about Little Red Ridinghood. One day she + went into the wood to visit her grandmother. The day after too, She + visited her every day, every week, every month, every year. She never + saw a wolf, no even a little fox. + + +

medium icon right:

+ + This is a story about Little Red Ridinghood. One day she went into the + wood to visit her grandmother. The day after too, She visited her every + day, every week, every month, every year. She never saw a wolf, no even + a little fox. Go to{' '} + + Statistikkbanken + {' '} + to read more This is a story about Little Red Ridinghood. One day she + went into the wood to visit her grandmother. The day after too, She + visited her every day, every week, every month, every year. She never + saw a wolf, no even a little fox. + + +

small without icon:

+ + This is a story about Little Red Ridinghood. One day she went into the + wood to visit her grandmother. The day after too, She visited her every + day, every week, every month, every year. She never saw a wolf, no even + a little fox. Go to{' '} + + Statistikkbanken + {' '} + to read more. This is a story about Little Red Ridinghood. One day she + went into the wood to visit her grandmother. The day after too, She + visited her every day, every week, every month, every year. She never + saw a wolf, no even a little fox. + + +

Standalone link

+ +

medium without icon:

+ + Statistikkbanken + + +

medium icon left:

+ + Statistikkbanken + + +

medium icon right:

+ + Statistikkbanken + + +

small without icon:

+ + Statistikkbanken + + +

small icon left:

+ + Statistikkbanken{' '} + + +

small icon right:

+ + Statistikkbanken + +
+ + ); +}; diff --git a/libs/pxweb2-ui/src/lib/components/Link/Link.tsx b/libs/pxweb2-ui/src/lib/components/Link/Link.tsx index d45b00bf..d4d282b2 100644 --- a/libs/pxweb2-ui/src/lib/components/Link/Link.tsx +++ b/libs/pxweb2-ui/src/lib/components/Link/Link.tsx @@ -1,17 +1,46 @@ import React from 'react'; -import styles from './Link.module.scss'; +import cl from 'clsx'; -interface LinkProps { +import classes from './Link.module.scss'; +import { Icon, IconProps } from '../Icon/Icon'; + +interface LinkProps extends React.AnchorHTMLAttributes { + size?: 'small' | 'medium'; + icon?: IconProps['iconName']; + iconPosition?: 'left' | 'right'; children: React.ReactNode; href: string; + inline?: boolean; + noUnderline?: boolean; } - -export const Link: React.FC = ({ children, href }) => { +export function Link({ + children, + size, + href, + icon, + iconPosition, + inline = false, + noUnderline = false, + ...rest +}: LinkProps) { return ( - + + {icon && iconPosition === 'left' && ( + + )} {children} + {icon && iconPosition === 'right' && ( + + )} ); -}; - +} export default Link;