@korsolutions/ui 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # TODO
2
+ - [ ] Line height
@@ -1,5 +1,6 @@
1
1
  import { E as InputStyles, f as SelectStyles, k as FieldStyles, r as CardStyles, u as SelectRootBaseProps, w as InputPrimitiveBaseProps, x as ButtonStyles } from "../index-Dafk8ZGv.mjs";
2
2
  import React from "react";
3
+ import { TextProps, TextStyle } from "react-native";
3
4
 
4
5
  //#region src/components/button/variants/index.d.ts
5
6
  declare const ButtonVariants: {
@@ -81,4 +82,53 @@ interface SelectProps<T> extends SelectRootBaseProps {
81
82
  }
82
83
  declare function Select<T>(props: SelectProps<T>): React.JSX.Element;
83
84
  //#endregion
84
- export { Button, Card, Field, FieldProps, Input, Select, SelectOption, SelectProps };
85
+ //#region src/components/typography/variants/body-lg.d.ts
86
+ declare function useTextVariantBodyLg(): TextStyle;
87
+ //#endregion
88
+ //#region src/components/typography/variants/body-md.d.ts
89
+ declare function useTextVariantBodyMd(): TextStyle;
90
+ //#endregion
91
+ //#region src/components/typography/variants/body-sm.d.ts
92
+ declare function useTextVariantBodySm(): TextStyle;
93
+ //#endregion
94
+ //#region src/components/typography/variants/heading-lg.d.ts
95
+ declare function useTextVariantHeadingLg(): TextStyle;
96
+ //#endregion
97
+ //#region src/components/typography/variants/heading-md.d.ts
98
+ declare function useTextVariantHeadingMd(): TextStyle;
99
+ //#endregion
100
+ //#region src/components/typography/variants/heading-sm.d.ts
101
+ declare function useTextVariantHeadingSm(): TextStyle;
102
+ //#endregion
103
+ //#region src/components/typography/variants/index.d.ts
104
+ declare const TypographyVariants: {
105
+ "body-sm": typeof useTextVariantBodySm;
106
+ "body-md": typeof useTextVariantBodyMd;
107
+ "body-lg": typeof useTextVariantBodyLg;
108
+ "heading-sm": typeof useTextVariantHeadingSm;
109
+ "heading-md": typeof useTextVariantHeadingMd;
110
+ "heading-lg": typeof useTextVariantHeadingLg;
111
+ };
112
+ //#endregion
113
+ //#region src/components/typography/typography.d.ts
114
+ interface TypographyProps extends TextProps {
115
+ variant?: keyof typeof TypographyVariants;
116
+ }
117
+ declare function Typography(props: TypographyProps): React.JSX.Element;
118
+ //#endregion
119
+ //#region src/components/link/variants/default.d.ts
120
+ declare function useLinkVariantDefault(): TextStyle;
121
+ //#endregion
122
+ //#region src/components/link/variants/index.d.ts
123
+ declare const LinkVariants: {
124
+ default: typeof useLinkVariantDefault;
125
+ };
126
+ //#endregion
127
+ //#region src/components/link/link.d.ts
128
+ interface LinkProps extends TextProps {
129
+ href?: string;
130
+ variant?: keyof typeof LinkVariants;
131
+ }
132
+ declare function Link(props: LinkProps): React.JSX.Element;
133
+ //#endregion
134
+ export { Button, Card, Field, FieldProps, Input, Link, LinkProps, Select, SelectOption, SelectProps, Typography, TypographyProps };
@@ -1,7 +1,8 @@
1
- import { n as useTheme } from "../themes-BrLbh9h6.mjs";
1
+ import { n as useTheme } from "../themes-DXcjBdO2.mjs";
2
2
  import "../portal-DoPaAohb.mjs";
3
3
  import { a as FieldPrimitive, i as InputPrimitive, n as SelectPrimitive, r as ButtonPrimitive, t as CardPrimitive } from "../primitives-C2enZ5Ku.mjs";
4
4
  import React from "react";
5
+ import { Linking, Text } from "react-native";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
7
 
7
8
  //#region src/utils/use-themed-styles.ts
@@ -10,14 +11,16 @@ const useThemedStyles = (callback) => {
10
11
  return callback({
11
12
  colors: theme.colors,
12
13
  radius: theme.radius,
13
- fontFamily: theme.fontFamily
14
+ fontFamily: theme.fontFamily,
15
+ letterSpacing: theme.letterSpacing,
16
+ fontSize: theme.fontSize
14
17
  });
15
18
  };
16
19
 
17
20
  //#endregion
18
21
  //#region src/components/button/variants/default.tsx
19
22
  const useButtonVariantDefault = () => {
20
- return useThemedStyles(({ colors, radius, fontFamily }) => ({
23
+ return useThemedStyles(({ colors, radius, fontFamily, fontSize }) => ({
21
24
  root: {
22
25
  default: {
23
26
  flexDirection: "row",
@@ -35,7 +38,7 @@ const useButtonVariantDefault = () => {
35
38
  label: {
36
39
  default: {
37
40
  color: colors.primaryForeground,
38
- fontSize: 16,
41
+ fontSize,
39
42
  fontWeight: "bold",
40
43
  fontFamily
41
44
  },
@@ -70,7 +73,7 @@ function Button(props) {
70
73
  //#endregion
71
74
  //#region src/components/card/variants/default.tsx
72
75
  function useCardVariantDefault() {
73
- return useThemedStyles(({ colors, radius, fontFamily }) => ({
76
+ return useThemedStyles(({ colors, radius, fontFamily, fontSize }) => ({
74
77
  root: { default: {
75
78
  borderWidth: 1,
76
79
  borderColor: colors.border,
@@ -82,7 +85,7 @@ function useCardVariantDefault() {
82
85
  header: { default: { paddingHorizontal: 24 } },
83
86
  title: { default: {
84
87
  fontFamily,
85
- fontSize: 18,
88
+ fontSize: fontSize * 1.25,
86
89
  fontWeight: "600",
87
90
  color: colors.foreground
88
91
  } },
@@ -111,7 +114,7 @@ function Card(props) {
111
114
  //#endregion
112
115
  //#region src/components/input/variants/default.tsx
113
116
  function useInputVariantDefault() {
114
- return useThemedStyles(({ colors, radius, fontFamily }) => ({
117
+ return useThemedStyles(({ colors, radius, fontFamily, fontSize }) => ({
115
118
  default: {
116
119
  placeholderTextColor: colors.mutedForeground,
117
120
  selectionColor: colors.primary,
@@ -124,6 +127,7 @@ function useInputVariantDefault() {
124
127
  paddingHorizontal: 16,
125
128
  outlineWidth: 0,
126
129
  fontFamily,
130
+ fontSize,
127
131
  height: 48,
128
132
  color: colors.foreground
129
133
  }
@@ -143,7 +147,8 @@ const InputVariants = { default: useInputVariantDefault };
143
147
  //#endregion
144
148
  //#region src/components/input/input.tsx
145
149
  function Input(props) {
146
- const variantStyles = (props.variant ? InputVariants[props.variant] : InputVariants["default"])();
150
+ const useVariantStyles = InputVariants[props.variant ?? "default"];
151
+ const variantStyles = useVariantStyles();
147
152
  return /* @__PURE__ */ jsx(InputPrimitive, {
148
153
  ...props,
149
154
  styles: variantStyles
@@ -153,25 +158,25 @@ function Input(props) {
153
158
  //#endregion
154
159
  //#region src/components/field/variants/default.tsx
155
160
  const useFieldVariantDefault = () => {
156
- return useThemedStyles(({ colors, fontFamily }) => ({
161
+ return useThemedStyles(({ colors, fontFamily, fontSize }) => ({
157
162
  root: {
158
163
  flexDirection: "column",
159
164
  gap: 8
160
165
  },
161
166
  label: {
162
167
  fontFamily,
163
- fontSize: 14,
168
+ fontSize: fontSize * .875,
164
169
  fontWeight: "600",
165
170
  color: colors.foreground
166
171
  },
167
172
  description: {
168
173
  fontFamily,
169
- fontSize: 14,
174
+ fontSize: fontSize * .875,
170
175
  color: colors.mutedForeground
171
176
  },
172
177
  error: {
173
178
  fontFamily,
174
- fontSize: 14,
179
+ fontSize: fontSize * .875,
175
180
  color: colors.danger
176
181
  }
177
182
  }));
@@ -203,7 +208,7 @@ function Field(props) {
203
208
  //#endregion
204
209
  //#region src/components/select/variants/default.tsx
205
210
  function useSelectVariantDefault() {
206
- return useThemedStyles(({ colors, radius, fontFamily }) => ({
211
+ return useThemedStyles(({ colors, radius, fontFamily, fontSize }) => ({
207
212
  root: {
208
213
  default: {},
209
214
  disabled: {}
@@ -223,7 +228,7 @@ function useSelectVariantDefault() {
223
228
  value: {
224
229
  default: {
225
230
  fontFamily,
226
- fontSize: 16,
231
+ fontSize,
227
232
  color: colors.foreground
228
233
  },
229
234
  disabled: { color: colors.mutedForeground }
@@ -231,7 +236,7 @@ function useSelectVariantDefault() {
231
236
  placeholder: {
232
237
  default: {
233
238
  fontFamily,
234
- fontSize: 16,
239
+ fontSize,
235
240
  color: colors.mutedForeground
236
241
  },
237
242
  disabled: { color: colors.mutedForeground }
@@ -256,7 +261,7 @@ function useSelectVariantDefault() {
256
261
  paddingVertical: 12,
257
262
  paddingHorizontal: 16,
258
263
  fontFamily,
259
- fontSize: 16,
264
+ fontSize,
260
265
  color: colors.foreground,
261
266
  borderRadius: radius / 2
262
267
  },
@@ -287,4 +292,129 @@ function Select(props) {
287
292
  }
288
293
 
289
294
  //#endregion
290
- export { Button, Card, Field, Input, Select };
295
+ //#region src/components/typography/variants/body-lg.tsx
296
+ function useTextVariantBodyLg() {
297
+ return useThemedStyles(({ colors, fontFamily, letterSpacing, fontSize }) => ({
298
+ color: colors.foreground,
299
+ fontSize: fontSize * 1.25,
300
+ fontFamily,
301
+ letterSpacing
302
+ }));
303
+ }
304
+
305
+ //#endregion
306
+ //#region src/components/typography/variants/body-md.tsx
307
+ function useTextVariantBodyMd() {
308
+ return useThemedStyles(({ colors, fontFamily, letterSpacing, fontSize }) => ({
309
+ color: colors.foreground,
310
+ fontSize,
311
+ fontFamily,
312
+ letterSpacing
313
+ }));
314
+ }
315
+
316
+ //#endregion
317
+ //#region src/components/typography/variants/body-sm.tsx
318
+ function useTextVariantBodySm() {
319
+ return useThemedStyles(({ colors, fontFamily, letterSpacing, fontSize }) => ({
320
+ color: colors.foreground,
321
+ fontSize: fontSize * .875,
322
+ fontFamily,
323
+ letterSpacing
324
+ }));
325
+ }
326
+
327
+ //#endregion
328
+ //#region src/components/typography/variants/heading-lg.tsx
329
+ function useTextVariantHeadingLg() {
330
+ return useThemedStyles(({ colors, fontFamily, letterSpacing, fontSize }) => ({
331
+ color: colors.foreground,
332
+ fontSize: fontSize * 1.5,
333
+ fontFamily,
334
+ letterSpacing,
335
+ fontWeight: "600"
336
+ }));
337
+ }
338
+
339
+ //#endregion
340
+ //#region src/components/typography/variants/heading-md.tsx
341
+ function useTextVariantHeadingMd() {
342
+ return useThemedStyles(({ colors, fontFamily, letterSpacing, fontSize }) => ({
343
+ color: colors.foreground,
344
+ fontSize: fontSize * 1.25,
345
+ fontFamily,
346
+ letterSpacing,
347
+ fontWeight: "600"
348
+ }));
349
+ }
350
+
351
+ //#endregion
352
+ //#region src/components/typography/variants/heading-sm.tsx
353
+ function useTextVariantHeadingSm() {
354
+ return useThemedStyles(({ colors, fontFamily, letterSpacing, fontSize }) => ({
355
+ color: colors.foreground,
356
+ fontSize,
357
+ fontFamily,
358
+ letterSpacing,
359
+ fontWeight: "600"
360
+ }));
361
+ }
362
+
363
+ //#endregion
364
+ //#region src/components/typography/variants/index.ts
365
+ const TypographyVariants = {
366
+ ["body-sm"]: useTextVariantBodySm,
367
+ ["body-md"]: useTextVariantBodyMd,
368
+ ["body-lg"]: useTextVariantBodyLg,
369
+ ["heading-sm"]: useTextVariantHeadingSm,
370
+ ["heading-md"]: useTextVariantHeadingMd,
371
+ ["heading-lg"]: useTextVariantHeadingLg
372
+ };
373
+
374
+ //#endregion
375
+ //#region src/components/typography/typography.tsx
376
+ function Typography(props) {
377
+ const useVariantStyles = TypographyVariants[props.variant ?? "body-md"];
378
+ const variantStyles = useVariantStyles();
379
+ return /* @__PURE__ */ jsx(Text, {
380
+ ...props,
381
+ style: variantStyles
382
+ });
383
+ }
384
+
385
+ //#endregion
386
+ //#region src/components/link/variants/default.tsx
387
+ function useLinkVariantDefault() {
388
+ return useThemedStyles(({ colors, fontFamily, letterSpacing, fontSize }) => ({
389
+ color: colors.primary,
390
+ fontSize,
391
+ fontFamily,
392
+ textDecorationLine: "underline",
393
+ letterSpacing
394
+ }));
395
+ }
396
+
397
+ //#endregion
398
+ //#region src/components/link/variants/index.ts
399
+ const LinkVariants = { default: useLinkVariantDefault };
400
+
401
+ //#endregion
402
+ //#region src/components/link/link.tsx
403
+ function Link(props) {
404
+ const useVariantStyles = LinkVariants[props.variant ?? "default"];
405
+ const variantStyles = useVariantStyles();
406
+ const handlePress = async (e) => {
407
+ if (props.href) {
408
+ if (await Linking.canOpenURL(props.href)) await Linking.openURL(props.href);
409
+ }
410
+ props.onPress?.(e);
411
+ };
412
+ return /* @__PURE__ */ jsx(Text, {
413
+ ...props,
414
+ style: variantStyles,
415
+ onPress: handlePress
416
+ });
417
+ }
418
+
419
+ //#endregion
420
+ export { Button, Card, Field, Input, Link, Select, Typography };
package/dist/index.d.mts CHANGED
@@ -21,13 +21,18 @@ interface Colors {
21
21
  info: Color;
22
22
  }
23
23
  type Radius = number;
24
+ type FontFamily = string;
25
+ type LetterSpacing = number;
26
+ type FontSize = number;
24
27
  //#endregion
25
28
  //#region src/themes/provider.d.ts
26
29
  interface ThemeContext {
27
30
  colors: Colors;
28
31
  radius: Radius;
29
- fontFamily: string;
32
+ fontFamily: FontFamily;
30
33
  colorScheme: ColorScheme;
34
+ letterSpacing: LetterSpacing;
35
+ fontSize: FontSize;
31
36
  setColorScheme: (scheme: ColorScheme) => void;
32
37
  setTheme: (themeName: ThemeName) => void;
33
38
  themeName: ThemeName;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as useTheme, t as ThemeProvider } from "./themes-BrLbh9h6.mjs";
1
+ import { n as useTheme, t as ThemeProvider } from "./themes-DXcjBdO2.mjs";
2
2
  import { n as PortalHost } from "./portal-DoPaAohb.mjs";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
4
 
@@ -44,7 +44,9 @@ const defaultThemeAssets = {
44
44
  dark: darkColors
45
45
  },
46
46
  radius: 10,
47
- fontFamily: "System"
47
+ fontFamily: "System",
48
+ letterSpacing: 0,
49
+ fontSize: 16
48
50
  };
49
51
 
50
52
  //#endregion
@@ -71,7 +73,9 @@ const ThemeProvider = (props) => {
71
73
  setColorScheme,
72
74
  colors,
73
75
  radius: themesAssets.radius,
74
- fontFamily: themesAssets.fontFamily
76
+ fontFamily: themesAssets.fontFamily,
77
+ letterSpacing: themesAssets.letterSpacing,
78
+ fontSize: themesAssets.fontSize
75
79
  },
76
80
  children: props.children
77
81
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@korsolutions/ui",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
@@ -3,7 +3,7 @@ import { useThemedStyles } from "@/utils/use-themed-styles";
3
3
 
4
4
  export const useButtonVariantDefault = (): ButtonStyles => {
5
5
  return useThemedStyles(
6
- ({ colors, radius, fontFamily }): ButtonStyles => ({
6
+ ({ colors, radius, fontFamily, fontSize }): ButtonStyles => ({
7
7
  root: {
8
8
  default: {
9
9
  flexDirection: "row",
@@ -25,7 +25,7 @@ export const useButtonVariantDefault = (): ButtonStyles => {
25
25
  label: {
26
26
  default: {
27
27
  color: colors.primaryForeground,
28
- fontSize: 16,
28
+ fontSize,
29
29
  fontWeight: "bold",
30
30
  fontFamily,
31
31
  },
@@ -3,7 +3,7 @@ import { useThemedStyles } from "@/utils/use-themed-styles";
3
3
 
4
4
  export function useCardVariantDefault(): CardStyles {
5
5
  return useThemedStyles(
6
- ({ colors, radius, fontFamily }): CardStyles => ({
6
+ ({ colors, radius, fontFamily, fontSize }): CardStyles => ({
7
7
  root: {
8
8
  default: {
9
9
  borderWidth: 1,
@@ -22,7 +22,7 @@ export function useCardVariantDefault(): CardStyles {
22
22
  title: {
23
23
  default: {
24
24
  fontFamily,
25
- fontSize: 18,
25
+ fontSize: fontSize * 1.25,
26
26
  fontWeight: "600",
27
27
  color: colors.foreground,
28
28
  },
@@ -3,25 +3,25 @@ import { useThemedStyles } from "@/utils/use-themed-styles";
3
3
 
4
4
  export const useFieldVariantDefault = (): FieldStyles => {
5
5
  return useThemedStyles(
6
- ({ colors, fontFamily }): FieldStyles => ({
6
+ ({ colors, fontFamily, fontSize }): FieldStyles => ({
7
7
  root: {
8
8
  flexDirection: "column",
9
9
  gap: 8,
10
10
  },
11
11
  label: {
12
12
  fontFamily,
13
- fontSize: 14,
13
+ fontSize: fontSize * 0.875,
14
14
  fontWeight: "600",
15
15
  color: colors.foreground,
16
16
  },
17
17
  description: {
18
18
  fontFamily,
19
- fontSize: 14,
19
+ fontSize: fontSize * 0.875,
20
20
  color: colors.mutedForeground,
21
21
  },
22
22
  error: {
23
23
  fontFamily,
24
- fontSize: 14,
24
+ fontSize: fontSize * 0.875,
25
25
  color: colors.danger,
26
26
  },
27
27
  })
@@ -3,3 +3,5 @@ export * from "./card/card";
3
3
  export * from "./input/input";
4
4
  export * from "./field/field";
5
5
  export * from "./select/select";
6
+ export * from "./typography/typography";
7
+ export * from "./link/link";
@@ -7,7 +7,7 @@ interface InputProps extends InputPrimitiveBaseProps {
7
7
  }
8
8
 
9
9
  export function Input(props: InputProps) {
10
- const useVariantStyles = props.variant ? InputVariants[props.variant] : InputVariants["default"];
10
+ const useVariantStyles = InputVariants[props.variant ?? "default"];
11
11
  const variantStyles = useVariantStyles();
12
12
 
13
13
  return <InputPrimitive {...props} styles={variantStyles} />;
@@ -3,7 +3,7 @@ import { useThemedStyles } from "@/utils/use-themed-styles";
3
3
 
4
4
  export function useInputVariantDefault(): InputStyles {
5
5
  return useThemedStyles(
6
- ({ colors, radius, fontFamily }): InputStyles => ({
6
+ ({ colors, radius, fontFamily, fontSize }): InputStyles => ({
7
7
  default: {
8
8
  placeholderTextColor: colors.mutedForeground,
9
9
  selectionColor: colors.primary,
@@ -16,6 +16,7 @@ export function useInputVariantDefault(): InputStyles {
16
16
  paddingHorizontal: 16,
17
17
  outlineWidth: 0,
18
18
  fontFamily,
19
+ fontSize,
19
20
  height: 48,
20
21
  color: colors.foreground,
21
22
  },
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { Text as RnText, TextProps as RnTextProps, Linking } from "react-native";
3
+ import { LinkVariants } from "./variants";
4
+
5
+ export interface LinkProps extends RnTextProps {
6
+ href?: string;
7
+
8
+ variant?: keyof typeof LinkVariants;
9
+ }
10
+
11
+ export function Link(props: LinkProps) {
12
+ const useVariantStyles = LinkVariants[props.variant ?? "default"];
13
+ const variantStyles = useVariantStyles();
14
+
15
+ const handlePress: RnTextProps["onPress"] = async (e) => {
16
+ if (props.href) {
17
+ const supported = await Linking.canOpenURL(props.href);
18
+ if (supported) {
19
+ await Linking.openURL(props.href);
20
+ }
21
+ }
22
+ props.onPress?.(e);
23
+ };
24
+
25
+ return <RnText {...props} style={variantStyles} onPress={handlePress} />;
26
+ }
@@ -0,0 +1,14 @@
1
+ import { useThemedStyles } from "@/utils/use-themed-styles";
2
+ import { TextStyle } from "react-native";
3
+
4
+ export function useLinkVariantDefault(): TextStyle {
5
+ return useThemedStyles(
6
+ ({ colors, fontFamily, letterSpacing, fontSize }): TextStyle => ({
7
+ color: colors.primary,
8
+ fontSize,
9
+ fontFamily,
10
+ textDecorationLine: "underline",
11
+ letterSpacing,
12
+ })
13
+ );
14
+ }
@@ -0,0 +1,5 @@
1
+ import { useLinkVariantDefault } from "./default";
2
+
3
+ export const LinkVariants = {
4
+ default: useLinkVariantDefault,
5
+ };
@@ -3,7 +3,7 @@ import { useThemedStyles } from "@/utils/use-themed-styles";
3
3
 
4
4
  export function useSelectVariantDefault(): SelectStyles {
5
5
  return useThemedStyles(
6
- ({ colors, radius, fontFamily }): SelectStyles => ({
6
+ ({ colors, radius, fontFamily, fontSize }): SelectStyles => ({
7
7
  root: {
8
8
  default: {},
9
9
  disabled: {},
@@ -25,7 +25,7 @@ export function useSelectVariantDefault(): SelectStyles {
25
25
  value: {
26
26
  default: {
27
27
  fontFamily,
28
- fontSize: 16,
28
+ fontSize,
29
29
  color: colors.foreground,
30
30
  },
31
31
  disabled: {
@@ -35,7 +35,7 @@ export function useSelectVariantDefault(): SelectStyles {
35
35
  placeholder: {
36
36
  default: {
37
37
  fontFamily,
38
- fontSize: 16,
38
+ fontSize,
39
39
  color: colors.mutedForeground,
40
40
  },
41
41
  disabled: {
@@ -62,7 +62,7 @@ export function useSelectVariantDefault(): SelectStyles {
62
62
  paddingVertical: 12,
63
63
  paddingHorizontal: 16,
64
64
  fontFamily,
65
- fontSize: 16,
65
+ fontSize,
66
66
  color: colors.foreground,
67
67
  borderRadius: radius / 2,
68
68
  },
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { Text as RnText, TextProps as RnTextProps } from "react-native";
3
+ import { TypographyVariants } from "./variants";
4
+
5
+ export interface TypographyProps extends RnTextProps {
6
+ variant?: keyof typeof TypographyVariants;
7
+ }
8
+
9
+ export function Typography(props: TypographyProps) {
10
+ const useVariantStyles = TypographyVariants[props.variant ?? "body-md"];
11
+ const variantStyles = useVariantStyles();
12
+ return <RnText {...props} style={variantStyles} />;
13
+ }
@@ -0,0 +1,13 @@
1
+ import { useThemedStyles } from "@/utils/use-themed-styles";
2
+ import { TextStyle } from "react-native";
3
+
4
+ export function useTextVariantBodyLg(): TextStyle {
5
+ return useThemedStyles(
6
+ ({ colors, fontFamily, letterSpacing, fontSize }): TextStyle => ({
7
+ color: colors.foreground,
8
+ fontSize: fontSize * 1.25,
9
+ fontFamily,
10
+ letterSpacing,
11
+ })
12
+ );
13
+ }
@@ -0,0 +1,13 @@
1
+ import { useThemedStyles } from "@/utils/use-themed-styles";
2
+ import { TextStyle } from "react-native";
3
+
4
+ export function useTextVariantBodyMd(): TextStyle {
5
+ return useThemedStyles(
6
+ ({ colors, fontFamily, letterSpacing, fontSize }): TextStyle => ({
7
+ color: colors.foreground,
8
+ fontSize,
9
+ fontFamily,
10
+ letterSpacing,
11
+ })
12
+ );
13
+ }
@@ -0,0 +1,13 @@
1
+ import { useThemedStyles } from "@/utils/use-themed-styles";
2
+ import { TextStyle } from "react-native";
3
+
4
+ export function useTextVariantBodySm(): TextStyle {
5
+ return useThemedStyles(
6
+ ({ colors, fontFamily, letterSpacing, fontSize }): TextStyle => ({
7
+ color: colors.foreground,
8
+ fontSize: fontSize * 0.875,
9
+ fontFamily,
10
+ letterSpacing,
11
+ })
12
+ );
13
+ }
@@ -0,0 +1,14 @@
1
+ import { useThemedStyles } from "@/utils/use-themed-styles";
2
+ import { TextStyle } from "react-native";
3
+
4
+ export function useTextVariantHeadingLg(): TextStyle {
5
+ return useThemedStyles(
6
+ ({ colors, fontFamily, letterSpacing, fontSize }): TextStyle => ({
7
+ color: colors.foreground,
8
+ fontSize: fontSize * 1.5,
9
+ fontFamily,
10
+ letterSpacing,
11
+ fontWeight: "600",
12
+ })
13
+ );
14
+ }
@@ -0,0 +1,14 @@
1
+ import { useThemedStyles } from "@/utils/use-themed-styles";
2
+ import { TextStyle } from "react-native";
3
+
4
+ export function useTextVariantHeadingMd(): TextStyle {
5
+ return useThemedStyles(
6
+ ({ colors, fontFamily, letterSpacing, fontSize }): TextStyle => ({
7
+ color: colors.foreground,
8
+ fontSize: fontSize * 1.25,
9
+ fontFamily,
10
+ letterSpacing,
11
+ fontWeight: "600",
12
+ })
13
+ );
14
+ }
@@ -0,0 +1,14 @@
1
+ import { useThemedStyles } from "@/utils/use-themed-styles";
2
+ import { TextStyle } from "react-native";
3
+
4
+ export function useTextVariantHeadingSm(): TextStyle {
5
+ return useThemedStyles(
6
+ ({ colors, fontFamily, letterSpacing, fontSize }): TextStyle => ({
7
+ color: colors.foreground,
8
+ fontSize,
9
+ fontFamily,
10
+ letterSpacing,
11
+ fontWeight: "600",
12
+ })
13
+ );
14
+ }
@@ -0,0 +1,15 @@
1
+ import { useTextVariantBodyLg } from "./body-lg";
2
+ import { useTextVariantBodyMd } from "./body-md";
3
+ import { useTextVariantBodySm } from "./body-sm";
4
+ import { useTextVariantHeadingLg } from "./heading-lg";
5
+ import { useTextVariantHeadingMd } from "./heading-md";
6
+ import { useTextVariantHeadingSm } from "./heading-sm";
7
+
8
+ export const TypographyVariants = {
9
+ ["body-sm"]: useTextVariantBodySm,
10
+ ["body-md"]: useTextVariantBodyMd,
11
+ ["body-lg"]: useTextVariantBodyLg,
12
+ ["heading-sm"]: useTextVariantHeadingSm,
13
+ ["heading-md"]: useTextVariantHeadingMd,
14
+ ["heading-lg"]: useTextVariantHeadingLg,
15
+ };
@@ -8,4 +8,6 @@ export const defaultThemeAssets: ThemeAssets = {
8
8
  },
9
9
  radius: 10,
10
10
  fontFamily: "System",
11
+ letterSpacing: 0,
12
+ fontSize: 16,
11
13
  };
@@ -1,13 +1,15 @@
1
1
  import { createContext, PropsWithChildren, useContext, useEffect, useState } from "react";
2
- import { Colors, ColorScheme, Radius, ThemeName } from "./types";
2
+ import { Colors, ColorScheme, FontFamily, FontSize, LetterSpacing, Radius, ThemeName } from "./types";
3
3
  import { themes } from "./themes";
4
4
  import { useColorScheme } from "react-native";
5
5
 
6
6
  interface ThemeContext {
7
7
  colors: Colors;
8
8
  radius: Radius;
9
- fontFamily: string;
9
+ fontFamily: FontFamily;
10
10
  colorScheme: ColorScheme;
11
+ letterSpacing: LetterSpacing;
12
+ fontSize: FontSize;
11
13
  setColorScheme: (scheme: ColorScheme) => void;
12
14
  setTheme: (themeName: ThemeName) => void;
13
15
  themeName: ThemeName;
@@ -40,6 +42,8 @@ export const ThemeProvider = (props: PropsWithChildren) => {
40
42
  colors,
41
43
  radius: themesAssets.radius,
42
44
  fontFamily: themesAssets.fontFamily,
45
+ letterSpacing: themesAssets.letterSpacing,
46
+ fontSize: themesAssets.fontSize,
43
47
  }}
44
48
  >
45
49
  {props.children}
@@ -22,9 +22,13 @@ export interface Colors {
22
22
 
23
23
  export type Radius = number;
24
24
  export type FontFamily = string;
25
+ export type LetterSpacing = number;
26
+ export type FontSize = number;
25
27
 
26
28
  export interface ThemeAssets {
27
29
  colors: Record<ColorScheme, Colors>;
28
30
  radius: Radius;
29
31
  fontFamily: FontFamily;
32
+ letterSpacing: LetterSpacing;
33
+ fontSize: FontSize;
30
34
  }
@@ -1,13 +1,21 @@
1
1
  import { useTheme } from "@/themes";
2
- import { Colors, FontFamily, Radius } from "@/themes/types";
2
+ import { Colors, FontFamily, FontSize, LetterSpacing, Radius } from "@/themes/types";
3
3
 
4
4
  interface CallbackProps {
5
5
  colors: Colors;
6
6
  radius: Radius;
7
7
  fontFamily: FontFamily;
8
+ letterSpacing: LetterSpacing;
9
+ fontSize: FontSize;
8
10
  }
9
11
 
10
12
  export const useThemedStyles = <T>(callback: (props: CallbackProps) => T): T => {
11
13
  const theme = useTheme();
12
- return callback({ colors: theme.colors, radius: theme.radius, fontFamily: theme.fontFamily });
14
+ return callback({
15
+ colors: theme.colors,
16
+ radius: theme.radius,
17
+ fontFamily: theme.fontFamily,
18
+ letterSpacing: theme.letterSpacing,
19
+ fontSize: theme.fontSize,
20
+ });
13
21
  };