-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathwith-caption.stories.tsx
120 lines (117 loc) Β· 4.01 KB
/
with-caption.stories.tsx
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
import React from 'react'
import 'photoswipe/dist/photoswipe.css'
import { Meta, StoryObj } from '@storybook/react'
import { Gallery, Item } from '..'
const storyMeta: Meta = {
title: 'Demo/Caption',
}
export const Caption: StoryObj = {
render: () => {
const smallItemStyles: React.CSSProperties = {
cursor: 'pointer',
objectFit: 'cover',
width: '100%',
maxHeight: '100%',
}
return (
<Gallery withCaption>
<div
style={{
display: 'grid',
gridTemplateColumns: '240px 171px 171px',
gridTemplateRows: '114px 114px',
gridGap: 12,
}}
>
<Item<HTMLImageElement>
original="https://farm4.staticflickr.com/3894/15008518202_c265dfa55f_h.jpg"
thumbnail="https://farm4.staticflickr.com/3894/15008518202_b016d7d289_m.jpg"
width="1600"
height="1600"
alt="Photo of seashore by Folkert Gorter"
caption="Author: Folkert Gorter"
>
{({ ref, open }) => (
<img
style={{ cursor: 'pointer' }}
src="https://farm4.staticflickr.com/3894/15008518202_b016d7d289_m.jpg"
ref={ref}
onClick={open}
/>
)}
</Item>
<Item<HTMLImageElement>
original="https://farm6.staticflickr.com/5591/15008867125_b61960af01_h.jpg"
thumbnail="https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_m.jpg"
width="1600"
height="1068"
alt="Photo of mountain lake by Samuel Rohl"
// No `caption` there
>
{({ ref, open }) => (
<img
style={smallItemStyles}
src="https://farm6.staticflickr.com/5591/15008867125_68a8ed88cc_m.jpg"
ref={ref}
onClick={open}
/>
)}
</Item>
<Item<HTMLImageElement>
original="https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_b.jpg"
thumbnail="https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_m.jpg"
width="1600"
height="1066"
alt="Photo of fog in the village by Ales Krivec"
// You can use html tags
caption="<h1>Author: Ales Krivec</h1>"
>
{({ ref, open }) => (
<img
style={smallItemStyles}
src="https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_m.jpg"
ref={ref}
onClick={open}
/>
)}
</Item>
<Item<HTMLImageElement>
original="https://farm6.staticflickr.com/5584/14985868676_b51baa4071_h.jpg"
thumbnail="https://farm6.staticflickr.com/5584/14985868676_4b802b932a_m.jpg"
width="1600"
height="1066"
alt="Photo of river sunset by Michael Hull"
caption="Author: Michael Hull"
>
{({ ref, open }) => (
<img
style={{ ...smallItemStyles, gridColumnStart: 2 }}
src="https://farm6.staticflickr.com/5584/14985868676_4b802b932a_m.jpg"
ref={ref}
onClick={open}
/>
)}
</Item>
<Item<HTMLImageElement>
original="https://farm4.staticflickr.com/3920/15008465772_d50c8f0531_h.jpg"
thumbnail="https://farm4.staticflickr.com/3920/15008465772_383e697089_m.jpg"
width="1600"
height="1066"
alt="Photo of bear by Thomas Lefebvre"
caption="Author: Thomas Lefebvre"
>
{({ ref, open }) => (
<img
style={smallItemStyles}
src="https://farm4.staticflickr.com/3920/15008465772_383e697089_m.jpg"
ref={ref}
onClick={open}
/>
)}
</Item>
</div>
</Gallery>
)
},
}
export default storyMeta