lazy-svelte-image 0.0.2 → 1.0.4
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/README.md
CHANGED
|
@@ -1,58 +1,50 @@
|
|
|
1
|
-
#
|
|
1
|
+
# lazy-image-loader
|
|
2
2
|
|
|
3
|
-
Everything you need to build a Svelte library, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
A custom Image component/tag like component with customizations, loader ...
|
|
6
5
|
|
|
7
|
-
##
|
|
6
|
+
## Installing the Package
|
|
8
7
|
|
|
9
8
|
If you're seeing this, you've probably already done this step. Congrats!
|
|
10
9
|
|
|
11
10
|
```bash
|
|
12
|
-
|
|
13
|
-
npm create svelte@latest
|
|
14
|
-
|
|
15
|
-
# create a new project in my-app
|
|
16
|
-
npm create svelte@latest my-app
|
|
11
|
+
npm i lazy-svelte-image
|
|
17
12
|
```
|
|
18
13
|
|
|
19
|
-
##
|
|
14
|
+
## Usage
|
|
20
15
|
|
|
21
|
-
Once you've
|
|
16
|
+
Once you've installed you can import the package and use just like ```<img>``` . an exaple is given below
|
|
22
17
|
|
|
23
18
|
```bash
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
# or start the server and open the app in a new browser tab
|
|
27
|
-
npm run dev -- --open
|
|
28
|
-
```
|
|
19
|
+
import { Image } from 'lazy-svelte-image'
|
|
29
20
|
|
|
30
|
-
Everything inside `src/lib` is part of your library, everything inside `src/routes` can be used as a showcase or preview app.
|
|
31
21
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
To build your library:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
npm run package
|
|
38
|
-
```
|
|
22
|
+
<Image src="" alt="" />
|
|
39
23
|
|
|
40
|
-
|
|
24
|
+
# or
|
|
41
25
|
|
|
42
|
-
|
|
43
|
-
npm run build
|
|
26
|
+
<Image> <!-- slot--> </Image>
|
|
44
27
|
```
|
|
45
28
|
|
|
46
|
-
You can preview the production build with `npm run preview`.
|
|
47
29
|
|
|
48
|
-
|
|
30
|
+
## Customization
|
|
49
31
|
|
|
50
|
-
|
|
32
|
+
Currenlty you can provide custom loader nad broken image icon as slot. use slot like how you use it in svelte.
|
|
51
33
|
|
|
52
|
-
|
|
34
|
+
#### For custom Broken Images/Icons
|
|
53
35
|
|
|
54
|
-
|
|
36
|
+
```bash
|
|
37
|
+
<span slot="boken">
|
|
38
|
+
<!-- provide contents here -->
|
|
39
|
+
</span>
|
|
40
|
+
```
|
|
41
|
+
#### For custom Loaders
|
|
55
42
|
|
|
56
43
|
```bash
|
|
57
|
-
|
|
44
|
+
<span slot="loader">
|
|
45
|
+
<!-- provide loader -->
|
|
46
|
+
</span>
|
|
58
47
|
```
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
##### Looking forward for feature requests and usages 😃..
|
|
@@ -4,7 +4,7 @@ let loaded = false;
|
|
|
4
4
|
let failed = false;
|
|
5
5
|
let loading = false;
|
|
6
6
|
let icons = {
|
|
7
|
-
loader: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" width="
|
|
7
|
+
loader: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid" width="80" height="80" style="shape-rendering: auto; display: block; background: transparent;" xmlns:xlink="http://www.w3.org/1999/xlink"><g><circle stroke-dasharray="113.09733552923255 39.69911184307752" r="24" stroke-width="4" stroke="#629aa9" fill="none" cy="50" cx="50"><animateTransform keyTimes="0;1" values="0 50 50;360 50 50" dur="1s" repeatCount="indefinite" type="rotate" attributeName="transform"></animateTransform></circle><g></g></g><!-- [ldio] generated by https://loading.io --></svg>',
|
|
8
8
|
broken: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M38.8 5.1C28.4-3.1 13.3-1.2 5.1 9.2S-1.2 34.7 9.2 42.9l592 464c10.4 8.2 25.5 6.3 33.7-4.1s6.3-25.5-4.1-33.7L489.3 358.2l90.5-90.5c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114l-96 96-31.9-25C430.9 239.6 420.1 175.1 377 132c-52.2-52.3-134.5-56.2-191.3-11.7L38.8 5.1zM239 162c30.1-14.9 67.7-9.9 92.8 15.3c20 20 27.5 48.3 21.7 74.5L239 162zM116.6 187.9L60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5l61.8-61.8-50.6-39.9zM220.9 270c-2.1 39.8 12.2 80.1 42.2 110c38.9 38.9 94.4 51 143.6 36.3L220.9 270z"/></svg>'
|
|
9
9
|
};
|
|
10
10
|
onMount(() => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as Image } from './component/Image.svelte';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Reexport your entry components here
|
|
2
|
-
export { default as
|
|
2
|
+
export { default as Image } from './component/Image.svelte';
|
package/package.json
CHANGED
|
File without changes
|