@boostdev/design-system-components 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -1
- package/dist/client.cjs +50 -50
- package/dist/client.css +470 -470
- package/dist/client.js +50 -50
- package/dist/index.cjs +50 -50
- package/dist/index.css +470 -470
- package/dist/index.js +50 -50
- package/dist/native/index.cjs +3692 -352
- package/dist/native/index.d.cts +359 -3
- package/dist/native/index.d.ts +359 -3
- package/dist/native/index.js +3811 -364
- package/package.json +1 -1
- package/src/components/interaction/Button/Button.native.stories.tsx +10 -12
- package/src/components/interaction/Button/Button.native.tsx +3 -3
- package/src/components/interaction/Dialog/Dialog.native.mdx +61 -0
- package/src/components/interaction/Dialog/Dialog.native.spec.tsx +73 -0
- package/src/components/interaction/Dialog/Dialog.native.stories.tsx +53 -0
- package/src/components/interaction/Dialog/Dialog.native.tsx +128 -0
- package/src/components/interaction/Drawer/Drawer.native.mdx +58 -0
- package/src/components/interaction/Drawer/Drawer.native.spec.tsx +81 -0
- package/src/components/interaction/Drawer/Drawer.native.stories.tsx +33 -0
- package/src/components/interaction/Drawer/Drawer.native.tsx +175 -0
- package/src/components/interaction/DropdownMenu/DropdownMenu.native.mdx +74 -0
- package/src/components/interaction/DropdownMenu/DropdownMenu.native.spec.tsx +78 -0
- package/src/components/interaction/DropdownMenu/DropdownMenu.native.stories.tsx +51 -0
- package/src/components/interaction/DropdownMenu/DropdownMenu.native.tsx +254 -0
- package/src/components/interaction/Popover/Popover.native.mdx +61 -0
- package/src/components/interaction/Popover/Popover.native.spec.tsx +73 -0
- package/src/components/interaction/Popover/Popover.native.stories.tsx +44 -0
- package/src/components/interaction/Popover/Popover.native.tsx +87 -0
- package/src/components/interaction/Rating/Rating.native.mdx +55 -0
- package/src/components/interaction/Rating/Rating.native.spec.tsx +38 -0
- package/src/components/interaction/Rating/Rating.native.stories.tsx +37 -0
- package/src/components/interaction/Rating/Rating.native.tsx +50 -0
- package/src/components/interaction/Toast/Toast.native.mdx +81 -0
- package/src/components/interaction/Toast/Toast.native.spec.tsx +80 -0
- package/src/components/interaction/Toast/Toast.native.stories.tsx +47 -0
- package/src/components/interaction/Toast/Toast.native.tsx +202 -0
- package/src/components/interaction/form/Checkbox/Checkbox.native.stories.tsx +2 -4
- package/src/components/interaction/form/Checkbox/Checkbox.native.tsx +1 -1
- package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.native.mdx +78 -0
- package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.native.spec.tsx +57 -0
- package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.native.stories.tsx +96 -0
- package/src/components/interaction/form/CheckboxGroup/CheckboxGroup.native.tsx +61 -0
- package/src/components/interaction/form/Combobox/Combobox.native.mdx +86 -0
- package/src/components/interaction/form/Combobox/Combobox.native.spec.tsx +60 -0
- package/src/components/interaction/form/Combobox/Combobox.native.stories.tsx +99 -0
- package/src/components/interaction/form/Combobox/Combobox.native.tsx +211 -0
- package/src/components/interaction/form/FileInput/FileInput.native.mdx +86 -0
- package/src/components/interaction/form/FileInput/FileInput.native.spec.tsx +73 -0
- package/src/components/interaction/form/FileInput/FileInput.native.stories.tsx +69 -0
- package/src/components/interaction/form/FileInput/FileInput.native.tsx +129 -0
- package/src/components/interaction/form/FormInput/FormInput.native.mdx +81 -0
- package/src/components/interaction/form/FormInput/FormInput.native.spec.tsx +51 -0
- package/src/components/interaction/form/FormInput/FormInput.native.stories.tsx +54 -0
- package/src/components/interaction/form/FormInput/FormInput.native.tsx +122 -0
- package/src/components/interaction/form/NumberInput/NumberInput.native.mdx +87 -0
- package/src/components/interaction/form/NumberInput/NumberInput.native.spec.tsx +63 -0
- package/src/components/interaction/form/NumberInput/NumberInput.native.stories.tsx +63 -0
- package/src/components/interaction/form/NumberInput/NumberInput.native.tsx +198 -0
- package/src/components/interaction/form/Radio/Radio.native.spec.tsx +79 -0
- package/src/components/interaction/form/Radio/Radio.native.stories.tsx +12 -14
- package/src/components/interaction/form/Radio/Radio.native.tsx +1 -1
- package/src/components/interaction/form/RadioGroup/RadioGroup.native.mdx +79 -0
- package/src/components/interaction/form/RadioGroup/RadioGroup.native.spec.tsx +66 -0
- package/src/components/interaction/form/RadioGroup/RadioGroup.native.stories.tsx +96 -0
- package/src/components/interaction/form/RadioGroup/RadioGroup.native.tsx +61 -0
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.native.mdx +78 -0
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.native.spec.tsx +82 -0
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.native.stories.tsx +99 -0
- package/src/components/interaction/form/SegmentedControl/SegmentedControl.native.tsx +121 -0
- package/src/components/interaction/form/Select/Select.native.mdx +85 -0
- package/src/components/interaction/form/Select/Select.native.spec.tsx +64 -0
- package/src/components/interaction/form/Select/Select.native.stories.tsx +75 -0
- package/src/components/interaction/form/Select/Select.native.tsx +252 -0
- package/src/components/interaction/form/Slider/Slider.native.mdx +83 -0
- package/src/components/interaction/form/Slider/Slider.native.spec.tsx +51 -0
- package/src/components/interaction/form/Slider/Slider.native.stories.tsx +58 -0
- package/src/components/interaction/form/Slider/Slider.native.tsx +188 -0
- package/src/components/interaction/form/Switch/Switch.native.stories.tsx +2 -4
- package/src/components/interaction/form/Textarea/Textarea.native.mdx +76 -0
- package/src/components/interaction/form/Textarea/Textarea.native.spec.tsx +50 -0
- package/src/components/interaction/form/Textarea/Textarea.native.stories.tsx +50 -0
- package/src/components/interaction/form/Textarea/Textarea.native.tsx +108 -0
- package/src/components/interaction/form/atoms/Label.native.spec.tsx +39 -0
- package/src/components/interaction/form/atoms/Label.native.stories.tsx +1 -1
- package/src/components/interaction/form/atoms/Message.native.stories.tsx +1 -1
- package/src/components/layout/ButtonGroup/ButtonGroup.native.spec.tsx +83 -0
- package/src/components/layout/ButtonGroup/ButtonGroup.native.stories.tsx +13 -19
- package/src/components/layout/Card/Card.native.spec.tsx +102 -0
- package/src/components/layout/Card/Card.native.stories.tsx +9 -11
- package/src/components/layout/Card/Card.native.tsx +1 -1
- package/src/components/layout/IconWrapper/IconWrapper.native.stories.tsx +7 -11
- package/src/components/layout/SectionHeader/SectionHeader.native.spec.tsx +51 -0
- package/src/components/layout/SectionHeader/SectionHeader.native.stories.tsx +6 -8
- package/src/components/ui/Accordion/Accordion.native.mdx +65 -0
- package/src/components/ui/Accordion/Accordion.native.spec.tsx +69 -0
- package/src/components/ui/Accordion/Accordion.native.stories.tsx +52 -0
- package/src/components/ui/Accordion/Accordion.native.tsx +141 -0
- package/src/components/ui/Alert/Alert.native.spec.tsx +76 -0
- package/src/components/ui/Alert/Alert.native.stories.tsx +8 -10
- package/src/components/ui/Alert/Alert.native.tsx +7 -7
- package/src/components/ui/Avatar/Avatar.native.stories.tsx +6 -8
- package/src/components/ui/Avatar/Avatar.native.tsx +2 -2
- package/src/components/ui/Badge/Badge.native.spec.tsx +45 -0
- package/src/components/ui/Badge/Badge.native.stories.tsx +6 -8
- package/src/components/ui/Badge/Badge.native.tsx +2 -2
- package/src/components/ui/Breadcrumb/Breadcrumb.native.mdx +52 -0
- package/src/components/ui/Breadcrumb/Breadcrumb.native.spec.tsx +49 -0
- package/src/components/ui/Breadcrumb/Breadcrumb.native.stories.tsx +46 -0
- package/src/components/ui/Breadcrumb/Breadcrumb.native.tsx +83 -0
- package/src/components/ui/Calendar/Calendar.native.mdx +58 -0
- package/src/components/ui/Calendar/Calendar.native.spec.tsx +92 -0
- package/src/components/ui/Calendar/Calendar.native.stories.tsx +45 -0
- package/src/components/ui/Calendar/Calendar.native.tsx +294 -0
- package/src/components/ui/Carousel/Carousel.native.mdx +55 -0
- package/src/components/ui/Carousel/Carousel.native.spec.tsx +55 -0
- package/src/components/ui/Carousel/Carousel.native.stories.tsx +59 -0
- package/src/components/ui/Carousel/Carousel.native.tsx +184 -0
- package/src/components/ui/Collapsible/Collapsible.native.mdx +53 -0
- package/src/components/ui/Collapsible/Collapsible.native.spec.tsx +68 -0
- package/src/components/ui/Collapsible/Collapsible.native.stories.tsx +48 -0
- package/src/components/ui/Collapsible/Collapsible.native.tsx +139 -0
- package/src/components/ui/DescriptionList/DescriptionList.native.mdx +50 -0
- package/src/components/ui/DescriptionList/DescriptionList.native.spec.tsx +37 -0
- package/src/components/ui/DescriptionList/DescriptionList.native.stories.tsx +48 -0
- package/src/components/ui/DescriptionList/DescriptionList.native.tsx +54 -0
- package/src/components/ui/Link/Link.native.mdx +53 -0
- package/src/components/ui/Link/Link.native.spec.tsx +35 -0
- package/src/components/ui/Link/Link.native.stories.tsx +46 -0
- package/src/components/ui/Link/Link.native.tsx +48 -0
- package/src/components/ui/Loading/Loading.native.stories.tsx +6 -8
- package/src/components/ui/NotificationBanner/NotificationBanner.native.spec.tsx +85 -0
- package/src/components/ui/NotificationBanner/NotificationBanner.native.stories.tsx +8 -10
- package/src/components/ui/NotificationBanner/NotificationBanner.native.tsx +7 -7
- package/src/components/ui/Pagination/Pagination.native.mdx +62 -0
- package/src/components/ui/Pagination/Pagination.native.spec.tsx +86 -0
- package/src/components/ui/Pagination/Pagination.native.stories.tsx +47 -0
- package/src/components/ui/Pagination/Pagination.native.tsx +157 -0
- package/src/components/ui/Progress/Progress.native.spec.tsx +56 -0
- package/src/components/ui/Progress/Progress.native.stories.tsx +1 -1
- package/src/components/ui/Progress/Progress.native.tsx +2 -2
- package/src/components/ui/ProgressCircle/ProgressCircle.native.mdx +63 -0
- package/src/components/ui/ProgressCircle/ProgressCircle.native.spec.tsx +39 -0
- package/src/components/ui/ProgressCircle/ProgressCircle.native.stories.tsx +36 -0
- package/src/components/ui/ProgressCircle/ProgressCircle.native.tsx +176 -0
- package/src/components/ui/Separator/Separator.native.spec.tsx +39 -0
- package/src/components/ui/Separator/Separator.native.stories.tsx +10 -14
- package/src/components/ui/Skeleton/Skeleton.native.spec.tsx +39 -0
- package/src/components/ui/Skeleton/Skeleton.native.stories.tsx +6 -8
- package/src/components/ui/Skeleton/Skeleton.native.tsx +2 -1
- package/src/components/ui/Table/Table.native.mdx +72 -0
- package/src/components/ui/Table/Table.native.spec.tsx +83 -0
- package/src/components/ui/Table/Table.native.stories.tsx +55 -0
- package/src/components/ui/Table/Table.native.tsx +196 -0
- package/src/components/ui/Tabs/Tabs.native.mdx +65 -0
- package/src/components/ui/Tabs/Tabs.native.spec.tsx +65 -0
- package/src/components/ui/Tabs/Tabs.native.stories.tsx +57 -0
- package/src/components/ui/Tabs/Tabs.native.tsx +133 -0
- package/src/components/ui/Tooltip/Tooltip.native.mdx +47 -0
- package/src/components/ui/Tooltip/Tooltip.native.spec.tsx +37 -0
- package/src/components/ui/Tooltip/Tooltip.native.stories.tsx +38 -0
- package/src/components/ui/Tooltip/Tooltip.native.tsx +57 -0
- package/src/components/ui/Typography/Typography.native.spec.tsx +49 -0
- package/src/components/ui/Typography/Typography.native.stories.tsx +8 -10
- package/src/native/ThemeContext.tsx +3 -3
- package/src/native.ts +37 -0
- package/src/stories/ReactNative.mdx +48 -13
- package/src/web-components/interaction/BdsAccordion.stories.tsx +1 -1
- package/src/web-components/interaction/BdsCollapsible.stories.tsx +1 -1
- package/src/web-components/interaction/BdsSkipLink.stories.tsx +1 -1
- package/src/web-components/interaction/BdsTabs.stories.tsx +1 -1
- package/src/web-components/interaction/BdsTooltip.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsCheckbox.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsCheckboxGroup.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsCombobox.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsFileInput.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsFormInput.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsNumberInput.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsRadio.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsRadioGroup.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsSegmentedControl.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsSelect.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsSlider.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsSwitch.stories.tsx +1 -1
- package/src/web-components/interaction/form/BdsTextarea.stories.tsx +1 -1
- package/src/web-components/ui/BdsButtonGroup.stories.tsx +1 -1
- package/src/web-components/ui/BdsCard.stories.tsx +1 -1
- package/src/web-components/ui/BdsIconWrapper.stories.tsx +1 -1
- package/src/web-components/ui/BdsRating.stories.tsx +1 -1
- package/src/web-components/ui/BdsSectionHeader.stories.tsx +1 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
StyleSheet,
|
|
4
|
+
View,
|
|
5
|
+
Text,
|
|
6
|
+
ScrollView,
|
|
7
|
+
Pressable,
|
|
8
|
+
StyleProp,
|
|
9
|
+
ViewStyle,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import { spacing, font, border, lineHeight } from '../../../native/tokens';
|
|
12
|
+
import { useTheme } from '../../../native/ThemeContext';
|
|
13
|
+
|
|
14
|
+
export interface TableColumn<Row> {
|
|
15
|
+
key: string;
|
|
16
|
+
header: ReactNode;
|
|
17
|
+
sortable?: boolean;
|
|
18
|
+
render?: (row: Row) => ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface TableProps<Row extends Record<string, unknown>> {
|
|
22
|
+
columns: TableColumn<Row>[];
|
|
23
|
+
rows: Row[];
|
|
24
|
+
caption?: string;
|
|
25
|
+
sortKey?: string;
|
|
26
|
+
sortDirection?: 'asc' | 'desc';
|
|
27
|
+
onSort?: (key: string, direction: 'asc' | 'desc') => void;
|
|
28
|
+
style?: StyleProp<ViewStyle>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const styles = StyleSheet.create({
|
|
32
|
+
wrapper: {
|
|
33
|
+
borderRadius: border.radius.s,
|
|
34
|
+
overflow: 'hidden',
|
|
35
|
+
},
|
|
36
|
+
caption: {
|
|
37
|
+
fontSize: font.size.bodyS,
|
|
38
|
+
fontFamily: font.family.body,
|
|
39
|
+
fontWeight: font.weight.semibold,
|
|
40
|
+
lineHeight: lineHeight.bodyS,
|
|
41
|
+
paddingVertical: spacing.xs,
|
|
42
|
+
paddingHorizontal: spacing.m,
|
|
43
|
+
},
|
|
44
|
+
headerRow: {
|
|
45
|
+
flexDirection: 'row',
|
|
46
|
+
},
|
|
47
|
+
headerCell: {
|
|
48
|
+
flex: 1,
|
|
49
|
+
minWidth: 100,
|
|
50
|
+
paddingVertical: spacing.s,
|
|
51
|
+
paddingHorizontal: spacing.m,
|
|
52
|
+
flexDirection: 'row',
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
gap: spacing.xxs,
|
|
55
|
+
},
|
|
56
|
+
headerText: {
|
|
57
|
+
fontSize: font.size.bodyS,
|
|
58
|
+
fontFamily: font.family.body,
|
|
59
|
+
fontWeight: font.weight.semibold,
|
|
60
|
+
lineHeight: lineHeight.bodyS,
|
|
61
|
+
},
|
|
62
|
+
sortIndicator: {
|
|
63
|
+
fontSize: font.size.bodyS,
|
|
64
|
+
},
|
|
65
|
+
row: {
|
|
66
|
+
flexDirection: 'row',
|
|
67
|
+
borderTopWidth: 1,
|
|
68
|
+
minHeight: 44,
|
|
69
|
+
},
|
|
70
|
+
cell: {
|
|
71
|
+
flex: 1,
|
|
72
|
+
minWidth: 100,
|
|
73
|
+
paddingVertical: spacing.s,
|
|
74
|
+
paddingHorizontal: spacing.m,
|
|
75
|
+
justifyContent: 'center',
|
|
76
|
+
},
|
|
77
|
+
cellText: {
|
|
78
|
+
fontSize: font.size.body,
|
|
79
|
+
fontFamily: font.family.body,
|
|
80
|
+
fontWeight: font.weight.body,
|
|
81
|
+
lineHeight: lineHeight.body,
|
|
82
|
+
},
|
|
83
|
+
pressed: {
|
|
84
|
+
opacity: 0.75,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export function Table<Row extends Record<string, unknown>>({
|
|
89
|
+
columns,
|
|
90
|
+
rows,
|
|
91
|
+
caption,
|
|
92
|
+
sortKey,
|
|
93
|
+
sortDirection,
|
|
94
|
+
onSort,
|
|
95
|
+
style,
|
|
96
|
+
}: Readonly<TableProps<Row>>) {
|
|
97
|
+
const { colors } = useTheme();
|
|
98
|
+
|
|
99
|
+
const handleSort = (key: string) => {
|
|
100
|
+
if (!onSort) return;
|
|
101
|
+
const nextDirection = sortKey === key && sortDirection === 'asc' ? 'desc' : 'asc';
|
|
102
|
+
onSort(key, nextDirection);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const getSortLabel = (col: TableColumn<Row>): string => {
|
|
106
|
+
const base = `Sort by ${String(col.header)}`;
|
|
107
|
+
if (sortKey !== col.key) return base;
|
|
108
|
+
return `${base}, currently ${sortDirection === 'asc' ? 'ascending' : 'descending'}`;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<ScrollView
|
|
113
|
+
horizontal
|
|
114
|
+
showsHorizontalScrollIndicator={true}
|
|
115
|
+
style={[styles.wrapper, { backgroundColor: colors.colorBg }, style]}
|
|
116
|
+
>
|
|
117
|
+
<View>
|
|
118
|
+
{caption && (
|
|
119
|
+
<Text style={[styles.caption, { color: colors.colorOnBgSubtle }]}>
|
|
120
|
+
{caption}
|
|
121
|
+
</Text>
|
|
122
|
+
)}
|
|
123
|
+
|
|
124
|
+
<View style={[styles.headerRow, { backgroundColor: colors.colorBgSubtle }]}>
|
|
125
|
+
{columns.map(col =>
|
|
126
|
+
col.sortable ? (
|
|
127
|
+
<Pressable
|
|
128
|
+
key={col.key}
|
|
129
|
+
onPress={() => handleSort(col.key)}
|
|
130
|
+
accessibilityRole="button"
|
|
131
|
+
accessibilityLabel={getSortLabel(col)}
|
|
132
|
+
style={({ pressed }) => [styles.headerCell, pressed && styles.pressed]}
|
|
133
|
+
>
|
|
134
|
+
<Text style={[styles.headerText, { color: colors.colorOnBg }]}>
|
|
135
|
+
{col.header}
|
|
136
|
+
</Text>
|
|
137
|
+
<Text
|
|
138
|
+
style={[
|
|
139
|
+
styles.sortIndicator,
|
|
140
|
+
{
|
|
141
|
+
color: sortKey === col.key
|
|
142
|
+
? colors.colorInteractive
|
|
143
|
+
: colors.colorOnBgSubtle,
|
|
144
|
+
},
|
|
145
|
+
]}
|
|
146
|
+
importantForAccessibility="no"
|
|
147
|
+
accessibilityElementsHidden={true}
|
|
148
|
+
>
|
|
149
|
+
{sortKey === col.key
|
|
150
|
+
? sortDirection === 'asc' ? '▲' : '▼'
|
|
151
|
+
: '▽'}
|
|
152
|
+
</Text>
|
|
153
|
+
</Pressable>
|
|
154
|
+
) : (
|
|
155
|
+
<View key={col.key} style={styles.headerCell}>
|
|
156
|
+
<Text style={[styles.headerText, { color: colors.colorOnBg }]}>
|
|
157
|
+
{col.header}
|
|
158
|
+
</Text>
|
|
159
|
+
</View>
|
|
160
|
+
),
|
|
161
|
+
)}
|
|
162
|
+
</View>
|
|
163
|
+
|
|
164
|
+
{rows.map((row, rowIndex) => (
|
|
165
|
+
<View
|
|
166
|
+
key={rowIndex}
|
|
167
|
+
style={[
|
|
168
|
+
styles.row,
|
|
169
|
+
{ borderTopColor: colors.colorBgSubtle },
|
|
170
|
+
rowIndex % 2 === 1 && { backgroundColor: colors.colorBgSubtle },
|
|
171
|
+
]}
|
|
172
|
+
accessibilityRole="none"
|
|
173
|
+
>
|
|
174
|
+
{columns.map(col => (
|
|
175
|
+
<View key={col.key} style={styles.cell}>
|
|
176
|
+
{col.render ? (
|
|
177
|
+
typeof col.render(row) === 'string' ? (
|
|
178
|
+
<Text style={[styles.cellText, { color: colors.colorOnBg }]}>
|
|
179
|
+
{col.render(row)}
|
|
180
|
+
</Text>
|
|
181
|
+
) : (
|
|
182
|
+
col.render(row)
|
|
183
|
+
)
|
|
184
|
+
) : (
|
|
185
|
+
<Text style={[styles.cellText, { color: colors.colorOnBg }]}>
|
|
186
|
+
{String(row[col.key] ?? '')}
|
|
187
|
+
</Text>
|
|
188
|
+
)}
|
|
189
|
+
</View>
|
|
190
|
+
))}
|
|
191
|
+
</View>
|
|
192
|
+
))}
|
|
193
|
+
</View>
|
|
194
|
+
</ScrollView>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Meta, Canvas, ArgTypes } from '@storybook/blocks';
|
|
2
|
+
import * as Stories from './Tabs.native.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={Stories} />
|
|
5
|
+
|
|
6
|
+
# Tabs (React Native)
|
|
7
|
+
|
|
8
|
+
React Native tabs component with a horizontally scrollable tab bar and content panels. Active tab is indicated with an underline in the interactive color.
|
|
9
|
+
|
|
10
|
+
> **Status: alpha** -- API may change before stable release.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { Tabs } from '@boostdev/components';
|
|
16
|
+
|
|
17
|
+
<Tabs
|
|
18
|
+
tabs={[
|
|
19
|
+
{ id: 'one', label: 'Tab One', content: <Text>Content one</Text> },
|
|
20
|
+
{ id: 'two', label: 'Tab Two', content: <Text>Content two</Text> },
|
|
21
|
+
]}
|
|
22
|
+
/>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Examples
|
|
26
|
+
|
|
27
|
+
### Default
|
|
28
|
+
<Canvas of={Stories.Default} />
|
|
29
|
+
|
|
30
|
+
### With default tab
|
|
31
|
+
<Canvas of={Stories.WithDefaultTab} />
|
|
32
|
+
|
|
33
|
+
### With disabled tab
|
|
34
|
+
<Canvas of={Stories.WithDisabledTab} />
|
|
35
|
+
|
|
36
|
+
### Many tabs (scrollable)
|
|
37
|
+
<Canvas of={Stories.ManyTabs} />
|
|
38
|
+
|
|
39
|
+
## Props
|
|
40
|
+
|
|
41
|
+
<ArgTypes of={Stories} />
|
|
42
|
+
|
|
43
|
+
## Props reference
|
|
44
|
+
|
|
45
|
+
| Prop | Type | Default | Description |
|
|
46
|
+
|------|------|---------|-------------|
|
|
47
|
+
| `tabs` | `TabItem[]` | -- | Array of tab definitions |
|
|
48
|
+
| `defaultTab` | `string` | First tab ID | ID of initially active tab |
|
|
49
|
+
| `style` | `StyleProp<ViewStyle>` | -- | Custom style for the container |
|
|
50
|
+
|
|
51
|
+
### TabItem
|
|
52
|
+
|
|
53
|
+
| Prop | Type | Description |
|
|
54
|
+
|------|------|-------------|
|
|
55
|
+
| `id` | `string` | Unique identifier |
|
|
56
|
+
| `label` | `ReactNode` | Tab button label |
|
|
57
|
+
| `content` | `ReactNode` | Panel content |
|
|
58
|
+
| `disabled` | `boolean` | Prevents selection |
|
|
59
|
+
|
|
60
|
+
## Accessibility
|
|
61
|
+
|
|
62
|
+
- Tab bar uses `tabbar` accessibility role
|
|
63
|
+
- Each tab button uses `tab` role with `selected` state
|
|
64
|
+
- Content area uses `tabpanel` role
|
|
65
|
+
- Disabled tabs have `disabled` accessibility state and reduced opacity
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
2
|
+
import { ThemeProvider } from '../../../native/ThemeContext';
|
|
3
|
+
import { Tabs } from './Tabs.native';
|
|
4
|
+
|
|
5
|
+
function renderWithTheme(ui: React.ReactElement) {
|
|
6
|
+
return render(<ThemeProvider>{ui}</ThemeProvider>);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const tabs = [
|
|
10
|
+
{ id: 'one', label: 'Tab One', content: <span>Content One</span> },
|
|
11
|
+
{ id: 'two', label: 'Tab Two', content: <span>Content Two</span> },
|
|
12
|
+
{ id: 'three', label: 'Tab Three', content: <span>Content Three</span> },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
describe('Tabs (native)', () => {
|
|
16
|
+
it('renders all tab labels', () => {
|
|
17
|
+
renderWithTheme(<Tabs tabs={tabs} />);
|
|
18
|
+
expect(screen.getByText('Tab One')).toBeInTheDocument();
|
|
19
|
+
expect(screen.getByText('Tab Two')).toBeInTheDocument();
|
|
20
|
+
expect(screen.getByText('Tab Three')).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('shows first tab content by default', () => {
|
|
24
|
+
renderWithTheme(<Tabs tabs={tabs} />);
|
|
25
|
+
expect(screen.getByText('Content One')).toBeInTheDocument();
|
|
26
|
+
expect(screen.queryByText('Content Two')).not.toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('respects defaultTab prop', () => {
|
|
30
|
+
renderWithTheme(<Tabs tabs={tabs} defaultTab="two" />);
|
|
31
|
+
expect(screen.queryByText('Content One')).not.toBeInTheDocument();
|
|
32
|
+
expect(screen.getByText('Content Two')).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('switches content when a tab is pressed', () => {
|
|
36
|
+
renderWithTheme(<Tabs tabs={tabs} />);
|
|
37
|
+
fireEvent.click(screen.getByText('Tab Two'));
|
|
38
|
+
expect(screen.queryByText('Content One')).not.toBeInTheDocument();
|
|
39
|
+
expect(screen.getByText('Content Two')).toBeInTheDocument();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('renders tab roles for all tabs', () => {
|
|
43
|
+
renderWithTheme(<Tabs tabs={tabs} />);
|
|
44
|
+
expect(screen.getByRole('tab', { name: 'Tab One' })).toBeInTheDocument();
|
|
45
|
+
expect(screen.getByRole('tab', { name: 'Tab Two' })).toBeInTheDocument();
|
|
46
|
+
expect(screen.getByRole('tab', { name: 'Tab Three' })).toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('disables tabs with disabled flag', () => {
|
|
50
|
+
const withDisabled = [
|
|
51
|
+
...tabs,
|
|
52
|
+
{ id: 'four', label: 'Disabled Tab', content: <span>Nope</span>, disabled: true },
|
|
53
|
+
];
|
|
54
|
+
renderWithTheme(<Tabs tabs={withDisabled} />);
|
|
55
|
+
expect(screen.getByRole('tab', { name: 'Disabled Tab' })).toHaveAttribute(
|
|
56
|
+
'aria-disabled',
|
|
57
|
+
'true',
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('renders tabpanel role for active content', () => {
|
|
62
|
+
renderWithTheme(<Tabs tabs={tabs} />);
|
|
63
|
+
expect(screen.getByRole('tabpanel')).toBeInTheDocument();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
import { ThemeProvider } from '../../../native/ThemeContext';
|
|
5
|
+
import { Tabs } from './Tabs.native';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
tags: ['!stable', 'alpha'],
|
|
9
|
+
title: 'React Native/UI/Tabs',
|
|
10
|
+
component: Tabs,
|
|
11
|
+
decorators: [(Story) => <ThemeProvider colorScheme="light"><Story /></ThemeProvider>],
|
|
12
|
+
parameters: { layout: 'padded' },
|
|
13
|
+
} satisfies Meta<typeof Tabs>;
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
const sampleTabs = [
|
|
19
|
+
{ id: 'overview', label: 'Overview', content: <Text>Overview content goes here.</Text> },
|
|
20
|
+
{ id: 'features', label: 'Features', content: <Text>Feature list and descriptions.</Text> },
|
|
21
|
+
{ id: 'pricing', label: 'Pricing', content: <Text>Pricing tiers and plan details.</Text> },
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export const Default: Story = {
|
|
25
|
+
args: {
|
|
26
|
+
tabs: sampleTabs,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const WithDefaultTab: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
tabs: sampleTabs,
|
|
33
|
+
defaultTab: 'features',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const WithDisabledTab: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
tabs: [
|
|
40
|
+
...sampleTabs,
|
|
41
|
+
{ id: 'admin', label: 'Admin', content: <Text>Admin panel.</Text>, disabled: true },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const ManyTabs: Story = {
|
|
47
|
+
args: {
|
|
48
|
+
tabs: [
|
|
49
|
+
{ id: 'home', label: 'Home', content: <Text>Home content</Text> },
|
|
50
|
+
{ id: 'discover', label: 'Discover', content: <Text>Discover content</Text> },
|
|
51
|
+
{ id: 'trending', label: 'Trending', content: <Text>Trending content</Text> },
|
|
52
|
+
{ id: 'saved', label: 'Saved', content: <Text>Saved content</Text> },
|
|
53
|
+
{ id: 'settings', label: 'Settings', content: <Text>Settings content</Text> },
|
|
54
|
+
{ id: 'profile', label: 'Profile', content: <Text>Profile content</Text> },
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { ReactNode, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
AccessibilityRole,
|
|
4
|
+
StyleSheet,
|
|
5
|
+
View,
|
|
6
|
+
Text,
|
|
7
|
+
Pressable,
|
|
8
|
+
ScrollView,
|
|
9
|
+
StyleProp,
|
|
10
|
+
ViewStyle,
|
|
11
|
+
} from 'react-native';
|
|
12
|
+
import { spacing, font, lineHeight } from '../../../native/tokens';
|
|
13
|
+
import { useTheme } from '../../../native/ThemeContext';
|
|
14
|
+
|
|
15
|
+
export interface TabItem {
|
|
16
|
+
id: string;
|
|
17
|
+
label: ReactNode;
|
|
18
|
+
content: ReactNode;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface TabsProps {
|
|
23
|
+
tabs: TabItem[];
|
|
24
|
+
defaultTab?: string;
|
|
25
|
+
style?: StyleProp<ViewStyle>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
container: {
|
|
30
|
+
overflow: 'hidden',
|
|
31
|
+
},
|
|
32
|
+
tabList: {
|
|
33
|
+
flexDirection: 'row',
|
|
34
|
+
borderBottomWidth: 2,
|
|
35
|
+
},
|
|
36
|
+
tabButton: {
|
|
37
|
+
minHeight: 44,
|
|
38
|
+
paddingHorizontal: spacing.m,
|
|
39
|
+
paddingVertical: spacing.s,
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
justifyContent: 'center',
|
|
42
|
+
borderBottomWidth: 2,
|
|
43
|
+
marginBottom: -2,
|
|
44
|
+
},
|
|
45
|
+
tabLabel: {
|
|
46
|
+
fontSize: font.size.body,
|
|
47
|
+
fontFamily: font.family.body,
|
|
48
|
+
lineHeight: lineHeight.body,
|
|
49
|
+
},
|
|
50
|
+
panel: {
|
|
51
|
+
paddingVertical: spacing.m,
|
|
52
|
+
},
|
|
53
|
+
pressed: {
|
|
54
|
+
opacity: 0.75,
|
|
55
|
+
},
|
|
56
|
+
disabled: {
|
|
57
|
+
opacity: 0.4,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export function Tabs({
|
|
62
|
+
tabs,
|
|
63
|
+
defaultTab,
|
|
64
|
+
style,
|
|
65
|
+
}: Readonly<TabsProps>) {
|
|
66
|
+
const { colors } = useTheme();
|
|
67
|
+
const [activeTab, setActiveTab] = useState(defaultTab ?? tabs[0]?.id);
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<View style={[styles.container, style]}>
|
|
71
|
+
<ScrollView
|
|
72
|
+
horizontal
|
|
73
|
+
showsHorizontalScrollIndicator={false}
|
|
74
|
+
contentContainerStyle={[styles.tabList, { borderBottomColor: colors.colorBgSubtle }]}
|
|
75
|
+
accessibilityRole="tabbar"
|
|
76
|
+
>
|
|
77
|
+
{tabs.map(tab => {
|
|
78
|
+
const isActive = activeTab === tab.id;
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Pressable
|
|
82
|
+
key={tab.id}
|
|
83
|
+
onPress={() => setActiveTab(tab.id)}
|
|
84
|
+
disabled={tab.disabled}
|
|
85
|
+
accessibilityRole="tab"
|
|
86
|
+
accessibilityState={{
|
|
87
|
+
selected: isActive,
|
|
88
|
+
disabled: tab.disabled,
|
|
89
|
+
}}
|
|
90
|
+
accessibilityLabel={typeof tab.label === 'string' ? tab.label : undefined}
|
|
91
|
+
style={({ pressed }) => [
|
|
92
|
+
styles.tabButton,
|
|
93
|
+
{
|
|
94
|
+
borderBottomColor: isActive
|
|
95
|
+
? colors.colorInteractive
|
|
96
|
+
: 'transparent',
|
|
97
|
+
},
|
|
98
|
+
tab.disabled && styles.disabled,
|
|
99
|
+
pressed && !tab.disabled && styles.pressed,
|
|
100
|
+
]}
|
|
101
|
+
>
|
|
102
|
+
<Text
|
|
103
|
+
style={[
|
|
104
|
+
styles.tabLabel,
|
|
105
|
+
{
|
|
106
|
+
color: isActive
|
|
107
|
+
? colors.colorInteractive
|
|
108
|
+
: colors.colorOnBgSubtle,
|
|
109
|
+
fontWeight: isActive ? font.weight.semibold : font.weight.body,
|
|
110
|
+
},
|
|
111
|
+
]}
|
|
112
|
+
>
|
|
113
|
+
{tab.label}
|
|
114
|
+
</Text>
|
|
115
|
+
</Pressable>
|
|
116
|
+
);
|
|
117
|
+
})}
|
|
118
|
+
</ScrollView>
|
|
119
|
+
|
|
120
|
+
{tabs.map(tab => {
|
|
121
|
+
const isActive = activeTab === tab.id;
|
|
122
|
+
|
|
123
|
+
if (!isActive) return null;
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<View key={tab.id} style={styles.panel} accessibilityRole={'tabpanel' as AccessibilityRole}>
|
|
127
|
+
{tab.content}
|
|
128
|
+
</View>
|
|
129
|
+
);
|
|
130
|
+
})}
|
|
131
|
+
</View>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Meta, Canvas, ArgTypes } from '@storybook/blocks';
|
|
2
|
+
import * as Stories from './Tooltip.native.stories';
|
|
3
|
+
|
|
4
|
+
<Meta of={Stories} />
|
|
5
|
+
|
|
6
|
+
# Tooltip (React Native)
|
|
7
|
+
|
|
8
|
+
React Native tooltip that appears on long press. Wraps children in a `Pressable` and shows the tooltip content above the trigger element.
|
|
9
|
+
|
|
10
|
+
> **Status: alpha** — API may change before stable release.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { Tooltip } from '@boostdev/components';
|
|
16
|
+
import { Text } from 'react-native';
|
|
17
|
+
|
|
18
|
+
<Tooltip content="Helpful information">
|
|
19
|
+
<Text>Long press me</Text>
|
|
20
|
+
</Tooltip>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Examples
|
|
24
|
+
|
|
25
|
+
### Default
|
|
26
|
+
<Canvas of={Stories.Default} />
|
|
27
|
+
|
|
28
|
+
### Long content
|
|
29
|
+
<Canvas of={Stories.LongContent} />
|
|
30
|
+
|
|
31
|
+
## Props
|
|
32
|
+
|
|
33
|
+
<ArgTypes of={Stories} />
|
|
34
|
+
|
|
35
|
+
## Props reference
|
|
36
|
+
|
|
37
|
+
| Prop | Type | Default | Description |
|
|
38
|
+
|------|------|---------|-------------|
|
|
39
|
+
| `content` | `string` | — | Tooltip text |
|
|
40
|
+
| `children` | `ReactNode` | — | Trigger element |
|
|
41
|
+
| `style` | `StyleProp<ViewStyle>` | — | Override wrapper styles |
|
|
42
|
+
|
|
43
|
+
## Accessibility
|
|
44
|
+
|
|
45
|
+
- Tooltip content is exposed via `accessibilityHint` on the pressable trigger
|
|
46
|
+
- When visible, the tooltip view has `accessibilityRole="text"` and `accessibilityLabel`
|
|
47
|
+
- Tooltip appears on long press and dismisses on press out
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { ThemeProvider } from '../../../native/ThemeContext';
|
|
3
|
+
import { Tooltip } from './Tooltip.native';
|
|
4
|
+
import { Text } from 'react-native';
|
|
5
|
+
|
|
6
|
+
function renderWithTheme(ui: React.ReactElement) {
|
|
7
|
+
return render(<ThemeProvider>{ui}</ThemeProvider>);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
describe('Tooltip (native)', () => {
|
|
11
|
+
it('renders children', () => {
|
|
12
|
+
renderWithTheme(
|
|
13
|
+
<Tooltip content="Helpful info">
|
|
14
|
+
<Text>Trigger</Text>
|
|
15
|
+
</Tooltip>,
|
|
16
|
+
);
|
|
17
|
+
expect(screen.getByText('Trigger')).toBeInTheDocument();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('does not show tooltip content by default', () => {
|
|
21
|
+
renderWithTheme(
|
|
22
|
+
<Tooltip content="Helpful info">
|
|
23
|
+
<Text>Trigger</Text>
|
|
24
|
+
</Tooltip>,
|
|
25
|
+
);
|
|
26
|
+
expect(screen.queryByText('Helpful info')).not.toBeInTheDocument();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('renders a wrapper element', () => {
|
|
30
|
+
const { container } = renderWithTheme(
|
|
31
|
+
<Tooltip content="Helpful info">
|
|
32
|
+
<Text>Trigger</Text>
|
|
33
|
+
</Tooltip>,
|
|
34
|
+
);
|
|
35
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
4
|
+
import { ThemeProvider } from '../../../native/ThemeContext';
|
|
5
|
+
import { Tooltip } from './Tooltip.native';
|
|
6
|
+
|
|
7
|
+
const meta = {
|
|
8
|
+
tags: ['!stable', 'alpha'],
|
|
9
|
+
title: 'React Native/UI/Tooltip',
|
|
10
|
+
component: Tooltip,
|
|
11
|
+
decorators: [
|
|
12
|
+
(Story) => (
|
|
13
|
+
<ThemeProvider colorScheme="light">
|
|
14
|
+
<div style={{ padding: '60px 20px 20px' }}>
|
|
15
|
+
<Story />
|
|
16
|
+
</div>
|
|
17
|
+
</ThemeProvider>
|
|
18
|
+
),
|
|
19
|
+
],
|
|
20
|
+
parameters: { layout: 'padded' },
|
|
21
|
+
} satisfies Meta<typeof Tooltip>;
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
type Story = StoryObj<typeof meta>;
|
|
25
|
+
|
|
26
|
+
export const Default: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
content: 'Helpful tooltip text',
|
|
29
|
+
children: <Text>Long press me</Text>,
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const LongContent: Story = {
|
|
34
|
+
args: {
|
|
35
|
+
content: 'This is a longer tooltip that provides more detailed information about the element.',
|
|
36
|
+
children: <Text>Long press for details</Text>,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ReactNode, useState } from 'react';
|
|
2
|
+
import { StyleSheet, View, Text, Pressable, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import { spacing, font, border } from '../../../native/tokens';
|
|
4
|
+
import { useTheme } from '../../../native/ThemeContext';
|
|
5
|
+
|
|
6
|
+
interface TooltipProps {
|
|
7
|
+
content: string;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
style?: StyleProp<ViewStyle>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const styles = StyleSheet.create({
|
|
13
|
+
wrapper: {
|
|
14
|
+
position: 'relative',
|
|
15
|
+
},
|
|
16
|
+
tooltip: {
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
bottom: '100%',
|
|
19
|
+
start: 0,
|
|
20
|
+
marginBottom: spacing.xxs,
|
|
21
|
+
paddingVertical: spacing.xxs,
|
|
22
|
+
paddingHorizontal: spacing.xs,
|
|
23
|
+
borderRadius: border.radius.full,
|
|
24
|
+
zIndex: 10,
|
|
25
|
+
alignSelf: 'flex-start',
|
|
26
|
+
},
|
|
27
|
+
text: {
|
|
28
|
+
fontSize: font.size.bodyS,
|
|
29
|
+
fontFamily: font.family.body,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export function Tooltip({ content, children, style }: Readonly<TooltipProps>) {
|
|
34
|
+
const { colors } = useTheme();
|
|
35
|
+
const [visible, setVisible] = useState(false);
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<View style={[styles.wrapper, style]}>
|
|
39
|
+
<Pressable
|
|
40
|
+
onLongPress={() => setVisible(true)}
|
|
41
|
+
onPressOut={() => setVisible(false)}
|
|
42
|
+
accessibilityHint={content}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</Pressable>
|
|
46
|
+
{visible && (
|
|
47
|
+
<View
|
|
48
|
+
style={[styles.tooltip, { backgroundColor: colors.colorOnBg }]}
|
|
49
|
+
accessibilityRole="text"
|
|
50
|
+
accessibilityLabel={content}
|
|
51
|
+
>
|
|
52
|
+
<Text style={[styles.text, { color: colors.colorBg }]}>{content}</Text>
|
|
53
|
+
</View>
|
|
54
|
+
)}
|
|
55
|
+
</View>
|
|
56
|
+
);
|
|
57
|
+
}
|