Categories
Top Vue Packages

Top Vue Packages for Timelines, Text Editors, Animating Numbers, and Smooth Reflow

Vue.js is an easy to use web app framework that we can use to develop interactive front end apps.

In this article, we’ll look at the best packages for adding timelines, text editors, animating numbers, and smooth reflow.

vue-cute-timeline

vue-cute-timeline is a timeline component that we can use with Vue apps.

To install it, we run:

npm i vue-cute-timeline

Then we can use it by writing:

<template>
  <div id="app">
    <timeline>
      <timeline-title>title</timeline-title>
      <timeline-item bg-color="#9dd8e0">foo</timeline-item>
      <timeline-item :hollow="true">bar</timeline-item>
    </timeline>
  </div>
</template>

<script>
import { Timeline, TimelineItem, TimelineTitle } from "vue-cute-timeline";

export default {
  components: {
    Timeline,
    TimelineItem,
    TimelineTitle
  }
};
</script>

We just import the timeline components.

Then we get a vertical timeline with the content between the tags.

bg-color has a background color.

hollow makes the dot hollow.

vue-ckeditor2

vue-ckeditor2 is a package that we can use to add swipe gesture components.

To use it, we run:

npm i npm i vue-ckeditor2-swiper

to install it.

Then we can use it by writing:

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
    <title>codesandbox</title>
    <script src="https://cdn.ckeditor.com/4.14.0/standard/ckeditor.js"></script>
  </head>
  <body>
    <noscript>
      <strong
        >We're sorry but codesandbox doesn't work properly without JavaScript
        enabled. Please enable it to continue.</strong
      >
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>

App.vue

<template>
  <div>
    <vue-ckeditor
      v-model="content"
      :config="config"
      @blur="onBlur($event)"
      @focus="onFocus($event)"
      @contentDom="onContentDom($event)"
      @dialogDefinition="onDialogDefinition($event)"
      @fileUploadRequest="onFileUploadRequest($event)"
      @fileUploadResponse="onFileUploadResponse($event)"
    />
  </div>
</template>

<script>
import VueCkeditor from "vue-ckeditor2";

export default {
  components: { VueCkeditor },
  data() {
    return {
      content: "",
      config: {
        toolbar: [
          ["Bold", "Italic", "Underline", "Strike", "Subscript", "Superscript"]
        ],
        height: 300
      }
    };
  },
  methods: {
    onBlur(evt) {
      console.log(evt);
    },
    onFocus(evt) {
      console.log(evt);
    },
    onContentDom(evt) {
      console.log(evt);
    },
    onDialogDefinition(evt) {
      console.log(evt);
    },
    onFileUploadRequest(evt) {
      console.log(evt);
    },
    onFileUploadResponse(evt) {
      console.log(evt);
    }
  }
};
</script>

We add the CKEditor script in index.html so that we can use the package.

Then we put the vue-ckeditor component in our app.

v-model binds to the content that we enter.

We should see the bold, italics, and strikethrough buttons since we specified that in the toolbar property.

Vue Smooth Reflow (VSR)

Vue Smooth Reflow will add transitions to any reflows, including toggle on and off elements and manipulating lists.

To use it, we first install it by running:

npm i vue-smooth-reflow

Then we can use it by writing:

main.js

<template>
  <div>
    <div v-for="n in nums" :key="n">{{n}}</div>
  </div>
</template>

<script>
import smoothReflow from "vue-smooth-reflow";
export default {
  mixins: [smoothReflow],
  data() {
    return {
      nums: []
    };
  },
  mounted() {
    this.$smoothReflow();
    const timer = setInterval(() => {
      if (this.nums.length === 10) {
        clearInterval(timer);
      }
      this.nums.push(this.nums.length);
    }, 500);
  }
};
</script>

We register the mixin, and then we use the $smoothReflow method to enable smooth reflow.

Then we add a timer to add items to nums , which will be rendered with v-for .

