Skip to content

Commit ef23f6b

Browse files
committed
chore(example): added new example for typescript and expo
1 parent 7669cdb commit ef23f6b

File tree

4 files changed

+107
-3
lines changed

4 files changed

+107
-3
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"build": "pnpm run --filter './packages/**' build",
55
"check": "pnpm run --filter './packages/**' --parallel check",
66
"ios": "pnpm run --filter './packages/app' ios",
7+
"ios-typescript": "pnpm run --filter './packages/app-typescript' ios",
78
"test": "vitest run --coverage"
89
},
910
"devDependencies": {

packages/app-typescript/App.tsx

+102-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,115 @@
11
import { StatusBar } from 'expo-status-bar';
2-
import { StyleSheet, Text, View } from 'react-native';
2+
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
3+
import { createTokens, type VariantProps } from 'jacaranda'
4+
5+
const { styles } = createTokens({
6+
colors: {
7+
white: '#ffffff',
8+
black: '#000000',
9+
primary50: '#ecfeff',
10+
primary100: '#cffafe',
11+
primary200: '#a5f3fc',
12+
primary300: '#67e8f9',
13+
primary400: '#22d3ee',
14+
primary500: '#06b6d4',
15+
primary600: '#0e93d1',
16+
primary700: '#1570ad',
17+
// Secondary
18+
secondary50: '#ecfdf5',
19+
secondary100: '#d9f9eb',
20+
secondary200: '#bbfde8',
21+
secondary300: '#86f9d9',
22+
secondary400: '#0d9488',
23+
secondary500: '#027a7b',
24+
secondary600: '#016464',
25+
secondary700: '#014747',
26+
},
27+
spacing: {
28+
1: 4,
29+
2: 8,
30+
3: 12,
31+
4: 16,
32+
5: 20,
33+
6: 24,
34+
7: 28,
35+
8: 32,
36+
}
37+
})
38+
39+
type ButtonProps = VariantProps<typeof buttonStyles> & {
40+
children?: React.ReactNode;
41+
};
42+
43+
const Button = (props: ButtonProps) => {
44+
return <TouchableOpacity style={buttonStyles(props)}>
45+
<Text>{props.children}</Text>
46+
</TouchableOpacity>
47+
}
48+
49+
const buttonStyles = styles({
50+
base: {
51+
paddingHorizontal: '$spacing.8',
52+
paddingVertical: '$spacing.3',
53+
borderRadius: '$spacing.2',
54+
},
55+
variants: {
56+
color: {
57+
primary: {
58+
backgroundColor: '$colors.primary500',
59+
},
60+
secondary: {
61+
backgroundColor: '$colors.secondary500',
62+
},
63+
}
64+
},
65+
defaultVariants: {
66+
color: 'primary'
67+
}
68+
})
69+
70+
type TypographyProps = VariantProps<typeof typographyStyles> & {
71+
children?: React.ReactNode;
72+
};
73+
74+
const Typography = (props: TypographyProps) => {
75+
return <Text style={typographyStyles(props)}>{props.children}</Text>
76+
}
77+
78+
const typographyStyles = styles({
79+
base: {},
80+
variants: {
81+
color: {
82+
white: { color: '$colors.white' },
83+
black: { color: '$colors.black' },
84+
},
85+
size: {
86+
sm: { fontSize: 10 },
87+
md: { fontSize: 16 },
88+
lg: { fontSize: 24 },
89+
}
90+
},
91+
defaultVariants: {
92+
size: 'md',
93+
color: 'white'
94+
}
95+
})
396

497
export default function App() {
598
return (
6-
<View style={styles.container}>
99+
<View style={sty.container}>
7100
<Text>Open up App.tsx to start working on your app!</Text>
8101
<StatusBar style="auto" />
102+
<Button color="secondary">
103+
<Typography color="white">Hello</Typography>
104+
</Button>
105+
<Button color="primary">
106+
<Typography color="black">Hello</Typography>
107+
</Button>
9108
</View>
10109
);
11110
}
12111

13-
const styles = StyleSheet.create({
112+
const sty = StyleSheet.create({
14113
container: {
15114
flex: 1,
16115
backgroundColor: '#fff',

packages/app-typescript/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"dependencies": {
1212
"expo": "~52.0.37",
1313
"expo-status-bar": "~2.0.1",
14+
"jacaranda": "workspace:*",
1415
"react": "18.3.1",
1516
"react-native": "0.76.7"
1617
},

pnpm-lock.yaml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)