-
Notifications
You must be signed in to change notification settings - Fork 165
/
Copy pathattributes.stories.js
123 lines (115 loc) · 2.73 KB
/
attributes.stories.js
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
import { storiesOf } from '@storybook/html'
storiesOf('attributes', module)
.add(
'data-zoom-src',
() => `
<img
src="image-1.thumbnail.jpg"
data-zoom-src="image-1.jpg"
>
<script>
const zoom = mediumZoom('img');
</script>
`,
{
notes: {
markdown: `Zoom on an image having a \`data-zoom-src\` attribute.`,
},
}
)
.add(
'srcset',
() => `
<img
srcset="
image-1x300.jpg 300w,
image-1x600.jpg 600w,
image-1x800.jpg 800w,
image-1x1000.jpg 1000w,
image-1x1200.jpg 1200w
"
>
<script>
const zoom = mediumZoom('img');
</script>
`,
{
notes: {
markdown: `
Zoom on an image having \`srcset\` attributes.
`,
},
}
)
.add(
'srcset and data-zoom-src',
() => `
<img
src="image-1x300.jpg"
srcset="
image-1x300.jpg 300w,
image-1x600.jpg 600w,
"
sizes="(max-width: 400px) 100vw, 400px"
data-zoom-src="image-1.jpg"
>
<script>
const zoom = mediumZoom('img');
</script>
`,
{
notes: `Zoom with srcset and data-zoom-src defined (zoom-target wins).`,
}
)
.add(
'SVG',
() => `
<img src="crab.svg">
<script>
const zoom = mediumZoom('img');
</script>
`,
{
notes: `
Zoom on a SVG.
The image fills the entire container.
<em>Icon made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></em>
`,
}
)
.add(
'<picture> tag',
() => `
<picture>
<source type="image/jpeg" srcset="image-1x300.jpg 300w, image-1x600.jpg 600w"></source>
<img>
</picture>
<script>
const zoom = mediumZoom('img');
</script>
`,
{
notes: `
Zoom on an image inside a <picture> tag.
The cloned image mirrors the picture structure and resizes the same as a usual image tag.
`,
}
)
.add(
'<picture> tag and data-zoom-src',
() => `
<picture>
<source type="image/jpeg" srcset="image-1x300.jpg 300w, image-1x600.jpg 600w"></source>
<img data-zoom-src="image-1.jpg">
</picture>
<script>
const zoom = mediumZoom('img');
</script>
`,
{
notes: `
Zoom on an image inside a <picture> tag.
The cloned image mirrors the picture structure and resizes the same as a usual image tag, which then uses the data-zoom-src value once loaded.
`,
}
)