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!: Change naming approach of all typography tokens #1845

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
40c7fa2
Introduce actually primitive brand typography tokens
VincentSmedinga Nov 21, 2024
5886458
Model heading and body scales in common tokens
VincentSmedinga Nov 21, 2024
331325d
Apply new typography tokens to all components
VincentSmedinga Nov 21, 2024
25a8923
Remove unnecessary extra logging config
VincentSmedinga Nov 22, 2024
9ec050b
Rename token in stylesheet
VincentSmedinga Nov 22, 2024
214f7b0
Add new compact tokens
VincentSmedinga Nov 22, 2024
a351a31
Remove obsolete text tokens
VincentSmedinga Nov 22, 2024
00de72a
Choose 2xl line height for xl body text
VincentSmedinga Nov 26, 2024
ce3f12f
Rename documentation page
VincentSmedinga Nov 26, 2024
545756c
WIP Update documentation
VincentSmedinga Nov 26, 2024
d87c070
Update tokens for recent components
VincentSmedinga Feb 1, 2025
c9de0fb
Update examples and alignment in docs
VincentSmedinga Feb 1, 2025
3f48741
Remove ‘brand’ from typography token names
VincentSmedinga Feb 1, 2025
5325582
Remove ‘common’ from typography token names
VincentSmedinga Feb 1, 2025
0e5d04b
Rename token in stylesheet again
VincentSmedinga Feb 1, 2025
68fcac7
Add more token overviews to docs
VincentSmedinga Feb 3, 2025
19a55d4
Merge branch 'develop' into feat/DES-1073-typography-tokens
VincentSmedinga Feb 12, 2025
ed970ba
Use primitive values in common tokens
VincentSmedinga Feb 12, 2025
0fea502
Remove old organisation of typography tokens
VincentSmedinga Feb 12, 2025
3b5f042
Promote common tokens to brand level
VincentSmedinga Feb 12, 2025
bb8c975
Remove ‘level’ from heading tokens
VincentSmedinga Feb 12, 2025
e1c42cc
Merge branch 'develop' into feat/DES-1073-typography-tokens
VincentSmedinga Feb 12, 2025
986d9c4
Restore old line heights for now
VincentSmedinga Feb 12, 2025
d8413cf
Update common typography tokens
VincentSmedinga Feb 12, 2025
e854fec
Fix common typography tokens
VincentSmedinga Feb 12, 2025
ba14501
Add missing token for button font weight
VincentSmedinga Feb 12, 2025
65c28c4
Share font family token between groups
VincentSmedinga Feb 12, 2025
2474f37
Remove unused font family token in Switch
VincentSmedinga Feb 12, 2025
27b50d6
Fix token names in heading stylesheet
VincentSmedinga Feb 12, 2025
29dd1da
Merge font family sections in docs
VincentSmedinga Feb 12, 2025
85c79aa
Only abbreviate ‘extra’ in t-shirt sizes
VincentSmedinga Feb 14, 2025
03d8687
Fix renamed token
VincentSmedinga Feb 14, 2025
3674430
Use extra bold for body text as well
VincentSmedinga Feb 14, 2025
b1b69ec
Separate body text and headings in Icon size prop
VincentSmedinga Feb 14, 2025
0d50988
Add examples of Heading and Paragraph with Icon
VincentSmedinga Feb 18, 2025
b596b28
Merge branch 'develop' into feat/DES-1073-typography-tokens
VincentSmedinga Feb 18, 2025
664a863
Update links to typography docs
VincentSmedinga Feb 19, 2025
a4e95a8
Fix typo
VincentSmedinga Feb 21, 2025
59175b2
Remove ‘body-text’ group to indicate it as default
VincentSmedinga Feb 20, 2025
e62c6bd
Move modifiers to end of token names
VincentSmedinga Feb 20, 2025
8ccca01
Make heading tokens variations of size
VincentSmedinga Feb 20, 2025
17870f2
Codify reuse of token values
VincentSmedinga Feb 20, 2025
2498212
Handle font weight tokens consistently
VincentSmedinga Feb 20, 2025
9b47a8f
Remove verbose typography grouping
VincentSmedinga Feb 20, 2025
c694f54
Handle font family tokens consistently
VincentSmedinga Feb 20, 2025
98e9669
Reorganize documentation
VincentSmedinga Feb 20, 2025
aa266c5
WIP Move Heading tokens into Common layer
VincentSmedinga Feb 21, 2025
5c72189
Merge branch 'develop' into feat/DES-1073-typography-tokens
VincentSmedinga Feb 25, 2025
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
1 change: 1 addition & 0 deletions packages/css/src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
display: inline-flex;
font-family: var(--ams-button-font-family);
font-size: var(--ams-button-font-size);
font-weight: var(--ams-button-font-weight);
gap: var(--ams-button-gap);
justify-content: center;
line-height: var(--ams-button-line-height);
Expand Down
24 changes: 12 additions & 12 deletions packages/css/src/components/heading/heading.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,33 @@
}

