@compsych/mobile-ui 1.0.2 → 1.0.4
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compsych/mobile-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "ComPsych React Native Design System — 19 mobile UI components with self-contained design tokens",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
],
|
|
19
19
|
"license": "UNLICENSED",
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@expo-google-fonts/google-sans": ">=0.4.0",
|
|
22
21
|
"@expo/vector-icons": ">=15.0.0",
|
|
22
|
+
"expo-font": ">=13.0.0",
|
|
23
23
|
"react": ">=18.0.0",
|
|
24
24
|
"react-native": ">=0.73.0"
|
|
25
25
|
}
|
package/src/BodyText.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text, type TextProps } from 'react-native';
|
|
3
|
+
import { useFonts } from 'expo-font';
|
|
3
4
|
|
|
4
5
|
import { sys } from './tokens';
|
|
5
6
|
|
|
@@ -23,7 +24,7 @@ const FONT_FAMILY: Record<string, string> = {
|
|
|
23
24
|
semibold: 'GoogleSans_600SemiBold',
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
const VARIANT_TOKEN_KEY: Record<BodyVariant,
|
|
27
|
+
const VARIANT_TOKEN_KEY: Record<BodyVariant, keyof typeof sys.typeScale> = {
|
|
27
28
|
large: 'bodyLarge',
|
|
28
29
|
medium: 'bodyMedium',
|
|
29
30
|
small: 'bodySmall',
|
|
@@ -41,6 +42,12 @@ export function BodyText({
|
|
|
41
42
|
style,
|
|
42
43
|
...rest
|
|
43
44
|
}: BodyTextProps) {
|
|
45
|
+
const [fontsLoaded] = useFonts({
|
|
46
|
+
GoogleSans_400Regular: require('./fonts/GoogleSans_400Regular.ttf'),
|
|
47
|
+
GoogleSans_500Medium: require('./fonts/GoogleSans_500Medium.ttf'),
|
|
48
|
+
GoogleSans_600SemiBold: require('./fonts/GoogleSans_600SemiBold.ttf'),
|
|
49
|
+
});
|
|
50
|
+
|
|
44
51
|
const token = ts[VARIANT_TOKEN_KEY[variant]];
|
|
45
52
|
const weight = emphasized ? token.sysFontWeightEmphasized : token.sysFontWeight;
|
|
46
53
|
|
|
@@ -48,7 +55,7 @@ export function BodyText({
|
|
|
48
55
|
<Text
|
|
49
56
|
style={[
|
|
50
57
|
{
|
|
51
|
-
fontFamily: FONT_FAMILY[weight],
|
|
58
|
+
fontFamily: fontsLoaded ? FONT_FAMILY[weight] : undefined,
|
|
52
59
|
fontSize: token.sysFontSize,
|
|
53
60
|
lineHeight: token.sysLineHeight,
|
|
54
61
|
letterSpacing: token.sysTracking,
|
package/src/HeaderText.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Text, type TextProps } from 'react-native';
|
|
3
|
+
import { useFonts } from 'expo-font';
|
|
3
4
|
|
|
4
5
|
import { sys } from './tokens';
|
|
5
6
|
|
|
@@ -26,7 +27,7 @@ const FONT_FAMILY: Record<string, string> = {
|
|
|
26
27
|
semibold: 'GoogleSans_600SemiBold',
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
const VARIANT_TOKEN_KEY: Record<HeaderVariant,
|
|
30
|
+
const VARIANT_TOKEN_KEY: Record<HeaderVariant, keyof typeof sys.typeScale> = {
|
|
30
31
|
large: 'displayLarge',
|
|
31
32
|
medium: 'displayMedium',
|
|
32
33
|
small: 'displaySmall',
|
|
@@ -47,6 +48,12 @@ export function HeaderText({
|
|
|
47
48
|
style,
|
|
48
49
|
...rest
|
|
49
50
|
}: HeaderTextProps) {
|
|
51
|
+
const [fontsLoaded] = useFonts({
|
|
52
|
+
GoogleSans_400Regular: require('./fonts/GoogleSans_400Regular.ttf'),
|
|
53
|
+
GoogleSans_500Medium: require('./fonts/GoogleSans_500Medium.ttf'),
|
|
54
|
+
GoogleSans_600SemiBold: require('./fonts/GoogleSans_600SemiBold.ttf'),
|
|
55
|
+
});
|
|
56
|
+
|
|
50
57
|
const token = ts[VARIANT_TOKEN_KEY[variant]];
|
|
51
58
|
const weight = emphasized ? token.sysFontWeightEmphasized : token.sysFontWeight;
|
|
52
59
|
|
|
@@ -55,7 +62,7 @@ export function HeaderText({
|
|
|
55
62
|
accessibilityRole="header"
|
|
56
63
|
style={[
|
|
57
64
|
{
|
|
58
|
-
fontFamily: FONT_FAMILY[weight],
|
|
65
|
+
fontFamily: fontsLoaded ? FONT_FAMILY[weight] : undefined,
|
|
59
66
|
fontSize: token.sysFontSize,
|
|
60
67
|
lineHeight: token.sysLineHeight,
|
|
61
68
|
letterSpacing: token.sysTracking,
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|