Skip to content

Commit 60bd080

Browse files
committed
chore: updated example implementation
1 parent 15f2952 commit 60bd080

File tree

4 files changed

+120
-95
lines changed

4 files changed

+120
-95
lines changed

packages/app-typescript/App.tsx

Lines changed: 4 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,11 @@
11
import { StatusBar } from 'expo-status-bar';
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-
})
2+
import { StyleSheet, View } from 'react-native';
3+
import { Typography } from './components/Typography';
4+
import { Button } from './components/Button';
965

976
export default function App() {
987
return (
998
<View style={sty.container}>
100-
<Text>Open up App.tsx to start working on your app!</Text>
1019
<StatusBar style="auto" />
10210
<Button color="secondary">
10311
<Typography color="white">Hello</Typography>
@@ -115,5 +23,6 @@ const sty = StyleSheet.create({
11523
backgroundColor: '#fff',
11624
alignItems: 'center',
11725
justifyContent: 'center',
26+
gap: 12
11827
},
11928
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { TouchableOpacity } from 'react-native';
2+
import { type VariantProps } from 'jacaranda'
3+
import { Typography } from './Typography';
4+
import { styles } from '../jacaranda.config';
5+
6+
7+
type ButtonProps = VariantProps<typeof buttonStyles> & {
8+
children?: React.ReactNode;
9+
};
10+
11+
export const Button = (props: ButtonProps) => {
12+
return <TouchableOpacity style={buttonStyles(props)}>
13+
<Typography>{props.children}</Typography>
14+
</TouchableOpacity>
15+
}
16+
17+
const buttonStyles = styles({
18+
base: {
19+
paddingHorizontal: '$spacing.8',
20+
paddingVertical: '$spacing.3',
21+
borderRadius: '$spacing.2',
22+
},
23+
variants: {
24+
color: {
25+
primary: {
26+
backgroundColor: '$colors.primary500',
27+
},
28+
secondary: {
29+
backgroundColor: '$colors.secondary500',
30+
},
31+
}
32+
},
33+
defaultVariants: {
34+
color: 'primary'
35+
}
36+
})
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { Text } from 'react-native';
2+
import { VariantProps } from 'jacaranda';
3+
import { styles } from '../jacaranda.config';
4+
5+
type TypographyProps = VariantProps<typeof typographyStyles> & {
6+
children?: React.ReactNode;
7+
};
8+
9+
export const Typography = (props: TypographyProps) => {
10+
return <Text style={typographyStyles(props)}>{props.children}</Text>
11+
}
12+
13+
const typographyStyles = styles({
14+
base: {},
15+
variants: {
16+
color: {
17+
white: { color: '$colors.white' },
18+
black: { color: '$colors.black' },
19+
},
20+
level: {
21+
1: { fontSize: 24 },
22+
2: { fontSize: 20 },
23+
3: { fontSize: 16 },
24+
4: { fontSize: 14 },
25+
5: { fontSize: 12 },
26+
},
27+
weight: {
28+
regular: { fontWeight: 'normal' },
29+
medium: { fontWeight: 'medium' },
30+
semibold: { fontWeight: 'semibold' },
31+
bold: { fontWeight: 'bold' },
32+
},
33+
align: {
34+
left: { textAlign: 'left' },
35+
center: { textAlign: 'center' },
36+
right: { textAlign: 'right' },
37+
}
38+
},
39+
defaultVariants: {
40+
level: 3,
41+
color: 'white',
42+
weight: 'medium',
43+
align: 'left'
44+
}
45+
})
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { createTokens } from 'jacaranda';
2+
3+
export const { styles } = createTokens({
4+
colors: {
5+
white: '#ffffff',
6+
black: '#000000',
7+
primary50: '#ecfeff',
8+
primary100: '#cffafe',
9+
primary200: '#a5f3fc',
10+
primary300: '#67e8f9',
11+
primary400: '#22d3ee',
12+
primary500: '#06b6d4',
13+
primary600: '#0e93d1',
14+
primary700: '#1570ad',
15+
// Secondary
16+
secondary50: '#ecfdf5',
17+
secondary100: '#d9f9eb',
18+
secondary200: '#bbfde8',
19+
secondary300: '#86f9d9',
20+
secondary400: '#0d9488',
21+
secondary500: '#027a7b',
22+
secondary600: '#016464',
23+
secondary700: '#014747',
24+
},
25+
spacing: {
26+
1: 4,
27+
2: 8,
28+
3: 12,
29+
4: 16,
30+
5: 20,
31+
6: 24,
32+
7: 28,
33+
8: 32,
34+
}
35+
});

0 commit comments

Comments
 (0)