Categories
Top Vue Packages

Top Vue Packages for Adding Sliders, Highlighting Code, 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 auto-scrolling, animating numbers, highlighting code, sliders, and displaying notifications.

vue-seamless-scroll

vue-seamless-scroll lets us add a component that automatically scrolls through its contents.

To use it, we run:

npm i vue-seamless-scroll

to install it.

Then we can write:

<template>
  <vue-seamless-scroll :data="listData" class="seamless-warp">
    <ul class="item">
      <li v-for="item in listData" :key="item">
        <span v-text="item"></span>
      </li>
    </ul>
  </vue-seamless-scroll>
</template>

<script>
import vueSeamlessScroll from "vue-seamless-scroll";

export default {
  components: {
    vueSeamlessScroll
  },
  data() {
    return {
      listData: Array(20)
        .fill()
        .map((_, i) => i)
    };
  }
};
</script>

We register the component.

And then we use the vue-seamless-scroll component.

We set the data prop to set the scroll data.

Then we loop through the entries we want to render.

Whatever is inside will be scrolled through continuously.

It’ll loop so it’ll keep scrolling from beginning to end until we navigate away from the page.

animated-number-vue

animated-number-vue lets us animate numbers in a Vue app.

To use it, we run:

npm i animated-number-vue

to install it.

Then we use it by writing:

<template>
  <animated-number :value="value" :formatValue="formatToPrice" :duration="300"/>
</template>
<script>
import AnimatedNumber from "animated-number-vue";

export default {
  components: {
    AnimatedNumber
  },
  data() {
    return {
      value: 1000
    };
  },
  methods: {
    formatToPrice(value) {
      return `$ ${value.toFixed(2)}`;
    }
  }
};
</script>

We use the animated-number component to display the animated number.

duration is the length of the animation.

value is the end number of the animation.

Vue Carousel 3d

Vue Carousel 3d is a 3D carousel for Vue apps.

To use it, we run:

npm i vue-carousel-3d

to install it.

Then we write:

main.js

import Vue from "vue";
import App from "./App.vue";
import Carousel3d from "vue-carousel-3d";

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

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

App.vue

<template>
  <div>
    <carousel-3d>
      <slide :index="0">Slide 1</slide>
      <slide :index="1">Slide 2</slide>
      <slide :index="2">Slide 3</slide>
    </carousel-3d>
  </div>
</template>

<script>
export default {};

to use it.

We use the carousel-3d with at least 3 slides.

The slide components house the slides.

Then we can flip through the slides.

Vue Toast Notification

Vue Toast Notification is a Vue plugin that lets us display toast in our Vue app.

To use it, we install it by running:

npm i vue-toast-notification

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueToast from "vue-toast-notification";
import "vue-toast-notification/dist/theme-default.css";

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

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

App.vue

<template>
  <div id="app"></div>
</template>

<script>
export default {
  mounted() {
    this.$toast.open("hello!");
  }
};
</script>

We import the CSS and register the library.

Then we call this.$toast.open to open a basic notification.

We also display notifications for errors, warnings, and info messages.

Also, we can write:

<template>
  <div id="app"></div>
</template>

<script>
export default {
  mounted() {
    this.$toast.open({
      message: "Hello Vue",
      type: "success",
      duration: 5000,
      dismissible: true
    });
  }
};
</script>

to set our own options.

dismissible makes it dismissible.

message is the message.

type is the type of toast.

duration is the length of time to display the toast.

vue-hljs

vue-hljs lets us display code in our Vue app with syntax highlighting.

To use it, we run:

npm i vue-hljs

to install it.

Then we write:

main.js

import Vue from "vue";
import App from "./App.vue";
import vueHljs from "vue-hljs";
import "vue-hljs/dist/vue-hljs.min.css";

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

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

App.vue

<template>
  <div id="app">
    <div v-highlight>
      <pre>
        <code class="javascript">const foo = 'bar'</code>
      </pre>
    </div>
  </div>
</template>

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

to display the code.

We just use the v-highlight directive to add the syntax highlighting.

Conclusion

vue-hljs lets us add syntax highlighting to our code display.

vue-seamless-scroll makes scrolling automatic.

Vue Toast Notification displays notifications in various formats.

