@shopify/shop-minis-cli 0.0.83 → 0.0.84

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.
Files changed (94) hide show
  1. package/build/commands/codemod/releases/index.js +2 -0
  2. package/build/commands/codemod/releases/index.js.map +1 -1
  3. package/build/commands/codemod/releases/v0-0-84.d.ts +3 -0
  4. package/build/commands/codemod/releases/v0-0-84.js +41 -0
  5. package/build/commands/codemod/releases/v0-0-84.js.map +1 -0
  6. package/build/commands/create-mini/index.js +0 -10
  7. package/build/commands/create-mini/index.js.map +1 -1
  8. package/build/commands/generate-graphql-types/index.js +1 -1
  9. package/build/commands/generate-graphql-types/index.js.map +1 -1
  10. package/build/data/types/autogenerated/shop-minis-admin-api/graphql.d.ts +151 -1
  11. package/build/data/types/autogenerated/shop-minis-admin-api/graphql.js +4 -0
  12. package/build/data/types/autogenerated/shop-minis-admin-api/graphql.js.map +1 -1
  13. package/package.json +1 -1
  14. package/templates/__template_common/.eslintrc.js +1 -1
  15. package/templates/__template_hello_world/src/assets/Modal-component-thumbnail.png +0 -0
  16. package/templates/__template_hello_world/src/assets/ProductCard-component-thumbnail.png +0 -0
  17. package/templates/__template_hello_world/src/assets/ProductLink-component-thumbnail.png +0 -0
  18. package/templates/__template_hello_world/src/assets/assets.d.ts +0 -4
  19. package/templates/__template_hello_world/src/assets/figma-logo.svg +0 -14
  20. package/templates/__template_hello_world/src/assets/shop-minis-logo.svg +0 -7
  21. package/templates/__template_hello_world/src/components/ButtonCTA.tsx +0 -31
  22. package/templates/__template_hello_world/src/components/ComponentLink.ts +0 -94
  23. package/templates/__template_hello_world/src/components/ComponentListItem.tsx +0 -39
  24. package/templates/__template_hello_world/src/components/FeaturedComponents.tsx +0 -110
  25. package/templates/__template_hello_world/src/components/Header.tsx +0 -40
  26. package/templates/__template_hello_world/src/components/quiz/ImageCarouselSlide.tsx +0 -54
  27. package/templates/__template_hello_world/src/components/quiz/MultipleChoiceSlide.tsx +0 -77
  28. package/templates/__template_hello_world/src/components/quiz/QuizProvider.tsx +0 -64
  29. package/templates/__template_hello_world/src/components/quiz/QuizSlide.tsx +0 -79
  30. package/templates/__template_hello_world/src/components/quiz/QuizSlideCommander.tsx +0 -35
  31. package/templates/__template_hello_world/src/components/quiz/TextFieldSlide.tsx +0 -84
  32. package/templates/__template_hello_world/src/components/quiz/TextSlide.tsx +0 -6
  33. package/templates/__template_hello_world/src/components/quiz/types.ts +0 -72
  34. package/templates/__template_hello_world/src/data/Test.graphql +0 -33
  35. package/templates/__template_hello_world/src/data/Test.graphql.d.ts +0 -107
  36. package/templates/__template_hello_world/src/data/TestProducts.graphql +0 -64
  37. package/templates/__template_hello_world/src/data/TestProducts.graphql.d.ts +0 -197
  38. package/templates/__template_hello_world/src/fixtures/mocked-products-with-variants.ts +0 -274
  39. package/templates/__template_hello_world/src/hooks/useQuizData.ts +0 -26
  40. package/templates/__template_hello_world/src/hooks/useQuizState.ts +0 -27
  41. package/templates/__template_hello_world/src/index.tsx +0 -10
  42. package/templates/__template_hello_world/src/routes.tsx +0 -149
  43. package/templates/__template_hello_world/src/screens/AccordionScreen.tsx +0 -73
  44. package/templates/__template_hello_world/src/screens/AvatarScreen.tsx +0 -95
  45. package/templates/__template_hello_world/src/screens/BottomSheetScreen.tsx +0 -712
  46. package/templates/__template_hello_world/src/screens/ButtonsScreen.tsx +0 -90
  47. package/templates/__template_hello_world/src/screens/GridScreen.tsx +0 -74
  48. package/templates/__template_hello_world/src/screens/HomeScreen.tsx +0 -81
  49. package/templates/__template_hello_world/src/screens/IconsScreen.tsx +0 -181
  50. package/templates/__template_hello_world/src/screens/ImageMultipleChoiceScreen.tsx +0 -145
  51. package/templates/__template_hello_world/src/screens/InputScreen.tsx +0 -149
  52. package/templates/__template_hello_world/src/screens/MediaScreen.tsx +0 -130
  53. package/templates/__template_hello_world/src/screens/ModalScreen.tsx +0 -379
  54. package/templates/__template_hello_world/src/screens/MultipleChoiceScreen.tsx +0 -75
  55. package/templates/__template_hello_world/src/screens/ProductCardGridScreen.tsx +0 -68
  56. package/templates/__template_hello_world/src/screens/ProductCardScreen.tsx +0 -62
  57. package/templates/__template_hello_world/src/screens/ProductLinkScreen.tsx +0 -215
  58. package/templates/__template_hello_world/src/screens/ProgressIndicatorScreen.tsx +0 -77
  59. package/templates/__template_hello_world/src/screens/QuantityPickerScreen.tsx +0 -76
  60. package/templates/__template_hello_world/src/screens/QuizResultScreen.tsx +0 -82
  61. package/templates/__template_hello_world/src/screens/QuizScreen.tsx +0 -40
  62. package/templates/__template_hello_world/src/screens/QuizSlideScreen.tsx +0 -150
  63. package/templates/__template_hello_world/src/screens/ShopActionsScreen.tsx +0 -48
  64. package/templates/__template_hello_world/src/screens/SpinnerScreen.tsx +0 -63
  65. package/templates/__template_hello_world/src/screens/TypographyScreen.tsx +0 -274
  66. package/templates/__template_hello_world/src/screens/VariantPickerScreen.tsx +0 -120
  67. package/templates/__template_hello_world/src/screens/WebViewScreen.tsx +0 -42
  68. package/templates/__template_hello_world/src/types.ts +0 -31
  69. package/templates/__template_hello_world/src/utils/getFlagEmoji.ts +0 -7
  70. package/templates/__template_hello_world/src/utils/mockQuizData.ts +0 -330
  71. package/templates/__template_hello_world/src/utils/quizUtils.ts +0 -75
  72. package/templates/__template_snowboardz/src/assets/assets.d.ts +0 -4
  73. package/templates/__template_snowboardz/src/assets/circle-blue.svg +0 -9
  74. package/templates/__template_snowboardz/src/assets/circle-green.svg +0 -9
  75. package/templates/__template_snowboardz/src/assets/circle-purple.svg +0 -9
  76. package/templates/__template_snowboardz/src/assets/circle-rainbow.svg +0 -34
  77. package/templates/__template_snowboardz/src/assets/circle-red.svg +0 -9
  78. package/templates/__template_snowboardz/src/assets/circle-yellow.svg +0 -9
  79. package/templates/__template_snowboardz/src/assets/skill-level-icon-advanced.svg +0 -3
  80. package/templates/__template_snowboardz/src/assets/skill-level-icon-beginner.svg +0 -3
  81. package/templates/__template_snowboardz/src/assets/skill-level-icon-intermediate.svg +0 -3
  82. package/templates/__template_snowboardz/src/components/ColorButton.tsx +0 -79
  83. package/templates/__template_snowboardz/src/components/ColorPicker.tsx +0 -40
  84. package/templates/__template_snowboardz/src/components/EmptyResult.tsx +0 -52
  85. package/templates/__template_snowboardz/src/components/SkillLevelIcon.tsx +0 -41
  86. package/templates/__template_snowboardz/src/components/SkillLevelPicker.tsx +0 -92
  87. package/templates/__template_snowboardz/src/data/TestProducts.graphql +0 -34
  88. package/templates/__template_snowboardz/src/data/TestProducts.graphql.d.ts +0 -118
  89. package/templates/__template_snowboardz/src/hooks/useSnowboardData.tsx +0 -37
  90. package/templates/__template_snowboardz/src/index.tsx +0 -10
  91. package/templates/__template_snowboardz/src/routes.tsx +0 -17
  92. package/templates/__template_snowboardz/src/screens/HomeScreen.tsx +0 -126
  93. package/templates/__template_snowboardz/src/types.ts +0 -12
  94. package/templates/__template_snowboardz/src/utils.ts +0 -17
