Skip to content

Commit 1605b08

Browse files
feat: implemented typography hook
1 parent fdd67dc commit 1605b08

File tree

4 files changed

+95
-2
lines changed

4 files changed

+95
-2
lines changed

src/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,10 @@ export {
2828
type SurfaceContainerThemeBlock,
2929
} from './theme/theme.types';
3030
export {useTheme} from './theme/useTheme.hook';
31-
export {buildThemesFromColors} from './theme/theme';
32-
export {LightTheme, DarkTheme, ThemeContainer, defaultThemeColors, type ThemeContainerProps} from './theme/Theme.context';
31+
export {LightTheme, DarkTheme, defaultThemeColors, buildThemesFromColors} from './theme/build-theme';
32+
33+
export {materialTypography} from './typography/typography.styles';
34+
export {useTypography} from './typography/useTypography.component';
35+
export {type MaterialTypography} from './typography/typography.types';
36+
37+
export {type MaterialComponentsProviderProps, MaterialComponentsProvider} from './provider/MaterialComponents.context';
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import {StyleSheet} from 'react-native';
2+
3+
import {type MaterialTypography} from './typography.types';
4+
5+
export const materialTypography = StyleSheet.create<MaterialTypography>({
6+
displayLarge: {
7+
fontSize: 57,
8+
letterSpacing: -0.25,
9+
},
10+
displayMedium: {
11+
fontSize: 45,
12+
},
13+
displaySmall: {
14+
fontSize: 36,
15+
},
16+
headlineLarge: {
17+
fontSize: 32,
18+
},
19+
headlineMedium: {
20+
fontSize: 28,
21+
},
22+
headlineSmall: {
23+
fontSize: 24,
24+
},
25+
titleLarge: {
26+
fontSize: 22,
27+
},
28+
titleMedium: {
29+
fontSize: 16,
30+
letterSpacing: 0.15,
31+
},
32+
titleSmall: {
33+
fontSize: 14,
34+
letterSpacing: 0.1,
35+
},
36+
labelLarge: {
37+
fontSize: 14,
38+
letterSpacing: 0.1,
39+
},
40+
labelMedium: {
41+
fontSize: 12,
42+
letterSpacing: 0.5,
43+
},
44+
labelSmall: {
45+
fontSize: 11,
46+
letterSpacing: 0.5,
47+
},
48+
bodyLarge: {
49+
fontSize: 16,
50+
letterSpacing: 0.5,
51+
},
52+
bodyMedium: {
53+
fontSize: 14,
54+
letterSpacing: 0.25,
55+
},
56+
bodySmall: {
57+
fontSize: 12,
58+
letterSpacing: 0.4,
59+
},
60+
});

src/typography/typography.types.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type {TextStyle} from 'react-native';
2+
3+
export interface MaterialTypography {
4+
displayLarge: TextStyle;
5+
displayMedium: TextStyle;
6+
displaySmall: TextStyle;
7+
headlineLarge: TextStyle;
8+
headlineMedium: TextStyle;
9+
headlineSmall: TextStyle;
10+
titleLarge: TextStyle;
11+
titleMedium: TextStyle;
12+
titleSmall: TextStyle;
13+
labelLarge: TextStyle;
14+
labelMedium: TextStyle;
15+
labelSmall: TextStyle;
16+
bodyLarge: TextStyle;
17+
bodyMedium: TextStyle;
18+
bodySmall: TextStyle;
19+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {useContext} from 'react';
2+
3+
import {MaterialComponentsContext} from '../provider/MaterialComponents.context';
4+
5+
export const useTypography = () => {
6+
const {typography} = useContext(MaterialComponentsContext);
7+
8+
return typography;
9+
};

0 commit comments

Comments
 (0)