@gleich/ui 0.0.4 → 0.0.5
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/dist/image.svelte +49 -0
- package/dist/image.svelte.d.ts +11 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/package.json +5 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
const {
|
|
3
|
+
src,
|
|
4
|
+
alt,
|
|
5
|
+
placeholder,
|
|
6
|
+
height,
|
|
7
|
+
width,
|
|
8
|
+
aspectRatio
|
|
9
|
+
}: {
|
|
10
|
+
src: string;
|
|
11
|
+
alt: string;
|
|
12
|
+
height: number;
|
|
13
|
+
width: number;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
aspectRatio?: string;
|
|
16
|
+
} = $props();
|
|
17
|
+
|
|
18
|
+
let img: HTMLElement;
|
|
19
|
+
|
|
20
|
+
function removeBackground() {
|
|
21
|
+
if (img.style.backgroundImage && placeholder) {
|
|
22
|
+
img.style.backgroundImage = 'none';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<img
|
|
28
|
+
{src}
|
|
29
|
+
bind:this={img}
|
|
30
|
+
onload={removeBackground}
|
|
31
|
+
loading="lazy"
|
|
32
|
+
decoding="async"
|
|
33
|
+
{alt}
|
|
34
|
+
{height}
|
|
35
|
+
{width}
|
|
36
|
+
style={`${aspectRatio ? `aspect-ratio: ${aspectRatio};` : ''} ${placeholder ? `background-image: url('${placeholder}');` : ''}`}
|
|
37
|
+
/>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
img {
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: 100%;
|
|
43
|
+
object-fit: cover;
|
|
44
|
+
background-size: cover;
|
|
45
|
+
background-position: center;
|
|
46
|
+
background-repeat: no-repeat;
|
|
47
|
+
display: block;
|
|
48
|
+
}
|
|
49
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type $$ComponentProps = {
|
|
2
|
+
src: string;
|
|
3
|
+
alt: string;
|
|
4
|
+
height: number;
|
|
5
|
+
width: number;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
aspectRatio?: string;
|
|
8
|
+
};
|
|
9
|
+
declare const Image: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
10
|
+
type Image = ReturnType<typeof Image>;
|
|
11
|
+
export default Image;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import Card from './card.svelte';
|
|
|
2
2
|
import Copyright from './card.svelte';
|
|
3
3
|
import DynamicHead from './dynamic-head.svelte';
|
|
4
4
|
import Error from './error.svelte';
|
|
5
|
+
import Image from './image.svelte';
|
|
5
6
|
import Logo from './logo.svelte';
|
|
6
7
|
import Scrolling from './scrolling.svelte';
|
|
7
|
-
export { Card, Copyright, DynamicHead, Error, Logo, Scrolling };
|
|
8
|
+
export { Card, Copyright, DynamicHead, Error, Image, Logo, Scrolling };
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import Card from './card.svelte';
|
|
|
2
2
|
import Copyright from './card.svelte';
|
|
3
3
|
import DynamicHead from './dynamic-head.svelte';
|
|
4
4
|
import Error from './error.svelte';
|
|
5
|
+
import Image from './image.svelte';
|
|
5
6
|
import Logo from './logo.svelte';
|
|
6
7
|
import Scrolling from './scrolling.svelte';
|
|
7
|
-
export { Card, Copyright, DynamicHead, Error, Logo, Scrolling };
|
|
8
|
+
export { Card, Copyright, DynamicHead, Error, Image, Logo, Scrolling };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gleich/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite dev --open",
|
|
@@ -52,6 +52,10 @@
|
|
|
52
52
|
"./scrolling.svelte": {
|
|
53
53
|
"types": "./dist/scrolling.svelte.d.ts",
|
|
54
54
|
"svelte": "./dist/scrolling.svelte"
|
|
55
|
+
},
|
|
56
|
+
"./image.svelte": {
|
|
57
|
+
"types": "./dist/image.svelte.d.ts",
|
|
58
|
+
"svelte": "./dist/image.svelte"
|
|
55
59
|
}
|
|
56
60
|
},
|
|
57
61
|
"peerDependencies": {
|