├── .editorconfig
├── .eslintrc.json
├── .gitignore
├── CHANGELOG.md
├── README.md
├── package.json
├── prettier.config.js
├── rollup.config.js
└── src
├── BulletListLoader.svelte
├── CodeLoader.svelte
├── ContentLoader.svelte
├── FacebookLoader.svelte
├── InstagramLoader.svelte
├── ListLoader.svelte
├── TableLoader.svelte
└── index.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | end_of_line = lf
5 | insert_final_newline = true
6 |
7 | [*.{js,css,html,svelte}]
8 | charset = utf-8
9 | indent_style = tab
10 | indent_size = 4
11 | trim_trailing_whitespace = true
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "parserOptions": {
4 | "ecmaVersion": 2019,
5 | "sourceType": "module"
6 | },
7 | "plugins": ["svelte3"],
8 | "overrides": [{
9 | "files": ["**/*.svelte"],
10 | "processor": "svelte3/svelte3"
11 | }],
12 | "env": {
13 | "es6": true,
14 | "browser": true
15 | }
16 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | Thumbs.db
3 | node_modules
4 | yarn.lock
5 | package-lock.json
6 | *.log
7 | .idea/
8 | index.js
9 | index.mjs
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # svelte-content-loader changelog
2 |
3 | ## 1.1.3
4 | * prettier config added
5 | * a11y improved
6 | * props of built-in loaders
7 | * TableLoader added
8 |
9 | ## 1.1.2
10 | * eslint added
11 | * CHANGELOG & editorconfig added
12 |
13 | ## 1.1.1
14 | * README updated
15 |
16 | ## 1.1.0
17 | * Update to latest Svelte 3
18 | * Few new props added: baseUrl, primaryOpacity, secondaryOpacity
19 |
20 | ## 1.0.0
21 |
22 | * First release
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Svelte Content Loader for Svelte 3
2 |
3 | [](https://www.npmjs.com/package/svelte-content-loader) [](https://www.npmjs.com/package/svelte-content-loader)
4 |
5 | SVG component to create placeholder loading, like Facebook cards loading.
6 |
7 | 
8 |
9 | ## Features
10 |
11 | This is a Svelte port for [vue-content-loader](https://github.com/egoist/vue-content-loader).
12 |
13 | - Completely customizable: you can change the colors, speed and sizes.
14 | - You can use it right now: there are a lot of presets already.
15 | - Performance:
16 | - Tree-shakable and highly optimized bundle.
17 | - Pure SVG, so it's works without any javascript, canvas, etc.
18 | - Vanilla JS components.
19 |
20 | ## Install
21 |
22 | ```bash
23 | npm i svelte-content-loader --save
24 | ```
25 |
26 | ```bash
27 | yarn add svelte-content-loader
28 | ```
29 |
30 | CDN: [UNPKG](https://unpkg.com/svelte-content-loader/) | [jsDelivr](https://cdn.jsdelivr.net/npm/svelte-content-loader/) (available as `window.ContentLoader`)
31 |
32 | ## Usage
33 |
34 | ```html
35 |
36 |
37 |
40 | ```
41 |
42 | ### Built-in loaders
43 |
44 | ```js
45 | import {
46 | FacebookLoader,
47 | CodeLoader,
48 | BulletListLoader,
49 | InstagramLoader,
50 | ListLoader
51 | } from 'svelte-content-loader'
52 | ```
53 |
54 | `ContentLoader` is a meta loader while other loaders are just higher-order components of it. By default `ContentLoader` only displays a simple rectangle, here's how you can use it to create custom loaders:
55 |
56 | ```html
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 | ```
66 |
67 | This is also how [ListLoader](./src/ListLoader.svelte) is created.
68 |
69 | If you are **not** using using es6, instead of importing add
70 |
71 | ```html
72 |
73 | ```
74 |
75 | just before closing body tag.
76 |
77 | ## API
78 |
79 | ### Props
80 |
81 | |Name|Type|Default|Description|
82 | |---|---|---|---|
83 | |width|number|`400`||
84 | |height|number|`130`||
85 | |speed|number|`2`||
86 | |preserveAspectRatio|string|`'xMidYMid meet'`||
87 | |primaryColor|string|`'#f9f9f9'`||
88 | |secondaryColor|string|`'#ecebeb'`||
89 | |uniqueKey|string|`randomId()`|Unique ID, you need to make it consistent for SSR|
90 | |animate|boolean|`true`||
91 | |baseUrl|string|empty string|Required if you're using in your