We add an item every half a second.

Now the items will be animated with a transition effect when it’s added.

vue-animate-number

vue-animate-number is a useful package for letting us animate numbers.

To use it, we install the package by writing:

npm i vue-animate-number

Then we use the package by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueAnimateNumber from "vue-animate-number";
Vue.use(VueAnimateNumber);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <animate-number from="1" to="10" duration="1000" easing="easeOutQuad" :formatter="formatter"></animate-number>
  </div>
</template>

<script>
export default {
  methods: {
    formatter(num) {
      return num.toFixed(2);
    },

    startAnimate() {
      this.$refs.myNum.start();
    }
  }
};
</script>

We add the animate-number component.

from is the starting number for the animation.

to is the ending number for the animation.

duration is the length of the animation in milliseconds.

easing lets us animate in a nonlinear fashion.

formatter is the formatter function for the number. Every value will go through the function before it’s displayed.

Conclusion

vue-cute-timeline lets us add a vertical timeline to our Vue app.

vue-ckeditor2 lets us add a text editor to our app.

Vue Smooth Reflow (VSR) adds transition effects for reflows.

vue-animate-number allows us to animate number displays.

Categories
Top Vue Packages

Top Vue Packages for QR Codes, Rendering Markdown, and More

Vue.js is an easy to use web app framework that we can use to develop interactive front end apps.

In this article, we’ll look at the best packages for adding a loading spinner, carousel, rendering Markdown to HTML, display a QR code, and show a sidebar menu.

vue-owl-carousel

vue-owl-carousel lets us add an image carousel to our Vue app.

To use it, we run:

npm i vue-owl-carousel

to install it.

Then we write:

<template>
  <div>
    <carousel>
      <img v-for="n in 10" :key="n" :src="`https://placeimg.com/200/200/any?${n}`">
    </carousel>
  </div>
</template>

<script>
import carousel from "vue-owl-carousel";

export default {
  components: { carousel }
};
</script>

to add a carousel to our app.

We use the carousel component to add the carousel.

Then we add images between the tags to populate the images.

Navigation is displayed automatically when the screen can’t display all the images on the screen simultaneously.

It takes a few props.

autoplay lets us enable autoplay.

nav lets us enable or disable the navigation.

It also emits a few events.

changed and updated events are emitted.

vue-sidebar-menu

vue-sidebar-menu is a library that lets us add a sidebar easily into our Vue app.

To install it, we run:

npm i vue-sidebar-menu

Then we write:

<template>
  <div>
    <sidebar-menu :menu="menu"/>
  </div>
</template>

<script>
import { SidebarMenu } from "vue-sidebar-menu";
import "vue-sidebar-menu/dist/vue-sidebar-menu.css";

export default {
  components: {
    SidebarMenu
  },
  data() {
    return {
      menu: [
        {
          header: true,
          title: "menu",
          hiddenOnCollapse: true
        },
        {
          href: "/",
          title: "user",
          icon: "fa fa-user"
        },
        {
          href: "/charts",
          title: "charts",
          icon: "fa fa-chart-area",
          child: [
            {
              href: "/charts/sublink",
              title: "child"
            }
          ]
        }
      ]
    };
  }
};
</script>

to add it.

icon is for the classes for the icons.

href is the path to do to.

child is the child links.

title is the name that’s displayed on the menu entry.

hiddenOnCollapse lets us choose whether to hide the menu on collapse or not.

Vue Showdown

Vue Showdown is a Markdown display component.

We can use it to render Markdown into HTML.

To install it, we run:

npm install vue-showdown

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueShowdown from "vue-showdown";

Vue.use(VueShowdown, {
  flavor: "github",
  options: {
    emoji: false
  }
});
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <VueShowdown markdown="## markdown" flavor="github" :options="{ emoji: true }"/>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  }
};
</script>

We use the VueShowdown component by registering it with some options.

