-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathplugins.stories.tsx
130 lines (124 loc) Β· 4.27 KB
/
plugins.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
121
122
123
124
125
126
127
128
129
130
import React from 'react'
import 'photoswipe/dist/photoswipe.css'
import { Meta, StoryObj } from '@storybook/react'
import 'photoswipe-dynamic-caption-plugin/photoswipe-dynamic-caption-plugin.css'
// @ts-expect-error
import PhotoSwipeDynamicCaption from 'photoswipe-dynamic-caption-plugin'
import { Gallery, Item } from '..'
const storyMeta: Meta = {
title: 'Demo/Plugins',
}
export const Plugins: StoryObj = {
render: () => {
const smallItemStyles: React.CSSProperties = {
cursor: 'pointer',
objectFit: 'cover',
width: '100%',
maxHeight: '100%',
}
return (
<Gallery
plugins={(pswpLightbox) => {
// register plugin
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const captionPlugin = new PhotoSwipeDynamicCaption(pswpLightbox, {
captionContent: (slide: any) => slide.data.alt,
})
// register another plugin
// ...
}}
>
<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"
>
{({ 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"
>
{({ 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"
>
{({ 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"
>
{({ 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"
>
{({ 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