Skip to content

Commit

Permalink
feat: typography updates (#2740)
Browse files Browse the repository at this point in the history
* Change title treatment to semibold

* Change deprecated headline size 3 mapping to s

* adjust weight of trailing content and add gap between the label and details

* Improve visual hierarchy of group headlines

* update values of some tokens

* Update ListItem story

* Migrate overlooked typography sizes

---------

Co-authored-by: Connor Bär <[email protected]>
  • Loading branch information
sirineJ and connor-baer authored Oct 29, 2024
1 parent 4a2f1a6 commit c15abee
Show file tree
Hide file tree
Showing 24 changed files with 52 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .storybook/components/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export function Icons() {
groupBy(activeIcons, 'category'),
).map(([category, items]) => (
<section key={category} className={classes.category}>
<Headline as="h2" size="two" id={slugify(category)}>
<Headline as="h2" size="m" id={slugify(category)}>
{category}
</Headline>
<div className={classes.list}>
Expand Down
7 changes: 1 addition & 6 deletions .storybook/components/Statuses.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,7 @@ export function Status({
<Badge variant={variant}>{label}</Badge>
</LinkTo>
{children && (
<Body
size="two"
as="span"
className={classes.description}
variant="subtle"
>
<Body size="s" as="span" className={classes.description} color="subtle">
{children}
</Body>
)}
Expand Down
2 changes: 1 addition & 1 deletion .storybook/components/Teaser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface TeaserProps {
export function Teaser({ title, children }: TeaserProps) {
return (
<Card className={classes.base}>
<Headline as="h2" size="three" id={slugify(title)}>
<Headline as="h2" size="s" id={slugify(title)}>
{title}
</Headline>

Expand Down
2 changes: 1 addition & 1 deletion .storybook/components/Theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function CopyButton({ name }: { name: CustomPropertyName }) {
return (
<Anchor
style={{ marginLeft: '1rem' }}
size="two"
size="s"
onClick={() =>
navigator.clipboard
.writeText(name)
Expand Down
2 changes: 1 addition & 1 deletion packages/circuit-ui/components/Badge/Badge.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
display: inline-block;
padding: 2px var(--cui-spacings-byte);
font-size: var(--cui-body-s-font-size);
font-weight: var(--cui-font-weight-bold);
font-weight: var(--cui-font-weight-semibold);
line-height: var(--cui-body-s-line-height);
text-align: center;
letter-spacing: 0.25px;
Expand Down
2 changes: 1 addition & 1 deletion packages/circuit-ui/components/Button/base.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
height: auto;
margin: 0;
font-size: var(--cui-body-m-font-size);
font-weight: var(--cui-font-weight-bold);
font-weight: var(--cui-font-weight-semibold);
text-align: center;
text-decoration: none;
cursor: pointer;
Expand Down
2 changes: 1 addition & 1 deletion packages/circuit-ui/components/Headline/Headline.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Beyond the `<h1>`, heading levels should be nested hierarchically to make them e

Don't skip heading levels: an `<h4>` should not directly follow an `<h2>`.

In contrast, skipping headline _sizes_ and jumping from e.g. `<Headline size="two" as="h2" />` to `<Headline size="four" as="h4" />` does not constitute an accessibility issue, although we recommend keeping sizes visually consistent across pages.
In contrast, skipping headline _sizes_ and jumping from e.g. `<Headline size="l" as="h2" />` to `<Headline size="s" as="h4" />` does not constitute an accessibility issue, although we recommend keeping sizes visually consistent across pages.

#### Avoid sections without headings

Expand Down
2 changes: 1 addition & 1 deletion packages/circuit-ui/components/Headline/Headline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface HeadlineProps extends HTMLAttributes<HTMLHeadingElement> {
const deprecatedSizeMap: Record<string, string> = {
'one': 'l',
'two': 'm',
'three': 'm',
'three': 's',
'four': 's',
};

Expand Down
2 changes: 2 additions & 0 deletions packages/circuit-ui/components/ListItem/ListItem.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ button.base:active {
display: flex;
flex: auto;
flex-direction: column;
gap: var(--cui-spacings-bit);
align-items: flex-start;
min-width: 0;
}
Expand All @@ -125,6 +126,7 @@ button.base:active {
display: flex;
flex: none;
flex-direction: column;
gap: var(--cui-spacings-bit);
align-items: flex-end;
align-self: stretch;
justify-content: center;
Expand Down
3 changes: 2 additions & 1 deletion packages/circuit-ui/components/ListItem/ListItem.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const Details = (
/>
<Body
size="s"
weight="bold"
weight="semibold"
color="success"
style={{ marginRight: 'var(--cui-spacings-bit)' }}
>
{item.status}
Expand Down
2 changes: 1 addition & 1 deletion packages/circuit-ui/components/ListItem/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export const ListItem = forwardRef<
>
<div className={classes.chevron}>
{isString(trailingLabel) ? (
<Body size="m" weight="bold">
<Body size="m" weight="semibold">
{trailingLabel}
</Body>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ export const NotificationInline = forwardRef<
<span className={utilClasses.hideVisually}>{iconLabel}</span>
<div className={classes.content}>
{headline && (
<Body weight="bold" as={isString(headline) ? 'h3' : headline.as}>
<Body
weight="semibold"
as={isString(headline) ? 'h3' : headline.as}
>
{isString(headline) ? headline : headline.label}
</Body>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const NotificationModal: ModalComponent<NotificationModalProps> = ({
</CloseButton>
)}
<NotificationImage image={image} />
<Headline as="h2" size="m" className={classes.headline}>
<Headline as="h2" size="s" className={classes.headline}>
{headline}
</Headline>
{body && <Body>{body}</Body>}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function NotificationToast({
<span className={utilClasses.hideVisually}>{iconLabel}</span>
<div className={classes.content}>
{headline && (
<Body weight="bold" as="h3">
<Body weight="semibold" as="h3">
{headline}
</Body>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function DesktopNavigation({
aria-label={secondaryNavigationLabel}
>
<Skeleton className={classes.headline} as="div">
<Headline as="h2" size="m">
<Headline as="h2" size="s">
{activePrimaryLink?.label}
</Headline>
</Skeleton>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
list-style: none;
}

.headline {
text-transform: uppercase;
}

.anchor {
flex-wrap: wrap;
padding: var(--cui-spacings-mega) var(--cui-spacings-giga);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
useFocusList,
type FocusProps,
} from '../../../../hooks/useFocusList/index.js';
import { Headline } from '../../../Headline/index.js';
import { Body } from '../../../Body/index.js';
import { Badge } from '../../../Badge/index.js';
import { useComponents } from '../../../ComponentsContext/index.js';
Expand Down Expand Up @@ -77,9 +76,15 @@ function SecondaryGroup({
<li>
{label && (
<Skeleton className={classes['group-headline']} as="div">
<Headline as="h3" size="s">
<Body
color="subtle"
className={classes.headline}
weight="semibold"
as="h3"
size="s"
>
{label}
</Headline>
</Body>
</Skeleton>
)}
<ul role="list" className={classes.list}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

.base[aria-selected="true"] {
position: relative;
font-weight: var(--cui-font-weight-semibold);
color: var(--cui-fg-normal);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function UtilityLink({
<Icon aria-hidden="true" size="24" />
</Skeleton>
<Skeleton>
<Body as="span" className={classes.label}>
<Body as="span" className={classes.label} weight="semibold">
{label}
</Body>
</Skeleton>
Expand Down
6 changes: 3 additions & 3 deletions packages/design-tokens/themes/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ export const shared = [
},
{
name: '--cui-font-weight-semibold',
value: '550',
value: '560',
type: 'fontWeight',
},
{
name: '--cui-font-weight-bold',
value: '650',
value: '630',
type: 'fontWeight',
},
/* Letter spacing */
Expand Down Expand Up @@ -213,7 +213,7 @@ export const shared = [
},
{
name: '--cui-headline-m-font-size',
value: '1.375rem',
value: '1.5rem',
type: 'dimension',
},
{
Expand Down
13 changes: 12 additions & 1 deletion packages/eslint-plugin-circuit-ui/no-renamed-props/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ const configs: (Config & { components: string[] })[] = [
},
{
type: 'values',
components: ['Title', 'Display', 'Headline'],
components: ['Title', 'Display'],
prop: 'size',
values: {
one: 'l',
Expand All @@ -264,6 +264,17 @@ const configs: (Config & { components: string[] })[] = [
four: 's',
},
},
{
type: 'values',
components: ['Headline'],
prop: 'size',
values: {
one: 'l',
two: 'm',
three: 's',
four: 's',
},
},
{
type: 'values',
components: ['Anchor', 'Body', 'List'],
Expand Down
2 changes: 1 addition & 1 deletion templates/astro/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const title = 'Welcome to Circuit UI + Astro';
---

<Root title={title}>
<Display as="h1" size="three">
<Display as="h1" size="m">
{title}
</Display>

Expand Down
2 changes: 1 addition & 1 deletion templates/nextjs/template/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function Page() {
return (
<div className={styles.grid}>
<main className={styles.main}>
<Display as="h1" size="three">
<Display as="h1" size="m">
{metadata.title as string}
</Display>

Expand Down
2 changes: 1 addition & 1 deletion templates/remix/app/routes/_index/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const meta: MetaFunction = () => [
export default function Index() {
return (
<>
<Display as="h1" size="three">
<Display as="h1" size="m">
{title}
</Display>

Expand Down

0 comments on commit c15abee

Please sign in to comment.