@shopify/shop-minis-react 0.0.29 → 0.0.31
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/dist/components/atoms/list.js +37 -31
- package/dist/components/atoms/list.js.map +1 -1
- package/dist/components/commerce/search.js.map +1 -1
- package/dist/hooks/navigation/useNavigateWithTransition.js.map +1 -1
- package/dist/hooks/navigation/useShopNavigation.js.map +1 -1
- package/dist/hooks/user/useCurrentUser.js.map +1 -1
- package/dist/hooks/user/useFollowedShopsActions.js.map +1 -1
- package/dist/hooks/user/useGenerateUserToken.js +12 -0
- package/dist/hooks/user/useGenerateUserToken.js.map +1 -0
- package/dist/hooks/util/useImagePicker.js.map +1 -1
- package/dist/index.js +111 -106
- package/dist/index.js.map +1 -1
- package/dist/mocks.js +24 -16
- package/dist/mocks.js.map +1 -1
- package/dist/shop-minis-platform/src/types/user.js +6 -0
- package/dist/shop-minis-platform/src/types/user.js.map +1 -0
- package/package.json +2 -2
- package/src/components/atoms/list.tsx +24 -4
- package/src/components/commerce/search.tsx +1 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/navigation/useNavigateWithTransition.ts +6 -1
- package/src/hooks/navigation/useShopNavigation.ts +3 -1
- package/src/hooks/user/useCurrentUser.ts +3 -0
- package/src/hooks/user/useFollowedShopsActions.ts +2 -2
- package/src/hooks/user/useGenerateUserToken.ts +25 -0
- package/src/hooks/util/{useImagePicker.tsx → useImagePicker.ts} +8 -2
- package/src/mocks.ts +11 -4
- package/src/stories/ImageContentWrapper.stories.tsx +68 -0
- package/src/stories/MerchantCard.stories.tsx +21 -0
- package/src/stories/ProductCard.stories.tsx +10 -3
- package/src/stories/ProductLink.stories.tsx +3 -3
- package/src/stories/QuantitySelector.stories.tsx +78 -0
- package/src/stories/VideoPlayer.stories.tsx +129 -0
- package/src/hooks/util/useImagePicker.doc.tsx +0 -41
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {fn} from 'storybook/test'
|
|
2
|
+
|
|
3
|
+
import {QuantitySelector} from '../components/commerce/quantity-selector'
|
|
4
|
+
|
|
5
|
+
import type {Meta, StoryObj} from '@storybook/react-vite'
|
|
6
|
+
|
|
7
|
+
type QuantitySelectorProps = React.ComponentProps<typeof QuantitySelector>
|
|
8
|
+
|
|
9
|
+
const meta: Meta<QuantitySelectorProps> = {
|
|
10
|
+
title: 'Commerce/QuantitySelector',
|
|
11
|
+
component: QuantitySelector,
|
|
12
|
+
parameters: {},
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
argTypes: {
|
|
15
|
+
quantity: {
|
|
16
|
+
control: 'number',
|
|
17
|
+
description: 'Current quantity value',
|
|
18
|
+
},
|
|
19
|
+
onQuantityChange: {
|
|
20
|
+
action: 'quantity changed',
|
|
21
|
+
description: 'Callback fired when quantity changes',
|
|
22
|
+
},
|
|
23
|
+
maxQuantity: {
|
|
24
|
+
control: 'number',
|
|
25
|
+
description: 'Maximum allowed quantity',
|
|
26
|
+
},
|
|
27
|
+
minQuantity: {
|
|
28
|
+
control: 'number',
|
|
29
|
+
description: 'Minimum allowed quantity',
|
|
30
|
+
},
|
|
31
|
+
disabled: {
|
|
32
|
+
control: 'boolean',
|
|
33
|
+
description: 'Whether the selector is disabled',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
args: {
|
|
37
|
+
onQuantityChange: fn(),
|
|
38
|
+
},
|
|
39
|
+
} satisfies Meta<QuantitySelectorProps>
|
|
40
|
+
|
|
41
|
+
export default meta
|
|
42
|
+
type Story = StoryObj<typeof meta>
|
|
43
|
+
|
|
44
|
+
export const Default: Story = {
|
|
45
|
+
args: {
|
|
46
|
+
quantity: 2,
|
|
47
|
+
maxQuantity: 10,
|
|
48
|
+
minQuantity: 1,
|
|
49
|
+
disabled: false,
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const AtMinimum: Story = {
|
|
54
|
+
args: {
|
|
55
|
+
quantity: 1,
|
|
56
|
+
maxQuantity: 10,
|
|
57
|
+
minQuantity: 1,
|
|
58
|
+
disabled: false,
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const AtMaximum: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
quantity: 10,
|
|
65
|
+
maxQuantity: 10,
|
|
66
|
+
minQuantity: 1,
|
|
67
|
+
disabled: false,
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const Disabled: Story = {
|
|
72
|
+
args: {
|
|
73
|
+
quantity: 3,
|
|
74
|
+
maxQuantity: 10,
|
|
75
|
+
minQuantity: 1,
|
|
76
|
+
disabled: true,
|
|
77
|
+
},
|
|
78
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {useRef} from 'react'
|
|
2
|
+
|
|
3
|
+
import {fn} from 'storybook/test'
|
|
4
|
+
|
|
5
|
+
import {VideoPlayer, VideoPlayerRef} from '../components/atoms/video-player'
|
|
6
|
+
|
|
7
|
+
import type {Meta, StoryObj} from '@storybook/react-vite'
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof VideoPlayer> = {
|
|
10
|
+
title: 'Atoms/VideoPlayer',
|
|
11
|
+
component: VideoPlayer,
|
|
12
|
+
parameters: {
|
|
13
|
+
layout: 'padded',
|
|
14
|
+
},
|
|
15
|
+
args: {
|
|
16
|
+
onPlay: fn(),
|
|
17
|
+
onPause: fn(),
|
|
18
|
+
onEnded: fn(),
|
|
19
|
+
onReady: fn(),
|
|
20
|
+
},
|
|
21
|
+
argTypes: {
|
|
22
|
+
src: {
|
|
23
|
+
control: 'text',
|
|
24
|
+
},
|
|
25
|
+
format: {
|
|
26
|
+
control: 'select',
|
|
27
|
+
options: ['video/mp4', 'video/webm', 'video/ogg'],
|
|
28
|
+
},
|
|
29
|
+
poster: {
|
|
30
|
+
control: 'text',
|
|
31
|
+
},
|
|
32
|
+
width: {
|
|
33
|
+
control: 'number',
|
|
34
|
+
},
|
|
35
|
+
height: {
|
|
36
|
+
control: 'number',
|
|
37
|
+
},
|
|
38
|
+
muted: {
|
|
39
|
+
control: 'boolean',
|
|
40
|
+
},
|
|
41
|
+
autoplay: {
|
|
42
|
+
control: 'boolean',
|
|
43
|
+
},
|
|
44
|
+
playButtonComponent: {
|
|
45
|
+
control: 'text',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
tags: ['autodocs'],
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default meta
|
|
52
|
+
type Story = StoryObj<typeof meta>
|
|
53
|
+
|
|
54
|
+
const SAMPLE_VIDEO_MP4 =
|
|
55
|
+
'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4'
|
|
56
|
+
const SAMPLE_POSTER =
|
|
57
|
+
'https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg'
|
|
58
|
+
|
|
59
|
+
export const FixedWidth: Story = {
|
|
60
|
+
args: {
|
|
61
|
+
src: SAMPLE_VIDEO_MP4,
|
|
62
|
+
width: 300,
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const FixedHeight: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
src: SAMPLE_VIDEO_MP4,
|
|
69
|
+
height: 200,
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const WithPoster: Story = {
|
|
74
|
+
args: {
|
|
75
|
+
src: SAMPLE_VIDEO_MP4,
|
|
76
|
+
poster: SAMPLE_POSTER,
|
|
77
|
+
width: 300,
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const WithCustomPlayButton: Story = {
|
|
82
|
+
args: {
|
|
83
|
+
src: SAMPLE_VIDEO_MP4,
|
|
84
|
+
poster: SAMPLE_POSTER,
|
|
85
|
+
width: 300,
|
|
86
|
+
playButtonComponent: (
|
|
87
|
+
<div className="bg-blue-500 text-white rounded-full p-4 shadow-lg">
|
|
88
|
+
<svg viewBox="0 0 24 24" className="w-8 h-8" fill="currentColor">
|
|
89
|
+
<path d="M8 5v14l11-7z" />
|
|
90
|
+
</svg>
|
|
91
|
+
</div>
|
|
92
|
+
),
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const WithImperativeControlsComponent = (args: any) => {
|
|
97
|
+
const videoRef = useRef<VideoPlayerRef>(null)
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<div className="space-y-4 flex flex-col items-center">
|
|
101
|
+
<VideoPlayer ref={videoRef} {...args} />
|
|
102
|
+
<div className="flex gap-2">
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
className="px-4 py-2 bg-primary text-white rounded"
|
|
106
|
+
onClick={() => videoRef.current?.play()}
|
|
107
|
+
>
|
|
108
|
+
Play
|
|
109
|
+
</button>
|
|
110
|
+
<button
|
|
111
|
+
type="button"
|
|
112
|
+
className="px-4 py-2 bg-red-400 text-white rounded"
|
|
113
|
+
onClick={() => videoRef.current?.pause()}
|
|
114
|
+
>
|
|
115
|
+
Pause
|
|
116
|
+
</button>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const WithImperativeControls: Story = {
|
|
123
|
+
render: WithImperativeControlsComponent,
|
|
124
|
+
args: {
|
|
125
|
+
src: SAMPLE_VIDEO_MP4,
|
|
126
|
+
poster: SAMPLE_POSTER,
|
|
127
|
+
width: 300,
|
|
128
|
+
},
|
|
129
|
+
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export const useImagePickerDoc = {
|
|
2
|
-
name: 'useImagePicker',
|
|
3
|
-
category: 'Utility',
|
|
4
|
-
description:
|
|
5
|
-
'Hook for selecting images from camera or gallery in web-based mini apps',
|
|
6
|
-
params: [
|
|
7
|
-
{
|
|
8
|
-
name: 'options',
|
|
9
|
-
type: 'UseImagePickerOptions',
|
|
10
|
-
description: 'Configuration options for the image picker',
|
|
11
|
-
optional: true,
|
|
12
|
-
properties: [
|
|
13
|
-
{
|
|
14
|
-
name: 'cameraFacing',
|
|
15
|
-
type: "'user' | 'environment'",
|
|
16
|
-
description: 'Which camera to use when opening camera',
|
|
17
|
-
optional: true,
|
|
18
|
-
default: "'environment'",
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
returns: [
|
|
24
|
-
{
|
|
25
|
-
name: 'openCamera',
|
|
26
|
-
type: '() => Promise<File>',
|
|
27
|
-
description: 'Function to open the camera for capturing an image',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'openGallery',
|
|
31
|
-
type: '() => Promise<File>',
|
|
32
|
-
description: 'Function to open the gallery for selecting an image',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'ImagePickerInputs',
|
|
36
|
-
type: 'React.FC',
|
|
37
|
-
description:
|
|
38
|
-
'Component that renders hidden file inputs. Must be rendered in your component for the picker to work',
|
|
39
|
-
},
|
|
40
|
-
],
|
|
41
|
-
}
|