@datocms/svelte 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +51 -0
- package/components/Head/Head.svelte +14 -0
- package/components/Head/Head.svelte.d.ts +61 -0
- package/components/Head/README.md +68 -0
- package/components/Head/__tests__/Head.test.d.ts +1 -0
- package/components/Head/__tests__/Head.test.js +11 -0
- package/components/Head/__tests__/__fixtures__/head.d.ts +2 -0
- package/components/Head/__tests__/__fixtures__/head.js +280 -0
- package/components/Head/__tests__/__snapshots__/Head.test.ts.snap +221 -0
- package/components/Image/Image.svelte +172 -0
- package/components/Image/Image.svelte.d.ts +83 -0
- package/components/Image/Placeholder.svelte +31 -0
- package/components/Image/Placeholder.svelte.d.ts +22 -0
- package/components/Image/README.md +167 -0
- package/components/Image/Sizer.svelte +17 -0
- package/components/Image/Sizer.svelte.d.ts +19 -0
- package/components/Image/Source.svelte +6 -0
- package/components/Image/Source.svelte.d.ts +18 -0
- package/components/Image/__tests__/Image.svelte.test.d.ts +1 -0
- package/components/Image/__tests__/Image.svelte.test.js +44 -0
- package/components/Image/__tests__/__fixtures__/image.d.ts +40 -0
- package/components/Image/__tests__/__fixtures__/image.js +40 -0
- package/components/Image/__tests__/__snapshots__/Image.svelte.test.ts.snap +927 -0
- package/components/StructuredText/Node.svelte +112 -0
- package/components/StructuredText/Node.svelte.d.ts +22 -0
- package/components/StructuredText/README.md +201 -0
- package/components/StructuredText/StructuredText.svelte +15 -0
- package/components/StructuredText/StructuredText.svelte.d.ts +19 -0
- package/components/StructuredText/__tests__/StructuredText.svelte.test.d.ts +1 -0
- package/components/StructuredText/__tests__/StructuredText.svelte.test.js +163 -0
- package/components/StructuredText/__tests__/__fixtures__/Block.svelte +11 -0
- package/components/StructuredText/__tests__/__fixtures__/Block.svelte.d.ts +19 -0
- package/components/StructuredText/__tests__/__fixtures__/CustomSpan.svelte +49 -0
- package/components/StructuredText/__tests__/__fixtures__/CustomSpan.svelte.d.ts +19 -0
- package/components/StructuredText/__tests__/__fixtures__/IncreasedLevelHeading.svelte +8 -0
- package/components/StructuredText/__tests__/__fixtures__/IncreasedLevelHeading.svelte.d.ts +19 -0
- package/components/StructuredText/__tests__/__fixtures__/InlineItem.svelte +8 -0
- package/components/StructuredText/__tests__/__fixtures__/InlineItem.svelte.d.ts +19 -0
- package/components/StructuredText/__tests__/__fixtures__/ItemLink.svelte +15 -0
- package/components/StructuredText/__tests__/__fixtures__/ItemLink.svelte.d.ts +21 -0
- package/components/StructuredText/__tests__/__fixtures__/structuredText.d.ts +6 -0
- package/components/StructuredText/__tests__/__fixtures__/structuredText.js +537 -0
- package/components/StructuredText/__tests__/__fixtures__/types.d.ts +27 -0
- package/components/StructuredText/__tests__/__fixtures__/types.js +1 -0
- package/components/StructuredText/__tests__/__snapshots__/StructuredText.svelte.test.ts.snap +463 -0
- package/components/StructuredText/nodes/Blockquote.svelte +5 -0
- package/components/StructuredText/nodes/Blockquote.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/Code.svelte +6 -0
- package/components/StructuredText/nodes/Code.svelte.d.ts +17 -0
- package/components/StructuredText/nodes/Heading.svelte +8 -0
- package/components/StructuredText/nodes/Heading.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/Link.svelte +6 -0
- package/components/StructuredText/nodes/Link.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/List.svelte +10 -0
- package/components/StructuredText/nodes/List.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/ListItem.svelte +5 -0
- package/components/StructuredText/nodes/ListItem.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/Paragraph.svelte +5 -0
- package/components/StructuredText/nodes/Paragraph.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/Root.svelte +5 -0
- package/components/StructuredText/nodes/Root.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/Span.svelte +49 -0
- package/components/StructuredText/nodes/Span.svelte.d.ts +19 -0
- package/components/StructuredText/nodes/ThematicBreak.svelte +5 -0
- package/components/StructuredText/nodes/ThematicBreak.svelte.d.ts +17 -0
- package/components/StructuredText/utils/Lines.svelte +11 -0
- package/components/StructuredText/utils/Lines.svelte.d.ts +16 -0
- package/index.d.ts +9 -0
- package/index.js +3 -0
- package/package.json +61 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
// Vitest Snapshot v1
|
|
2
|
+
|
|
3
|
+
exports[`Head > renders meta tags 1`] = `
|
|
4
|
+
<head>
|
|
5
|
+
<title>
|
|
6
|
+
Remix CMS - The easiest way to manage content with Remix
|
|
7
|
+
</title>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
<meta
|
|
11
|
+
content="Remix CMS - The easiest way to manage content with Remix"
|
|
12
|
+
property="og:title"
|
|
13
|
+
/>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
<meta
|
|
17
|
+
content="Remix CMS - The easiest way to manage content with Remix"
|
|
18
|
+
name="twitter:title"
|
|
19
|
+
/>
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<meta
|
|
23
|
+
content="Remix makes building scalable and fast React apps simple, pair it with a CMS that shares the same intuitiveness. Start a new Remix + Dato project now."
|
|
24
|
+
name="description"
|
|
25
|
+
/>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
<meta
|
|
29
|
+
content="Remix makes building scalable and fast React apps simple, pair it with a CMS that shares the same intuitiveness. Start a new Remix + Dato project now."
|
|
30
|
+
property="og:description"
|
|
31
|
+
/>
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
<meta
|
|
35
|
+
content="Remix makes building scalable and fast React apps simple, pair it with a CMS that shares the same intuitiveness. Start a new Remix + Dato project now."
|
|
36
|
+
name="twitter:description"
|
|
37
|
+
/>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<meta
|
|
41
|
+
content="https://www.datocms-assets.com/205/1642515293-full-logo.svg?fit=max&fm=jpg&w=1000"
|
|
42
|
+
property="og:image"
|
|
43
|
+
/>
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
<meta
|
|
47
|
+
content="746"
|
|
48
|
+
property="og:image:width"
|
|
49
|
+
/>
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
<meta
|
|
53
|
+
content="186"
|
|
54
|
+
property="og:image:height"
|
|
55
|
+
/>
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
<meta
|
|
59
|
+
content="https://www.datocms-assets.com/205/1642515293-full-logo.svg?fit=max&fm=jpg&w=1000"
|
|
60
|
+
name="twitter:image"
|
|
61
|
+
/>
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
<meta
|
|
65
|
+
content="en"
|
|
66
|
+
property="og:locale"
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
<meta
|
|
71
|
+
content="article"
|
|
72
|
+
property="og:type"
|
|
73
|
+
/>
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
<meta
|
|
77
|
+
content="DatoCMS"
|
|
78
|
+
property="og:site_name"
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
<meta
|
|
83
|
+
content="2022-01-18T14:02:47Z"
|
|
84
|
+
property="article:modified_time"
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
<meta
|
|
89
|
+
content="summary_large_image"
|
|
90
|
+
name="twitter:card"
|
|
91
|
+
/>
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
<meta
|
|
95
|
+
content="@datocms"
|
|
96
|
+
name="twitter:site"
|
|
97
|
+
/>
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
<link
|
|
101
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=16&w=16"
|
|
102
|
+
rel="icon"
|
|
103
|
+
sizes="16x16"
|
|
104
|
+
type="image/png"
|
|
105
|
+
/>
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
<link
|
|
109
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=32&w=32"
|
|
110
|
+
rel="icon"
|
|
111
|
+
sizes="32x32"
|
|
112
|
+
type="image/png"
|
|
113
|
+
/>
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
<link
|
|
117
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=96&w=96"
|
|
118
|
+
rel="icon"
|
|
119
|
+
sizes="96x96"
|
|
120
|
+
type="image/png"
|
|
121
|
+
/>
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
<link
|
|
125
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=192&w=192"
|
|
126
|
+
rel="icon"
|
|
127
|
+
sizes="192x192"
|
|
128
|
+
type="image/png"
|
|
129
|
+
/>
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
<link
|
|
133
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=57&w=57"
|
|
134
|
+
rel="apple-touch-icon"
|
|
135
|
+
sizes="57x57"
|
|
136
|
+
/>
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
<link
|
|
140
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=60&w=60"
|
|
141
|
+
rel="apple-touch-icon"
|
|
142
|
+
sizes="60x60"
|
|
143
|
+
/>
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
<link
|
|
147
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=72&w=72"
|
|
148
|
+
rel="apple-touch-icon"
|
|
149
|
+
sizes="72x72"
|
|
150
|
+
/>
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
<link
|
|
154
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=76&w=76"
|
|
155
|
+
rel="apple-touch-icon"
|
|
156
|
+
sizes="76x76"
|
|
157
|
+
/>
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
<link
|
|
161
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=114&w=114"
|
|
162
|
+
rel="apple-touch-icon"
|
|
163
|
+
sizes="114x114"
|
|
164
|
+
/>
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
<link
|
|
168
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=120&w=120"
|
|
169
|
+
rel="apple-touch-icon"
|
|
170
|
+
sizes="120x120"
|
|
171
|
+
/>
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
<link
|
|
175
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=144&w=144"
|
|
176
|
+
rel="apple-touch-icon"
|
|
177
|
+
sizes="144x144"
|
|
178
|
+
/>
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
<link
|
|
182
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=152&w=152"
|
|
183
|
+
rel="apple-touch-icon"
|
|
184
|
+
sizes="152x152"
|
|
185
|
+
/>
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
<link
|
|
189
|
+
href="https://www.datocms-assets.com/205/1525789775-dato.png?h=180&w=180"
|
|
190
|
+
rel="apple-touch-icon"
|
|
191
|
+
sizes="180x180"
|
|
192
|
+
/>
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
<meta
|
|
196
|
+
content="https://www.datocms-assets.com/205/1525789775-dato.png?h=70&w=70"
|
|
197
|
+
name="msapplication-square70x70logo"
|
|
198
|
+
/>
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
<meta
|
|
202
|
+
content="https://www.datocms-assets.com/205/1525789775-dato.png?h=150&w=150"
|
|
203
|
+
name="msapplication-square150x150logo"
|
|
204
|
+
/>
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
<meta
|
|
208
|
+
content="https://www.datocms-assets.com/205/1525789775-dato.png?h=310&w=310"
|
|
209
|
+
name="msapplication-square310x310logo"
|
|
210
|
+
/>
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
<meta
|
|
214
|
+
content="https://www.datocms-assets.com/205/1525789775-dato.png?h=150&w=310"
|
|
215
|
+
name="msapplication-square310x150logo"
|
|
216
|
+
/>
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
</head>
|
|
221
|
+
`;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<script context="module">import IntersectionObserver from "svelte-intersection-observer";
|
|
2
|
+
const isWindowDefined = typeof window !== "undefined";
|
|
3
|
+
const noTypeCheck = (x) => x;
|
|
4
|
+
const imageAddStrategy = ({ lazyLoad, intersecting, loaded }) => {
|
|
5
|
+
const isIntersectionObserverAvailable = isWindowDefined ? !!window.IntersectionObserver : false;
|
|
6
|
+
if (!lazyLoad) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
if (!isWindowDefined) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (isIntersectionObserverAvailable) {
|
|
13
|
+
return intersecting || loaded;
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
};
|
|
17
|
+
const imageShowStrategy = ({ lazyLoad, loaded }) => {
|
|
18
|
+
const isIntersectionObserverAvailable = isWindowDefined ? !!window.IntersectionObserver : false;
|
|
19
|
+
if (!lazyLoad) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (!isWindowDefined) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if (isIntersectionObserverAvailable) {
|
|
26
|
+
return loaded;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
};
|
|
30
|
+
const bogusBaseUrl = "https://example.com/";
|
|
31
|
+
const buildSrcSet = (src, width, candidateMultipliers) => {
|
|
32
|
+
if (!(src && width)) {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
return candidateMultipliers.map((multiplier) => {
|
|
36
|
+
const url = new URL(src, bogusBaseUrl);
|
|
37
|
+
if (multiplier !== 1) {
|
|
38
|
+
url.searchParams.set("dpr", `${multiplier}`);
|
|
39
|
+
const maxH = url.searchParams.get("max-h");
|
|
40
|
+
const maxW = url.searchParams.get("max-w");
|
|
41
|
+
if (maxH) {
|
|
42
|
+
url.searchParams.set("max-h", `${Math.floor(parseInt(maxH) * multiplier)}`);
|
|
43
|
+
}
|
|
44
|
+
if (maxW) {
|
|
45
|
+
url.searchParams.set("max-w", `${Math.floor(parseInt(maxW) * multiplier)}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const finalWidth = Math.floor(width * multiplier);
|
|
49
|
+
if (finalWidth < 50) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return `${url.toString().replace(bogusBaseUrl, "/")} ${finalWidth}w`;
|
|
53
|
+
}).filter(Boolean).join(",");
|
|
54
|
+
};
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<script>import { createEventDispatcher } from "svelte";
|
|
58
|
+
import Sizer from "./Sizer.svelte";
|
|
59
|
+
import Placeholder from "./Placeholder.svelte";
|
|
60
|
+
import Source from "./Source.svelte";
|
|
61
|
+
const dispatch = createEventDispatcher();
|
|
62
|
+
let element;
|
|
63
|
+
let intersecting = false;
|
|
64
|
+
let loaded = false;
|
|
65
|
+
export let alt = null;
|
|
66
|
+
export let data;
|
|
67
|
+
let klass = null;
|
|
68
|
+
export { klass as class };
|
|
69
|
+
export let pictureClass = null;
|
|
70
|
+
export let fadeInDuration = 500;
|
|
71
|
+
export let intersectionThreshold = 0;
|
|
72
|
+
export let intersectionMargin = "0px";
|
|
73
|
+
let rawLazyLoad = true;
|
|
74
|
+
export { rawLazyLoad as lazyLoad };
|
|
75
|
+
export let style = {};
|
|
76
|
+
export let pictureStyle = null;
|
|
77
|
+
export let layout = "intrinsic";
|
|
78
|
+
export let objectFit = void 0;
|
|
79
|
+
export let objectPosition = void 0;
|
|
80
|
+
export let usePlaceholder = true;
|
|
81
|
+
export let sizes = null;
|
|
82
|
+
export let priority = false;
|
|
83
|
+
export let srcSetCandidates = [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4];
|
|
84
|
+
$:
|
|
85
|
+
({ width, height, aspectRatio } = data);
|
|
86
|
+
$:
|
|
87
|
+
lazyLoad = priority ? false : rawLazyLoad;
|
|
88
|
+
$:
|
|
89
|
+
addImage = imageAddStrategy({
|
|
90
|
+
lazyLoad,
|
|
91
|
+
intersecting,
|
|
92
|
+
loaded
|
|
93
|
+
});
|
|
94
|
+
$:
|
|
95
|
+
showImage = imageShowStrategy({
|
|
96
|
+
lazyLoad,
|
|
97
|
+
intersecting,
|
|
98
|
+
loaded
|
|
99
|
+
});
|
|
100
|
+
let transition = fadeInDuration > 0 ? `opacity ${fadeInDuration}ms` : void 0;
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<IntersectionObserver
|
|
104
|
+
{element}
|
|
105
|
+
bind:intersecting
|
|
106
|
+
threshold={intersectionThreshold}
|
|
107
|
+
rootMargin={intersectionMargin}
|
|
108
|
+
>
|
|
109
|
+
<div
|
|
110
|
+
bind:this={element}
|
|
111
|
+
class={klass}
|
|
112
|
+
style:overflow="hidden"
|
|
113
|
+
style:position={style.position ?? layout === 'fill' ? 'absolute' : 'relative'}
|
|
114
|
+
style:width={style.width ?? layout === 'fixed' ? data.width : '100%'}
|
|
115
|
+
style:maxWidth={style.maxWidth ?? layout === 'intrinsic' ? data.width : null}
|
|
116
|
+
style:height={style.height ?? layout === 'fill' ? '100%' : null}
|
|
117
|
+
data-testid="image"
|
|
118
|
+
>
|
|
119
|
+
{#if layout !== 'fill' && width}
|
|
120
|
+
<Sizer {width} {height} {aspectRatio} />
|
|
121
|
+
{/if}
|
|
122
|
+
|
|
123
|
+
{#if usePlaceholder && (data.bgColor || data.base64)}
|
|
124
|
+
<Placeholder
|
|
125
|
+
base64={data.base64}
|
|
126
|
+
backgroundColor={data.bgColor}
|
|
127
|
+
{objectFit}
|
|
128
|
+
{objectPosition}
|
|
129
|
+
{showImage}
|
|
130
|
+
{fadeInDuration}
|
|
131
|
+
/>
|
|
132
|
+
{/if}
|
|
133
|
+
|
|
134
|
+
{#if addImage}
|
|
135
|
+
<picture style={pictureStyle} data-testid="picture">
|
|
136
|
+
{#if data.webpSrcSet}
|
|
137
|
+
<Source srcset={data.webpSrcSet} sizes={sizes ?? data.sizes ?? null} type="image/webp" />
|
|
138
|
+
{/if}
|
|
139
|
+
<Source
|
|
140
|
+
srcset={data.srcSet ?? buildSrcSet(data.src, data.width, srcSetCandidates) ?? null}
|
|
141
|
+
sizes={sizes ?? data.sizes ?? null}
|
|
142
|
+
/>
|
|
143
|
+
{#if data.src}
|
|
144
|
+
<img
|
|
145
|
+
{...noTypeCheck({
|
|
146
|
+
// See: https://github.com/sveltejs/language-tools/issues/1026#issuecomment-1002839154
|
|
147
|
+
fetchpriority: priority ? 'high' : undefined
|
|
148
|
+
})}
|
|
149
|
+
src={data.src}
|
|
150
|
+
alt={alt ?? data.alt ?? ''}
|
|
151
|
+
title={data.title ?? null}
|
|
152
|
+
on:load={() => {
|
|
153
|
+
dispatch('load');
|
|
154
|
+
loaded = true;
|
|
155
|
+
}}
|
|
156
|
+
class={pictureClass}
|
|
157
|
+
style:opacity={showImage ? 1 : 0}
|
|
158
|
+
style:transition
|
|
159
|
+
style:position="absolute"
|
|
160
|
+
style:left="0"
|
|
161
|
+
style:top="0"
|
|
162
|
+
style:width="100%"
|
|
163
|
+
style:height="100%"
|
|
164
|
+
style:objectFit
|
|
165
|
+
style:objectPosition
|
|
166
|
+
data-testid="img"
|
|
167
|
+
/>
|
|
168
|
+
{/if}
|
|
169
|
+
</picture>
|
|
170
|
+
{/if}
|
|
171
|
+
</div>
|
|
172
|
+
</IntersectionObserver>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
export type Maybe<T> = T | null;
|
|
3
|
+
export type ResponsiveImageType = {
|
|
4
|
+
/** A base64-encoded thumbnail to offer during image loading */
|
|
5
|
+
base64?: Maybe<string>;
|
|
6
|
+
/** The height of the image */
|
|
7
|
+
height?: Maybe<number>;
|
|
8
|
+
/** The width of the image */
|
|
9
|
+
width?: number;
|
|
10
|
+
/** The aspect ratio (width/height) of the image */
|
|
11
|
+
aspectRatio?: number;
|
|
12
|
+
/** The HTML5 `sizes` attribute for the image */
|
|
13
|
+
sizes?: Maybe<string>;
|
|
14
|
+
/** The fallback `src` attribute for the image */
|
|
15
|
+
src?: Maybe<string>;
|
|
16
|
+
/** The HTML5 `srcSet` attribute for the image */
|
|
17
|
+
srcSet?: Maybe<string>;
|
|
18
|
+
/** The HTML5 `srcSet` attribute for the image in WebP format, for browsers that support the format */
|
|
19
|
+
webpSrcSet?: Maybe<string>;
|
|
20
|
+
/** The background color for the image placeholder */
|
|
21
|
+
bgColor?: Maybe<string>;
|
|
22
|
+
/** Alternate text (`alt`) for the image */
|
|
23
|
+
alt?: Maybe<string>;
|
|
24
|
+
/** Title attribute (`title`) for the image */
|
|
25
|
+
title?: Maybe<string>;
|
|
26
|
+
};
|
|
27
|
+
import type * as CSS from 'csstype';
|
|
28
|
+
declare const __propDef: {
|
|
29
|
+
props: {
|
|
30
|
+
alt?: string | null | undefined;
|
|
31
|
+
/** The actual response you get from a DatoCMS `responsiveImage` GraphQL query */ data: ResponsiveImageType;
|
|
32
|
+
/** Additional CSS className for root node */ class?: string | null | undefined;
|
|
33
|
+
/** Additional CSS class for the image inside the `<picture />` tag */ pictureClass?: string | null | undefined;
|
|
34
|
+
/** Duration (in ms) of the fade-in transition effect upoad image loading */ fadeInDuration?: number | undefined;
|
|
35
|
+
/** Indicate at what percentage of the placeholder visibility the loading of the image should be triggered. A value of 0 means that as soon as even one pixel is visible, the callback will be run. A value of 1.0 means that the threshold isn't considered passed until every pixel is visible */ intersectionThreshold?: number | undefined;
|
|
36
|
+
/** Margin around the placeholder. Can have values similar to the CSS margin property (top, right, bottom, left). The values can be percentages. This set of values serves to grow or shrink each side of the placeholder element's bounding box before computing intersections */ intersectionMargin?: string | undefined;
|
|
37
|
+
/** Whether enable lazy loading or not */ lazyLoad?: boolean | undefined;
|
|
38
|
+
/** Additional CSS rules to add to the root node */ style?: Record<string, string> | undefined;
|
|
39
|
+
/** Additional CSS rules to add to the image inside the `<picture />` tag */ pictureStyle?: string | null | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* The layout behavior of the image as the viewport changes size
|
|
42
|
+
*
|
|
43
|
+
* Possible values:
|
|
44
|
+
*
|
|
45
|
+
* * `intrinsic` (default): the image will scale the dimensions down for smaller viewports, but maintain the original dimensions for larger viewports
|
|
46
|
+
* * `fixed`: the image dimensions will not change as the viewport changes (no responsiveness) similar to the native img element
|
|
47
|
+
* * `responsive`: the image will scale the dimensions down for smaller viewports and scale up for larger viewports
|
|
48
|
+
* * `fill`: image will stretch both width and height to the dimensions of the parent element, provided the parent element is `relative`
|
|
49
|
+
**/ layout?: "fill" | "intrinsic" | "fixed" | "responsive" | undefined;
|
|
50
|
+
/** Defines how the image will fit into its parent container when using layout="fill" */ objectFit?: CSS.Properties['objectFit'];
|
|
51
|
+
/** Defines how the image is positioned within its parent element when using layout="fill". */ objectPosition?: CSS.Properties['objectPosition'];
|
|
52
|
+
/** Whether the component should use a blurred image placeholder */ usePlaceholder?: boolean | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* The HTML5 `sizes` attribute for the image
|
|
55
|
+
*
|
|
56
|
+
* Learn more about srcset and sizes:
|
|
57
|
+
* -> https://web.dev/learn/design/responsive-images/#sizes
|
|
58
|
+
* -> https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-sizes
|
|
59
|
+
**/ sizes?: string | null | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* When true, the image will be considered high priority. Lazy loading is automatically disabled, and fetchpriority="high" is added to the image.
|
|
62
|
+
* You should use the priority property on any image detected as the Largest Contentful Paint (LCP) element. It may be appropriate to have multiple priority images, as different images may be the LCP element for different viewport sizes.
|
|
63
|
+
* Should only be used when the image is visible above the fold.
|
|
64
|
+
**/ priority?: boolean | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* If `data` does not contain `srcSet`, the candidates for the `srcset` of the image will be auto-generated based on these width multipliers
|
|
67
|
+
*
|
|
68
|
+
* Default candidate multipliers are [0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4]
|
|
69
|
+
**/ srcSetCandidates?: number[] | undefined;
|
|
70
|
+
};
|
|
71
|
+
events: {
|
|
72
|
+
load: CustomEvent<any>;
|
|
73
|
+
} & {
|
|
74
|
+
[evt: string]: CustomEvent<any>;
|
|
75
|
+
};
|
|
76
|
+
slots: {};
|
|
77
|
+
};
|
|
78
|
+
export type ImageProps = typeof __propDef.props;
|
|
79
|
+
export type ImageEvents = typeof __propDef.events;
|
|
80
|
+
export type ImageSlots = typeof __propDef.slots;
|
|
81
|
+
export default class Image extends SvelteComponentTyped<ImageProps, ImageEvents, ImageSlots> {
|
|
82
|
+
}
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script>export let base64 = null;
|
|
2
|
+
export let backgroundColor = null;
|
|
3
|
+
export let objectFit;
|
|
4
|
+
export let objectPosition;
|
|
5
|
+
export let showImage;
|
|
6
|
+
export let fadeInDuration = 0;
|
|
7
|
+
let transition = fadeInDuration > 0 ? `opacity ${fadeInDuration}ms` : void 0;
|
|
8
|
+
let opacity = showImage ? 0 : 1;
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<img
|
|
12
|
+
class="placeholder"
|
|
13
|
+
role="presentation"
|
|
14
|
+
aria-hidden="true"
|
|
15
|
+
alt=""
|
|
16
|
+
src={base64}
|
|
17
|
+
style:backgroundColor
|
|
18
|
+
style:objectFit
|
|
19
|
+
style:objectPosition
|
|
20
|
+
style:transition
|
|
21
|
+
style:opacity
|
|
22
|
+
/>
|
|
23
|
+
|
|
24
|
+
<style>
|
|
25
|
+
.placeholder {
|
|
26
|
+
position: absolute;
|
|
27
|
+
width: 100%;
|
|
28
|
+
top: 0;
|
|
29
|
+
scale: 110%;
|
|
30
|
+
}
|
|
31
|
+
</style>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type * as CSS from 'csstype';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
base64?: string | null | undefined;
|
|
6
|
+
backgroundColor?: string | null | undefined;
|
|
7
|
+
objectFit: CSS.Properties['objectFit'];
|
|
8
|
+
objectPosition: CSS.Properties['objectPosition'];
|
|
9
|
+
showImage: boolean;
|
|
10
|
+
fadeInDuration?: number | undefined;
|
|
11
|
+
};
|
|
12
|
+
events: {
|
|
13
|
+
[evt: string]: CustomEvent<any>;
|
|
14
|
+
};
|
|
15
|
+
slots: {};
|
|
16
|
+
};
|
|
17
|
+
export type PlaceholderProps = typeof __propDef.props;
|
|
18
|
+
export type PlaceholderEvents = typeof __propDef.events;
|
|
19
|
+
export type PlaceholderSlots = typeof __propDef.slots;
|
|
20
|
+
export default class Placeholder extends SvelteComponentTyped<PlaceholderProps, PlaceholderEvents, PlaceholderSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|