Vue Carousel 3d lets us add a 3D slider.

animated-number-vue animates numbers.

Categories
Top Vue Packages

Top Vue Packages for Adding Date Pickers, Drag and Drop, Media Queries 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 date picker, drag and drop between different arrays, media queries, content loading placeholders, and displaying toasts.

Vue date pick

We use the Vue date pick to add a date picker.

To install it, we run:

npm i vue-date-pick

Then we can use it by writing:

<template>
  <date-pick v-model="date"></date-pick>
</template>

<script>
import DatePick from "vue-date-pick";
import "vue-date-pick/dist/vueDatePick.css";

export default {
  components: { DatePick },
  data: () => ({
    date: "2020-01-01"
  })
};
</script>

date-pick has the date picker.

And we import the CSS to display the proper styles.

v-model binds the select date to the date state.

v-media-query

v-media-query is a useful media query library for Vue apps.

To install it, we run:

npm i v-media-query

to install it.

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import vMediaQuery from "v-media-query";

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

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

App.vue

<template>
  <div v-if="$mq.resize && $mq.above('600px')">big div</div>
</template>

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

We registered the plugin so that we can use the $mq property to get the screen size and whether the element is resizing.

above means the width is bigger than the given width.

There’s also the between method to check if the screen width is between a certain range.

below lets us check if the screen width is below a certain width.

Vue Content Loading

Vue Content Loading lets us display a placeholder graphic to show when something is loading.

To use it, we run:

npm i vue-content-loading

Then we can write:

<template>
  <vue-content-loading :width="300" :height="100">
    <circle cx="50" cy="50" r="30"/>
  </vue-content-loading>
</template>

<script>
import VueContentLoading from "vue-content-loading";

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

to use it.

vue-content-loading is the component that lets us show the placeholder elements.

We put an SVG inside to display it in an animated way.

There are many other customization options.

Vue-Easy-Toast

Vue-Easy-Toast is an easy to use notification component for Vue apps.

To use it, first we install it by running:

npm i vue-easy-toast

Then we can write:

main.js

import Vue from "vue";
import App from "./App.vue";
import Toast from "vue-easy-toast";

Vue.use(Toast);

Vue.config.productionTip = false;

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

App.vue

<template>
  <div></div>
</template>

<script>
export default {
  mounted() {
    this.$toast("hello");
  }
};
</script>

We use the $toast method to display the notification.

It has many options. We can change styling, positions, and transitions.

vue-dragula

vue-dragula lets us add drag and drop capabilities to our app.

To use it, we run:

npm i vue-dragula

Then we can use it by writing:

<template>
  <div>
    <div class="wrapper">
      <div class="container" v-dragula="colOne" bag="first-bag">
        <div v-for="n in colOne" :key="n">{{n}}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      colOne: Array(10)
        .fill()
        .map((_, i) => i)
    };
  }
};
</script>

Then we can drag and drop the numbers.

bag lets drag and drop between columns.

We can also drag and drop between containers:

<template>
  <div>
    <div class="wrapper">
      <div class="container" v-dragula="colOne" bag="first-bag">
        <div v-for="n in colOne" :key="n">{{n}}</div>
      </div>
      <div class="container" v-dragula="colTwo" bag="first-bag">
        <div v-for="n in colTwo" :key="n">{{n}}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      colOne: Array(10)
        .fill()
        .map((_, i) => i),
      colTwo: []
    };
  }
};
</script>

We can add drag and drop capabilities to move items between arrays.

Conclusion

Vue date pick is a useful date picker.

v-media-query lets us check media queries in Vue apps without CSS.

vue-dragula is a useful drag and drop library for Vue apps.

Vue Content Loading lets us add a content loading placeholder with SVGs.

Vue-Easy-Toast is a library for displaying toasts.

Categories
Top Vue Packages

Top Vue Packages for Handling Touch Events, Masonry Grid, 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 handling touch events, adding a masonry grid, adding Github buttons, and an HTML5 editor.

vue-hammer

vue-hammer is a component that lets us handle touch events.

To use it, we install it by running:

npm i vue2-hammer

Then we can use it by running:

main.js

