├── .babelrc
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .gitignore
├── .npmignore
├── LICENSE.md
├── README.md
├── config
├── webpack.config.base.js
├── webpack.config.browser.js
├── webpack.config.common.js
└── webpack.config.dev.js
├── index.js
├── package.json
└── src
├── components
├── ContentPlaceholders.vue
├── ContentPlaceholdersHeading.vue
├── ContentPlaceholdersImg.vue
└── ContentPlaceholdersText.vue
├── index.js
└── styles.scss
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | ["env", {
4 | "targets": {
5 | "browsers": ["> 1%", "last 2 versions"]
6 | }
7 | }]
8 | ]
9 | }
10 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 |
8 | [*]
9 | end_of_line = lf
10 | charset = utf-8
11 | trim_trailing_whitespace = true
12 | insert_final_newline = true
13 | indent_style = space
14 | indent_size = 2
15 |
16 | [*.hbs]
17 | insert_final_newline = false
18 |
19 | [*.{diff,md}]
20 | trim_trailing_whitespace = false
21 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | dist/
3 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: [
3 | 'standard',
4 | 'plugin:vue/recommended'
5 | ],
6 | globals: {
7 | VERSION: true,
8 | },
9 | parserOptions: {
10 | parser: 'babel-eslint',
11 | },
12 | 'rules': {
13 | 'arrow-parens': 0,
14 | 'generator-star-spacing': 0,
15 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
16 | 'comma-dangle': ['error', 'always-multiline'],
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | dist/
3 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | config/
3 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-content-placeholders
2 |
3 | 
4 | [](https://vuejs.org/)
5 |
6 | > Vue addon for rendering fake content while data is fetching to provide better UX and lower bounce rate.
7 |
8 | 
9 |
10 | ---
11 |
12 | ## :cd: Installation
13 |
14 | * via npm: `npm install vue-content-placeholders --save`
15 | * via yarn: `yarn add vue-content-placeholders`
16 |
17 | ## :rocket: Usage
18 |
19 | Include plugin in your `main.js` file.
20 |
21 | ```javascript
22 | import Vue from 'vue'
23 | import VueContentPlaceholders from 'vue-content-placeholders'
24 |
25 | Vue.use(VueContentPlaceholders)
26 | ```
27 |
28 | > ⚠️ A css file is included when importing the package. You may have to setup your bundler to embed the css in your page.
29 |
30 | ### Examples:
31 |
32 | ```html
33 |
34 |
35 |
36 |
37 | ```
38 |
39 | 
40 |
41 | ```html
42 |
43 |
44 |
45 |
46 | ```
47 |
48 | 
49 |
50 | ### Available components and properties
51 |
52 | * root ``
53 | * Boolean `animated` (default: true)
54 | * Boolean `rounded` (default: false) - border radius
55 | * Boolean `centered` (default: false)
56 | > these properties define how all children components will act
57 |
58 |
59 | * ``
60 | * Boolean `img` (default: false)
61 |
62 |
63 | * ``
64 | * Number `lines` (default: 4)
65 |
66 |
67 | * ``
68 |
69 | ---
70 |
71 | ## 🔓 License
72 |
73 | See the [LICENSE](LICENSE.md) file for license rights and limitations (MIT).
74 |
--------------------------------------------------------------------------------
/config/webpack.config.base.js:
--------------------------------------------------------------------------------
1 | var webpack = require('webpack')
2 | var ExtractTextPlugin = require('extract-text-webpack-plugin')
3 |
4 | var outputFile = 'vue-content-placeholders'
5 | var config = require('../package.json')
6 |
7 | module.exports = {
8 | entry: './src/index.js',
9 | module: {
10 | rules: [
11 | {
12 | enforce: 'pre',
13 | test: /\.(js|vue)$/,
14 | loader: 'eslint-loader',
15 | exclude: /node_modules/,
16 | },
17 | {
18 | test: /.js$/,
19 | use: 'babel-loader',
20 | },
21 | {
22 | test: /\.vue$/,
23 | loader: 'vue-loader',
24 | options: {
25 | loaders: {
26 | css: ExtractTextPlugin.extract('css-loader'),
27 | sass: ExtractTextPlugin.extract('css-loader!sass-loader'),
28 | scss: ExtractTextPlugin.extract('css-loader!sass-loader'),
29 | },
30 | },
31 | },
32 | ],
33 | },
34 | plugins: [
35 | new webpack.DefinePlugin({
36 | 'VERSION': JSON.stringify(config.version),
37 | }),
38 | new ExtractTextPlugin(outputFile + '.css'),
39 | ],
40 | }
41 |
--------------------------------------------------------------------------------
/config/webpack.config.browser.js:
--------------------------------------------------------------------------------
1 | var webpack = require('webpack')
2 | var merge = require('webpack-merge')
3 | var base = require('./webpack.config.base')
4 | var path = require('path')
5 |
6 | var outputFile = 'vue-content-placeholders'
7 | var globalName = 'VueContentPlaceholders'
8 |
9 | module.exports = merge(base, {
10 | output: {
11 | path: path.resolve(__dirname, '../dist'),
12 | filename: outputFile + '.browser.js',
13 | library: globalName,
14 | libraryTarget: 'umd',
15 | },
16 | externals: {},
17 | plugins: [
18 | new webpack.optimize.UglifyJsPlugin({
19 | compress: {
20 | warnings: true,
21 | },
22 | mangle: false,
23 | }),
24 | ],
25 | })
26 |
--------------------------------------------------------------------------------
/config/webpack.config.common.js:
--------------------------------------------------------------------------------
1 | var webpack = require('webpack')
2 | var merge = require('webpack-merge')
3 | var base = require('./webpack.config.base')
4 | var path = require('path')
5 |
6 | var outputFile = 'vue-content-placeholders'
7 |
8 | module.exports = merge(base, {
9 | output: {
10 | path: path.resolve(__dirname, '../dist'),
11 | filename: outputFile + '.common.js',
12 | libraryTarget: 'commonjs2',
13 | },
14 | target: 'node',
15 | externals: {},
16 | plugins: [
17 | new webpack.optimize.UglifyJsPlugin({
18 | compress: {
19 | warnings: true,
20 | },
21 | mangle: false,
22 | }),
23 | ],
24 | })
25 |
--------------------------------------------------------------------------------
/config/webpack.config.dev.js:
--------------------------------------------------------------------------------
1 | var merge = require('webpack-merge')
2 | var base = require('./webpack.config.base')
3 | var path = require('path')
4 |
5 | var outputFile = 'vue-content-placeholders'
6 | var globalName = 'VueContentPlaceholders'
7 |
8 | module.exports = merge(base, {
9 | output: {
10 | path: path.resolve(__dirname, '../dist'),
11 | filename: outputFile + '.common.js',
12 | library: globalName,
13 | libraryTarget: 'umd',
14 | },
15 | devtool: 'eval-source-map',
16 | })
17 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | export { default } from './dist/vue-content-placeholders.common'
2 | export * from './dist/vue-content-placeholders.common'
3 | import './dist/vue-content-placeholders.css'
4 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-content-placeholders",
3 | "description": "Vue Components for rendering animated content placeholders like facebook",
4 | "version": "0.2.0",
5 | "author": "Michał Sajnóg (http://github.com/michalsnik)",
6 | "keywords": [
7 | "vue",
8 | "vuejs",
9 | "plugin",
10 | "loader",
11 | "fake",
12 | "placeholder",
13 | "progressive",
14 | "skeleton-ui"
15 | ],
16 | "license": "MIT",
17 | "main": "dist/vue-content-placeholders.common.js",
18 | "unpkg": "dist/vue-content-placeholders.browser.js",
19 | "module": "index.js",
20 | "scripts": {
21 | "dev": "cross-env NODE_ENV=development webpack --config config/webpack.config.dev.js --progress --watch",
22 | "build": "npm run build:browser && npm run build:common",
23 | "build:browser": "cross-env NODE_ENV=production webpack --config config/webpack.config.browser.js --progress --hide-modules",
24 | "build:common": "cross-env NODE_ENV=production webpack --config config/webpack.config.common.js --progress --hide-modules",
25 | "prepublish": "npm run build",
26 | "lint": "eslint ."
27 | },
28 | "repository": {
29 | "type": "git",
30 | "url": "git+https://github.com/michalsnik/vue-content-placeholders.git"
31 | },
32 | "bugs": {
33 | "url": "https://github.com/michalsnik/vue-content-placeholders/issues"
34 | },
35 | "homepage": "https://github.com/michalsnik/vue-content-placeholders#readme",
36 | "devDependencies": {
37 | "babel-core": "^6.26.0",
38 | "babel-eslint": "^7.1.1",
39 | "babel-loader": "^6.0.0",
40 | "babel-preset-env": "^1.6.1",
41 | "cross-env": "^3.1.3",
42 | "css-loader": "^0.26.1",
43 | "eslint": "^3.12.1",
44 | "eslint-config-standard": "^6.2.1",
45 | "eslint-loader": "^1.6.1",
46 | "eslint-plugin-html": "^1.6.0",
47 | "eslint-plugin-promise": "^3.4.0",
48 | "eslint-plugin-standard": "^2.0.1",
49 | "eslint-plugin-vue": "^3.13.1",
50 | "extract-text-webpack-plugin": "^2.0.0-beta.4",
51 | "node-sass": "^4.0.0",
52 | "sass-loader": "^4.1.0",
53 | "vue-loader": "^10.0.0",
54 | "vue-template-compiler": "^2.1.6",
55 | "webpack": "^2.1.0-beta.28",
56 | "webpack-merge": "^1.1.2"
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/components/ContentPlaceholders.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
36 |
37 |
40 |
--------------------------------------------------------------------------------
/src/components/ContentPlaceholdersHeading.vue:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
27 |
--------------------------------------------------------------------------------
/src/components/ContentPlaceholdersImg.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
15 |
--------------------------------------------------------------------------------
/src/components/ContentPlaceholdersText.vue:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
23 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | import ContentPlaceholders from './components/ContentPlaceholders.vue'
2 | import ContentPlaceholdersHeading from './components/ContentPlaceholdersHeading.vue'
3 | import ContentPlaceholdersImg from './components/ContentPlaceholdersImg.vue'
4 | import ContentPlaceholdersText from './components/ContentPlaceholdersText.vue'
5 |
6 | export function install (Vue) {
7 | Vue.component('ContentPlaceholders', ContentPlaceholders)
8 | Vue.component('ContentPlaceholdersHeading', ContentPlaceholdersHeading)
9 | Vue.component('ContentPlaceholdersImg', ContentPlaceholdersImg)
10 | Vue.component('ContentPlaceholdersText', ContentPlaceholdersText)
11 | }
12 |
13 | export {
14 | ContentPlaceholders,
15 | ContentPlaceholdersHeading,
16 | ContentPlaceholdersImg,
17 | ContentPlaceholdersText,
18 | }
19 |
20 | const plugin = {
21 | version: VERSION,
22 | install,
23 | }
24 |
25 | export default plugin
26 |
27 | // Auto-install
28 | let GlobalVue = null
29 | if (typeof window !== 'undefined') {
30 | GlobalVue = window.Vue
31 | } else if (typeof global !== 'undefined') {
32 | GlobalVue = global.Vue
33 | }
34 | if (GlobalVue) {
35 | GlobalVue.use(plugin)
36 | }
37 |
--------------------------------------------------------------------------------
/src/styles.scss:
--------------------------------------------------------------------------------
1 | // Variables
2 | $vue-content-placeholders-primary-color: #ccc !default;
3 | $vue-content-placeholders-secondary-color: #eee !default;
4 | $vue-content-placeholders-border-radius: 6px !default;
5 | $vue-content-placeholders-line-height: 15px !default;
6 | $vue-content-placeholders-spacing: 10px !default;
7 |
8 |
9 |
10 | // Animations
11 | @keyframes vueContentPlaceholdersAnimation {
12 | 0% {
13 | transform: translate3d(-30%, 0, 0);
14 | }
15 |
16 | 100% {
17 | transform: translate3d(100%, 0, 0);
18 | }
19 | }
20 |
21 |
22 |
23 | // Mixins
24 | @mixin vue-content-placeholders {
25 | position: relative;
26 | overflow: hidden;
27 | height: $vue-content-placeholders-line-height;
28 | background: $vue-content-placeholders-secondary-color;
29 |
30 | .vue-content-placeholders-is-rounded & {
31 | border-radius: $vue-content-placeholders-border-radius;
32 | }
33 |
34 | .vue-content-placeholders-is-centered & {
35 | margin-left: auto;
36 | margin-right: auto;
37 | }
38 |
39 | .vue-content-placeholders-is-animated &::before {
40 | content: '';
41 | position: absolute;
42 | top: 0;
43 | left: 0;
44 | width: 100vw;
45 | max-width: 1000px;
46 | height: 100%;
47 | background: linear-gradient(to right, transparent 0%, darken($vue-content-placeholders-secondary-color, 5%) 15%, transparent 30%);
48 | animation-duration: 1.5s;
49 | animation-fill-mode: forwards;
50 | animation-iteration-count: infinite;
51 | animation-name: vueContentPlaceholdersAnimation;
52 | animation-timing-function: linear;
53 | }
54 | }
55 |
56 | @mixin vue-content-placeholders-spacing {
57 | [class^="vue-content-placeholders-"] + & {
58 | margin-top: 2 * $vue-content-placeholders-spacing;
59 | }
60 | }
61 |
62 |
63 |
64 | // Styles
65 | .vue-content-placeholders-heading {
66 | @include vue-content-placeholders-spacing;
67 | display: flex;
68 |
69 | &__img {
70 | @include vue-content-placeholders;
71 | width: 2 * $vue-content-placeholders-line-height + 3 * $vue-content-placeholders-spacing;
72 | height: 2 * $vue-content-placeholders-line-height + 3 * $vue-content-placeholders-spacing;
73 | margin-right: 1.5 * $vue-content-placeholders-spacing;
74 | }
75 |
76 | &__content {
77 | display: flex;
78 | flex: 1;
79 | flex-direction: column;
80 | justify-content: center;
81 | }
82 |
83 | &__title {
84 | @include vue-content-placeholders;
85 | width: 85%;
86 | margin-bottom: $vue-content-placeholders-spacing;
87 | background: $vue-content-placeholders-primary-color;
88 | }
89 |
90 | &__subtitle {
91 | @include vue-content-placeholders;
92 | width: 90%;
93 | }
94 | }
95 |
96 | .vue-content-placeholders-text {
97 | @include vue-content-placeholders-spacing;
98 |
99 | &__line {
100 | @include vue-content-placeholders;
101 | width: 100%;
102 | margin-bottom: $vue-content-placeholders-spacing;
103 |
104 | &:nth-child(4n + 1) {
105 | width: 80%;
106 | }
107 |
108 | &:nth-child(4n + 2) {
109 | width: 100%;
110 | }
111 |
112 | &:nth-child(4n + 3) {
113 | width: 70%;
114 | }
115 |
116 | &:nth-child(4n + 4) {
117 | width: 85%;
118 | }
119 | }
120 | }
121 |
122 | .vue-content-placeholders-img {
123 | @include vue-content-placeholders;
124 | @include vue-content-placeholders-spacing;
125 | width: 100%;
126 | height: 120px;
127 | }
128 |
--------------------------------------------------------------------------------