GitHub - willmendesneto/vue-skeleton-content-loader: Make beautiful, animated loading skeletons that automatically adapt to your Vue apps (original) (raw)

Vue Skeleton Content Loader

npm downloads npm npm

NPM NPM

Build Status Coverage Status npm bundle size (minified + gzip) npm

Why skeletons?

The idea of this component is to make the process transparent and easier. So the main point is to integrate this component with other tooling processes, such as:

It's totally transparent for you and you can integrate it easily into your application, improving your user experience 🎉

Demo

Try out our demos on Stackblitz!

Install

You can get it on NPM by installing the vue-skeleton-content-loader module as a project dependency.

npm install vue-skeleton-content-loader --save

Usage

Basic Usage - Local import

To use VueSkeletonContentLoader in your Vue application, you first need to import it into your component's script section.

// YourComponent.vue

Circle Skeleton

Line Skeleton

Square Skeleton

Global Registration - Component register via app boostrap file

For global availability across your application, you can register VueSkeletonContentLoader when you create your Vue app instance.

// main.ts or main.js import { createApp } from 'vue'; import App from './App.vue'; // Note: import default export for global registration import VueSkeletonContentLoader from 'vue-skeleton-content-loader';

const app = createApp(App); // Register globally app.component('VueSkeletonContentLoader', VueSkeletonContentLoader); app.mount('#app');

After global registration, you can use <VueSkeletonContentLoader> directly in any component's template without explicit import.

Props

VueSkeletonContentLoader accepts several props to customize its behavior and appearance:

Appearance

You can also define which appearance you want to use in your skeleton loader by passing the options in your component via the :appearance prop.

Options

Appearance props (specific for square)

When setting square as appearance, your component can also use these other input attributes to configure it properly

Animations

You can also define which CSS animation you want to use - even not use any, if it's the case - in your skeleton loader by passing the options in your component via the :animation prop.

Options

progress is the default animation, used as the single one previously. If you don't pass the animation attribute, it defaults to progress.

You can check the code details in the Stackblitz Live Demo Link

Theming

You can also define different styles for the skeleton loader by passing an object with the css styles - in dashed case - into the component via the :theme prop.

The :theme prop now accepts the same configuration as Vue's v-bind:style directive. That means you can manage to use it like you're doing with the built-in directive, having a pleasant and beautiful experience.

You should change the styles on the skeleton wrapper element in case you need to change the background color. You can check the code details in the Stackblitz Live Demo Link or check out a content load simulation in this Stackblitz Live Demo Link

Development

Run demo locally

  1. This project uses Vite as base. That means you just need to run npm run dev and access the link http://localhost:3000 (or whatever port Vite assigns) in your browser.

Run tests

  1. Run npm test to run tests. In case you want to test using watch, please use npm run tdd.

Contribute

For any type of contribution, please follow the instructions in CONTRIBUTING.md and read CODE_OF_CONDUCT.md and PUBLISHING_HOTFIX.md files.

Author

Wilson Mendes (willmendesneto)