import Vue from "vue";
import App from "./App.vue";
import { VueHammer } from "vue2-hammer";
Vue.use(VueHammer);
Vue.config.productionTip = false;

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

App.vue

<template>
  <div>
    <a v-hammer:tap="onTap">Tap me!</a>
  </div>
</template>

<script>
export default {
  methods: {
    onTap() {
      console.log('tapped');
    }
  }
};
</script>

We register the plugin and use the v-hammer:tap directive to detect taps on it.

Then onTap will run.

It can watch other events like panning, presses, and more.

vue-masonry-css

We can use the vue-masonry-css to display items in a grid.

To install it, we run:

npm i vue-masonry-css

to install it.

Then we can write:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueMasonry from "vue-masonry-css";

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

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

App.vue

<template>
  <div>
    <masonry :cols="3" :gutter="30">
      <div v-for="item in 100" :key="item">Item: {{item}}</div>
    </masonry>
  </div>
</template>

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

We use the masonry component to put the elements in a grid.

We can put anything inside it.

cols is the number of columns to display.

gutter is the gap between each column.

Vue GitHub Buttons

Vue GitHub Buttons let us add Github buttons into our Vue app to use it, we run:

npm i vue-github-buttons

to install it.

Then we can write:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueGitHubButtons from "vue-github-buttons";

import "vue-github-buttons/dist/vue-github-buttons.css";

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

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

App.vue

<template>
  <div>
    <gh-btns-watch slug="mertJF/tailblocks" show-count></gh-btns-watch>
    <gh-btns-star slug="mertJF/tailblocks" show-count></gh-btns-star>
    <gh-btns-fork slug="mertJF/tailblocks" show-count></gh-btns-fork>
  </div>
</template>

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

gh-btns-watch lets us get the number of watchers of a repo.

The slug is the repo name.

show-count shows the count.

gh-btns-star shows the number of stars on a repo.

gh-btns-fork shows the number of forks made on a repo.

The count is obtained automatically.

We can add useCache to the setting to use the cached values for the count instead of getting the value every time.

vue-html5-editor

vue-html5-editor is a HTML editor for Vue apps.

To use it, we run:

npm i vue-html5-editor

to install it.

Then we write the following:

index.html

<link
  rel="stylesheet"
  href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
/>

main.js

import Vue from "vue";
import App from "./App.vue";
import VueHtml5Editor from "vue-html5-editor";
Vue.use(VueHtml5Editor, {
  name: "vue-html5-editor",
  showModuleName: false,
  icons: {
    text: "fa fa-pencil",
    color: "fa fa-paint-brush",
    font: "fa fa-font",
    align: "fa fa-align-justify",
    list: "fa fa-list",
    link: "fa fa-chain",
    unlink: "fa fa-chain-broken",
    tabulation: "fa fa-table",
    image: "fa fa-file-image-o",
    hr: "fa fa-minus",
    eraser: "fa fa-eraser",
    undo: "fa-undo fa",
    "full-screen": "fa fa-arrows-alt",
    info: "fa fa-info"
  }
});
Vue.config.productionTip = false;

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

App.vue

<template>
  <div>
    <vue-html5-editor :content="content" :height="500"></vue-html5-editor>
  </div>
</template>

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

We add the vue-html-editor component to use it the editor.

Also, we add the Font Awesome CSS to add the icons.

Then we pass in the content to the editor.

We can also set an upload handler to handle image uploads.

Conclusion

vue-html5-editor is an HTML5 editor made for Vue.

Vue GitHub Buttons is a Github button component for Vue.

vue-hammer is a directive that handles touch events.

vue-masonry-css lets us create a masonry grid.

Categories
Top Vue Packages

Top Vue Packages for Adding Calendars, Smooth Scrolling, Query Builder, and Charts

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 calendars, smooth scrolling, query builder UI, and charts.

vue-smoothscroll

vue-smoothscroll lets us add a smooth scrolling effect to our Vue app.

To use it, we run:

npm i vue-smoothscroll

Then we write:

main.js

import Vue from "vue";
import App from "./App.vue";
const vueSmoothScroll = require("vue-smoothscroll");
Vue.use(vueSmoothScroll);
Vue.config.productionTip = false;

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

App.vue