flavor is the flavor of Markdown we render.

emoji lets us choose to render emoji or not.

We pass the Markdown into the markdown prop.

v-qrcode

v-qrcode lets us render QR codes in our Vue app.

To use it, we run:

npm i v-qrcode

to install it.

Then we write:

<template>
  <div>
    <qrcode :cls="qrCls" :value="qrText"></qrcode>
  </div>
</template>

<script>
import Qrcode from "v-qrcode";

export default {
  data() {
    return {
      qrCls: "qrcode",
      qrText: "hello"
    };
  },

  components: {
    Qrcode
  }
};
</script>

to use it.

We pass in the cls prop to set the class name of the wrapper.

value is the string to generate the QR code from.

We can also change the size, level, background, foreground, adding, and what element to render the code in.

vue-element-loading

The vue-element-loading plugin lets us add a loading spinner to our Vue app.

To use it, we run:

npm i vue-element-loading

to install it.

Then we write: main.js

import Vue from "vue";
import App from "./App.vue";
import VueElementLoading from "vue-element-loading";

Vue.component("VueElementLoading", VueElementLoading);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <vue-element-loading active spinner="bar-fade-scale"/>
  </div>
</template>

<script>
export default {};
</script>

to use it.

We have the vue-element component which loads the spinner.

active makes it show.

spinner lets us set the type of spinner we want to display.

Conclusion

vue-owl-carousel is an easy to use carousel library.

vue-sidebar-menu lets us display a sidebar menu in our app.

Vue Showdown renders Markdown into HTML.

v-qrcode displays a QR code created from a string.

vue-element-loading is a loading spinner.

Categories
Top Vue Packages

Top Vue Packages for Entering Text, File Uploading, and Rendering Trees

Vue.js is an easy to use web app framework that we can use to develop interactive front end apps.

In this article, we’ll look at the best packages for adding draggable and resizable elements, file uploading, text editor, displaying tree structures, and input mask.

v-file-upload

We can use the v-file-upload package to add a file upload component to our Vue app.

To use it, we run:

npm i v-file-upload

to install it.

Then we can write:

main.js

import Vue from "vue";
import App from "./App.vue";

import FileUpload from "v-file-upload";

Vue.use(FileUpload);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <file-upload :url="url" :thumb-url="thumbUrl" :headers="headers" @change="onFileChange"></file-upload>
</template>

<script>
import Vue from "vue";

export default {
  data() {
    return {
      url: "http://upload.url",
      headers: { "access-token": "<your-token>" },
      filesUploaded: []
    };
  },
  methods: {
    thumbUrl(file) {
      return file.thumnbnail;
    },
    onFileChange(file) {
      this.fileUploaded = file;
    }
  }
};
</script>

to use it.

We use the file-upload component.

We set the url prop to set the upload URL.

headers has the headers.

thumbUrl has the URL to the thumbnail.

Now we see a file selector on our screen.

vue-jstree

vue-jstree is a tree view for Vue apps.

To use it, we run:

npm i vue-jstree

to install it.

Then we write:

<template>
  <div>
    <v-jstree :data="data"></v-jstree>
  </div>
</template>

<script>
import VJstree from "vue-jstree";

export default {
  components: {
    VJstree
  },
  data() {
    return {
      data: [
        {
          text: "apple",
          children: [
            {
              text: "orange",
              selected: true
            },
            {
              text: "danger",
              icon: "fa fa-warning icon-state-danger"
            }
          ]
        },
        {
          text: "grape"
        }
      ]
    };
  }
};
</script>

to use it.

We use the v-jstree to include the tree view in our component.

The nodes are defined by arrays.

Each entry is an object with the text property for the text.

selected is an optional property to indicate selection.

icon os the class for the icon.

children is the class for the children.

We can change the icon class.

It takes a few props.

show-checkbox indicates whether to show a checkbox.

multiple lets us select multiple items.

collapse sets all tree nodes to the collapsed state.

