@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,75 +0,0 @@
1
- import {
2
- useMultiSelect,
3
- Box,
4
- MultipleChoice,
5
- Text,
6
- MultipleChoiceProps,
7
- } from '@shopify/shop-minis-platform-sdk'
8
- import {useState} from 'react'
9
- import {SafeAreaView} from 'react-native'
10
- import {ScrollView} from 'react-native-gesture-handler'
11
-
12
- import {Header} from '../components/Header'
13
-
14
- const CHOICE_COUNT = 10
15
-
16
- const createChoices = (
17
- numberOfChoices: number
18
- ): MultipleChoiceProps['choices'] => {
19
- return Array(numberOfChoices)
20
- .fill(undefined)
21
- .map((_, index) => ({
22
- label: `Option ${index + 1}`,
23
- value: index,
24
- }))
25
- }
26
-
27
- const choices = createChoices(CHOICE_COUNT)
28
-
29
- export const MultipleChoiceScreen = () => {
30
- const [selectedIndexes, toggleIndex] = useMultiSelect()
31
- const [selectedIndex, setSelectedIndex] = useState<number>()
32
- const [withPreSelectedIndexes, togglePreSelectedIndex] = useMultiSelect([
33
- 1, 4,
34
- ])
35
-
36
- return (
37
- <SafeAreaView style={{flex: 1}}>
38
- <ScrollView>
39
- <Header />
40
- <Box marginTop="s" marginHorizontal="gutter">
41
- <Text variant="headerNormal">Single Select</Text>
42
- </Box>
43
- <Box margin="s">
44
- <MultipleChoice
45
- selectedIndexes={selectedIndex === undefined ? [] : [selectedIndex]}
46
- choices={choices}
47
- onChoiceSelected={index =>
48
- setSelectedIndex(index === selectedIndex ? undefined : index)
49
- }
50
- />
51
- </Box>
52
- <Box marginTop="s" marginHorizontal="gutter">
53
- <Text variant="headerNormal">Multi Select</Text>
54
- </Box>
55
- <Box margin="s">
56
- <MultipleChoice
57
- selectedIndexes={selectedIndexes}
58
- choices={choices}
59
- onChoiceSelected={toggleIndex}
60
- />
61
- </Box>
62
- <Box marginTop="s" marginHorizontal="gutter">
63
- <Text variant="headerNormal">Preselect Options</Text>
64
- </Box>
65
- <Box margin="s">
66
- <MultipleChoice
67
- selectedIndexes={withPreSelectedIndexes}
68
- choices={choices}
69
- onChoiceSelected={togglePreSelectedIndex}
70
- />
71
- </Box>
72
- </ScrollView>
73
- </SafeAreaView>
74
- )
75
- }
@@ -1,68 +0,0 @@
1
- import {SafeAreaView} from 'react-native'
2
- import {
3
- useMinisQuery,
4
- Box,
5
- Text,
6
- TouchableProduct,
7
- ProductCard,
8
- ProductCardGrid,
9
- useTheme,
10
- } from '@shopify/shop-minis-platform-sdk'
11
-
12
- import TestProductsQuery from '../data/TestProducts.graphql'
13
- import {Header} from '../components/Header'
14
-
15
- const SHOP_GID = 'gid://shopify/Shop/68822335510'
16
- const PRODUCT_GIDS = [
17
- 'gid://shopify/Product/7982542651414',
18
- 'gid://shopify/Product/7982528397334',
19
- 'gid://shopify/Product/7982535704598',
20
- 'gid://shopify/Product/7982577352726',
21
- 'gid://shopify/Product/7982564245526',
22
- 'gid://shopify/Product/7982547763222',
23
- 'gid://shopify/Product/7982499495958',
24
- 'gid://shopify/Product/7982540521494',
25
- 'gid://shopify/Product/7982554710038',
26
- 'gid://shopify/Product/7982557200406',
27
- 'gid://shopify/Product/7982571257878',
28
- 'gid://shopify/Product/7982372388886',
29
- ]
30
-
31
- export const ProductCardGridScreen = () => {
32
- const theme = useTheme()
33
- const {loading, data} = useMinisQuery(TestProductsQuery, {
34
- variables: {
35
- shopId: SHOP_GID,
36
- productIds: PRODUCT_GIDS,
37
- },
38
- fetchPolicy: 'cache-and-network',
39
- })
40
-
41
- const products = data?.shop?.productsByIds ?? []
42
-
43
- if (loading || !products) return null
44
-
45
- return (
46
- <SafeAreaView
47
- style={{flex: 1, backgroundColor: theme.colors['backgrounds-regular']}}
48
- >
49
- <Header />
50
- <ProductCardGrid
51
- products={products}
52
- ListHeaderComponent={
53
- <Box pb="s">
54
- <Text variant="headerBold" mb="xs">
55
- ProductCardGrid
56
- </Text>
57
- </Box>
58
- }
59
- renderItem={({product}) => (
60
- <TouchableProduct product={product} key={product.id}>
61
- <ProductCard shopId={SHOP_GID} product={product} />
62
- </TouchableProduct>
63
- )}
64
- contentContainerStyle={{padding: theme.spacing.gutter}}
65
- />
66
- </SafeAreaView>
67
- )
68
- }
@@ -1,62 +0,0 @@
1
- import {SafeAreaView, ScrollView} from 'react-native'
2
- import {
3
- Box,
4
- ProductCard,
5
- Text,
6
- TouchableProduct,
7
- useMinisQuery,
8
- useTheme,
9
- } from '@shopify/shop-minis-platform-sdk'
10
-
11
- import TestQuery from '../data/Test.graphql'
12
- import {Header} from '../components/Header'
13
-
14
- const SHOP_GID = 'gid://shopify/Shop/68822335510'
15
- const PRODUCT_GID = 'gid://shopify/Product/7982542651414'
16
-
17
- export const ProductCardScreen = () => {
18
- const theme = useTheme()
19
- const {loading, data} = useMinisQuery(TestQuery, {
20
- variables: {
21
- shopId: SHOP_GID,
22
- productId: PRODUCT_GID,
23
- },
24
- fetchPolicy: 'cache-and-network',
25
- })
26
-
27
- if (loading || !data?.shop?.product) return null
28
-
29
- return (
30
- <SafeAreaView
31
- style={{flex: 1, backgroundColor: theme.colors['backgrounds-regular']}}
32
- >
33
- <ScrollView>
34
- <Header />
35
- <Box px="gutter">
36
- <Text variant="headerBold" mb="xs">
37
- ProductCard
38
- </Text>
39
- </Box>
40
- <Box flexDirection="row" px="gutter" pt="m">
41
- <Box flex={1} padding="xs">
42
- <Text variant="label">Default</Text>
43
- <TouchableProduct product={data.shop.product}>
44
- <ProductCard shopId={SHOP_GID} product={data.shop.product} />
45
- </TouchableProduct>
46
- </Box>
47
- <Box flex={1} padding="xs">
48
- <Text variant="label">With a badge</Text>
49
- <TouchableProduct product={data.shop.product}>
50
- <ProductCard
51
- shopId={SHOP_GID}
52
- product={data.shop.product}
53
- badgeText="New"
54
- badgeColor="backgrounds-dangerous"
55
- />
56
- </TouchableProduct>
57
- </Box>
58
- </Box>
59
- </ScrollView>
60
- </SafeAreaView>
61
- )
62
- }
@@ -1,215 +0,0 @@
1
- import {
2
- Box,
3
- CurrencyCode,
4
- ProductLink,
5
- ProductLinkProps,
6
- Text,
7
- useTheme,
8
- } from '@shopify/shop-minis-platform-sdk'
9
- import {SafeAreaView} from 'react-native'
10
-
11
- import {Header} from '../components/Header'
12
-
13
- const FIXTURE: ProductLinkProps['product'] = {
14
- __typename: 'Product',
15
- id: 'gid://shopify/Product/7982547763222',
16
- title: 'The Hero Snowboard',
17
- featuredImage: {
18
- __typename: 'Image',
19
- id: 'gid://shopify/ProductImage/39774118445078',
20
- altText: null,
21
- url: 'https://cdn.shopify.com/s/files/1/0688/2233/5510/products/Main_52f8e304-92d9-4a36-82af-50df8fe31c69.jpg?v=1674664826',
22
- },
23
- variants: {
24
- __typename: 'ProductVariantConnection',
25
- nodes: [
26
- {
27
- __typename: 'ProductVariant',
28
- id: 'gid://shopify/ProductVariant/43695288975382',
29
- title: 'Default Title',
30
- price: {
31
- __typename: 'Money',
32
- amount: '605.95',
33
- currencyCode: CurrencyCode.USD,
34
- },
35
- image: {
36
- __typename: 'Image',
37
- id: 'gid://shopify/ProductImage/39774118445078',
38
- altText: null,
39
- url: 'https://cdn.shopify.com/s/files/1/0688/2233/5510/products/Main_52f8e304-92d9-4a36-82af-50df8fe31c69.jpg?v=1674664826',
40
- },
41
- },
42
- ],
43
- },
44
- }
45
-
46
- const FIXTURE_WITH_DISCOUNT: ProductLinkProps['product'] = {
47
- __typename: 'Product',
48
- id: 'gid://shopify/Product/7982547763222',
49
- title: 'The Hero Snowboard',
50
- featuredImage: {
51
- __typename: 'Image',
52
- id: 'gid://shopify/ProductImage/39774118445078',
53
- altText: null,
54
- url: 'https://cdn.shopify.com/s/files/1/0688/2233/5510/products/Main_52f8e304-92d9-4a36-82af-50df8fe31c69.jpg?v=1674664826',
55
- },
56
- variants: {
57
- __typename: 'ProductVariantConnection',
58
- nodes: [
59
- {
60
- __typename: 'ProductVariant',
61
- id: 'gid://shopify/ProductVariant/43695288975382',
62
- title: 'Default Title',
63
- compareAtPrice: {
64
- __typename: 'Money',
65
- amount: '605.95',
66
- currencyCode: CurrencyCode.USD,
67
- },
68
- price: {
69
- __typename: 'Money',
70
- amount: '555.95',
71
- currencyCode: CurrencyCode.USD,
72
- },
73
- image: {
74
- __typename: 'Image',
75
- id: 'gid://shopify/ProductImage/39774118445078',
76
- altText: null,
77
- url: 'https://cdn.shopify.com/s/files/1/0688/2233/5510/products/Main_52f8e304-92d9-4a36-82af-50df8fe31c69.jpg?v=1674664826',
78
- },
79
- },
80
- ],
81
- },
82
- }
83
-
84
- const FIXTURE_WITH_DISCOUNT_BIG_MONEY: ProductLinkProps['product'] = {
85
- __typename: 'Product',
86
- id: 'gid://shopify/Product/7982547763222',
87
- title: 'The Hero Snowboard',
88
- featuredImage: {
89
- __typename: 'Image',
90
- id: 'gid://shopify/ProductImage/39774118445078',
91
- altText: null,
92
- url: 'https://cdn.shopify.com/s/files/1/0688/2233/5510/products/Main_52f8e304-92d9-4a36-82af-50df8fe31c69.jpg?v=1674664826',
93
- },
94
- variants: {
95
- __typename: 'ProductVariantConnection',
96
- nodes: [
97
- {
98
- __typename: 'ProductVariant',
99
- id: 'gid://shopify/ProductVariant/43695288975382',
100
- title: 'Default Title',
101
- compareAtPrice: {
102
- __typename: 'Money',
103
- amount: '22605.95',
104
- currencyCode: CurrencyCode.USD,
105
- },
106
- price: {
107
- __typename: 'Money',
108
- amount: '12555.95',
109
- currencyCode: CurrencyCode.USD,
110
- },
111
- image: {
112
- __typename: 'Image',
113
- id: 'gid://shopify/ProductImage/39774118445078',
114
- altText: null,
115
- url: 'https://cdn.shopify.com/s/files/1/0688/2233/5510/products/Main_52f8e304-92d9-4a36-82af-50df8fe31c69.jpg?v=1674664826',
116
- },
117
- },
118
- ],
119
- },
120
- }
121
-
122
- const FIXTURE_WITH_MULTIPLE_VARIANTS: ProductLinkProps['product'] = {
123
- __typename: 'Product',
124
- id: 'gid://shopify/Product/7982547763222',
125
- title: 'The Hero Snowboard',
126
- featuredImage: {
127
- __typename: 'Image',
128
- id: 'gid://shopify/ProductImage/39774118445078',
129
- altText: null,
130
- url: 'https://cdn.shopify.com/s/files/1/0688/2233/5510/products/Main_52f8e304-92d9-4a36-82af-50df8fe31c69.jpg?v=1674664826',
131
- },
132
- variants: {
133
- __typename: 'ProductVariantConnection',
134
- nodes: [
135
- {
136
- __typename: 'ProductVariant',
137
- id: 'gid://shopify/ProductVariant/43695288975382',
138
- title: 'Default Title',
139
- price: {
140
- __typename: 'Money',
141
- amount: '605.95',
142
- currencyCode: CurrencyCode.USD,
143
- },
144
- image: {
145
- __typename: 'Image',
146
- id: 'gid://shopify/ProductImage/39774118445078',
147
- altText: null,
148
- url: 'https://cdn.shopify.com/s/files/1/0688/2233/5510/products/Main_52f8e304-92d9-4a36-82af-50df8fe31c69.jpg?v=1674664826',
149
- },
150
- },
151
- {
152
- __typename: 'ProductVariant',
153
- id: 'gid://shopify/ProductVariant/43695281569814',
154
- title: 'Default Title',
155
- price: {
156
- __typename: 'Money',
157
- amount: '577.95',
158
- currencyCode: CurrencyCode.USD,
159
- },
160
- image: {
161
- __typename: 'Image',
162
- id: 'gid://shopify/ProductImage/39774117986326',
163
- altText: null,
164
- url: 'https://cdn.shopify.com/s/files/1/0688/2233/5510/products/Main.jpg?v=1674664528',
165
- },
166
- },
167
- ],
168
- },
169
- }
170
-
171
- export const ProductLinkScreen = () => {
172
- const theme = useTheme()
173
- return (
174
- <SafeAreaView
175
- style={{flex: 1, backgroundColor: theme.colors['backgrounds-regular']}}
176
- >
177
- <Header />
178
- <Box px="gutter">
179
- <Text variant="headerBold" mb="xs">
180
- ProductLink
181
- </Text>
182
- <Box marginBottom="m">
183
- <Text variant="bodyLarge" mb="xs">
184
- Default
185
- </Text>
186
- <ProductLink product={FIXTURE} />
187
- </Box>
188
-
189
- <Box marginBottom="m">
190
- <Text variant="bodyLarge" mb="xs">
191
- With discount
192
- </Text>
193
- <ProductLink product={FIXTURE_WITH_DISCOUNT} />
194
- </Box>
195
-
196
- <Box marginBottom="m">
197
- <Text variant="bodyLarge" mb="xs">
198
- With large discount
199
- </Text>
200
- <ProductLink product={FIXTURE_WITH_DISCOUNT_BIG_MONEY} />
201
- </Box>
202
-
203
- <Box marginBottom="m">
204
- <Text variant="bodyLarge" mb="xs">
205
- With variant selection
206
- </Text>
207
- <ProductLink
208
- product={FIXTURE_WITH_MULTIPLE_VARIANTS}
209
- productVariantId="gid://shopify/ProductVariant/43695281569814"
210
- />
211
- </Box>
212
- </Box>
213
- </SafeAreaView>
214
- )
215
- }
@@ -1,77 +0,0 @@
1
- import {useCallback, useState} from 'react'
2
- import {SafeAreaView} from 'react-native'
3
- import {
4
- Box,
5
- Text,
6
- ProgressIndicators,
7
- Button,
8
- useTheme,
9
- } from '@shopify/shop-minis-platform-sdk'
10
- import {runOnJS, useSharedValue, withTiming} from 'react-native-reanimated'
11
-
12
- import {Header} from '../components/Header'
13
-
14
- const PROGRESS_INDICATORS = 10
15
-
16
- export const ProgressIndicatorScreen = () => {
17
- const theme = useTheme()
18
- const currentActiveAnimatedIndicator = useSharedValue(0)
19
- const progress = useSharedValue(0)
20
-
21
- const [currentActive, setCurrentActive] = useState(
22
- currentActiveAnimatedIndicator.value
23
- )
24
-
25
- const startProgressIndicator = useCallback(() => {
26
- progress.value = withTiming(1, {duration: 5000}, finished => {
27
- if (
28
- finished &&
29
- currentActiveAnimatedIndicator.value < PROGRESS_INDICATORS - 1
30
- ) {
31
- currentActiveAnimatedIndicator.value += 1
32
- progress.value = 0
33
- runOnJS(setCurrentActive)(currentActiveAnimatedIndicator.value)
34
-
35
- runOnJS(startProgressIndicator)()
36
- }
37
- })
38
- }, [progress, currentActiveAnimatedIndicator])
39
-
40
- const reset = useCallback(() => {
41
- currentActiveAnimatedIndicator.value = 0
42
- progress.value = 0
43
- setCurrentActive(0)
44
- }, [currentActiveAnimatedIndicator, progress])
45
-
46
- return (
47
- <SafeAreaView
48
- style={{flex: 1, backgroundColor: theme.colors['backgrounds-regular']}}
49
- >
50
- <Header />
51
- <Box flex={1} px="gutter">
52
- <Text variant="headerBold">ProgressIndicators</Text>
53
-
54
- <Box
55
- my="s"
56
- padding="m"
57
- backgroundColor="backgrounds-overlay"
58
- borderRadius={16}
59
- flex={1}
60
- >
61
- <ProgressIndicators
62
- numberOfIndicators={PROGRESS_INDICATORS}
63
- currentStep={currentActive}
64
- progress={progress}
65
- width="100%"
66
- />
67
- <Box marginTop="s">
68
- <Button onPress={startProgressIndicator} text="Start" />
69
- </Box>
70
- <Box marginTop="s">
71
- <Button onPress={reset} text="Stop and reset" variant="secondary" />
72
- </Box>
73
- </Box>
74
- </Box>
75
- </SafeAreaView>
76
- )
77
- }
@@ -1,76 +0,0 @@
1
- import {useState} from 'react'
2
- import {SafeAreaView, ScrollView} from 'react-native'
3
- import {
4
- Box,
5
- QuantityPicker,
6
- QuantityPickerProps,
7
- Text,
8
- } from '@shopify/shop-minis-platform-sdk'
9
-
10
- import {Header} from '../components/Header'
11
-
12
- export const QuantityPickerScreen = () => {
13
- return (
14
- <SafeAreaView style={{flex: 1}}>
15
- <ScrollView style={{flex: 1}}>
16
- <Header />
17
- <Box px="gutter">
18
- <Text variant="heroBold">QuantityPicker</Text>
19
-
20
- <Box paddingTop="m">
21
- <Text>No limits</Text>
22
- </Box>
23
-
24
- <Box paddingTop="xs">
25
- <StatefulQuantityPicker quantity={1} disabled={false} />
26
- </Box>
27
-
28
- <Box paddingTop="m">
29
- <Text>Maximum 10 items</Text>
30
- </Box>
31
-
32
- <Box paddingTop="xs">
33
- <StatefulQuantityPicker
34
- quantity={1}
35
- maxQuantity={10}
36
- disabled={false}
37
- />
38
- </Box>
39
-
40
- <Box paddingTop="m">
41
- <Text>Disabled</Text>
42
- </Box>
43
-
44
- <Box paddingTop="xs">
45
- <StatefulQuantityPicker quantity={5} disabled />
46
- </Box>
47
-
48
- <Box paddingTop="m">
49
- <Text>With Label</Text>
50
- </Box>
51
-
52
- <Box paddingTop="xs">
53
- <StatefulQuantityPicker label="Quantity" quantity={5} />
54
- </Box>
55
- </Box>
56
- </ScrollView>
57
- </SafeAreaView>
58
- )
59
- }
60
-
61
- type StatefulQuantityPickerProps = Omit<QuantityPickerProps, 'onQuantityChange'>
62
-
63
- function StatefulQuantityPicker({
64
- quantity: initialQuantity,
65
- ...props
66
- }: StatefulQuantityPickerProps) {
67
- const [quantity, setQuantity] = useState<number>(initialQuantity)
68
-
69
- return (
70
- <QuantityPicker
71
- {...props}
72
- quantity={quantity}
73
- onQuantityChange={setQuantity}
74
- />
75
- )
76
- }
@@ -1,82 +0,0 @@
1
- import {Box, Text} from '@shopify/shop-minis-platform-sdk'
2
- import {useMemo} from 'react'
3
- import {Image, SafeAreaView, ScrollView} from 'react-native'
4
-
5
- import {useQuizContext} from '../components/quiz/QuizProvider'
6
- import {
7
- addNameToText,
8
- getImageCarouselAnswerUrls,
9
- getMultilpleChoiceAnswerLabels,
10
- getQuestionById,
11
- } from '../utils/quizUtils'
12
-
13
- export const QuizResultScreen = () => {
14
- const {quizResult, quizData, userName} = useQuizContext()
15
-
16
- const formattedResults = useMemo(() => {
17
- if (!quizData) return []
18
-
19
- return Object.entries(quizResult!).map(([questionId, result]) => {
20
- let answer = ''
21
- // image carousel type will be an imageUrl
22
- let type: 'imageUrl' | 'string' = 'string'
23
-
24
- switch (result.slideType) {
25
- case 'MultipleChoiceSlide':
26
- answer = getMultilpleChoiceAnswerLabels(
27
- quizData,
28
- questionId,
29
- result.answer as number[]
30
- ).join(', ')
31
- break
32
- case 'ImageCarouselSlide':
33
- type = 'imageUrl'
34
- answer = getImageCarouselAnswerUrls(
35
- quizData,
36
- questionId,
37
- result.answer as number[]
38
- )[0]
39
- break
40
- default:
41
- answer = result.answer as string
42
- }
43
-
44
- const question = addNameToText(
45
- getQuestionById(quizData, questionId),
46
- userName
47
- )
48
-
49
- return {
50
- type,
51
- question,
52
- answer,
53
- }
54
- })
55
- }, [quizData, quizResult, userName])
56
-
57
- return (
58
- <SafeAreaView>
59
- <ScrollView>
60
- <Box paddingHorizontal="gutter" paddingVertical="xs">
61
- <Text variant="posterXS" textAlign="center" marginVertical="m">
62
- Results
63
- </Text>
64
- {formattedResults.map(({question, answer, type}, index) => (
65
- <Box key={question} marginBottom="s">
66
- <Text variant="headerNormal" marginBottom="xs">
67
- {index + 1}. {question}
68
- </Text>
69
- {type === 'imageUrl' ? (
70
- <Image
71
- style={{width: 160, height: 160}}
72
- source={{uri: answer}}
73
- />
74
- ) : null}
75
- {type === 'string' ? <Text>Answer: {answer}</Text> : null}
76
- </Box>
77
- ))}
78
- </Box>
79
- </ScrollView>
80
- </SafeAreaView>
81
- )
82
- }
@@ -1,40 +0,0 @@
1
- import {NavigationContainer} from '@react-navigation/native'
2
- import {createNativeStackNavigator} from '@react-navigation/native-stack'
3
-
4
- import {Header} from '../components/Header'
5
- import {QuizContextProvider} from '../components/quiz/QuizProvider'
6
-
7
- import {QuizResultScreen} from './QuizResultScreen'
8
- import {QuizSlideScreen} from './QuizSlideScreen'
9
-
10
- const Stack = createNativeStackNavigator()
11
-
12
- export const QuizScreen = () => {
13
- return (
14
- <QuizContextProvider>
15
- <>
16
- <Header />
17
- <NavigationContainer independent>
18
- <Stack.Navigator>
19
- <Stack.Screen
20
- name="QuizScreen.QuizSlide"
21
- component={QuizSlideScreen}
22
- options={{
23
- title: '__MINI_APP_NAME_PASCAL_CASE__ Quiz',
24
- headerBackTitle: 'Previous',
25
- }}
26
- initialParams={{
27
- slideIndex: 0,
28
- }}
29
- />
30
- <Stack.Screen
31
- name="QuizScreen.QuizResult"
32
- component={QuizResultScreen}
33
- options={{headerShown: false}}
34
- />
35
- </Stack.Navigator>
36
- </NavigationContainer>
37
- </>
38
- </QuizContextProvider>
39
- )
40
- }