@@ -1,90 +0,0 @@
1
- import {Alert, SafeAreaView, ScrollView} from 'react-native'
2
- import {
3
- Button,
4
- ButtonProps,
5
- Box,
6
- FastImageBox,
7
- Text,
8
- useTheme,
9
- } from '@shopify/shop-minis-platform-sdk'
10
-
11
- import {Header} from '../components/Header'
12
-
13
- export const ButtonsScreen = () => {
14
- const theme = useTheme()
15
- return (
16
- <SafeAreaView
17
- style={{backgroundColor: theme.colors['backgrounds-regular']}}
18
- >
19
- <ScrollView
20
- style={{backgroundColor: theme.colors['backgrounds-regular']}}
21
- >
22
- <Header />
23
- <Box px="gutter">
24
- <Text variant="headerBold" mb="xs">
25
- Button
26
- </Text>
27
- <Text variant="bodyTitleLarge" mt="m">
28
- Sizes
29
- </Text>
30
- {(['s', 'm', 'l'] as ButtonProps['size'][]).map(size => (
31
- <Box key={size} paddingVertical="xs">
32
- <Button size={size} text={size as string} onPress={() => {}} />
33
- </Box>
34
- ))}
35
- <Text variant="bodyTitleLarge" mt="m">
36
- Variants
37
- </Text>
38
- {(
39
- [
40
- 'primary',
41
- 'secondary',
42
- 'tertiary',
43
- 'outlined',
44
- 'overlay',
45
- ] as ButtonProps['variant'][]
46
- ).map(variant => (
47
- <Box key={variant as string} paddingVertical="xs">
48
- <Button
49
- variant={variant}
50
- text={variant as string}
51
- onPress={() => {}}
52
- />
53
- </Box>
54
- ))}
55
- <Box paddingVertical="xs">
56
- <FastImageBox
57
- height={200}
58
- resizeMode="cover"
59
- source={{uri: 'https://picsum.photos/id/1080/1000/1500'}}
60
- borderRadius={16}
61
- />
62
- <Box position="absolute" bottom={20} right={20} width={150}>
63
- <Box height={100} width={100} />
64
- <Button variant="overlay" text="overlay" onPress={() => {}} />
65
- </Box>
66
- </Box>
67
- <Text variant="bodyTitleLarge" mt="m">
68
- States
69
- </Text>
70
- <Box paddingVertical="xs">
71
- <Button
72
- disabled
73
- text="inactive"
74
- onPress={() => Alert.alert('Pressed')}
75
- />
76
- </Box>
77
- <Text variant="bodyTitleLarge" mt="m">
78
- Event handling
79
- </Text>
80
- <Box paddingVertical="xs">
81
- <Button
82
- text="Will alert when pressed"
83
- onPress={() => Alert.alert('Pressed')}
84
- />
85
- </Box>
86
- </Box>
87
- </ScrollView>
88
- </SafeAreaView>
89
- )
90
- }
@@ -1,74 +0,0 @@
1
- import {SafeAreaView} from 'react-native'
2
- import {Grid, Box, Text, useTheme} from '@shopify/shop-minis-platform-sdk'
3
-
4
- import {Header} from '../components/Header'
5
-
6
- export type GridRenderItem = (info: any) => React.ReactElement | null
7
-
8
- export const GridScreen = () => {
9
- const theme = useTheme()
10
- const elements = [
11
- {
12
- name: 'First',
13
- color: theme.colors['primary-button-background'],
14
- id: 1,
15
- },
16
- {
17
- name: 'Second',
18
- color: theme.colors['backgrounds-success'],
19
- id: 2,
20
- },
21
- {
22
- name: 'Third',
23
- color: theme.colors['backgrounds-success-subdued'],
24
- id: 7,
25
- },
26
- {
27
- name: 'Fourth',
28
- color: theme.colors['primary-button-background'],
29
- id: 5,
30
- },
31
- {
32
- name: 'Fifth',
33
- color: theme.colors['inactive-button-foreground'],
34
- id: 4,
35
- },
36
- {
37
- name: 'Fourth',
38
- color: theme.colors['highlights-discounted'],
39
- id: 3,
40
- },
41
- ]
42
-
43
- // TODO: forwardRef breaks <Grid />s generic types so using any for now
44
- const renderItem = ({item}: {item: any}) => {
45
- return (
46
- <Box
47
- alignItems="center"
48
- justifyContent="center"
49
- height={item.id % 2 === 0 ? 300 : 200}
50
- style={{
51
- backgroundColor: item.color,
52
- }}
53
- >
54
- <Text>{item.name}</Text>
55
- </Box>
56
- )
57
- }
58
-
59
- return (
60
- <SafeAreaView style={{flex: 1}}>
61
- <Header />
62
- <Box px="gutter">
63
- <Text variant="headerBold" mb="s">
64
- Grid
65
- </Text>
66
- </Box>
67
- <Grid
68
- data={elements}
69
- renderItem={renderItem}
70
- contentContainerStyle={{padding: theme.spacing.gutter}}
71
- />
72
- </SafeAreaView>
73
- )
74
- }
@@ -1,81 +0,0 @@
1
- import {Box, Text, useTheme} from '@shopify/shop-minis-platform-sdk'
2
- import {SafeAreaView, ScrollView} from 'react-native'
3
-
4
- import ShopMinisLogo from '../assets/shop-minis-logo.svg'
5
- import {ButtonCTA} from '../components/ButtonCTA'
6
- import {ComponentListItem} from '../components/ComponentListItem'
7
- import {FeaturedComponents} from '../components/FeaturedComponents'
8
- import {ComponentLink, componentLinks} from '../components/ComponentLink'
9
-
10
- const featuredComponents: ComponentLink[] = [
11
- {
12
- name: 'Modal',
13
- thumbnail: require('../assets/Modal-component-thumbnail.png'),
14
- screen: '__MINI_APP_NAME_PASCAL_CASE__.Modal',
15
- },
16
- {
17
- name: 'ProductLink',
18
- thumbnail: require('../assets/ProductLink-component-thumbnail.png'),
19
- screen: '__MINI_APP_NAME_PASCAL_CASE__.ProductLink',
20
- },
21
- {
22
- name: 'ProductCard',
23
- thumbnail: require('../assets/ProductCard-component-thumbnail.png'),
24
- screen: '__MINI_APP_NAME_PASCAL_CASE__.ProductCard',
25
- },
26
- ]
27
-
28
- export const HomeScreen = () => {
29
- const theme = useTheme()
30
- return (
31
- <SafeAreaView
32
- style={{flex: 1, backgroundColor: theme.colors['backgrounds-regular']}}
33
- >
34
- <ScrollView>
35
- <Box flex={1} p="gutter" backgroundColor="backgrounds-regular">
36
- <ShopMinisLogo width={100} />
37
- <Text variant="heroBold" mb="s" mt="xs">
38
- Hello, World!
39
- </Text>
40
- <Text variant="subtitle" mb="s">
41
- A Shop Mini to showcase UI components available in the SDK.
42
- </Text>
43
-
44
- <ButtonCTA />
45
-
46
- <Text variant="label" mb="s" mt="l">
47
- Featured components
48
- </Text>
49
- </Box>
50
- <Box backgroundColor="backgrounds-regular">
51
- <FeaturedComponents components={featuredComponents} />
52
- </Box>
53
- <Box flex={1} p="gutter" backgroundColor="backgrounds-regular">
54
- <Text variant="label" mb="s" mt="l">
55
- All components
56
- </Text>
57
- <Box flexDirection="column">
58
- {componentLinks.map(component => (
59
- <ComponentListItem
60
- key={component.name}
61
- name={component.name}
62
- screen={component.screen}
63
- />
64
- ))}
65
- </Box>
66
- </Box>
67
- <Box flex={1} p="gutter" backgroundColor="backgrounds-regular">
68
- <Text variant="label" mb="s" mt="l">
69
- Hooks
70
- </Text>
71
- <Box flexDirection="column">
72
- <ComponentListItem
73
- name="Shop actions"
74
- screen="__MINI_APP_NAME_PASCAL_CASE__.ShopActions"
75
- />
76
- </Box>
77
- </Box>
78
- </ScrollView>
79
- </SafeAreaView>
80
- )
81
- }
@@ -1,181 +0,0 @@
1
- import {Alert, SafeAreaView, ScrollView} from 'react-native'
2
- import {
3
- Box,
4
- FastImageBox,
5
- Icon,
6
- IconButton,
7
- Text,
8
- AVAILABLE_ICONS,
9
- useTheme,
10
- } from '@shopify/shop-minis-platform-sdk'
11
-
12
- import {Header} from '../components/Header'
13
-
14
- export const IconsScreen = () => {
15
- const theme = useTheme()
16
- return (
17
- <SafeAreaView
18
- style={{flex: 1, backgroundColor: theme.colors['backgrounds-regular']}}
19
- >
20
- <ScrollView>
21
- <Header />
22
- <Box px="gutter" pb="xs">
23
- <Text variant="headerBold">Icon</Text>
24
-
25
- <Box
26
- marginTop="xs"
27
- flexDirection="row"
28
- flexWrap="wrap"
29
- justifyContent="space-between"
30
- >
31
- {AVAILABLE_ICONS.map(icon => {
32
- return (
33
- <Box
34
- key={icon}
35
- alignItems="center"
36
- padding="s"
37
- flexGrow={1}
38
- flexBasis={100}
39
- >
40
- <Icon name={icon} />
41
- <Box marginTop="xs">
42
- <Text textAlign="center" variant="caption">
43
- {icon}
44
- </Text>
45
- </Box>
46
- </Box>
47
- )
48
- })}
49
- </Box>
50
-
51
- <Text variant="bodyLargeBold" mt="m">
52
- IconButton
53
- </Text>
54
-
55
- <Box flexDirection="row" alignItems="center" paddingVertical="xs">
56
- <Box minWidth={100}>
57
- <Text variant="bodySmall">default</Text>
58
- </Box>
59
- <IconButton
60
- name="favorites-heart"
61
- onPress={DEFAULT_ON_PRESS}
62
- accessibilityLabel="Favorite"
63
- />
64
- </Box>
65
- <Box flexDirection="row" alignItems="center" paddingVertical="xs">
66
- <Box minWidth={100}>
67
- <Text variant="bodySmall">overlay</Text>
68
- </Box>
69
- <IconButton
70
- name="favorites-heart"
71
- variant="overlay"
72
- onPress={DEFAULT_ON_PRESS}
73
- accessibilityLabel="Favorite"
74
- />
75
- </Box>
76
- <Box flexDirection="row" alignItems="center" paddingVertical="xs">
77
- <Box minWidth={100}>
78
- <Text variant="bodySmall">plain</Text>
79
- </Box>
80
- <IconButton
81
- name="favorites-heart"
82
- variant="plain"
83
- onPress={DEFAULT_ON_PRESS}
84
- accessibilityLabel="Favorite"
85
- />
86
- </Box>
87
- <Box flexDirection="row" alignItems="center" paddingVertical="xs">
88
- <Box minWidth={100}>
89
- <Text variant="bodySmall">filled</Text>
90
- </Box>
91
- <IconButton
92
- name="heart"
93
- variant="filled"
94
- backgroundColor="primary-button-background"
95
- onPress={DEFAULT_ON_PRESS}
96
- accessibilityLabel="Favorite"
97
- />
98
- </Box>
99
-
100
- <Text variant="headerBold">Disabled icon buttons</Text>
101
-
102
- <Box flexDirection="row" alignItems="center" paddingVertical="xs">
103
- <Box minWidth={100}>
104
- <Text variant="bodySmall">default</Text>
105
- </Box>
106
- <IconButton
107
- name="favorites-heart"
108
- disabled
109
- onPress={DEFAULT_ON_PRESS}
110
- accessibilityLabel="Favorite"
111
- />
112
- </Box>
113
- <Box flexDirection="row" alignItems="center" paddingVertical="xs">
114
- <Box minWidth={100}>
115
- <Text variant="bodySmall">overlay</Text>
116
- </Box>
117
- <IconButton
118
- name="favorites-heart"
119
- disabled
120
- variant="overlay"
121
- onPress={DEFAULT_ON_PRESS}
122
- accessibilityLabel="Favorite"
123
- />
124
- </Box>
125
- <Box flexDirection="row" alignItems="center" paddingVertical="xs">
126
- <Box minWidth={100}>
127
- <Text variant="bodySmall">plain</Text>
128
- </Box>
129
- <IconButton
130
- name="favorites-heart"
131
- disabled
132
- variant="plain"
133
- onPress={DEFAULT_ON_PRESS}
134
- accessibilityLabel="Favorite"
135
- />
136
- </Box>
137
- <Box flexDirection="row" alignItems="center" paddingVertical="xs">
138
- <Box minWidth={100}>
139
- <Text variant="bodySmall">filled</Text>
140
- </Box>
141
- <IconButton
142
- name="heart"
143
- disabled
144
- variant="filled"
145
- backgroundColor="primary-button-background"
146
- onPress={DEFAULT_ON_PRESS}
147
- accessibilityLabel="Favorite"
148
- />
149
- </Box>
150
-
151
- <Box paddingVertical="xs">
152
- <FastImageBox
153
- height={200}
154
- resizeMode="cover"
155
- source={{uri: 'https://picsum.photos/id/1080/1000/1000'}}
156
- />
157
- <Box position="absolute" bottom={20} right={80}>
158
- <IconButton
159
- name="favorites-heart"
160
- variant="overlay"
161
- onPress={DEFAULT_ON_PRESS}
162
- accessibilityLabel="Favorite"
163
- />
164
- </Box>
165
- <Box position="absolute" bottom={20} right={20}>
166
- <IconButton
167
- name="heart"
168
- variant="filled"
169
- backgroundColor="primary-button-background"
170
- onPress={DEFAULT_ON_PRESS}
171
- accessibilityLabel="Favorite"
172
- />
173
- </Box>
174
- </Box>
175
- </Box>
176
- </ScrollView>
177
- </SafeAreaView>
178
- )
179
- }
180
-
181
- const DEFAULT_ON_PRESS = () => Alert.alert('Pressed!')
@@ -1,145 +0,0 @@
1
- import {
2
- Box,
3
- Button,
4
- ImageMultipleChoice,
5
- ImageChoiceType,
6
- Text,
7
- useMultiSelect,
8
- useTheme,
9
- } from '@shopify/shop-minis-platform-sdk'
10
- import {useMemo, useState} from 'react'
11
- import {SafeAreaView, ScrollView} from 'react-native'
12
-
13
- const DEFAULT_IMAGE_SIZE = 160
14
- const MOCK_IMAGE_INDEX_OFFSET = 20
15
-
16
- const getMockImageUrl = (size: number, index: number) =>
17
- `https://picsum.photos/id/${index + MOCK_IMAGE_INDEX_OFFSET}/${size}`
18
-
19
- const createChoices = (numberOfChoices: number): ImageChoiceType[] => {
20
- return Array(numberOfChoices)
21
- .fill(undefined)
22
- .map((_, index) => ({
23
- label: `Option ${index + 1}`,
24
- value: index,
25
- imageSize: DEFAULT_IMAGE_SIZE,
26
- imageUrl: getMockImageUrl(DEFAULT_IMAGE_SIZE, index),
27
- }))
28
- }
29
-
30
- const initialChoices = createChoices(10)
31
-
32
- const textOptions = {
33
- short: 'Short Option',
34
- medium: 'Medium Medium Medium Option',
35
- long: 'Long Long Long Long Long Long Long Long Long Option',
36
- }
37
-
38
- const imageSizes = {
39
- 50: 50,
40
- 90: 90,
41
- 160: 160,
42
- 300: 300,
43
- }
44
-
45
- interface ControlSectionProps {
46
- label: string
47
- children: React.ReactNode
48
- }
49
-
50
- const ControlSection = ({label, children}: ControlSectionProps) => (
51
- <Box
52
- marginHorizontal="gutter"
53
- flexDirection="row"
54
- alignContent="center"
55
- alignItems="center"
56
- marginBottom="xs"
57
- >
58
- <Text marginEnd="s" variant="bodyLarge">
59
- {label}:
60
- </Text>
61
- {children}
62
- </Box>
63
- )
64
- export const ImageMultipleChoiceScreen = () => {
65
- const [choiceText, setChoiceText] =
66
- useState<keyof typeof textOptions>('short')
67
-
68
- const [imageSize, setImageSize] = useState(160)
69
- const [snap, setSnap] = useState(false)
70
- const [selectedIndexes, toggleIndex] = useMultiSelect()
71
- const [selectedIndex, setSelectedIndex] = useState<number>()
72
-
73
- const theme = useTheme()
74
-
75
- const choices = useMemo(() => {
76
- return initialChoices.map((choice, index) => ({
77
- ...choice,
78
- label: `${textOptions[choiceText]} ${index + 1}`,
79
- }))
80
- }, [choiceText])
81
-
82
- return (
83
- <SafeAreaView style={{flex: 1}}>
84
- <Box paddingVertical="xs">
85
- <ControlSection label="Text Length">
86
- <Box flexDirection="row">
87
- {Object.keys(textOptions).map(label => (
88
- <Button
89
- key={label}
90
- variant={choiceText === label ? 'primary' : 'outlined'}
91
- text={label}
92
- onPress={() => setChoiceText(label as keyof typeof textOptions)}
93
- />
94
- ))}
95
- </Box>
96
- </ControlSection>
97
- <ControlSection label="Image Size">
98
- <Box flexDirection="row">
99
- {Object.entries(imageSizes).map(([size, value]) => (
100
- <Button
101
- key={size}
102
- variant={imageSize === value ? 'primary' : 'outlined'}
103
- text={size}
104
- onPress={() => setImageSize(value)}
105
- />
106
- ))}
107
- </Box>
108
- </ControlSection>
109
- <ControlSection label="Snap">
110
- <Button
111
- variant={snap ? 'primary' : 'outlined'}
112
- text={snap ? 'no snap' : 'snap'}
113
- onPress={() => setSnap(!snap)}
114
- />
115
- </ControlSection>
116
- </Box>
117
- <ScrollView>
118
- <Box marginVertical="s" marginHorizontal="gutter">
119
- <Text variant="headerNormal">Single Select</Text>
120
- </Box>
121
- <ImageMultipleChoice
122
- initialOffsetX={theme.spacing.gutter}
123
- imageSize={imageSize}
124
- choices={choices}
125
- onChoiceSelected={index =>
126
- setSelectedIndex(index === selectedIndex ? undefined : index)
127
- }
128
- selectedIndexes={selectedIndex === undefined ? [] : [selectedIndex]}
129
- snap={snap}
130
- />
131
- <Box marginVertical="s" marginHorizontal="gutter">
132
- <Text variant="headerNormal">Multi Select</Text>
133
- </Box>
134
- <ImageMultipleChoice
135
- initialOffsetX={theme.spacing.gutter}
136
- imageSize={imageSize}
137
- choices={choices}
138
- onChoiceSelected={toggleIndex}
139
- selectedIndexes={selectedIndexes}
140
- snap={snap}
141
- />
142
- </ScrollView>
143
- </SafeAreaView>
144
- )
145
- }