1
1
<script lang =" ts" >
2
- import Picture from ' ./Picture .svelte'
2
+ import SveltePicture from ' ./SveltePicture .svelte'
3
3
import { len , lqipToBackground } from ' ./utils.js'
4
4
import type { HTMLImgAttributes } from ' svelte/elements'
5
- import type { Picture as PictureType } from ' vite-imagetools'
5
+ import type { Picture } from ' vite-imagetools'
6
6
7
7
interface $$Props extends Omit <HTMLImgAttributes , ' src' > {
8
8
/** imagetools import */
9
- src: PictureType
9
+ src: Picture
10
10
11
11
/** img tag `sizes` attr */
12
12
sizes? : string
@@ -35,8 +35,8 @@ export let loading: $$Props['loading'] = 'lazy'
35
35
export let decoding: $$Props [' decoding' ] = ' async'
36
36
export let ref: $$Props [' ref' ] = undefined
37
37
38
- let sources: PictureType [' sources' ] | undefined
39
- let img: (PictureType [' img' ] & { lqip? : string }) | undefined
38
+ let sources: Picture [' sources' ] | undefined
39
+ let img: (Picture [' img' ] & { lqip? : string }) | undefined
40
40
let background: string | undefined
41
41
42
42
$ : sources = src ?.sources
@@ -47,7 +47,7 @@ $: if (len(img)) {
47
47
</script >
48
48
49
49
{#if len (img )}
50
- <Picture {sources } {sizes }>
50
+ <SveltePicture {sources } {sizes }>
51
51
<!-- svelte-ignore a11y-missing-attribute a11y-no-noninteractive-element-interactions -->
52
52
<img
53
53
{loading }
@@ -61,24 +61,28 @@ $: if (len(img)) {
61
61
{...$$restProps }
62
62
src ={img ?.src }
63
63
/>
64
- </Picture >
64
+ </SveltePicture >
65
65
{/if }
66
66
67
67
<!--
68
- @component
69
- High-performance responsive/progressive images for SvelteKit
70
-
71
- ## Usage
72
- ```tsx
73
- <Img class="cool kitty" src="{cat}" alt="Very meow" />
74
- ```
75
-
76
- ## Props
77
- - `src: PictureType` - imagetools import
78
- - `sizes?: string` - img tag `sizes` attr
79
- - `width?: number` - img `width` override
80
- - `height?: number` - img `height` override
81
- - `loading?: 'lazy' | 'eager'` - img tag `loading` attr
82
- - `decoding?: 'async' | 'auto' | 'sync'` - img tag `decoding` attr
83
- - `ref?: HTMLImageElement` - bindable reference to `<img>` element
84
- -->
68
+ @component
69
+ High-performance responsive/progressive images for SvelteKit
70
+
71
+ ## Usage
72
+ ```html
73
+ <script>
74
+ import Img from '@zerodevx/svelte-img'
75
+ import cat from '$lib/assets/cat.jpg?as=run'
76
+ </script>
77
+ <Img class="cool kitty" src="{cat}" alt="Very meow" />
78
+ ```
79
+
80
+ ## Props
81
+ - `src: Picture` - imagetools import
82
+ - `sizes?: string` - img tag `sizes` attr
83
+ - `width?: number` - img `width` override
84
+ - `height?: number` - img `height` override
85
+ - `loading?: 'lazy' | 'eager'` - img tag `loading` attr
86
+ - `decoding?: 'async' | 'auto' | 'sync'` - img tag `decoding` attr
87
+ - `ref?: HTMLImageElement` - bindable reference to `<img>` element
88
+ -->
0 commit comments