Coder Social home page Coder Social logo

michalsnik / vue-content-placeholders Goto Github PK

View Code? Open in Web Editor NEW
1.6K 1.6K 87.0 11 KB

Composable components for rendering fake (progressive) content like facebook in vue

License: MIT License

JavaScript 46.38% Vue 20.63% CSS 32.99%
fake-content lazy-loading loader progressive-rendering skeleton vue vue-components

vue-content-placeholders's Introduction

vue-content-placeholders

npm vue2

Vue addon for rendering fake content while data is fetching to provide better UX and lower bounce rate.

example


๐Ÿ’ฟ Installation

  • via npm: npm install vue-content-placeholders --save
  • via yarn: yarn add vue-content-placeholders

๐Ÿš€ Usage

Include plugin in your main.js file.

import Vue from 'vue'
import VueContentPlaceholders from 'vue-content-placeholders'

Vue.use(VueContentPlaceholders)

โš ๏ธ A css file is included when importing the package. You may have to setup your bundler to embed the css in your page.

Examples:

<content-placeholders>
  <content-placeholders-heading :img="true" />
  <content-placeholders-text :lines="3" />
</content-placeholders>

rendered example

<content-placeholders :rounded="true">
  <content-placeholders-img />
  <content-placeholders-heading />
</content-placeholders>

rendered example

Available components and properties

  • root <content-placeholders>

    • Boolean animated (default: true)
    • Boolean rounded (default: false) - border radius
    • Boolean centered (default: false)

    these properties define how all children components will act

  • <content-placeholders-heading />

    • Boolean img (default: false)
  • <content-placeholders-text />

    • Number lines (default: 4)
  • <content-placeholders-img />


๐Ÿ”“ License

See the LICENSE file for license rights and limitations (MIT).

vue-content-placeholders's People

Contributors

michalsnik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-content-placeholders's Issues

Syntax error while using webpack with postcss

After adding this

import VueContentPlaceholders from 'vue-content-placeholders'
Vue.use(VueContentPlaceholders)

into my main.js of vue-cli webpack template with postcss, webpack shows me the following error:

app_1    | 20:28:59 webpack.1 | > Starting dev server...
app_1    | 20:29:25 webpack.1 |  ERROR  Failed to compile with 1 errors20:29:25
app_1    | 20:29:25 webpack.1 |
app_1    | 20:29:25 webpack.1 |  error  in ./~/vue-content-placeholders/dist/vue-content-placeholders.css
app_1    | 20:29:25 webpack.1 |
app_1    | 20:29:25 webpack.1 | Module build failed: Syntax Error
app_1    | 20:29:25 webpack.1 |
app_1    | 20:29:25 webpack.1 | (5:1) Unknown word
app_1    | 20:29:25 webpack.1 |
app_1    | 20:29:25 webpack.1 |   3 | // load the styles
app_1    | 20:29:25 webpack.1 |   4 | var content = require("!!../../css-loader/index.js??ref--8-1!./vue-content-placeholders.css");
app_1    | 20:29:25 webpack.1 | > 5 | if(typeof content === 'string') content = [[module.id, content, '']];
app_1    | 20:29:25 webpack.1 |     | ^
app_1    | 20:29:25 webpack.1 |   6 | if(content.locals) module.exports = content.locals;
app_1    | 20:29:25 webpack.1 |   7 | // add the styles to the DOM
app_1    | 20:29:25 webpack.1 |
app_1    | 20:29:25 webpack.1 |
app_1    | 20:29:25 webpack.1 |  @ ./~/vue-content-placeholders/index.js 3:0-44
app_1    | 20:29:25 webpack.1 |  @ ./src/main.js
app_1    | 20:29:25 webpack.1 |  @ multi ./build/dev-client ./src/main.js
app_1    | 20:29:25 webpack.1 |
app_1    | 20:29:25 webpack.1 | > Listening at http://localhost:8080

Vue 3 support ?

I'm trying to use this component with vue 3.
Will you provide any support ?

I tried something like this:

import { createApp } from 'vue'
import VueContentPlaceholders from 'vue-content-placeholders'
...
createApp(App).use(router)
  .use(VueContentPlaceholders)
  .mount('#app')

But this is what I got in the console:

vue-content-placeholders.common.js?5f56:1 Uncaught (in promise) TypeError: Cannot read property '_c' of undefined
    at Proxy.render (vue-content-placeholders.common.js?5f56:1)
    ...

Thanks.

correct way to use in ssr

in ssr mode, the animation doesn't work. what is the correct way to import css files.
In nuxt, I am importing it as mentioned in the README.md

CSS paints the body red

Any reason for this? Trying to implement onto an existing project but it's converting the body to red..

How to render data?

I used many ways but could not render my data after loading, hope to get help!

CSS Fails in Scoped SCSS

My app was using scoped scss which was failing to render CSS for the component.

<style lang="scss" scoped>
</style>

I had to create an unscoped one and copy SCSS codes into there to make it working.

<style lang="scss">
</style>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.