2023-07-07 06:31:17 +08:00
|
|
|
<script>
|
|
|
|
import { Meta, Template, Story } from "@storybook/addon-svelte-csf";
|
2023-08-04 06:01:18 +08:00
|
|
|
import Gallery from "./static/";
|
2023-07-07 06:31:17 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<Meta
|
|
|
|
title="Components/Gallery"
|
|
|
|
component={Gallery}
|
|
|
|
argTypes={{
|
|
|
|
label: {
|
|
|
|
control: "text",
|
|
|
|
description: "The gallery label",
|
|
|
|
name: "label",
|
2023-08-04 06:01:18 +08:00
|
|
|
value: "Gradio Button"
|
2023-07-07 06:31:17 +08:00
|
|
|
},
|
|
|
|
show_label: {
|
|
|
|
options: [true, false],
|
2023-07-07 23:51:18 +08:00
|
|
|
description: "Whether to show the label",
|
2023-07-07 06:31:17 +08:00
|
|
|
control: { type: "boolean" },
|
2023-08-04 06:01:18 +08:00
|
|
|
defaultValue: true
|
2023-07-07 06:31:17 +08:00
|
|
|
},
|
2023-10-03 11:11:09 +08:00
|
|
|
columns: {
|
2023-07-07 06:31:17 +08:00
|
|
|
options: [1, 2, 3, 4],
|
2023-09-14 02:59:39 +08:00
|
|
|
description: "The number of columns to show in grid",
|
2023-07-07 06:31:17 +08:00
|
|
|
control: { type: "select" },
|
2023-08-04 06:01:18 +08:00
|
|
|
defaultValue: 2
|
2023-07-07 06:31:17 +08:00
|
|
|
},
|
2023-10-03 11:11:09 +08:00
|
|
|
rows: {
|
2023-07-07 06:31:17 +08:00
|
|
|
options: [1, 2, 3, 4],
|
|
|
|
description: "The number of rows to show in grid",
|
|
|
|
control: { type: "select" },
|
2023-08-04 06:01:18 +08:00
|
|
|
defaultValue: 2
|
2023-07-07 06:31:17 +08:00
|
|
|
},
|
|
|
|
height: {
|
|
|
|
options: ["auto", 500, 600],
|
|
|
|
description: "The height of the grid",
|
|
|
|
control: { type: "select" },
|
2023-08-04 06:01:18 +08:00
|
|
|
defaultValue: "auto"
|
2023-07-07 06:31:17 +08:00
|
|
|
},
|
|
|
|
preview: {
|
|
|
|
options: [true, false],
|
|
|
|
description: "Whether to start the gallery in preview mode",
|
|
|
|
control: { type: "boolean" },
|
2023-08-04 06:01:18 +08:00
|
|
|
defaultValue: true
|
2023-07-07 06:31:17 +08:00
|
|
|
},
|
|
|
|
allow_preview: {
|
|
|
|
options: [true, false],
|
2023-07-07 23:51:18 +08:00
|
|
|
description: "Whether to allow a preview mode in the gallery",
|
2023-07-07 06:31:17 +08:00
|
|
|
control: { type: "boolean" },
|
2023-08-04 06:01:18 +08:00
|
|
|
defaultValue: true
|
2023-07-07 06:31:17 +08:00
|
|
|
},
|
|
|
|
object_fit: {
|
|
|
|
options: ["contain", "cover", "fill", "none", "scale-down"],
|
|
|
|
description: "How to display each indivial image in the grid",
|
|
|
|
control: { type: "select" },
|
2023-08-04 06:01:18 +08:00
|
|
|
defaultValue: "contain"
|
2023-07-07 06:31:17 +08:00
|
|
|
},
|
|
|
|
show_share_button: {
|
|
|
|
options: [true, false],
|
|
|
|
description: "Whether to show the share button in the gallery",
|
|
|
|
control: { type: "boolean" },
|
2023-08-04 06:01:18 +08:00
|
|
|
defaultValue: false
|
|
|
|
}
|
2023-07-07 06:31:17 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Template let:args>
|
|
|
|
<Gallery
|
|
|
|
value={[
|
|
|
|
[
|
|
|
|
"https://gradio-builds.s3.amazonaws.com/demo-files/cheetah_running.avif",
|
2023-08-04 06:01:18 +08:00
|
|
|
"A fast cheetah"
|
2023-07-07 06:31:17 +08:00
|
|
|
],
|
|
|
|
"https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg",
|
|
|
|
"https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-003.jpg",
|
|
|
|
"https://gradio-builds.s3.amazonaws.com/demo-files/cheetah3.webp",
|
|
|
|
"https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
|
|
|
|
"https://gradio-builds.s3.amazonaws.com/demo-files/main-qimg-0bbf31c18a22178cb7a8dd53640a3d05-lq.jpeg",
|
2023-08-04 06:01:18 +08:00
|
|
|
"https://gradio-builds.s3.amazonaws.com/demo-files/TheCheethcat.jpg"
|
2023-07-07 06:31:17 +08:00
|
|
|
]}
|
2023-07-25 22:02:44 +08:00
|
|
|
{...args}
|
2023-07-07 06:31:17 +08:00
|
|
|
/>
|
|
|
|
</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
|
2023-10-03 11:11:09 +08:00
|
|
|
name="Gallery with rows=3 and columns=3"
|
2023-07-07 06:31:17 +08:00
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
|
|
|
show_label: true,
|
2023-10-03 11:11:09 +08:00
|
|
|
rows: 3,
|
|
|
|
columns: 3
|
2023-07-07 06:31:17 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Story
|
2023-10-03 11:11:09 +08:00
|
|
|
name="Gallery with columns=4"
|
2023-07-07 06:31:17 +08:00
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
|
|
|
show_label: true,
|
2023-10-03 11:11:09 +08:00
|
|
|
columns: 4
|
2023-07-07 06:31:17 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Story
|
|
|
|
name="Gallery with height=600"
|
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
2023-08-04 06:01:18 +08:00
|
|
|
height: 600
|
2023-07-07 06:31:17 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Story
|
|
|
|
name="Gallery with allow_preview=false"
|
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
|
|
|
show_label: true,
|
2023-08-04 06:01:18 +08:00
|
|
|
allow_preview: false
|
2023-07-07 06:31:17 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Story
|
|
|
|
name="Gallery with preview"
|
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
|
|
|
show_label: true,
|
2023-08-04 06:01:18 +08:00
|
|
|
preview: true
|
2023-07-07 06:31:17 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Story
|
|
|
|
name="Gallery with object_fit=scale-down"
|
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
|
|
|
show_label: true,
|
2023-08-04 06:01:18 +08:00
|
|
|
object_fit: "scale-down"
|
2023-07-07 06:31:17 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Story
|
|
|
|
name="Gallery with object_fit=contain"
|
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
|
|
|
show_label: true,
|
2023-08-04 06:01:18 +08:00
|
|
|
object_fit: "contain"
|
2023-07-07 06:31:17 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Story
|
|
|
|
name="Gallery with object_fit=cover"
|
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
|
|
|
show_label: true,
|
2023-08-04 06:01:18 +08:00
|
|
|
object_fit: "cover"
|
2023-07-07 06:31:17 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Story
|
|
|
|
name="Gallery with object_fit=none"
|
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
|
|
|
show_label: true,
|
2023-08-04 06:01:18 +08:00
|
|
|
object_fit: "none"
|
2023-07-07 06:31:17 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Story
|
|
|
|
name="Gallery with object_fit=fill"
|
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
|
|
|
show_label: true,
|
2023-08-04 06:01:18 +08:00
|
|
|
object_fit: "fill"
|
2023-07-07 06:31:17 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Story
|
|
|
|
name="Gallery with share button"
|
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
|
|
|
show_label: true,
|
2023-08-04 06:01:18 +08:00
|
|
|
show_share_button: true
|
2023-07-25 22:02:44 +08:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Story
|
|
|
|
name="Gallery with overflow of images"
|
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
|
|
|
show_label: true,
|
2023-10-03 11:11:09 +08:00
|
|
|
rows: 2,
|
|
|
|
columns: 2,
|
2023-07-25 22:02:44 +08:00
|
|
|
height: 400,
|
|
|
|
value: [
|
|
|
|
"https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg",
|
|
|
|
"https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-003.jpg",
|
|
|
|
"https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
|
|
|
|
"https://gradio-builds.s3.amazonaws.com/demo-files/ghepardo-primo-piano.jpg",
|
2023-08-04 06:01:18 +08:00
|
|
|
"https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg"
|
|
|
|
]
|
2023-07-07 06:31:17 +08:00
|
|
|
}}
|
|
|
|
/>
|
2023-08-01 01:31:49 +08:00
|
|
|
|
|
|
|
<Story
|
|
|
|
name="Gallery with download button"
|
|
|
|
args={{
|
|
|
|
label: "My Cheetah Gallery",
|
2023-10-03 11:11:09 +08:00
|
|
|
rows: 2,
|
2023-08-01 01:31:49 +08:00
|
|
|
height: 400,
|
|
|
|
show_download_button: true,
|
2023-08-04 06:01:18 +08:00
|
|
|
value: ["https://gradio-builds.s3.amazonaws.com/demo-files/cheetah-002.jpg"]
|
2023-08-01 01:31:49 +08:00
|
|
|
}}
|
|
|
|
/>
|