<template>
  <div class="root">
    <div v-smoothscroll="{ duration : 500, callback: callback, axis :'y' }">
      <div :ref="`num-${n}`" v-for="n in 100" :key="n">{{n}}</div>
    </div>
  </div>
</template>

<script>
export default {
  methods: {
    callback() {
      console.log("scrolling");
    }
  }
};
</script>

to use it.

We use the v-smoothscroll directive to enable scrolling.

When we scroll, the callback will be run.

axis specifies the axis that we’re scrolling.

duration is the duration that we scroll.

Vue Query Builder

Vue Query Builder is a component that lets us add a query builder UI to our app.

To use it, we first install it by running:

npm install vue-query-builder

Then we use it by writing:

<template>
  <div class="root">
    <vue-query-builder v-model="query" :rules="rules"></vue-query-builder>
    <p>{{query}}</p>
  </div>
</template>

<script>
import VueQueryBuilder from "vue-query-builder";

export default {
  data() {
    return {
      rules: [
        {
          type: "text",
          id: "vegetable",
          label: "Vegetable"
        },
        {
          type: "radio",
          id: "fruit",
          label: "Fruit",
          choices: [
            { label: "apple", value: "apple" },
            { label: "orange", value: "orange" }
          ]
        }
      ],
      query: undefined
    };
  },
  components: { VueQueryBuilder }
};
</script>

We use the vue-query-builder component to add the query builder UI.

And we specify the rules so that the controls are displayed with those things on it.

choices show up as the choices. radio button shows up ad radio buttons.

type shows in the Match Type dropdown.

We can Add Rule and Add Group as we wish.

vue-schart

vue-schart is a chart library that’s easy to use.

We can use it by install it with:

npm i vue-schart

Then we write:

<template>
  <div id="app">
    <schart class="wrapper" canvasId="canvas" :options="options"/>
  </div>
</template>
<script>
import Schart from "vue-schart";
export default {
  data() {
    return {
      options: {
        type: "bar",
        title: {
          text: "Sales"
        },
        bgColor: "white",
        labels: ["apple", "orange", "grape"],
        datasets: [
          {
            label: "January sales",
            fillColor: "green",
            data: [474, 281, 482]
          },
          {
            label: "February sales",
            data: [164, 178, 190]
          }
        ]
      }
    };
  },
  components: {
    Schart
  }
};
</script>

<style>
.wrapper {
  width: 80vw;
  height: 300px;
}
</style>

to create a bar chart.

We use the schart component.

Also, we specify the ID of the canvas to set the canvas’s ID.

options has all our chart options including the data.

type is the chart type.

title is the chart title.

bgColor is the background color.

labels is the x-axis labels.

dataasets has all our datasets.

label has the label for the legend.

fillColor is the fill color of the bars.

data has the values for the y-axis.

vue-calendar-component

vue-calendar-component is a Vue calendar component that’s customizable.

To use it, we run:

npm i vue-calendar-component

to install it.

Then we can use it by writing:

<template>
  <div id="app">
    <Calendar :textTop="textTop" v-on:choseDay="clickDay" v-on:changeMonth="changeDate"></Calendar>
  </div>
</template>
<script>
import Calendar from "vue-calendar-component";

export default {
  components: {
    Calendar
  },
  data() {
    return {
      textTop: ["M", "T", "W", "T", "F", "S", "S"]
    };
  },
  methods: {
    clickDay(data) {
      console.log(data);
    },
    changeDate(data) {
      console.log(data);
    },
    clickToday(data) {
      console.log(data);
    }
  }
};
</script>

We use the Calendar component to display the calendar.

textTop lets us change the text for the day of the week.

It also emits events when a day or week is chosen from the calendar.

Also, it takes many other kinds of customizations. like changing to start on Sunday instead of Monday.

We can also use assign a ref to it to programmatically navigate the calendar.

Conclusion

vue-smoothscroll lets us add smooth scroll to our Vue app.

Vue Query Builder is a component that provides us with a query builder UI.

vue-schart is an easy to use chart component.

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

Categories
Top Vue Packages

Top Vue Packages for Adding Encryption, Rich Text Viewer, JSON Viewer, 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 how the best packages for add encryption, text viewer, JSON viewer, and an item selector.

