@nodeart/emdash-plugin-picture 0.0.0-stage → 0.1.0

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.
@@ -0,0 +1,90 @@
1
+ <script lang="ts">
2
+ import type { ImageCatalog } from '../../dist/catalog.mjs';
3
+ import {
4
+ resolvePictureRenderProps,
5
+ type MediaProps,
6
+ type MediaRef,
7
+ type PictureFallbackFormat
8
+ } from '../../dist/resolve-media.mjs';
9
+
10
+ interface Props {
11
+ media: MediaProps | MediaRef | string | null | undefined;
12
+ preset: string | null;
13
+ catalog?: ImageCatalog;
14
+ sizes?: string;
15
+ alt?: string;
16
+ width?: number;
17
+ height?: number;
18
+ fallbackFormat?: PictureFallbackFormat;
19
+ class?: string;
20
+ pictureClass?: string;
21
+ style?: string;
22
+ loading?: 'lazy' | 'eager';
23
+ decoding?: 'async' | 'auto' | 'sync';
24
+ fetchpriority?: 'high' | 'low' | 'auto';
25
+ title?: string;
26
+ }
27
+
28
+ let {
29
+ media,
30
+ preset,
31
+ catalog,
32
+ sizes,
33
+ alt,
34
+ width,
35
+ height,
36
+ fallbackFormat = 'png',
37
+ class: className,
38
+ pictureClass,
39
+ style,
40
+ loading = 'lazy',
41
+ decoding = 'async',
42
+ fetchpriority,
43
+ title
44
+ }: Props = $props();
45
+
46
+ const rendered = $derived(
47
+ resolvePictureRenderProps({
48
+ media,
49
+ preset,
50
+ catalog,
51
+ sizes,
52
+ alt,
53
+ width,
54
+ height,
55
+ fallbackFormat
56
+ })
57
+ );
58
+ </script>
59
+
60
+ {#if rendered}
61
+ <picture class={pictureClass ? `media-picture ${pictureClass}` : 'media-picture'}>
62
+ {#each rendered.sources as source (source.type)}
63
+ <source type={source.type} srcset={source.srcset} sizes={source.sizes} />
64
+ {/each}
65
+ <img
66
+ src={rendered.img.src}
67
+ srcset={rendered.img.srcset}
68
+ sizes={rendered.img.sizes}
69
+ alt={rendered.img.alt}
70
+ {title}
71
+ width={rendered.img.width}
72
+ height={rendered.img.height}
73
+ {loading}
74
+ {decoding}
75
+ {fetchpriority}
76
+ class={className}
77
+ {style}
78
+ />
79
+ </picture>
80
+ {/if}
81
+
82
+ <style>
83
+ .media-picture {
84
+ display: contents;
85
+ }
86
+
87
+ .media-picture > source {
88
+ display: none;
89
+ }
90
+ </style>
@@ -0,0 +1 @@
1
+ export { default as MediaPicture } from './MediaPicture.svelte';