Skip to content

Commit

Permalink
feat: Add 'medium' weight to Heading
Browse files Browse the repository at this point in the history
  • Loading branch information
frankieyan committed Feb 17, 2024
1 parent 3366d1e commit 2a021a9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/heading/heading.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
font-family: var(--reactist-font-family);
}

.weight-medium {
font-weight: var(--reactist-font-weight-medium);
}

.weight-light {
font-weight: var(--reactist-font-weight-regular);
}
Expand Down
2 changes: 1 addition & 1 deletion src/heading/heading.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export function HeadingPlaygroundStory(props: React.ComponentProps<typeof Headin
HeadingPlaygroundStory.argTypes = {
level: select(['1', '2', '3', '4', '5', '6'], '1'),
size: selectWithNone(['largest', 'larger', 'smaller'], 'none'),
weight: select(['regular', 'light'], 'regular'),
weight: select(['regular', 'medium', 'light'], 'regular'),
lineClamp: selectWithNone([1, 2, 3, 4, 5], 'none'),
tone: select(['normal', 'secondary', 'danger'], 'normal'),
align: selectWithNone(['start', 'center', 'end', 'justify'], 'none'),
Expand Down
7 changes: 7 additions & 0 deletions src/heading/heading.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ describe('Heading', () => {
expect(textElement).not.toHaveClass('weight-regular')
expect(textElement).not.toHaveClass('weight-light')

rerender(
<Heading level="1" data-testid="heading-element" weight="medium">
Heading
</Heading>,
)
expect(textElement).toHaveClass('weight-medium')

rerender(
<Heading level="1" data-testid="heading-element" weight="light">
Heading
Expand Down
4 changes: 2 additions & 2 deletions src/heading/heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ type HeadingProps = SupportedHeadingElementProps & {
*/
level: HeadingLevel
/**
* The weight of the heading. Used to de-emphasize the heading visually when using 'light'.
* The weight of the heading. Used to de-emphasize the heading visually when using 'medium' or 'light'.
*
* @default 'regular'
*/
weight?: 'regular' | 'light'
weight?: 'regular' | 'medium' | 'light'
/**
* Shifts the default heading visual text size up or down, depending on the original size
* imposed by the `level`. The heading continues to be semantically at the given level.
Expand Down

0 comments on commit 2a021a9

Please sign in to comment.