Skip to content

Commit

Permalink
update some font weight related properties in typography components
Browse files Browse the repository at this point in the history
  • Loading branch information
sirineJ committed Oct 15, 2024
1 parent 0fb5dc0 commit 66737ca
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 54 deletions.
5 changes: 5 additions & 0 deletions .changeset/yellow-moose-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@sumup-oss/eslint-plugin-circuit-ui": major
---

Added a semibold weight option to the Body and the Compact components. Added the `weight` prop to the Display component. Removed the `weight` prop from the Numeral component and changed its default font weight to semibold.
2 changes: 1 addition & 1 deletion packages/circuit-ui/components/Body/Body.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The Body component comes in three sizes. Use the default `m` size in most cases.

### Weights

The Body component comes in two weights. Use the default `regular` weight in most cases. Use the `as` prop to render bold text with the `strong` HTML element if appropriate.
The Body component comes in three weights. Use the default `regular` weight in most cases. Use the `as` prop to render bold text with the `strong` HTML element if appropriate.

<Story of={Stories.Weights} />

Expand Down
4 changes: 4 additions & 0 deletions packages/circuit-ui/components/Body/Body.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
font-weight: var(--cui-font-weight-regular);
}

.semibold {
font-weight: var(--cui-font-weight-semibold);
}

.bold {
font-weight: var(--cui-font-weight-bold);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/circuit-ui/components/Body/Body.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const Sizes = (args: BodyProps) =>
</Body>
));

const weights = ['regular', 'bold'] as const;
const weights = ['regular', 'semibold', 'bold'] as const;

