Categories
Top Vue Packages

Top Vue Packages for Displaying Messages, Lazy Loading Images, and Modals

asy 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 displaying messages, lazy loading images, and adding modals.

vue-toastr

vue-toastr is a toast component for Vue apps.

To use it, we run:

npm i vue-toastr

to install it.

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueToastr from "vue-toastr";
Vue.use(VueToastr, {});

Vue.config.productionTip = false;

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

App.vue

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

<script>
export default {
  mounted() {
    this.$toastr.defaultPosition = "toast-top-left";
    this.$toastr.s("<b>hello</b>");
  }
};
</script>

We create a toast by registering a plugin.

Then we use the $toastr property to set the default position and display the toast with the s method.

HTML is supported.

Other options like timeout, styles, etc. can be set.

vue-thin-modal

If we want to add models to our app easily, we can use the vue-thin-modal package to do it.

To install it, we run:

npm i vue-thin-modal

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueThinModal from "vue-thin-modal";
import "vue-thin-modal/dist/vue-thin-modal.css";

Vue.use(VueThinModal);

Vue.config.productionTip = false;

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

App.vue

<template>
  <div>
    <button type="button" @click="open">Open Modal</button>
    <modal name="demo">
      <div class="basic-modal">
        <h1 class="title">Title</h1>
        <button class="button" type="button" @click="close">Close Modal</button>
      </div>
    </modal>
  </div>
</template>

<script>
export default {
  methods: {
    open() {
      this.$modal.push("demo");
    },

    close() {
      this.$modal.pop();
    }
  }
};
</script>

We register the component and import the CSS.

Then we use the modal component to add the modal.

this.$modal.push opens the modal.

The argument is the value of the name prop of modal .

To close it, we call the pop method.

v-lazy-image

v-lazy-image is an image component that loads the image only when it’s shown on the screen.

To use it, we run:

npm i v-lazy-image

Then we can write:

main.js

import Vue from "vue";
import App from "./App.vue";
import { VLazyImagePlugin } from "v-lazy-image";

Vue.use(VLazyImagePlugin);

Vue.config.productionTip = false;

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

App.vue

<template>
  <div>
    <v-lazy-image
      src="http://placekitten.com/200/200"
      src-placeholder="http://placekitten.com/201/201"
    />
  </div>
</template>

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

to use it.

src is the URL of the actual image.

src-placeholder is the URL of the placeholder image.

We can progressively load images.

To do that, we can add transitions effects with CSS.

For instance, we can write:

<template>
  <div>
    <v-lazy-image
      src="http://placekitten.com/200/200"
      src-placeholder="http://placekitten.com/201/201"
    />
  </div>
</template>

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

<style scoped>
.v-lazy-image {
  filter: blur(20px);
  transition: filter 0.7s;
}
.v-lazy-image-loaded {
  filter: blur(0);
}
</style>

We just add transition effects to the v-lazy-image class to add a transition effect when the image loads.

Responsive images are also supported.

vue-flash-message

vue-flash-message is a package that lets us show messages on the screen.

To install it, we run:

npm i vue-flash-message

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueFlashMessage from "vue-flash-message";
Vue.use(VueFlashMessage);

Vue.config.productionTip = false;

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

App.vue

<template>
  <div>
    <flash-message></flash-message>
  </div>
</template>

<script>
export default {
  mounted() {
    this.flash("loaded", "success");
  }
};
</script>

We use the flash-message component to display messages which will be displayed for a few seconds.

We call this.flash to show the message.

The first argument is the content.

The 2nd argument is the type.

We can add the CSS that comes with the package to add styles:

import Vue from "vue";
import App from "./App.vue";
import VueFlashMessage from "vue-flash-message";
import "vue-flash-message/dist/vue-flash-message.min.css";

Vue.use(VueFlashMessage);

Vue.config.productionTip = false;

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

Other kinds of messages include error, warning, and info.

Conclusion

We can use vue-toastr or vue-flash-messag to display messages.

vue-thin-modal is a modal component for Vue apps.

v-lazy-image is a component for lazy loading images.

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.