loading-text is a loading function.

There are many more props it takes.

Vue-Trix Text Editor

Vue-Trix Text Editor is a rich text editor that we can use in our Vue app.,

To use it, we run:

npm i vue-trix

to install the package.

Then we write:

<template>
  <div>
    <VueTrix v-model="editorContent" placeholder="Enter content" localStorage/>
  </div>
</template>

<script>
import VueTrix from "vue-trix";

export default {
  components: {
    VueTrix
  },
  data(){
    return {
      editorContent: ''
    }
  }
};
</script>

to add the editor.

We add the VueTrix component to add it to our app.

We set a value for the placeholder to add a placeholder.

v-model binds the inputted value to the editorContent state.

localStorage save the inputted text to local storage.

vue-drag-resize

vue-drag-resize is an easy to use plugin to let us add draggable and resizable elements.

We install it by running:

npm i vue-drag-resize

Then we write:

<template>
  <div id="app">
    <VueDragResize isActive :w="200" :h="200" v-on:resizing="resize" v-on:dragging="resize">
      <p>{{ top }} х {{ left }}</p>
      <p>{{ width }} х {{ height }}</p>
    </VueDragResize>
  </div>
</template>

<script>
import VueDragResize from "vue-drag-resize";

export default {
  name: "app",

  components: {
    VueDragResize
  },

  data() {
    return {
      width: 0,
      height: 0,
      top: 0,
      left: 0
    };
  },

  methods: {
    resize(newRect) {
      this.width = newRect.width;
      this.height = newRect.height;
      this.top = newRect.top;
      this.left = newRect.left;
    }
  }
};
</script>

to use it.

We use the VueDraggable component to create a draggable and resizable component.

isActive sets the component to be active.

We set the initial height with the h prop.

The w prop is the initial width.

We listen to the resizing and dragging events to get the values of the new dimensions.

Conclusion

v-file-upload is a file upload component.

vue-jstree lets us display tree structures.

Vue-Trix Text Editor is a rich text editor for Vue apps.

vue-drag-resize lets us drag and resize elements.

Categories
Top Vue Packages

Top Vue Packages for Adding YouTube Videos, Autofill Box, and More

Vue.js is an easy to use web app framework that we can use to develop interactive front end apps.

In this article, we’ll look at the best packages for adding drag and drop items, YouTube videos, an input box with autofill, and a custom scrollbar.

Vue Smooth DnD

Vue Smooth DnD is an easy to use Vue library for making drag and drop lists.

To use it, we run:

npm i vue-smooth-dnd

Then we can use it by writing:

<template>
  <div>
    <div>
      <Container>
        <Draggable v-for="item in items" :key="item.id">
          <div>{{item.data}}</div>
        </Draggable>
      </Container>
    </div>
  </div>
</template>

<script>
import { Container, Draggable } from "vue-smooth-dnd";
export default {
  name: "Simple",
  components: { Container, Draggable },
  data() {
    return {
      items: Array(50)
        .fill()
        .map((_, i) => ({ id: i, data: `Draggable ${i}` }))
    };
  }
};
</script>

We use the Container and Draggable components to make the draggable container and items.

Container is the container.

Draggable are the draggable items.

We can change the classes of the items, the animation duration, drop placeholder, and other options.

vue-simple-suggest

As its name suggests, vue-simple-suggest is a simple package for adding an input box with autofill suggestions,

To use it, we run:

npm i vue-simple-suggest

Then we use it by writing:

<template>
  <div>
    <vue-simple-suggest v-model="chosen" :list="simpleSuggestionList" :filter-by-query="true"></vue-simple-suggest>

<p>{{ chosen }}</p>
  </div>
</template>

<script>
import VueSimpleSuggest from "vue-simple-suggest";
import "vue-simple-suggest/dist/styles.css";

