Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Remove deprecated ‘in list’ variant of Link #1064

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions packages/css/src/components/link/link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,6 @@
}
}

.amsterdam-link--in-list {
align-items: flex-start;
display: inline-flex;
font-size: var(--amsterdam-link-in-list-spacious-font-size);
gap: var(--amsterdam-link-in-list-gap);
line-height: var(--amsterdam-link-in-list-spacious-line-height);
text-decoration-line: var(--amsterdam-link-in-list-text-decoration-line);
text-decoration-thickness: var(--amsterdam-link-in-list-text-decoration-thickness);
text-underline-offset: var(--amsterdam-link-in-list-text-underline-offset);

&:hover {
text-decoration-line: var(--amsterdam-link-in-list-hover-text-decoration-line);
}

.amsterdam-theme--compact & {
font-size: var(--amsterdam-link-in-list-compact-font-size);
line-height: var(--amsterdam-link-in-list-compact-line-height);
}
}

// Override for icon size
.amsterdam-link--in-list__chevron {
span.amsterdam-icon svg {
height: 1rem;
width: 1rem;
}
}

.amsterdam-link--on-background-dark {
color: var(--amsterdam-link-on-background-dark-color);

Expand Down
12 changes: 0 additions & 12 deletions packages/react/src/Link/Link.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,6 @@ describe('Link', () => {
})

it('renders inline variant', () => {
const { container } = render(
<Link variant="inList" href="#">
{linktext}
</Link>,
)
const link = container.querySelector('a:only-child')
expect(link).toHaveClass('amsterdam-link amsterdam-link--in-list')
const icon = link ? link.querySelector('svg:only-child') : null
expect(icon).toBeInTheDocument()
})

it('renders inlist variant', () => {
const { container } = render(
<Link variant="inline" href="#">
{linktext}
Expand Down
27 changes: 4 additions & 23 deletions packages/react/src/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,21 @@
* Copyright (c) 2023 Gemeente Amsterdam
*/

import { ChevronRightIcon } from '@amsterdam/design-system-react-icons'
import clsx from 'clsx'
import { forwardRef } from 'react'
import type { AnchorHTMLAttributes, ForwardedRef, PropsWithChildren } from 'react'
import { Icon } from '../Icon/Icon'
import type { AnchorHTMLAttributes, ForwardedRef } from 'react'

type LinkOnBackground = 'default' | 'light' | 'dark'
/** @deprecated Use `LinkList` instead. */
type DeprecatedLinkVariantInList = 'inList'
type LinkVariant = 'standalone' | 'inline' | DeprecatedLinkVariantInList
type LinkVariant = 'standalone' | 'inline'

type CommonProps = {
export type LinkProps = {
variant?: LinkVariant
onBackground?: LinkOnBackground
} & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'placeholder'>

type ConditionalProps =
| {
variant?: 'standalone' | 'inline'
icon?: never
}
| {
variant?: 'inList'
icon?: Function
}

export type LinkProps = PropsWithChildren<CommonProps & ConditionalProps>

export const Link = forwardRef(
(
{ children, variant = 'standalone', icon, onBackground, className, ...otherProps }: LinkProps,
{ children, variant = 'standalone', onBackground, className, ...otherProps }: LinkProps,
ref: ForwardedRef<HTMLAnchorElement>,
) => (
<a
Expand All @@ -44,15 +28,12 @@ export const Link = forwardRef(
{
'amsterdam-link--standalone': variant === 'standalone',
'amsterdam-link--inline': variant === 'inline',
'amsterdam-link--in-list': variant === 'inList',
'amsterdam-link--in-list__chevron': variant === 'inList' && !icon,
'amsterdam-link--on-background-light': onBackground === 'light',
'amsterdam-link--on-background-dark': onBackground === 'dark',
},
className,
)}
>
{variant === 'inList' && <Icon svg={icon ?? ChevronRightIcon} size="level-5" />}
{children}
</a>
),
Expand Down
17 changes: 0 additions & 17 deletions proprietary/tokens/src/components/amsterdam/link.tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,6 @@
"color": { "value": "{amsterdam.color.purple}" }
}
},
"in-list": {
"gap": { "value": "0.5em" },
"text-decoration-line": { "value": "{amsterdam.link-appearance.subtle.text-decoration-line}" },
"text-decoration-thickness": { "value": "{amsterdam.link-appearance.text-decoration-thickness}" },
"text-underline-offset": { "value": "{amsterdam.link-appearance.text-underline-offset}" },
"hover": {
"text-decoration-line": { "value": "{amsterdam.link-appearance.subtle.hover.text-decoration-line}" }
},
"spacious": {
"font-size": { "value": "{amsterdam.typography.spacious.text-level.5.font-size}" },
"line-height": { "value": "{amsterdam.typography.spacious.text-level.5.line-height}" }
},
"compact": {
"font-size": { "value": "{amsterdam.typography.compact.text-level.5.font-size}" },
"line-height": { "value": "{amsterdam.typography.compact.text-level.5.line-height}" }
}
},
"standalone": {
"text-decoration-line": { "value": "{amsterdam.link-appearance.regular.text-decoration-line}" },
"text-decoration-thickness": { "value": "{amsterdam.link-appearance.text-decoration-thickness}" },
Expand Down
100 changes: 37 additions & 63 deletions storybook/storybook-react/src/Footer/Footer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,8 @@
* Copyright (c) 2023 Gemeente Amsterdam
*/

import {
Footer,
Grid,
Heading,
Link,
PageMenu,
Paragraph,
UnorderedList,
VisuallyHidden,
} from '@amsterdam/design-system-react'
import { Footer, Grid, Heading, LinkList, PageMenu, Paragraph, VisuallyHidden } from '@amsterdam/design-system-react'
import { EmailIcon, PhoneIcon } from '@amsterdam/design-system-react-icons'
import { Meta, StoryObj } from '@storybook/react'

const meta = {
Expand Down Expand Up @@ -40,18 +32,14 @@ export const Default: Story = {
<Paragraph size="small" inverseColor>
Heeft u een vraag en kunt u het antwoord niet vinden op deze site? Neem dan contact met ons op.
</Paragraph>
<UnorderedList markers={false}>
<li>
<Link href="mailto:[email protected]" variant="inList" onBackground="dark">
E-mail
</Link>
</li>
<li>
<Link href="tel:+31202510333" variant="inList" onBackground="dark">
020 251 0333
</Link>
</li>
</UnorderedList>
<LinkList>
<LinkList.Link href="mailto:[email protected]" icon={EmailIcon} onBackground="dark" size="small">
E-mail
</LinkList.Link>
<LinkList.Link href="tel:+31202510333" icon={PhoneIcon} onBackground="dark" size="small">
020 251 0333
</LinkList.Link>
</LinkList>
</div>
</Grid.Cell>
<Grid.Cell span={3} start={{ narrow: 1, medium: 5, wide: 5 }}>
Expand All @@ -62,52 +50,38 @@ export const Default: Story = {
<Paragraph size="small" inverseColor>
Bent u uitgenodigd om mee te doen aan onderzoek of heeft u vragen over het panel of stadspaspanel?
</Paragraph>
<UnorderedList markers={false}>
<li>
<Link href="/" variant="inList" onBackground="dark" rel="external">
Meedoen aan onderzoek
</Link>
</li>
<li>
<Link href="/" variant="inList" onBackground="dark" rel="external">
Panel Amsterdam
</Link>
</li>
<li>
<Link href="/" variant="inList" onBackground="dark" rel="external">
Stadspaspanel Amsterdam
</Link>
</li>
</UnorderedList>
<LinkList>
<LinkList.Link href="#" onBackground="dark" rel="external" size="small">
Meedoen aan onderzoek
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" rel="external" size="small">
Panel Amsterdam
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" rel="external" size="small">
Stadspaspanel Amsterdam
</LinkList.Link>
</LinkList>
</div>
</Grid.Cell>
<Grid.Cell span={3} start={{ narrow: 1, medium: 1, wide: 9 }}>
<div style={{ display: 'grid', gap: '2.5rem' }}>
<Heading level={2} size="level-4" inverseColor>
Onderzoek en Statistiek
</Heading>
<UnorderedList markers={false}>
<li>
<Link href="/" variant="inList" onBackground="dark">
Over Onderzoek en Statistiek
</Link>
</li>
<li>
<Link href="/" variant="inList" onBackground="dark">
Veelgestelde vragen
</Link>
</li>
<li>
<Link href="/" variant="inList" onBackground="dark" rel="external">
Nieuwsbrief
</Link>
</li>
<li>
<Link href="/" variant="inList" onBackground="dark">
Vacatures
</Link>
</li>
</UnorderedList>
<LinkList>
<LinkList.Link href="#" onBackground="dark" size="small">
Over Onderzoek en Statistiek
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" size="small">
Veelgestelde vragen
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" rel="external" size="small">
Nieuwsbrief
</LinkList.Link>
<LinkList.Link href="#" onBackground="dark" size="small">
Vacatures
</LinkList.Link>
</LinkList>
</div>
</Grid.Cell>
</Grid>
Expand All @@ -119,8 +93,8 @@ export const Default: Story = {
<Grid paddingVertical="small">
<Grid.Cell span="all">
<PageMenu>
<PageMenu.Link href="/">Privacy</PageMenu.Link>
<PageMenu.Link href="/">Toegankelijkheid</PageMenu.Link>
<PageMenu.Link href="#">Privacy</PageMenu.Link>
<PageMenu.Link href="#">Toegankelijkheid</PageMenu.Link>
</PageMenu>
</Grid.Cell>
</Grid>
Expand Down
14 changes: 1 addition & 13 deletions storybook/storybook-react/src/Link/Link.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import { Link, Paragraph } from '@amsterdam/design-system-react'
import * as Icons from '@amsterdam/design-system-react-icons'
import type { Meta, StoryObj } from '@storybook/react'

type Story = StoryObj<typeof Link>
Expand All @@ -13,16 +12,6 @@ const meta = {
title: 'Navigation/Link',
component: Link,
argTypes: {
icon: {
control: {
type: 'select',
},
options: Object.keys(Icons),
mapping: Icons,
table: {
category: 'API',
},
},
onBackground: {
control: {
type: 'radio',
Expand All @@ -36,9 +25,8 @@ const meta = {
variant: {
control: {
type: 'radio',
labels: { standalone: 'standalone', inline: 'inline', inList: 'inList' },
},
options: ['standalone', 'inline', 'inList'],
options: ['standalone', 'inline'],
table: {
category: 'API',
defaultValue: { summary: 'standalone' },
Expand Down
Loading
Loading