.ams-heading--level-1 {
font-size: var(--ams-heading-level-1-font-size);
line-height: var(--ams-heading-level-1-line-height);
font-size: var(--ams-heading-1-font-size);
line-height: var(--ams-heading-1-line-height);
}

.ams-heading--level-2 {
font-size: var(--ams-heading-level-2-font-size);
line-height: var(--ams-heading-level-2-line-height);
font-size: var(--ams-heading-2-font-size);
line-height: var(--ams-heading-2-line-height);
}

.ams-heading--level-3 {
font-size: var(--ams-heading-level-3-font-size);
line-height: var(--ams-heading-level-3-line-height);
font-size: var(--ams-heading-3-font-size);
line-height: var(--ams-heading-3-line-height);
}

.ams-heading--level-4 {
font-size: var(--ams-heading-level-4-font-size);
line-height: var(--ams-heading-level-4-line-height);
font-size: var(--ams-heading-4-font-size);
line-height: var(--ams-heading-4-line-height);
}

.ams-heading--level-5 {
font-size: var(--ams-heading-level-5-font-size);
line-height: var(--ams-heading-level-5-line-height);
font-size: var(--ams-heading-5-font-size);
line-height: var(--ams-heading-5-line-height);
}

.ams-heading--level-6 {
font-size: var(--ams-heading-level-6-font-size);
line-height: var(--ams-heading-level-6-line-height);
font-size: var(--ams-heading-6-font-size);
line-height: var(--ams-heading-6-line-height);
}