export default {
  components: {
    VueSimpleSuggest
  },
  data() {
    return {
      chosen: ""
    };
  },
  methods: {
    simpleSuggestionList() {
      return ["apple", "orange", "grape"];
    }
  }
};
</script>

We import the component and CSS to display the input box.

Then we specified the simpleSuggestionList to return the suggestions.

v-model binds the selected choice to the chosen state.

It also works with async data and others has many other options for changes.

We can return a promise in our suggestion function to use async data as our suggestion source:

<template>
  <div>
    <vue-simple-suggest v-model="chosen" :list="simpleSuggestionList" :filter-by-query="true"></vue-simple-suggest>
    <p>{{ chosen }}</p>
  </div>
</template>

<script>
import VueSimpleSuggest from "vue-simple-suggest";
import "vue-simple-suggest/dist/styles.css";

export default {
  components: {
    VueSimpleSuggest
  },
  data() {
    return {
      chosen: ""
    };
  },
  methods: {
    async simpleSuggestionList() {
      return Promise.resolve(["apple", "orange", "grape"]);
    }
  }
};
</script>

We return a promise instead of an array.

vue-youtube

vue-youtube is a Vue package that let us embed YouTube videos in our Vue app.

To use it, we run:

npm i vue-youtube

to install it.

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueYoutube from "vue-youtube";

Vue.use(VueYoutube);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <youtube ref="youtube" :video-id="videoId" :player-vars="playerVars" @playing="playing"></youtube>
  </div>
</template>

<script>
export default {
  data() {
    return {
      videoId: "NnsHhqAdOiM",
      playerVars: {
        autoplay: 1
      }
    };
  },
  computed: {
    player() {
      return this.$refs.youtube.player;
    }
  },
  methods: {
    async playVideo() {
      await this.player.playVideo();
    }
  }
};
</script>

We have the youtube component to embed the videos.

All we have to do is to specify the ID of the video and set a few options to play videos.

Vue 2 Scrollbar

Vue 2 Scrollbar is a custom scrollbar component for Vue apps.

To use it, we run:

npm i vue2-scrollbar

to install it.

Then we write:

<template>
  <div>
    <vue-scrollbar ref="Scrollbar" classes="my-scrollbar">
      <div class="scroll-me">
        <div v-for="n in 100" :key="n">{{n}}</div>
      </div>
    </vue-scrollbar>
  </div>
</template>

<script>
import VueScrollbar from "vue2-scrollbar";
import "vue2-scrollbar/dist/style/vue2-scrollbar.css";

export default {
  components: { VueScrollbar }
};
</script>

<style>
.my-scrollbar {
  max-height: 300px;
}
</style>

We add the vue-scrollbar component with the styles.

Also, we set the height of the container to 300px max.

Then we should see the scrollbar from the package displayed.

Conclusion

Vue Smooth DnD is a drag and drop component for Vue apps.

vue-simple-suggest lets us add an input box with autofill suggestions.

vue-youtube is a YouTube component for Vue apps.

Vue 2 Scrollbar provides us with a custom scrollbar.

Categories
Top Vue Packages

Top Vue Packages for Adding Wizards, Changing Title and Description, and More

Vue.js is an easy to use web app framework that we can use to develop interactive front end apps.

In this article, we’ll look at the best packages for adding wizards, changing titles and meta attributes, using Moment, and adding percentage displays.

vue-good-wizard

vue-good-wizard is a wizard plugin for Vue apps.

To use it, we install it by writing:

npm i vue-good-wizard

Then we can write:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueGoodWizard from "vue-good-wizard";

Vue.use(VueGoodWizard);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>
    <vue-good-wizard :steps="steps" :onNext="nextClicked" :onBack="backClicked">
      <div slot="page1">
        <h4>Step 1</h4>
        <p>This is step 1</p>
      </div>
      <div slot="page2">
        <h4>Step 2</h4>
        <p>This is step 2</p>
      </div>
      <div slot="page3">
        <h4>Review</h4>
        <p>review</p>
      </div>
    </vue-good-wizard>
  </div>
