File size: 5,372 Bytes
a03b3ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<script>
	import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
	import Gallery from "./Index.svelte";
</script>

<Meta
	title="Components/Gallery"
	component={Gallery}
	argTypes={{
		label: {
			control: "text",
			description: "The gallery label",
			name: "label",
			value: "Gradio Button"
		},
		show_label: {
			options: [true, false],
			description: "Whether to show the label",
			control: { type: "boolean" },
			defaultValue: true
		},
		columns: {
			options: [1, 2, 3, 4],
			description: "The number of columns to show in grid",
			control: { type: "select" },
			defaultValue: 2
		},
		rows: {
			options: [1, 2, 3, 4],
			description: "The number of rows to show in grid",
			control: { type: "select" },
			defaultValue: 2
		},
		height: {
			options: ["auto", 500, 600],
			description: "The height of the grid",
			control: { type: "select" },
			defaultValue: "auto"
		},
		preview: {
			options: [true, false],
			description: "Whether to start the gallery in preview mode",
			control: { type: "boolean" },
			defaultValue: true
		},
		allow_preview: {
			options: [true, false],
			description: "Whether to allow a preview mode in the gallery",
			control: { type: "boolean" },
			defaultValue: true
		},
		object_fit: {
			options: ["contain", "cover", "fill", "none", "scale-down"],
			description: "How to display each indivial image in the grid",
			control: { type: "select" },
			defaultValue: "contain"
		},
		show_share_button: {
			options: [true, false],
			description: "Whether to show the share button in the gallery",
			control: { type: "boolean" },
			defaultValue: false
		}
	}}
/>

<Template let:args>
	<Gallery
		value={[
			{
				image: {
					path: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah_running.avif",
					url: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah_running.avif",
					orig_name: "cheetah_running.avif"
				},
				caption: "A fast cheetah"
			},
			{
				image: {
					path: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg",
					url: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg",
					orig_name: "cheetah-002.jpg"
				}
			},
			{
				image: {
					path: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-003.jpg",
					url: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-003.jpg",
					orig_name: "cheetah-003.jpg"
				}
			},
			{
				image: {
					path: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah3.webp",
					url: "https://gradio-builds.s3.amazonaws.com/demo-files/cheetah3.webp",
					orig_name: "cheetah3.webp"
				}
			},
			{
				image: {
					path: "https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
					url: "https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
					orig_name: "ghepardo-primo-piano.jpg"
				}
			},
			{
				image: {
					path: "https://gradio-builds.s3.amazonaws.com/demo-files/main-qimg-0bbf31c18a22178cb7a8dd53640a3d05-lq.jpeg",
					url: "https://gradio-builds.s3.amazonaws.com/demo-files/main-qimg-0bbf31c18a22178cb7a8dd53640a3d05-lq.jpeg",
					orig_name: "main-qimg-0bbf31c18a22178cb7a8dd53640a3d05-lq.jpeg"
				}
			},
			{
				image: {
					path: "https://gradio-builds.s3.amazonaws.com/demo-files/TheCheethcat.jpg",
					url: "https://gradio-builds.s3.amazonaws.com/demo-files/TheCheethcat.jpg",
					orig_name: "TheCheethcat.jpg"
				}
			}
		]}
		{...args}
	/>
</Template>

<Story
	name="Gallery with label"
	args={{ label: "My Cheetah Gallery", show_label: true }}
/>
<Story
	name="Gallery without label"
	args={{ label: "My Cheetah Gallery", show_label: false }}
/>
<Story
	name="Gallery with rows=3 and columns=3"
	args={{
		label: "My Cheetah Gallery",
		show_label: true,
		rows: 3,
		columns: 3
	}}
/>
<Story
	name="Gallery with columns=4"
	args={{
		label: "My Cheetah Gallery",
		show_label: true,
		columns: 4
	}}
/>
<Story
	name="Gallery with height=600"
	args={{
		label: "My Cheetah Gallery",
		height: 600
	}}
/>
<Story
	name="Gallery with allow_preview=false"
	args={{
		label: "My Cheetah Gallery",
		show_label: true,
		allow_preview: false
	}}
/>
<Story
	name="Gallery with preview"
	args={{
		label: "My Cheetah Gallery",
		show_label: true,
		preview: true
	}}
/>
<Story
	name="Gallery with object_fit=scale-down"
	args={{
		label: "My Cheetah Gallery",
		show_label: true,
		object_fit: "scale-down"
	}}
/>
<Story
	name="Gallery with object_fit=contain"
	args={{
		label: "My Cheetah Gallery",
		show_label: true,
		object_fit: "contain"
	}}
/>
<Story
	name="Gallery with object_fit=cover"
	args={{
		label: "My Cheetah Gallery",
		show_label: true,
		object_fit: "cover"
	}}
/>
<Story
	name="Gallery with object_fit=none"
	args={{
		label: "My Cheetah Gallery",
		show_label: true,
		object_fit: "none"
	}}
/>
<Story
	name="Gallery with object_fit=fill"
	args={{
		label: "My Cheetah Gallery",
		show_label: true,
		object_fit: "fill"
	}}
/>
<Story
	name="Gallery with share button"
	args={{
		label: "My Cheetah Gallery",
		show_label: true,
		show_share_button: true
	}}
/>

<Story
	name="Gallery with overflow of images"
	args={{
		label: "My Cheetah Gallery",
		show_label: true,
		rows: 2,
		columns: 2,
		height: 400
	}}
/>

<Story
	name="Gallery with download button"
	args={{
		label: "My Cheetah Gallery",
		rows: 2,
		height: 400,
		show_download_button: true
	}}
/>