frontend/components: introduce a dashed ghost button to the new entry

Pedro Lucas Porcellis porcellis@eletrotupi.com 1 month ago 9671ed464961e554cd1fcbecdee8ef718000e49c
Parents: b1af73d
3 file(s) changed
  • frontend/app/(tabs)/new/entry.tsx +11 -1
  • frontend/components/ui/Button.tsx +26 -4
  • frontend/constants/theme.ts +2 -0
frontend/app/(tabs)/new/entry.tsx
@@ -27,6 +27,10 @@ const { user } = useAuth();
27 27 // TODO: transform this into a specific mood component
28 28 const { initialMood } = useLocalSearchParams();
29 29
30 + const editComponents = () => {
31 + console.log("Wants to open the components");
32 + }
33 +
30 34 return (
31 35 <View>
32 36 <ScrollView
@@ -53,7 +57,7 @@ variant="darkGhost"
53 57 onChangeText={(val) => console.log(val)}
54 58 minRows={4}
55 59 maxRows={6}
56 - placeholder="Escreva uma nota rápida sobre o seu dia..."
60 + placeholder="Escreva uma nota rápida sobre o seu dia até o momento..."
57 61 />
58 62 </Card>
59 63
@@ -63,6 +67,12 @@ <Grid gap={4}>
63 67 <Card style={{height: 38}} />
64 68 <Card style={{height: 38}} />
65 69 </Grid>
70 +
71 + <Button title="Adicionar Componentes"
72 + onPress={editComponents}
73 + textStyle={{ fontWeight: 500 }}
74 + variant="dashed"
75 + />
66 76 </Section>
67 77 </View>
68 78 </ScrollView>
frontend/components/ui/Button.tsx
@@ -12,7 +12,7 @@ import { useThemeColor } from '@/hooks/use-theme-color';
12 12
13 13 interface ButtonProps extends TouchableOpacityProps {
14 14 title: string;
15 - variant?: 'primary' | 'secondary' | 'outline' | 'ghost';
15 + variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'dashed';
16 16 size?: 'small' | 'medium' | 'large';
17 17 loading?: boolean;
18 18 disabled?: boolean;
@@ -33,8 +33,10 @@ ...props
33 33 }) => {
34 34 const primaryColor = useThemeColor({}, 'tint');
35 35 const textColor = useThemeColor({}, 'text');
36 + const textSecondaryColor = useThemeColor({}, 'textSecondary');
36 37 const backgroundColor = useThemeColor({}, 'background');
37 38 const borderColor = useThemeColor({}, 'border');
39 + const borderDashedColor = useThemeColor({}, 'borderDashed');
38 40
39 41 const getBackgroundColor = () => {
40 42 if (disabled) return useThemeColor({ light: '#e5e5e5', dark: '#404040' }, 'background');
@@ -45,6 +47,7 @@ case 'secondary':
45 47 return useThemeColor({ light: '#f3f4f6', dark: '#374151' }, 'background');
46 48 case 'outline':
47 49 case 'ghost':
50 + case 'dashed':
48 51 return 'transparent';
49 52 default:
50 53 return primaryColor;
@@ -53,27 +56,45 @@ };
53 56
54 57 const getTextColor = () => {
55 58 if (disabled) return useThemeColor({}, 'text');
59 +
56 60 switch (variant) {
57 61 case 'primary':
58 62 case 'secondary':
59 63 case 'outline':
60 64 case 'ghost':
61 65 return textColor;
66 + case 'dashed':
67 + return textSecondaryColor;
62 68 default:
63 69 return '#fff';
64 70 }
65 71 };
66 72
67 73 const getBorderWidth = () => {
68 - return variant === 'outline' ? 1 : 0;
74 + if (variant === 'outline' || variant === 'dashed') {
75 + return 1;
76 + } else {
77 + return 0;
78 + }
69 79 };
70 80
71 81 const getBorderColor = () => {
72 - if (variant === 'outline') {
73 - return disabled ? borderColor : primaryColor;
82 + if (variant === 'outline' || variant === 'dashed') {
83 + if (disabled) {
84 + return borderColor;
85 + } else if (variant === 'dashed') {
86 + return borderDashedColor;
87 + } else {
88 + return primaryColor;
89 + }
74 90 }
91 +
75 92 return 'transparent';
76 93 };
94 +
95 + const getBorderStyle = () => {
96 + return variant === 'dashed' ? 'dashed' : 'solid';
97 + }
77 98
78 99 const getHeight = () => {
79 100 switch (size) {
@@ -109,6 +130,7 @@ {
109 130 backgroundColor: getBackgroundColor(),
110 131 borderWidth: getBorderWidth(),
111 132 borderColor: getBorderColor(),
133 + borderStyle: getBorderStyle(),
112 134 height: getHeight(),
113 135 opacity: disabled || loading ? 0.6 : 1,
114 136 },
frontend/constants/theme.ts
@@ -22,6 +22,7 @@
22 22 // Borders & Accents
23 23 const BORDER_SUBTLE = '#f1f5f9';
24 24 const BORDER_SUBTLE_GRAY = '#E5E7EB';
25 + const BORDER_SUBTLE_LIGHT_GRAY = '#CBD5E1';
25 26 const STATUS_ACTIVE_BG = 'rgba(19, 236, 91, 0.1)';
26 27
27 28 // Semantic Color Pills and stuff
@@ -44,6 +45,7 @@ background: BACKGROUND_LIGHT,
44 45 surface: SURFACE_LIGHT,
45 46 tint: NEON_GREEN,
46 47 backgroundDarkGhost: BACKGROUND_DARK_GHOST,
48 + borderDashed: BORDER_SUBTLE_LIGHT_GRAY,
47 49
48 50 // Interactive States
49 51 icon: TEXT_SECONDARY,