Добавлен компонент Picture
This commit is contained in:
33
src/lib/components/Picture.svelte
Normal file
33
src/lib/components/Picture.svelte
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{#if src}
|
||||||
|
<picture>
|
||||||
|
{#if src?.sources}
|
||||||
|
{#each Object.entries(src.sources) as [ format, srcset ]}
|
||||||
|
<source {srcset} type={`image/${format}`}/>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<Image
|
||||||
|
src={src?.img?.src || src}
|
||||||
|
width={src?.img?.w}
|
||||||
|
height={src?.img?.h}
|
||||||
|
{...others}
|
||||||
|
/>
|
||||||
|
</picture>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { Image } from './Image.svelte'
|
||||||
|
|
||||||
|
let {
|
||||||
|
src,
|
||||||
|
...others
|
||||||
|
} = $props()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
picture {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1 +1,2 @@
|
|||||||
export { default as Image } from './components/Image.svelte'
|
export { default as Image } from './components/Image.svelte'
|
||||||
|
export { default as Picture } from './components/Picture.svelte'
|
||||||
Reference in New Issue
Block a user