export const Weights = (args: BodyProps) =>
weights.map((weight) => (
Expand Down
4 changes: 2 additions & 2 deletions packages/circuit-ui/components/Body/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ export interface BodyProps extends HTMLAttributes<HTMLParagraphElement> {
*/
| 'two';
/**
* Choose from two font weights. Default: `regular`.
* Choose from three font weights. Default: `regular`.
*
* Use the `as` prop to render the component as the `strong` HTML element
* if appropriate.
*/
weight?: 'regular' | 'bold';
weight?: 'regular' | 'semibold' | 'bold';
/**
* Choose a style or text decoration. Underline is reserved for hyperlinks.
*
Expand Down
2 changes: 1 addition & 1 deletion packages/circuit-ui/components/Compact/Compact.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The Compact component comes in three sizes. Use the default `m` size in most cas

### Weights

The Compact component comes in two weights. Use the default `regular` weight in most cases.
The Compact component comes in three weights. Use the default `regular` weight in most cases.

<Story of={Stories.Weights} />

Expand Down
4 changes: 4 additions & 0 deletions packages/circuit-ui/components/Compact/Compact.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
font-weight: var(--cui-font-weight-regular);
}

.semibold {
font-weight: var(--cui-font-weight-semibold);
}

.bold {
font-weight: var(--cui-font-weight-bold);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/circuit-ui/components/Compact/Compact.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const Sizes = (args: CompactProps) =>
</Compact>
));

const weights = ['regular', 'bold'] as const;
const weights = ['regular', 'semibold', 'bold'] as const;

export const Weights = (args: CompactProps) =>
weights.map((weight) => (
Expand Down
4 changes: 2 additions & 2 deletions packages/circuit-ui/components/Compact/Compact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export interface CompactProps extends HTMLAttributes<HTMLParagraphElement> {
*/
size?: 's' | 'm' | 'l';
/**
* Choose from two font weights. Default: `regular`.
* Choose from three font weights. Default: `regular`.
*/
weight?: 'regular' | 'bold';
weight?: 'regular' | 'semibold' | 'bold';
/**
* Choose a foreground color. Default: `normal`.
*/
Expand Down
6 changes: 6 additions & 0 deletions packages/circuit-ui/components/Display/Display.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ The Display component comes in three sizes. In most cases, use the [Headline com

<Story of={Stories.Sizes} />

### Weights

The Display component comes in three weight. Use the default `bold` weight in most cases.

<Story of={Stories.Weights} />

---

## Accessibility
Expand Down
14 changes: 14 additions & 0 deletions packages/circuit-ui/components/Display/Display.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@
letter-spacing: var(--cui-letter-spacing);
}

/* Weights */

.regular {
font-weight: var(--cui-font-weight-regular);
}

.semibold {
font-weight: var(--cui-font-weight-semibold);
}

.bold {
font-weight: var(--cui-font-weight-bold);
}

/* Sizes */

.l {
Expand Down
13 changes: 13 additions & 0 deletions packages/circuit-ui/components/Display/Display.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,16 @@ export const Sizes = (args: DisplayProps) =>
Sizes.args = {
as: 'h1',
};

const weights = ['regular', 'semibold', 'bold'] as const;

export const Weights = (args: DisplayProps) =>
weights.map((weight) => (
<Display key={weight} {...args} weight={weight}>
This is weight {weight}
</Display>
));

Weights.args = {
as: 'h1',
};
16 changes: 14 additions & 2 deletions packages/circuit-ui/components/Display/Display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ import { deprecate } from '../../util/logger.js';
import classes from './Display.module.css';

export interface DisplayProps extends HTMLAttributes<HTMLHeadingElement> {
/**
* Choose from three font weights. Default: `regular`.
*/
weight?: 'regular' | 'semibold' | 'bold';
/**
* Choose from 3 font sizes. Defaults to `m`.
*/
Expand Down Expand Up @@ -64,7 +68,10 @@ const deprecatedSizeMap: Record<string, string> = {
* A flexible title component capable of rendering any HTML heading element.
*/
export const Display = forwardRef<HTMLHeadingElement, DisplayProps>(
({ className, as, size: legacySize = 'm', ...props }, ref) => {
(
{ className, as, size: legacySize = 'm', weight = 'bold', ...props },
ref,
) => {
if (
process.env.NODE_ENV !== 'production' &&
process.env.NODE_ENV !== 'test' &&
Expand Down Expand Up @@ -94,7 +101,12 @@ export const Display = forwardRef<HTMLHeadingElement, DisplayProps>(
<Element
{...props}
ref={ref}
className={clsx(classes.base, classes[size], className)}
className={clsx(
classes.base,
classes[size],
classes[weight],
className,
)}
/>
);
},
Expand Down
6 changes: 0 additions & 6 deletions packages/circuit-ui/components/Numeral/Numeral.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ The Numeral component comes in three sizes. Use the default `m` size in most cas

<Story of={Stories.Sizes} />

### Weights

The Numeral component comes in two weights. Use the default `regular` weight in most cases.

<Story of={Stories.Weights} />

### Colors

The Numeral component accepts any foreground color. Use the default `normal` color in most cases.
Expand Down
11 changes: 1 addition & 10 deletions packages/circuit-ui/components/Numeral/Numeral.module.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.base {
font-weight: var(--cui-font-weight-semibold);
font-variant-numeric: tabular-nums;
letter-spacing: var(--cui-letter-spacing);
}
Expand All @@ -20,16 +21,6 @@
line-height: var(--cui-numeral-s-line-height);
}

/* Weights */

.regular {
font-weight: var(--cui-font-weight-regular);
}

.bold {
font-weight: var(--cui-font-weight-bold);
}

/* Colors */

.normal {
Expand Down
9 changes: 0 additions & 9 deletions packages/circuit-ui/components/Numeral/Numeral.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,6 @@ export const Sizes = (args: NumeralProps) =>
</Numeral>
));

const weights = ['regular', 'bold'] as const;

export const Weights = (args: NumeralProps) =>
weights.map((weight) => (
<Numeral key={weight} {...args} weight={weight}>
{content} in {weight} weight
</Numeral>
));

const colors = [
'normal',
'subtle',
Expand Down
21 changes: 2 additions & 19 deletions packages/circuit-ui/components/Numeral/Numeral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ export interface NumeralProps extends HTMLAttributes<HTMLParagraphElement> {
* Choose from 3 font sizes. Default `m`.
*/
size?: 's' | 'm' | 'l';
/**
* Choose from two font weights. Default: `regular`.
*/
weight?: 'regular' | 'bold';
/**
* Choose a foreground color. Default: `normal`.
*/
Expand All @@ -55,26 +51,13 @@ export interface NumeralProps extends HTMLAttributes<HTMLParagraphElement> {
*/
export const Numeral = forwardRef<HTMLParagraphElement, NumeralProps>(
(
{
className,
as: Element = 'p',
size = 'm',
weight = 'regular',
color = 'normal',
...props
},
{ className, as: Element = 'p', size = 'm', color = 'normal', ...props },
ref,
) => (
<Element
{...props}
ref={ref}
className={clsx(
classes.base,
classes[size],
classes[weight],
classes[color],
className,
)}
className={clsx(classes.base, classes[size], classes[color], className)}
/>
),
);
Expand Down

0 comments on commit 66737ca

Please sign in to comment.