Skip to content

Commit

Permalink
chore: * remove 'typography' infix from typography tokens.
Browse files Browse the repository at this point in the history
* remove old letter-spacing tokens and introduce unique --cui-letter-spacing token.
* update typography tokens to their final values.
* update some readme files.
* Update theme page.
  • Loading branch information
sirineJ committed Oct 13, 2024
1 parent 00727aa commit c61d10c
Show file tree
Hide file tree
Showing 36 changed files with 251 additions and 312 deletions.
27 changes: 24 additions & 3 deletions .storybook/components/Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,20 @@ type PreviewProps = { name: CustomPropertyName };
type PreviewComponent = ComponentType<PreviewProps>;

function filterCustomProperties(namespace: string, type?: string) {
const typographyPrefixes = [
'body',
'display',
'headline',
'compact',
'numeral',
'typography',
]; //kept 'typography' for deprecated tokens

return schema.filter((token) => {
const isNamespace = token.name.startsWith(`--cui-${namespace}`);
const isNamespace =
namespace === 'typography'
? typographyPrefixes.some((el) => token.name.startsWith(`--cui-${el}`))
: token.name.startsWith(`--cui-${namespace}`);
const isType = type ? token.type === type : true;
return isNamespace && isType;
});
Expand Down Expand Up @@ -79,8 +91,17 @@ function getRows(
{
children: (
<div style={{ display: 'flex' }}>
<code style={{ whiteSpace: 'nowrap' }}>{name}</code>
<CopyButton name={name} />
<code
style={{
whiteSpace: 'nowrap',
maxWidth: '320px',
textOverflow: 'ellipsis',
overflow: 'hidden',
}}
>
{name}
</code>
{!deprecation && <CopyButton name={name} />}
{deprecation && (
<Tooltip
type="description"
Expand Down
4 changes: 2 additions & 2 deletions docs/features/1-theme.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Use spacings for gutters, margins, and paddings. Don't use it for border width,

## Typography

Avoid using the `var(--cui-typography-*)` CSS custom properties directly in your styles. Instead, use the typography components [`Display`](Typography/Display/Docs), [`Headline`](Typography/Headline/Docs), and [`Body`](Typography/Body/Docs).
Avoid using the CSS typography properties directly in your styles. Instead, use the typography components [`Display`](Typography/Display/Docs), [`Headline`](Typography/Headline/Docs), [`Body`](Typography/Body/Docs) and [`Numeral`](Typography/Numeral/Docs).

<CustomPropertiesTable namespace="typography" preview={Typography} />

Expand All @@ -73,7 +73,7 @@ Avoid using the `var(--cui-typography-*)` CSS custom properties directly in your

<CustomPropertiesTable namespace="font-weight" preview={FontWeight} />

Pass `variant="highlight"` to the `Body` component to make it bold. The font weight of the `Title`, `Headline` and `SubHeadline` components is bold by default and should not be overwritten.
Pass the `weight` prop to the `Body` component to adjust its font-weight styling. The font weight of the `Display`, `Headline` and the `Numeral` components is bold by default and should not be overwritten.

## Transitions

Expand Down
4 changes: 2 additions & 2 deletions packages/circuit-ui/components/Badge/Badge.module.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.base {
display: inline-block;
padding: 2px var(--cui-spacings-byte);
font-size: var(--cui-typography-body-s-font-size);
font-size: var(--cui-body-s-font-size);
font-weight: var(--cui-font-weight-bold);
line-height: var(--cui-typography-body-s-line-height);
line-height: var(--cui-body-s-line-height);
text-align: center;
letter-spacing: 0.25px;
border-radius: var(--cui-border-radius-pill);
Expand Down
18 changes: 9 additions & 9 deletions packages/circuit-ui/components/Body/Body.module.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/* Sizes */

.l {
font-size: var(--cui-typography-body-l-font-size);
line-height: var(--cui-typography-body-l-line-height);
letter-spacing: var(--cui-typography-body-l-letter-spacing);
font-size: var(--cui-body-l-font-size);
line-height: var(--cui-body-l-line-height);
letter-spacing: var(--cui-letter-spacing);
}

.m {
font-size: var(--cui-typography-body-m-font-size);
line-height: var(--cui-typography-body-m-line-height);
letter-spacing: var(--cui-typography-body-m-letter-spacing);
font-size: var(--cui-body-m-font-size);
line-height: var(--cui-body-m-line-height);
letter-spacing: var(--cui-letter-spacing);
}

.s {
font-size: var(--cui-typography-body-s-font-size);
line-height: var(--cui-typography-body-s-line-height);
letter-spacing: var(--cui-typography-body-s-letter-spacing);
font-size: var(--cui-body-s-font-size);
line-height: var(--cui-body-s-line-height);
letter-spacing: var(--cui-letter-spacing);
}

/* Weights */
Expand Down
10 changes: 5 additions & 5 deletions packages/circuit-ui/components/Button/base.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
width: auto;
height: auto;
margin: 0;
font-size: var(--cui-typography-body-m-font-size);
font-size: var(--cui-body-m-font-size);
font-weight: var(--cui-font-weight-bold);
text-align: center;
text-decoration: none;
Expand Down Expand Up @@ -165,8 +165,8 @@
--loader-gap: 3px;
--loader-transform: scale(150%);

font-size: var(--cui-typography-body-s-font-size);
line-height: var(--cui-typography-body-s-line-height);
font-size: var(--cui-body-s-font-size);
line-height: var(--cui-body-s-line-height);
border-radius: var(--cui-border-radius-byte);
}

Expand All @@ -177,8 +177,8 @@
--loader-gap: 5px;
--loader-transform: scale(133%);

font-size: var(--cui-typography-body-m-font-size);
line-height: var(--cui-typography-body-m-line-height);
font-size: var(--cui-body-m-font-size);
line-height: var(--cui-body-m-line-height);
border-radius: var(--cui-border-radius-byte);
}

Expand Down
8 changes: 4 additions & 4 deletions packages/circuit-ui/components/Calendar/Calendar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@
align-items: center;
justify-content: center;
aspect-ratio: 1 / 1;
font-size: var(--cui-typography-body-m-font-size);
font-size: var(--cui-body-m-font-size);
font-weight: var(--cui-font-weight-bold);
line-height: var(--cui-typography-body-m-line-height);
line-height: var(--cui-body-m-line-height);
}

.day {
width: 100%;
height: 100%;
aspect-ratio: 1 / 1;
padding: 0;
font-size: var(--cui-typography-body-m-font-size);
font-size: var(--cui-body-m-font-size);
font-variant-numeric: tabular-nums;
line-height: var(--cui-typography-body-m-line-height);
line-height: var(--cui-body-m-line-height);
color: var(--cui-fg-normal);
touch-action: manipulation;
cursor: pointer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@media (max-width: 479px) {
.base {
font-size: var(--cui-typography-body-s-font-size);
line-height: var(--cui-typography-body-s-line-height);
font-size: var(--cui-body-s-font-size);
line-height: var(--cui-body-s-line-height);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

.base + .label::before {
position: absolute;
top: calc(var(--cui-typography-body-m-line-height) / 2);
top: calc(var(--cui-body-m-line-height) / 2);
left: 0;
box-sizing: border-box;
display: block;
Expand Down
4 changes: 2 additions & 2 deletions packages/circuit-ui/components/Checkbox/Checkbox.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ export const Indeterminate = (args: {
style={{
display: 'block',
marginBottom: 'var(--cui-spacings-bit)',
fontSize: 'var(--cui-typography-body-s-font-size)',
lineHeight: 'var(--cui-typography-body-s-line-height)',
fontSize: 'var(--cui-body-s-font-size)',
lineHeight: 'var(--cui-body-s-line-height)',
}}
>
{label}
Expand Down
18 changes: 9 additions & 9 deletions packages/circuit-ui/components/Compact/Compact.module.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/* Sizes */

.l {
font-size: var(--cui-typography-compact-l-font-size);
line-height: var(--cui-typography-compact-l-line-height);
letter-spacing: var(--cui-typography-compact-l-letter-spacing);
font-size: var(--cui-compact-l-font-size);
line-height: var(--cui-compact-l-line-height);
letter-spacing: var(--cui-letter-spacing);
}

.m {
font-size: var(--cui-typography-compact-m-font-size);
line-height: var(--cui-typography-compact-m-line-height);
letter-spacing: var(--cui-typography-compact-m-letter-spacing);
font-size: var(--cui-compact-m-font-size);
line-height: var(--cui-compact-m-line-height);
letter-spacing: var(--cui-letter-spacing);
}

.s {
font-size: var(--cui-typography-compact-s-font-size);
line-height: var(--cui-typography-compact-s-line-height);
letter-spacing: var(--cui-typography-compact-s-letter-spacing);
font-size: var(--cui-compact-s-font-size);
line-height: var(--cui-compact-s-line-height);
letter-spacing: var(--cui-letter-spacing);
}

/* Weights */
Expand Down
18 changes: 9 additions & 9 deletions packages/circuit-ui/components/Display/Display.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
/* Sizes */

.l {
font-size: var(--cui-typography-display-l-font-size);
line-height: var(--cui-typography-display-l-line-height);
letter-spacing: var(--cui-typography-display-l-letter-spacing);
font-size: var(--cui-display-l-font-size);
line-height: var(--cui-display-l-line-height);
letter-spacing: var(--cui-letter-spacing);
}

.m {
font-size: var(--cui-typography-display-m-font-size);
line-height: var(--cui-typography-display-m-line-height);
letter-spacing: var(--cui-typography-display-m-letter-spacing);
font-size: var(--cui-display-m-font-size);
line-height: var(--cui-display-m-line-height);
letter-spacing: var(--cui-letter-spacing);
}

.s {
font-size: var(--cui-typography-display-s-font-size);
line-height: var(--cui-typography-display-s-line-height);
letter-spacing: var(--cui-typography-display-s-letter-spacing);
font-size: var(--cui-display-s-font-size);
line-height: var(--cui-display-s-line-height);
letter-spacing: var(--cui-letter-spacing);
}
14 changes: 7 additions & 7 deletions packages/circuit-ui/components/Field/Field.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
.label,
.legend {
display: block;
font-size: var(--cui-typography-body-s-font-size);
line-height: var(--cui-typography-body-s-line-height);
font-size: var(--cui-body-s-font-size);
line-height: var(--cui-body-s-line-height);
}

.label-text {
Expand All @@ -33,8 +33,8 @@

.description {
display: block;
font-size: var(--cui-typography-body-s-font-size);
line-height: var(--cui-typography-body-s-line-height);
font-size: var(--cui-body-s-font-size);
line-height: var(--cui-body-s-line-height);
color: var(--cui-fg-subtle);
}

Expand All @@ -46,8 +46,8 @@
.validation-hint {
display: flex;
margin-top: var(--cui-spacings-bit);
font-size: var(--cui-typography-body-s-font-size);
line-height: var(--cui-typography-body-s-line-height);
font-size: var(--cui-body-s-font-size);
line-height: var(--cui-body-s-line-height);
color: var(--cui-fg-subtle);
transition: color var(--cui-transitions-default);
}
Expand Down Expand Up @@ -91,7 +91,7 @@
width: var(--cui-icon-sizes-kilo);
height: var(--cui-icon-sizes-kilo);
margin-top: calc(
(var(--cui-typography-body-s-line-height) - var(--cui-icon-sizes-kilo)) / 2
(var(--cui-body-s-line-height) - var(--cui-icon-sizes-kilo)) / 2
);
margin-right: var(--cui-spacings-bit);
}
18 changes: 9 additions & 9 deletions packages/circuit-ui/components/Headline/Headline.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@
/* Sizes */

.l {
font-size: var(--cui-typography-headline-l-font-size);
line-height: var(--cui-typography-headline-l-line-height);
letter-spacing: var(--cui-typography-headline-l-letter-spacing);
font-size: var(--cui-headline-l-font-size);
line-height: var(--cui-headline-l-line-height);
letter-spacing: var(--cui-letter-spacing);
}

.m {
font-size: var(--cui-typography-headline-m-font-size);
line-height: var(--cui-typography-headline-m-line-height);
letter-spacing: var(--cui-typography-headline-m-letter-spacing);
font-size: var(--cui-headline-m-font-size);
line-height: var(--cui-headline-m-line-height);
letter-spacing: var(--cui-letter-spacing);
}

.s {
font-size: var(--cui-typography-headline-s-font-size);
line-height: var(--cui-typography-headline-s-line-height);
letter-spacing: var(--cui-typography-headline-s-letter-spacing);
font-size: var(--cui-headline-s-font-size);
line-height: var(--cui-headline-s-line-height);
letter-spacing: var(--cui-letter-spacing);
}
4 changes: 2 additions & 2 deletions packages/circuit-ui/components/Input/Input.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
width: 100%;
padding: var(--cui-spacings-kilo) var(--cui-spacings-mega);
margin: 0;
font-size: var(--cui-typography-body-m-font-size);
line-height: var(--cui-typography-body-m-line-height);
font-size: var(--cui-body-m-font-size);
line-height: var(--cui-body-m-line-height);
appearance: none;
background-color: var(--cui-bg-normal);
border: none;
Expand Down
1 change: 1 addition & 0 deletions packages/circuit-ui/components/List/List.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The List component comes in two variants, `ordered` or `unordered`.

### Sizes

[//]: # (TODO Body no longer comes in two sizes)
The List component has two available sizes, `one` and `two`, matching the [`Body` component](Typography/Body)'s sizes.

For consistency, the list's size should be the same as the surrounding content's size.
Expand Down
8 changes: 4 additions & 4 deletions packages/circuit-ui/components/List/List.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

.one {
padding-left: var(--cui-spacings-kilo);
font-size: var(--cui-typography-body-m-font-size);
line-height: var(--cui-typography-body-m-line-height);
font-size: var(--cui-body-m-font-size);
line-height: var(--cui-body-m-line-height);
}

.one li {
Expand All @@ -32,8 +32,8 @@

.two {
padding-left: var(--cui-spacings-kilo);
font-size: var(--cui-typography-body-s-font-size);
line-height: var(--cui-typography-body-s-line-height);
font-size: var(--cui-body-s-font-size);
line-height: var(--cui-body-s-line-height);
}

.two li {
Expand Down
4 changes: 2 additions & 2 deletions packages/circuit-ui/components/ListItem/ListItem.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ button.base:active {
display: flex;
align-items: center;
max-width: 100%;
min-height: var(--cui-typography-body-m-line-height);
min-height: var(--cui-body-m-line-height);
}

.trailing {
Expand Down Expand Up @@ -150,6 +150,6 @@ button.base:active {
}

.navigation .trailing .details {
height: var(--cui-typography-body-m-line-height);
height: var(--cui-body-m-line-height);
margin-right: calc(var(--cui-spacings-mega) + var(--cui-spacings-bit));
}
Loading

0 comments on commit c61d10c

Please sign in to comment.