.ams-heading--inverse {
Expand Down
2 changes: 1 addition & 1 deletion packages/css/src/components/icon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Icons are aligned to the left of the text by default and vertically centred to t

Icons use the same text levels as all typographic components to determine their size.
This ensures easy alignment between icons and text.
[Refer to the typography documentation for more information](/docs/brand-design-tokens-text--docs).
[Refer to the typography documentation for more information](/docs/brand-design-tokens-typography--docs).

## Overview

Expand Down
71 changes: 46 additions & 25 deletions packages/css/src/components/icon/icon.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@

.ams-icon {
align-items: center;
block-size: calc(var(--ams-icon-font-size) * var(--ams-icon-line-height));
display: inline-flex;
}

.ams-icon svg {
fill: currentColor;
svg {
block-size: var(--ams-icon-font-size);
fill: currentColor;
inline-size: var(--ams-icon-font-size);
}
}

.ams-icon--inverse {
Expand All @@ -21,38 +24,56 @@
justify-content: center;
}

.ams-icon--size-3 {
block-size: calc(var(--ams-icon-size-3-font-size) * var(--ams-icon-size-3-line-height));
}
.ams-icon--small {
block-size: calc(var(--ams-icon-small-font-size) * var(--ams-icon-small-line-height));

.ams-icon--size-3 svg {
block-size: var(--ams-icon-size-3-font-size);
inline-size: var(--ams-icon-size-3-font-size);
svg {
block-size: var(--ams-icon-small-font-size);
inline-size: var(--ams-icon-small-font-size);
}
}

.ams-icon--size-4 {
block-size: calc(var(--ams-icon-size-4-font-size) * var(--ams-icon-size-4-line-height));
}
.ams-icon--large {
block-size: calc(var(--ams-icon-large-font-size) * var(--ams-icon-large-line-height));

.ams-icon--size-4 svg {
block-size: var(--ams-icon-size-4-font-size);
inline-size: var(--ams-icon-size-4-font-size);
svg {
block-size: var(--ams-icon-large-font-size);
inline-size: var(--ams-icon-large-font-size);
}
}

.ams-icon--size-5 {
block-size: calc(var(--ams-icon-size-5-font-size) * var(--ams-icon-size-5-line-height));
.ams-icon--heading-3 {
block-size: calc(var(--ams-icon-heading-3-font-size) * var(--ams-icon-heading-3-line-height));

svg {
block-size: var(--ams-icon-heading-3-font-size);
inline-size: var(--ams-icon-heading-3-font-size);
}
}

.ams-icon--size-5 svg {
block-size: var(--ams-icon-size-5-font-size);
inline-size: var(--ams-icon-size-5-font-size);
.ams-icon--heading-4 {
block-size: calc(var(--ams-icon-heading-4-font-size) * var(--ams-icon-heading-4-line-height));

svg {
block-size: var(--ams-icon-heading-4-font-size);
inline-size: var(--ams-icon-heading-4-font-size);
}
}

.ams-icon--size-6 {
block-size: calc(var(--ams-icon-size-6-font-size) * var(--ams-icon-size-6-line-height));
.ams-icon--heading-5 {
block-size: calc(var(--ams-icon-heading-5-font-size) * var(--ams-icon-heading-5-line-height));

svg {
block-size: var(--ams-icon-heading-5-font-size);
inline-size: var(--ams-icon-heading-5-font-size);
}
}

.ams-icon--size-6 svg {
block-size: var(--ams-icon-size-6-font-size);
inline-size: var(--ams-icon-size-6-font-size);
.ams-icon--heading-6 {
block-size: calc(var(--ams-icon-heading-6-font-size) * var(--ams-icon-heading-6-line-height));

svg {
block-size: var(--ams-icon-heading-6-font-size);
inline-size: var(--ams-icon-heading-6-font-size);
}
}
2 changes: 1 addition & 1 deletion packages/react/src/Accordion/AccordionSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const AccordionSection = forwardRef(
onClick={() => setIsExpanded(!isExpanded)}
type="button"
>
<Icon className="ams-accordion__icon" size="level-4" svg={ChevronDownIcon} />
<Icon className="ams-accordion__icon" size="heading-4" svg={ChevronDownIcon} />
{label}
</button>
</HeadingTag>
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ export const Alert = forwardRef(
return (
<section {...restProps} className={clsx('ams-alert', severity && `ams-alert--${severity}`, className)} ref={ref}>
<div className="ams-alert__severity-indicator">
<Icon color="inverse" size="level-4" svg={SeverityIcon} />
<Icon color="inverse" size="heading-4" svg={SeverityIcon} />
</div>
<div className="ams-alert__content">
<Row align="between" alignVertical="start">
<Heading level={headingLevel} size="level-4">
{heading}
</Heading>
{closeable && <IconButton label={closeButtonLabel} onClick={onClose} size="level-4" />}
{closeable && <IconButton label={closeButtonLabel} onClick={onClose} size="heading-4" />}
</Row>
{children}
</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/Avatar/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const AvatarContent = ({ imageSrc, initials }: AvatarContentProps) => {
return <span aria-hidden={true}>{initials}</span>
}

return <Icon size="level-6" svg={PersonalLoginIcon} />
return <Icon size="small" svg={PersonalLoginIcon} />
}

export type AvatarProps = {
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export const Button = forwardRef(
ref={ref}
type={type || 'button'}
>
{icon && (iconBefore || iconOnly) && <Icon size="level-5" square={iconOnly} svg={icon} />}
{icon && (iconBefore || iconOnly) && <Icon square={iconOnly} svg={icon} />}
{icon && iconOnly ? <span className="ams-visually-hidden">{children}</span> : children}
{icon && !iconBefore && !iconOnly && <Icon size="level-5" svg={icon} />}
{icon && !iconBefore && !iconOnly && <Icon svg={icon} />}
</button>
),
)
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const DialogRoot = forwardRef(
<Heading level={1} size="level-4">
{heading}
</Heading>
<IconButton label={closeButtonLabel} onClick={closeDialog} size="level-4" type="button" />
<IconButton label={closeButtonLabel} onClick={closeDialog} size="heading-4" type="button" />
</header>
<div className="ams-dialog__body">{children}</div>
{footer && <footer className="ams-dialog__footer">{footer}</footer>}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/ErrorMessage/ErrorMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const ErrorMessage = forwardRef(
ref: ForwardedRef<HTMLParagraphElement>,
) => (
<p {...restProps} className={clsx('ams-error-message', className)} ref={ref}>
<Icon size="level-6" svg={icon ? icon : AlertIcon} />
<Icon size="small" svg={icon ? icon : AlertIcon} />
<span className="ams-visually-hidden">
{prefix}
{': '}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/FileList/FileListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const FileListItem = forwardRef(
{file.type.startsWith('image/') ? (
<img alt={file.name} src={URL.createObjectURL(file)} />
) : (
<Icon size="level-3" square svg={DocumentIcon} />
<Icon size="heading-3" square svg={DocumentIcon} />
)}
</div>
<div className="ams-file-list__item-info">
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ const HeaderRoot = forwardRef(
{menuButtonText}
</span>
<Icon
size="level-5"
svg={
<HeaderMenuIcon
className={clsx('ams-header__menu-icon', open && 'ams-header__menu-icon--open')}
Expand Down
18 changes: 8 additions & 10 deletions packages/react/src/Icon/Icon.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AlertIcon } from '@amsterdam/design-system-react-icons'
import { render } from '@testing-library/react'
import { createRef } from 'react'
import { Icon } from './Icon'
import { Icon, iconSizes } from './Icon'
import '@testing-library/jest-dom'

describe('Icon', () => {
Expand Down Expand Up @@ -29,16 +29,14 @@ describe('Icon', () => {
expect(svg).toBeInTheDocument()
})

it('renders the right size classes', () => {
const { container: level3 } = render(<Icon size="level-3" svg={AlertIcon} />)
const { container: level4 } = render(<Icon size="level-4" svg={AlertIcon} />)
const { container: level5 } = render(<Icon size="level-5" svg={AlertIcon} />)
const { container: level6 } = render(<Icon size="level-6" svg={AlertIcon} />)
iconSizes.forEach((size) => {
it(`renders the correct class name for a ‘${size}’ icon`, () => {
const { container } = render(<Icon size={size} svg={AlertIcon} />)

expect(level3.firstChild).toHaveClass('ams-icon--size-3')
expect(level4.firstChild).toHaveClass('ams-icon--size-4')
expect(level5.firstChild).toHaveClass('ams-icon--size-5')
expect(level6.firstChild).toHaveClass('ams-icon--size-6')
const icon = container.querySelector(':only-child')

expect(icon).toHaveClass(`ams-icon--${size}`)
})
})

it('renders the right square class', () => {
Expand Down
15 changes: 8 additions & 7 deletions packages/react/src/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,28 @@ import clsx from 'clsx'
import { forwardRef } from 'react'
import type { ForwardedRef, HTMLAttributes, ReactNode } from 'react'

export const iconSizes = ['small', 'large', 'heading-3', 'heading-4', 'heading-5', 'heading-6']

type IconSize = (typeof iconSizes)[number]

export type IconProps = {
/** Changes the icon colour for readability on a dark background. */
color?: 'inverse'
/** The size of the icon. Corresponds with the text levels. */
size?: 'level-3' | 'level-4' | 'level-5' | 'level-6'
/** The size of the icon. Choose the size of the corresponding body text or heading. */
size?: IconSize
/** Whether the icon container should be made square. */
square?: boolean
/** The component rendering the icon’s markup. */
svg: Function | ReactNode
} & HTMLAttributes<HTMLSpanElement>

export const Icon = forwardRef(
({ className, color, size = 'level-3', square, svg, ...restProps }: IconProps, ref: ForwardedRef<HTMLElement>) => (
({ className, color, size, square, svg, ...restProps }: IconProps, ref: ForwardedRef<HTMLElement>) => (
<span
className={clsx(
'ams-icon',
color && `ams-icon--${color}`,
size === 'level-3' && 'ams-icon--size-3',
size === 'level-4' && 'ams-icon--size-4',
size === 'level-5' && 'ams-icon--size-5',
size === 'level-6' && 'ams-icon--size-6',
size && `ams-icon--${size}`,
square && 'ams-icon--square',
className,
)}
Expand Down
9 changes: 5 additions & 4 deletions packages/react/src/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@ import clsx from 'clsx'
import { forwardRef } from 'react'
import type { ButtonHTMLAttributes, ForwardedRef } from 'react'
import { Icon } from '../Icon'
import type { IconProps } from '../Icon'

export type IconButtonProps = {
/** Changes the text colour for readability on a light or dark background. */
color?: 'contrast' | 'inverse'
/** The accessible text for the button. Will be announced by screen readers. Should describe the button’s action. */
label: string
/** The size of the icon. Corresponds with the text levels. */
size?: 'level-3' | 'level-4' | 'level-5' | 'level-6'
/** The size of the icon. Choose the size of the corresponding body text or heading. */
size?: IconProps['size']
/** The component rendering the icon’s markup. */
svg?: Function
svg?: IconProps['svg']
} & ButtonHTMLAttributes<HTMLButtonElement>

export const IconButton = forwardRef(
(
{ className, color, label, size = 'level-5', svg = CloseIcon, ...restProps }: IconButtonProps,
{ className, color, label, size, svg = CloseIcon, ...restProps }: IconButtonProps,
ref: ForwardedRef<HTMLButtonElement>,
) => (
<button
Expand Down
8 changes: 1 addition & 7 deletions packages/react/src/LinkList/LinkListLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ export type LinkListLinkProps = {
size?: 'small' | 'large'
} & PropsWithChildren<AnchorHTMLAttributes<HTMLAnchorElement>>

const iconSizeMap = {
small: 'level-6',
medium: 'level-5',
large: 'level-4',
} as const

/** One link with a Link List. */
export const LinkListLink = forwardRef(
(
Expand All @@ -42,7 +36,7 @@ export const LinkListLink = forwardRef(
ref={ref}
{...restProps}
>
<Icon size={iconSizeMap[size ?? 'medium']} svg={icon ?? ChevronRightIcon} />
<Icon size={size} svg={icon ?? ChevronRightIcon} />
{children}
</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/PageMenu/PageMenuLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const PageMenuLink = forwardRef(
<li>
<a {...restProps} className={clsx('ams-page-menu__link', className)} ref={ref}>
{children}
{icon && <Icon size="level-6" svg={icon} />}
{icon && <Icon size="small" svg={icon} />}
</a>
</li>
),
Expand Down
4 changes: 2 additions & 2 deletions packages/react/src/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const Pagination = forwardRef(
</span>
{page !== 1 && (
<Link className="ams-pagination__link" href={linkTemplate(page - 1)} rel="prev">
<Icon size="level-5" svg={ChevronLeftIcon} />
<Icon svg={ChevronLeftIcon} />
<span className="ams-visually-hidden">{previousVisuallyHiddenLabel}</span>
<span aria-hidden>{previousLabel}</span>
</Link>
Expand All @@ -105,7 +105,7 @@ export const Pagination = forwardRef(
<Link className="ams-pagination__link" href={linkTemplate(page + 1)} rel="next">
<span className="ams-visually-hidden">{nextVisuallyHiddenLabel}</span>
<span aria-hidden>{nextLabel}</span>
<Icon size="level-5" svg={ChevronRightIcon} />
<Icon svg={ChevronRightIcon} />
</Link>
)}
</nav>
Expand Down
3 changes: 0 additions & 3 deletions proprietary/tokens/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,6 @@ defaultMode.buildAllPlatforms()

modes.map((mode) => {
const styleDictionary = new StyleDictionary({
log: {
verbosity: 'verbose',
},
platforms: generateSharedConfig(mode),
source: [`./src/**/*.${mode}.tokens.json`],
})
Expand Down
Loading
Loading