-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathFontFamilyPickerRow.tsx
More file actions
100 lines (96 loc) · 2.21 KB
/
Copy pathFontFamilyPickerRow.tsx
File metadata and controls
100 lines (96 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { type FC } from 'react';
import { Pressable, ScrollView, StyleSheet, Text } from 'react-native';
export interface FontFamilyOption {
label: string;
value: string;
}
interface Props {
families: FontFamilyOption[];
activeFamily: string;
onSelectFamily: (family: string) => void;
onClear: () => void;
}
export const FontFamilyPickerRow: FC<Props> = ({
families,
activeFamily,
onSelectFamily,
onClear,
}) => {
return (
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
style={styles.container}
contentContainerStyle={styles.content}
>
<Pressable
testID="font-family-clear"
style={styles.clearButton}
onPress={onClear}
>
<Text style={styles.clearText}>✕</Text>
</Pressable>
{families.map(({ label, value }) => {
const isActive = value === activeFamily;
return (
<Pressable
key={value}
testID={`font-family-${value}`}
onPress={() => onSelectFamily(value)}
style={[styles.familyButton, isActive && styles.familyButtonActive]}
>
<Text style={[styles.familyText, { fontFamily: value }]}>
{label}
</Text>
</Pressable>
);
})}
</ScrollView>
);
};
const styles = StyleSheet.create({
container: {
width: '100%',
backgroundColor: 'rgba(0, 26, 114, 0.9)',
},
content: {
flexDirection: 'row',
alignItems: 'center',
paddingHorizontal: 8,
paddingVertical: 8,
gap: 8,
},
clearButton: {
width: 28,
height: 28,
borderRadius: 14,
backgroundColor: 'rgba(255,255,255,0.15)',
justifyContent: 'center',
alignItems: 'center',
},
clearText: {
color: 'white',
fontSize: 14,
lineHeight: 16,
},
familyButton: {
minWidth: 36,
height: 28,
paddingHorizontal: 8,
borderRadius: 14,
backgroundColor: 'rgba(255,255,255,0.15)',
justifyContent: 'center',
alignItems: 'center',
},
familyButtonActive: {
backgroundColor: 'rgb(0, 26, 114)',
borderWidth: 2,
borderColor: 'white',
},
familyText: {
color: 'white',
fontSize: 14,
fontWeight: '600',
lineHeight: 16,
},
});