-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(webapp): extract Title component
This way, we don't need to duplicate text styles for headings (font size, color, weight).
- Loading branch information
1 parent
bea9fa1
commit dc15093
Showing
16 changed files
with
103 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { style, styleVariants } from '@vanilla-extract/css' | ||
|
||
import { vars } from '#/styles/theme.css' | ||
|
||
export const title = style({ | ||
color: vars.color.text, | ||
fontWeight: vars.fontWeight.medium, | ||
}) | ||
|
||
export const titleSize = styleVariants({ | ||
l: { | ||
fontSize: '2rem', | ||
}, | ||
|
||
m: { | ||
fontSize: '1.5rem', | ||
}, | ||
|
||
s: { | ||
fontSize: '1rem', | ||
}, | ||
|
||
xs: { | ||
fontSize: '0.875rem', | ||
}, | ||
}) | ||
|
||
export const titleVariant = styleVariants({ | ||
default: { | ||
color: vars.color.text, | ||
}, | ||
|
||
tertiary: { | ||
color: vars.color.textTertiary, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import classNames from 'classnames' | ||
import React, { type HTMLAttributes } from 'react' | ||
|
||
import * as s from './Title.css' | ||
|
||
type TitleProps = HTMLAttributes<HTMLHeadingElement> & { | ||
as?: 'h1' | 'h2' | 'h3' | ||
size?: keyof typeof s.titleSize | ||
variant?: keyof typeof s.titleVariant | ||
} | ||
|
||
export const Title = ({ | ||
as: Component = 'h1', | ||
size = 'm', | ||
variant = 'default', | ||
className, | ||
...rest | ||
}: TitleProps) => ( | ||
<Component | ||
className={classNames( | ||
s.title, | ||
s.titleSize[size], | ||
s.titleVariant[variant], | ||
className, | ||
)} | ||
{...rest} | ||
/> | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './Title' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters