Skip to content

Commit c90e9cc

Browse files
committed
Fixup types and intellisense
1 parent 4d65c51 commit c90e9cc

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

src/lib/SvelteImg.svelte

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { Picture as PictureType } from 'vite-imagetools'
66
77
interface $$Props extends HTMLButtonAttributes {
88
/** imagetools import */
9-
src?: PictureType
9+
src: PictureType | undefined
1010
1111
/** img tag `sizes` attr */
1212
sizes?: string
@@ -18,10 +18,10 @@ interface $$Props extends HTMLButtonAttributes {
1818
height?: number
1919
2020
/** img tag `loading` attr */
21-
loading: 'lazy' | 'eager'
21+
loading?: 'lazy' | 'eager'
2222
2323
/** img tag `decoding` attr */
24-
decoding: 'async' | 'auto' | 'sync'
24+
decoding?: 'async' | 'auto' | 'sync'
2525
2626
/** bindable reference to `<img>` element */
2727
ref?: HTMLImageElement
@@ -70,18 +70,13 @@ $: if (len(img)) {
7070
7171
## Usage
7272
```tsx
73-
<script>
74-
// Import original full-sized image with `?as=run` query param
75-
import cat from '$lib/assets/cat.jpg?as=run'
76-
import Img from '@zerodevx/svelte-img'
77-
</script>
7873
<Img class="cool kitty" src="{cat}" alt="Very meow" />
7974
```
8075
8176
## Props
8277
- `src?: PictureType` - imagetools import
8378
- `sizes?: string` - img tag `sizes` attr
84-
- `width?: number` - img width override */
79+
- `width?: number` - img width override
8580
- `height?: number` - img height override
8681
- `loading: 'lazy' | 'eager'` - img tag `loading` attr
8782
- `decoding: 'async' | 'auto' | 'sync'` - img tag `decoding` attr

src/routes/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import i3 from './assets/1920/3.jpg?h=720&as=run'
99
import i4 from './assets/1920/4.jpg?h=720&as=run'
1010
import i5 from './assets/1920/5.jpg?h=720&as=run'
1111
import pllx from './assets/pllx.jpg?h=1024&as=run'
12-
import Img, { FxReveal, FxParallax } from '$lib'
12+
import Img, { FxReveal, FxParallax } from '$lib/index.js'
1313
import { version } from '$app/environment'
1414
import testSingle from './assets/640/01.jpg?w=80&h=80&format=jpg&as=run:0'
1515
import testFallback from './assets/640/01.jpg?h=80'

0 commit comments

Comments
 (0)