|
| 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 | +## Install |
| 8 | + |
| 9 | +```bash |
| 10 | +yarn add @rem/vue-content-loader |
| 11 | +``` |
| 12 | + |
| 13 | +__NOTE: You're installing `@rem/vue-content-loader` instead of `vue-content-loader`.__ |
| 14 | + |
| 15 | +CDN: [UNPKG](https://unpkg.com/@rem/vue-content-loader/) | [jsDelivr](https://cdn.jsdelivr.net/npm/@rem/vue-content-loader/) (available as `window.contentLoaders`) |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +```vue |
| 20 | +<template> |
| 21 | + <content-loader></content-loader> |
| 22 | +</template> |
| 23 | +
|
| 24 | +<script> |
| 25 | +import { ContentLoader } from '@rem/vue-content-loader' |
| 26 | +
|
| 27 | +export default { |
| 28 | + components: { |
| 29 | + ContentLoader |
| 30 | + } |
| 31 | +} |
| 32 | +</script> |
| 33 | +``` |
| 34 | + |
| 35 | +🔥 [Check out the __storybook__ to see how it rocks!](https://vue-content-loader.egoist.moe) |
| 36 | + |
| 37 | +### Built-in loaders |
| 38 | + |
| 39 | +```js |
| 40 | +import { |
| 41 | + ContentLoader, |
| 42 | + FacebookLoader, |
| 43 | + CodeLoader, |
| 44 | + BulletListLoader, |
| 45 | + InstagramLoader, |
| 46 | + ListLoader |
| 47 | +} from '@rem/vue-content-loader' |
| 48 | +``` |
| 49 | + |
| 50 | +`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: |
| 51 | + |
| 52 | +```vue |
| 53 | +<ContentLoader> |
| 54 | + <rect x="0" y="0" rx="3" ry="3" width="250" height="10" /> |
| 55 | + <rect x="20" y="20" rx="3" ry="3" width="220" height="10" /> |
| 56 | + <rect x="20" y="40" rx="3" ry="3" width="170" height="10" /> |
| 57 | + <rect x="0" y="60" rx="3" ry="3" width="250" height="10" /> |
| 58 | + <rect x="20" y="80" rx="3" ry="3" width="200" height="10" /> |
| 59 | + <rect x="20" y="100" rx="3" ry="3" width="80" height="10" /> |
| 60 | +</ContentLoader> |
| 61 | +``` |
| 62 | + |
| 63 | +This is also how [ListLoader](./src/ListLoader.js) is created. |
| 64 | + |
| 65 | +## API |
| 66 | + |
| 67 | +### Props |
| 68 | + |
| 69 | + |
| 70 | +|Prop|Type|Default|Description| |
| 71 | +|---|---|---|---| |
| 72 | +|width|number|`400`|| |
| 73 | +|height|number|`130`|| |
| 74 | +|speed|number|`2`|| |
| 75 | +|preserveAspectRatio|string|`'xMidYMid meet'`|| |
| 76 | +|primaryColor|string|`'#f9f9f9'`|| |
| 77 | +|secondaryColor|string|`'#ecebeb'`|| |
| 78 | +|uniquekey|string|`randomId()`|Unique ID, you need to change it for SSR| |
| 79 | +|animate|boolean|`true`|| |
| 80 | + |
| 81 | + |
| 82 | +## License |
| 83 | + |
| 84 | +MIT © [EGOIST](https://github.com/egoist) |
0 commit comments