├── .editorconfig
├── .github
└── FUNDING.yml
├── .gitignore
├── .prettierrc
├── README.md
├── babel.config.js
├── bili.config.js
├── circle.yml
├── jest.config.js
├── package.json
├── renovate.json
├── src
├── BulletListLoader.tsx
├── CodeLoader.tsx
├── ContentLoader.spec.js
├── ContentLoader.tsx
├── FacebookLoader.tsx
├── InstagramLoader.tsx
├── ListLoader.tsx
├── __snapshots__
│ └── index.spec.js.snap
├── index.spec.js
├── index.ts
└── uid.ts
├── stories
├── Storybook.vue
├── index.js
├── poi.config.js
└── storybook.js
├── tsconfig.json
└── yarn.lock
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: egoist
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | dist
3 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "semi": false,
3 | "singleQuote": true
4 | }
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-content-loader
2 |
3 | [](https://npmjs.com/package/vue-content-loader) [](https://npmjs.com/package/vue-content-loader) [](https://circleci.com/gh/egoist/vue-content-loader/tree/master)
4 |
5 | SVG component to create placeholder loading, like Facebook cards loading.
6 |
7 | 
8 |
9 | ## Features
10 |
11 | This is a Vue port for [react-content-loader](https://github.com/danilowoz/react-content-loader).
12 |
13 | - Completely customizable: you can change the colors, speed and sizes.
14 | - Create your own loading: use the [online tool](https://create-content-loader.now.sh/) to create your custom loader easily.
15 | - You can use it right now: there are a lot of presets already.
16 | - Performance:
17 | - Tree-shakable and highly optimized bundle.
18 | - Pure SVG, so it's works without any javascript, canvas, etc.
19 | - Pure functional components.
20 |
21 | ## Install
22 |
23 | ⚠️ **The latest version is compatible with Vue 3 only.** For Vue 2 & Nuxt 2, use `vue-content-loader@^0.2` instead.
24 |
25 | With npm:
26 |
27 | ```bash
28 | npm i vue-content-loader
29 | ```
30 |
31 | Or with yarn:
32 |
33 | ```bash
34 | yarn add vue-content-loader
35 | ```
36 |
37 | CDN: [UNPKG](https://unpkg.com/vue-content-loader/) | [jsDelivr](https://cdn.jsdelivr.net/npm/vue-content-loader/) (available as `window.contentLoaders`)
38 |
39 | ## Usage
40 |
41 | 👀👉 Demo: [CodeSandbox](https://codesandbox.io/s/vue-content-loader-igfyf?file=/src/App.vue)
42 |
43 | ```vue
44 |
45 |
46 |
47 |
48 |
57 | ```
58 |
59 | ### Built-in loaders
60 |
61 | ```js
62 | import {
63 | ContentLoader,
64 | FacebookLoader,
65 | CodeLoader,
66 | BulletListLoader,
67 | InstagramLoader,
68 | ListLoader,
69 | } from 'vue-content-loader'
70 | ```
71 |
72 | `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:
73 |
74 | ```vue
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | ```
84 |
85 | This is also how [ListLoader](./src/ListLoader.js) is created.
86 |
87 | You can also use the [online tool](http://danilowoz.com/create-vue-content-loader/) to create shapes for your custom loader.
88 |
89 | ## API
90 |
91 | ### Props
92 |
93 | | Prop | Type | Default | Description |
94 | | ------------------- | -------------- | ---------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
95 | | width | number, string | | SVG width in pixels without unit |
96 | | height | number, string | | SVG height in pixels without unit |
97 | | viewBox | string | `'0 0 ${width ?? 400} ${height ?? 130}'` | See [SVG viewBox](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox) attribute |
98 | | preserveAspectRatio | string | `'xMidYMid meet'` | See [SVG preserveAspectRatio](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio) attribute |
99 | | speed | number | `2` | Animation speed |
100 | | primaryColor | string | `'#f9f9f9'` | Background color |
101 | | secondaryColor | string | `'#ecebeb'` | Highlight color |
102 | | uniqueKey | string | `randomId()` | Unique ID, you need to make it consistent for SSR |
103 | | animate | boolean | `true` | |
104 | | baseUrl | string | empty string | Required if you're using `` in your `