Coder Social home page Coder Social logo

weiningning / vue-content-loader Goto Github PK

View Code? Open in Web Editor NEW

This project forked from egoist/vue-content-loader

0.0 1.0 0.0 119 KB

SVG component to create placeholder loading, like Facebook cards loading.

Home Page: https://vue-content-loader.egoist.moe

JavaScript 77.54% HTML 22.46%

vue-content-loader's Introduction

vue-content-loader

NPM version NPM downloads CircleCI

SVG component to create placeholder loading, like Facebook cards loading.

preview

Features

This is a Vue port for react-content-loader.

  • Completely customizable: you can change the colors, speed and sizes.
  • Create your own loading: use the online tool to create your custom loader easily.
  • You can use it right now: there are a lot of presets already.
  • Performance:
    • Tree-shakable and highly optimized bundle.
    • Pure SVG, so it's works without any javascript, canvas, etc.
    • Pure functional components.

Install

yarn add vue-content-loader

CDN: UNPKG | jsDelivr (available as window.contentLoaders)

Usage

๐Ÿ‘€๐Ÿ‘‰ Demos: Storybook | with Nuxt.js

<template>
  <content-loader></content-loader>
</template>

<script>
import { ContentLoader } from 'vue-content-loader'

export default {
  components: {
    ContentLoader
  }
}
</script>

Built-in loaders

import {
  ContentLoader,
  FacebookLoader,
  CodeLoader,
  BulletListLoader,
  InstagramLoader,
  ListLoader
} from 'vue-content-loader'

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:

<ContentLoader>
  <rect x="0" y="0" rx="3" ry="3" width="250" height="10" />
  <rect x="20" y="20" rx="3" ry="3" width="220" height="10" />
  <rect x="20" y="40" rx="3" ry="3" width="170" height="10" />
  <rect x="0" y="60" rx="3" ry="3" width="250" height="10" />
  <rect x="20" y="80" rx="3" ry="3" width="200" height="10" />
  <rect x="20" y="100" rx="3" ry="3" width="80" height="10" />
</ContentLoader>

This is also how ListLoader is created.

You can also use the online tool to create shapes for your custom loader.

API

Props

Prop Type Default Description
width number 400
height number 130
speed number 2
preserveAspectRatio string 'xMidYMid meet'
primaryColor string '#f9f9f9'
secondaryColor string '#ecebeb'
uniqueKey string randomId() Unique ID, you need to make it consistent for SSR
animate boolean true

Credits

This is basically a Vue port for react-content-loader.

Thanks to @alidcastano for transferring the package name to me. ๐Ÿ˜˜

License

MIT ยฉ EGOIST

vue-content-loader's People

Contributors

egoist avatar lafreefall avatar

Watchers

James Cloos avatar

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.