-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathFontSizePickerRow.tsx
More file actions
93 lines (90 loc) · 2.02 KB
/
Copy pathFontSizePickerRow.tsx
File metadata and controls
93 lines (90 loc) · 2.02 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
import { type FC } from 'react';
import { Pressable, ScrollView, StyleSheet, Text } from 'react-native';
interface Props {
sizes: number[];
activeSize: number;
onSelectSize: (size: number) => void;
onClear: () => void;
}
export const FontSizePickerRow: FC<Props> = ({
sizes,
activeSize,
onSelectSize,
onClear,
}) => {
return (
<ScrollView
horizontal
showsHorizontalScrollIndicator={false}
style={styles.container}
contentContainerStyle={styles.content}
>
<Pressable
testID="font-size-clear"
style={styles.clearButton}
onPress={onClear}
>
<Text style={styles.clearText}>✕</Text>
</Pressable>
{sizes.map((size) => {
const isActive = size === activeSize;
return (
<Pressable
key={size}
testID={`font-size-${size}`}
onPress={() => onSelectSize(size)}
style={[styles.sizeButton, isActive && styles.sizeButtonActive]}
>
<Text style={styles.sizeText}>{size}</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,
},
sizeButton: {
minWidth: 36,
height: 28,
paddingHorizontal: 8,
borderRadius: 14,
backgroundColor: 'rgba(255,255,255,0.15)',
justifyContent: 'center',
alignItems: 'center',
},
sizeButtonActive: {
backgroundColor: 'rgb(0, 26, 114)',
borderWidth: 2,
borderColor: 'white',
},
sizeText: {
color: 'white',
fontSize: 14,
fontWeight: '600',
lineHeight: 16,
},
});