vue-cryptojs

vue-cryptojs lets us add encryption to our Vue app via a wrapper for crypto-js.

To install it, we run:

npm i vue-cryptojs

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueCryptojs from "vue-cryptojs";

Vue.use(VueCryptojs);

Vue.config.productionTip = false;

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

App.vue

<template>
  <div></div>
</template>

<script>
export default {
  mounted() {
    const encryptedText = this.CryptoJS.AES.encrypt(
      "hello world",
      "secret"
    ).toString();
    console.log(encryptedText);
  }
};
</script>

We register the plugin so that we can call this.CryptoJS.AES.encrypt in our app.

Also, we can use:

Vue.CryptoJS
this.$CryptoJS

to get the same object.

vue-swatches

vue-swatches lets us add a color picker into our Vue app with a few lines code.

We can install it by running:

npm i vue-swatches

Now we can use it in our component:

<template>
  <div>
    <v-swatches v-model="color"></v-swatches>
  </div>
</template>

<script>
import VSwatches from "vue-swatches";
import "vue-swatches/dist/vue-swatches.css";

export default {
  components: { VSwatches },
  data() {
    return {
      color: "green"
    };
  }
};
</script>

v-swatches is the component for the color picker.

The color code string is bound to the component with v-model .

v-selectpage

v-selectpage is a package that lets us add a UI component to lets users select items.

To install it, we run:

npm i v-selectpage

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import vSelectPage from "v-selectpage";
Vue.use(vSelectPage, {});
Vue.config.productionTip = false;

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

App.vue

<template>
  <v-selectpage
    :data="list"
    key-field="id"
    show-field="name"
    placeholder="choose a fruit"
    language="en"
  ></v-selectpage>
</template>

<script>
export default {
  data() {
    return {
      list: [
        { id: 1, name: "apple", desc: "apple" },
        { id: 2, name: "orange", desc: "orange" }
      ]
    };
  }
};
</script>

We use the v-selectpage component with the data prop to populate the selections.

key-field is the unique ID for each entry.

show-field is the property name of the field to show,.

placeholder has the placeholder.

language is the language.

It also supports multiple selections, pagination, right to left languages, and more.

vue-json-viewer

The vue-json-viewer package provides us with a JSON viewer that we can use in our Vue app.

To use it, we run:

npm i vue-json-viewer

Then we use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import JsonViewer from "vue-json-viewer";

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

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

App.vue

<template>
  <json-viewer :value="jsonData"></json-viewer>
</template>

<script>
export default {
  data() {
    return {
      jsonData: { foo: { bar: 2 } }
    };
  }
};
</script>

We register the plugin and use the json-viewer component.

The value prop has the JSON we want to display.

We can make it copyable with the copyable prop.

boxed makes a box.

expand-depth will collapse the blocks under the given depth.

It also has a slot for adding a copy button.

@toast-ui/vue-editor

We can use @toast-ui/vue-editor package to add a text editor to a Vue app.

To install it, we run:

npm i @toast-ui/vue-editor

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import "codemirror/lib/codemirror.css";
import "@toast-ui/editor/dist/toastui-editor.css";

Vue.config.productionTip = false;

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

App.vue

<template>
  <editor
    :initialValue="editorText"
    :options="editorOptions"
    height="500px"
    initialEditType="wysiwyg"
    previewStyle="vertical"
  />
</template>
<script>
import "codemirror/lib/codemirror.css";
import "@toast-ui/editor/dist/toastui-editor.css";

import { Editor } from "@toast-ui/vue-editor";

export default {
  components: {
    editor: Editor
  },
  data() {
    return {
      editorText: "hello world.",
      editorOptions: {
        hideModeSwitch: true
      }
    };
  }
};
</script>

We set the initialValue to the text we want.

Also, we can set the options bu passing an object to the options prop.

initialEditType is set to wysiwyg to enable WYSIWYG editing.

Conclusion

@toast-ui/vue-editor is a text editor that we can use for viewing content.

vue-cryptojs lets us add crypto JS to our Vue app.

vue-swatches lets us add the color picker.

vue-json-viewer lets us add a JSON viewer.

v-selectpage lets us add an item selector.