1 | import { Public_Sans, Barlow } from 'next/font/google';
|
---|
2 |
|
---|
3 | // ----------------------------------------------------------------------
|
---|
4 |
|
---|
5 | export function remToPx(value: string) {
|
---|
6 | return Math.round(parseFloat(value) * 16);
|
---|
7 | }
|
---|
8 |
|
---|
9 | export function pxToRem(value: number) {
|
---|
10 | return `${value / 16}rem`;
|
---|
11 | }
|
---|
12 |
|
---|
13 | export function responsiveFontSizes({ sm, md, lg }: { sm: number; md: number; lg: number }) {
|
---|
14 | return {
|
---|
15 | '@media (min-width:600px)': {
|
---|
16 | fontSize: pxToRem(sm),
|
---|
17 | },
|
---|
18 | '@media (min-width:900px)': {
|
---|
19 | fontSize: pxToRem(md),
|
---|
20 | },
|
---|
21 | '@media (min-width:1200px)': {
|
---|
22 | fontSize: pxToRem(lg),
|
---|
23 | },
|
---|
24 | };
|
---|
25 | }
|
---|
26 |
|
---|
27 | declare module '@mui/material/styles' {
|
---|
28 | interface TypographyVariants {
|
---|
29 | fontWeightSemiBold: React.CSSProperties['fontWeight'];
|
---|
30 | }
|
---|
31 | }
|
---|
32 | export const primaryFont = Public_Sans({
|
---|
33 | weight: ['400', '500', '600', '700', '800'],
|
---|
34 | subsets: ['latin'],
|
---|
35 | display: 'swap',
|
---|
36 | fallback: ['Helvetica', 'Arial', 'sans-serif'],
|
---|
37 | });
|
---|
38 |
|
---|
39 | export const secondaryFont = Barlow({
|
---|
40 | weight: ['900'],
|
---|
41 | subsets: ['latin'],
|
---|
42 | display: 'swap',
|
---|
43 | fallback: ['Helvetica', 'Arial', 'sans-serif'],
|
---|
44 | });
|
---|
45 |
|
---|
46 | // ----------------------------------------------------------------------
|
---|
47 |
|
---|
48 | // LEARN MORE
|
---|
49 | // https://nextjs.org/docs/basic-features/font-optimization#google-fonts
|
---|
50 |
|
---|
51 | export const typography = {
|
---|
52 | fontFamily: primaryFont.style.fontFamily,
|
---|
53 | fontWeightRegular: 400,
|
---|
54 | fontWeightMedium: 500,
|
---|
55 | fontWeightSemiBold: 600,
|
---|
56 | fontWeightBold: 700,
|
---|
57 | h1: {
|
---|
58 | fontWeight: 800,
|
---|
59 | lineHeight: 80 / 64,
|
---|
60 | fontSize: pxToRem(40),
|
---|
61 | ...responsiveFontSizes({ sm: 52, md: 58, lg: 64 }),
|
---|
62 | },
|
---|
63 | h2: {
|
---|
64 | fontWeight: 800,
|
---|
65 | lineHeight: 64 / 48,
|
---|
66 | fontSize: pxToRem(32),
|
---|
67 | ...responsiveFontSizes({ sm: 40, md: 44, lg: 48 }),
|
---|
68 | },
|
---|
69 | h3: {
|
---|
70 | fontWeight: 700,
|
---|
71 | lineHeight: 1.5,
|
---|
72 | fontSize: pxToRem(24),
|
---|
73 | ...responsiveFontSizes({ sm: 26, md: 30, lg: 32 }),
|
---|
74 | },
|
---|
75 | h4: {
|
---|
76 | fontWeight: 700,
|
---|
77 | lineHeight: 1.5,
|
---|
78 | fontSize: pxToRem(20),
|
---|
79 | ...responsiveFontSizes({ sm: 20, md: 24, lg: 24 }),
|
---|
80 | },
|
---|
81 | h5: {
|
---|
82 | fontWeight: 700,
|
---|
83 | lineHeight: 1.5,
|
---|
84 | fontSize: pxToRem(18),
|
---|
85 | ...responsiveFontSizes({ sm: 19, md: 20, lg: 20 }),
|
---|
86 | },
|
---|
87 | h6: {
|
---|
88 | fontWeight: 700,
|
---|
89 | lineHeight: 28 / 18,
|
---|
90 | fontSize: pxToRem(17),
|
---|
91 | ...responsiveFontSizes({ sm: 18, md: 18, lg: 18 }),
|
---|
92 | },
|
---|
93 | subtitle1: {
|
---|
94 | fontWeight: 600,
|
---|
95 | lineHeight: 1.5,
|
---|
96 | fontSize: pxToRem(16),
|
---|
97 | },
|
---|
98 | subtitle2: {
|
---|
99 | fontWeight: 600,
|
---|
100 | lineHeight: 22 / 14,
|
---|
101 | fontSize: pxToRem(14),
|
---|
102 | },
|
---|
103 | body1: {
|
---|
104 | lineHeight: 1.5,
|
---|
105 | fontSize: pxToRem(16),
|
---|
106 | },
|
---|
107 | body2: {
|
---|
108 | lineHeight: 22 / 14,
|
---|
109 | fontSize: pxToRem(14),
|
---|
110 | },
|
---|
111 | caption: {
|
---|
112 | lineHeight: 1.5,
|
---|
113 | fontSize: pxToRem(12),
|
---|
114 | },
|
---|
115 | overline: {
|
---|
116 | fontWeight: 700,
|
---|
117 | lineHeight: 1.5,
|
---|
118 | fontSize: pxToRem(12),
|
---|
119 | textTransform: 'uppercase',
|
---|
120 | },
|
---|
121 | button: {
|
---|
122 | fontWeight: 700,
|
---|
123 | lineHeight: 24 / 14,
|
---|
124 | fontSize: pxToRem(14),
|
---|
125 | textTransform: 'unset',
|
---|
126 | },
|
---|
127 | } as const;
|
---|