File tree Expand file tree Collapse file tree 5 files changed +195
-2
lines changed Expand file tree Collapse file tree 5 files changed +195
-2
lines changed Original file line number Diff line number Diff line change 1515 "build" : " tsc -b && vite build" ,
1616 "lint" : " eslint ." ,
1717 "preview" : " vite preview" ,
18- "storybook" : " storybook dev -p 6006" ,
18+ "storybook" : " storybook dev -p 6006 --no-open " ,
1919 "build-storybook" : " storybook build"
2020 },
2121 "dependencies" : {
Original file line number Diff line number Diff line change 1+ import { Typography } from "./Typography" ;
2+
3+ import type { Meta , StoryObj } from "@storybook/react-vite" ;
4+
5+ const meta : Meta < typeof Typography > = {
6+ title : "Components/Typography" ,
7+ component : Typography ,
8+ tags : [ "autodocs" ] ,
9+ } ;
10+
11+ export default meta ;
12+
13+ type Story = StoryObj < typeof Typography > ;
14+
15+ export const Primary : Story = {
16+ args : {
17+ children : "Typography" ,
18+ } ,
19+ render : ( ) => (
20+ < div style = { { display : "flex" , flexDirection : "column" , gap : "0.5rem" } } >
21+ < Typography variant = "h1" > Heading 1</ Typography >
22+ < Typography variant = "h2" > Heading 2</ Typography >
23+ < Typography variant = "h3" > Heading 3</ Typography >
24+ < Typography variant = "h4" > Heading 4</ Typography >
25+ < Typography variant = "h5" > Heading 5</ Typography >
26+ < Typography variant = "h6" > Heading 6</ Typography >
27+ < Typography variant = "body" > Body</ Typography >
28+ < Typography variant = "body-semibold" > Body-semibold</ Typography >
29+ < Typography variant = "hint" > Hint</ Typography >
30+ </ div >
31+ ) ,
32+ } ;
Original file line number Diff line number Diff line change 1+ import MuiTypography from "@mui/material/Typography" ;
2+ import type { TypographyProps as MuiTypographyProps } from "@mui/material/Typography" ;
3+ import React from "react" ;
4+
5+ declare module "@mui/material/styles" {
6+ interface TypographyVariants {
7+ body : React . CSSProperties ;
8+ "body-semibold" : React . CSSProperties ;
9+ hint : React . CSSProperties ;
10+ }
11+
12+ interface TypographyVariantsOptions {
13+ body ?: React . CSSProperties ;
14+ "body-semibold" ?: React . CSSProperties ;
15+ hint ?: React . CSSProperties ;
16+ }
17+ }
18+
19+ declare module "@mui/material/Typography" {
20+ interface TypographyPropsVariantOverrides {
21+ body : true ;
22+ "body-semibold" : true ;
23+ hint : true ;
24+ body1 : false ;
25+ body2 : false ;
26+ button : false ;
27+ overline : false ;
28+ subtitle1 : false ;
29+ subtitle2 : false ;
30+ caption : false ;
31+ }
32+ }
33+
34+ export type TypographyProps = MuiTypographyProps ;
35+
36+ export const Typography : React . FC < TypographyProps > = ( props ) => {
37+ return < MuiTypography { ...props } /> ;
38+ } ;
Original file line number Diff line number Diff line change 1+ import type {
2+ Breakpoints ,
3+ TypographyVariantsOptions ,
4+ } from "@mui/material/styles" ;
5+
6+ export function createTypographyOptions (
7+ breakpoints : Breakpoints ,
8+ ) : TypographyVariantsOptions {
9+ const xsOnly = breakpoints . only ( "xs" ) ;
10+
11+ return {
12+ fontSize : 14 ,
13+ fontWeightLight : 300 ,
14+ fontWeightRegular : 400 ,
15+ fontWeightMedium : 500 ,
16+ fontWeightBold : 600 ,
17+ fontFamily : '"Inter", sans-serif' ,
18+
19+ h1 : {
20+ fontSize : "32px" ,
21+ lineHeight : "40px" ,
22+ fontWeight : 700 ,
23+ [ xsOnly ] : {
24+ fontSize : "28px" ,
25+ lineHeight : "36px" ,
26+ } ,
27+ } ,
28+
29+ h2 : {
30+ fontSize : "24px" ,
31+ lineHeight : "28px" ,
32+ fontWeight : 500 ,
33+ [ xsOnly ] : {
34+ fontSize : "22px" ,
35+ lineHeight : "26px" ,
36+ } ,
37+ } ,
38+
39+ h3 : {
40+ fontSize : "20px" ,
41+ lineHeight : "28px" ,
42+ fontWeight : 500 ,
43+ [ xsOnly ] : {
44+ fontSize : "20px" ,
45+ lineHeight : "26px" ,
46+ } ,
47+ } ,
48+
49+ h4 : {
50+ fontSize : "16px" ,
51+ lineHeight : "24px" ,
52+ fontWeight : 500 ,
53+ [ xsOnly ] : {
54+ fontSize : "17px" ,
55+ lineHeight : "26px" ,
56+ } ,
57+ } ,
58+
59+ h5 : {
60+ fontSize : "14px" ,
61+ lineHeight : "22px" ,
62+ fontWeight : 600 ,
63+ [ xsOnly ] : {
64+ fontSize : "16px" ,
65+ lineHeight : "26px" ,
66+ } ,
67+ } ,
68+
69+ h6 : {
70+ fontSize : "12px" ,
71+ lineHeight : "16px" ,
72+ fontWeight : 700 ,
73+ letterSpacing : "0.1em" ,
74+ textTransform : "uppercase" ,
75+ [ xsOnly ] : {
76+ fontSize : "14px" ,
77+ lineHeight : "20px" ,
78+ } ,
79+ } ,
80+
81+ body : {
82+ fontSize : "14px" ,
83+ lineHeight : "20px" ,
84+ fontWeight : 600 ,
85+ [ xsOnly ] : {
86+ fontSize : "16px" ,
87+ lineHeight : "26px" ,
88+ } ,
89+ } ,
90+
91+ "body-semibold" : {
92+ fontSize : "14px" ,
93+ lineHeight : "20px" ,
94+ fontWeight : 400 ,
95+ [ xsOnly ] : {
96+ fontSize : "16px" ,
97+ lineHeight : "26px" ,
98+ } ,
99+ } ,
100+
101+ hint : {
102+ fontSize : "12px" ,
103+ lineHeight : "18px" ,
104+ fontWeight : 400 ,
105+ [ xsOnly ] : {
106+ fontSize : "14px" ,
107+ lineHeight : "20px" ,
108+ } ,
109+ } ,
110+
111+ body1 : undefined ,
112+ body2 : undefined ,
113+ button : undefined ,
114+ overline : undefined ,
115+ subtitle1 : undefined ,
116+ subtitle2 : undefined ,
117+ caption : undefined ,
118+ } ;
119+ }
Original file line number Diff line number Diff line change 11import { type ColorSystemOptions } from "@mui/material" ;
22import { createTheme as createMuiTheme } from "@mui/material/styles" ;
33import { Color , ColorDark } from "./color" ;
4+ import { createTypographyOptions } from "./Typography/typographyOptions" ;
45
56export function createTheme ( ) {
7+ const basicTheme = createMuiTheme ( ) ;
8+
69 const theme = createMuiTheme ( {
710 colorSchemes : {
811 light : {
@@ -15,13 +18,14 @@ export function createTheme() {
1518 cssVariables : {
1619 colorSchemeSelector : ".sd-theme-%s" ,
1720 } ,
21+ typography : createTypographyOptions ( basicTheme . breakpoints ) ,
1822 } ) ;
1923
2024 return theme ;
2125}
2226
2327function createPalette (
24- colorScheme : "light" | "dark"
28+ colorScheme : "light" | "dark" ,
2529) : ColorSystemOptions [ "palette" ] {
2630 const color = colorScheme === "light" ? Color : ColorDark ;
2731
You can’t perform that action at this time.
0 commit comments