</template>

<script>
export default {
  name: "demo",
  data() {
    return {
      steps: [
        {
          label: "Step 1",
          slot: "page1"
        },
        {
          label: "Step 2",
          slot: "page2"
        },
        {
          label: "Review",
          slot: "page3",
          options: {
            nextDisabled: true
          }
        }
      ]
    };
  },
  methods: {
    nextClicked(currentPage) {
      console.log("next clicked", currentPage);
      return true;
    },
    backClicked(currentPage) {
      console.log("back clicked", currentPage);
      return true;
    }
  }
};
</script>

We use the vue-good-wizard component to create the wizard.

The steps prop has an array with the slot names and labels.

The slot property of each entry has the slots.

Then we populate the slots we defined by putting whatever we want in it.

options has options we can set on each step.

It also emits events and we can set listeners for them.

vue-headful

We can use the vue-headful package to set the title and meta description of our app.

We can install it by running:

npm i vue-headful

Then we write:

<template>
  <div>
    <vue-headful title="headful title" description="headful description"/>
  </div>
</template>

to use it.

vue-headful is the component to set the metadata.

title sets the title.

description sets the meta tag’s description attribute.

We can also set other attributes of the meta tag and the link tag.

vue-simple-calendar

vue-simple-calendar is a calendar component for Vue apps.

To use it, we run:

npm i vue-simple-calendar

to install the package.

Then we write:

<template>
  <div id="app">
    <calendar-view :show-date="showDate">
      <calendar-view-header
        slot="header"
        slot-scope="t"
        :header-props="t.headerProps"
        [@input](http://twitter.com/input "Twitter profile for @input")="setShowDate"
      />
    </calendar-view>
  </div>
</template>
<script>
import { CalendarView, CalendarViewHeader } from "vue-simple-calendar";
import "vue-simple-calendar/static/css/default.css";
import "vue-simple-calendar/static/css/holidays-us.css";

export default {
  name: "app",
  data() {
    return { showDate: new Date() };
  },
  components: {
    CalendarView,
    CalendarViewHeader
  },
  methods: {
    setShowDate(d) {
      this.showDate = d;
    }
  }
};
</script>

to use it.

We’ve to import the component and CSS files.

We then use the calendar-view for adding the calendar.

And we use the calendar-view-header component to add the header.

showDate sets the default date to show.

vue-easy-pie-chart

vue-easy-pie-chart lets us display a circular percentage display to our Vue app.

We install it by running:

npm i vue-easy-pie-chart

Then we write:

<template>
  <div>
    <vue-easy-pie-chart :percent="70"></vue-easy-pie-chart>
  </div>
</template>
<script>
import VueEasyPieChart from "vue-easy-pie-chart";
import "vue-easy-pie-chart/dist/vue-easy-pie-chart.css";

export default {
  components: { VueEasyPieChart }
};
</script>

to use it.

We set the percent to display the percentage.

Also, we’ve import the CSS to make it look correct.

vue-momentjs

vue-momentjs is a Vue plugin wrapper for moment.js.

We can install it by running:

npm install moment vue-momentjs

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import moment from "moment";
import VueMomentJS from "vue-momentjs";

Vue.use(VueMomentJS, moment);
Vue.config.productionTip = false;

new Vue({
  render: h => h(App)
}).$mount("#app");

App.vue

<template>
  <div>{{date}}</div>
</template>
<script>
export default {
  data() {
    return {
      date: this.$moment(new Date()).format("YYYY-MM-DD")
    };
  }
};
</script>

We use the this.$moment property to call the moment function.

Then we can call any other method of the moment object with it.

Conclusion

vue-good-wizard is a wizard component for Vue.

vue-headful lets us change the title and meta description for our Vue app.

vue-momentjs is a small wrapper for moment.

vue-easy-pie-chart is a percentage display.