Categories
Top Vue Packages

Top Vue Packages for Adding a JSON Viewer, Image Cropper, Date Picker, and

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 JSON viewer, cropper, date picker, and notifications.

vue-json-tree-view

vue-json-tree-view is a nice JSON data viewer.

To use it, we run:

npm i vue-json-tree-view

to install it.

Then we can write:

<template>
  <div>
    <tree-view :data="jsonSource" :options="{ maxDepth: 3 }"></tree-view>
  </div>
</template>

<script>
export default {
  data() {
    return {
      jsonSource: {
        foo: {
          bar: 1
        },
        baz: [1, 2, 3]
      }
    };
  }
};
</script>

to display the JSON on the screen.

We used the tree-view component to display the jsonSource object on the screen.

maxDepth is the maximum depth we display expanded.

The component emits a change-data emit which we can listen to.

Custom styles can also be applied.

VueCtkDateTimePicker

VueCtkDateTimePicker is an easy to use date and time picker for Vue apps.

To use it, we run:

npm i vue-ctk-date-time-picker

to install it.

Then we can write:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueCtkDateTimePicker from "vue-ctk-date-time-picker";
import "vue-ctk-date-time-picker/dist/vue-ctk-date-time-picker.css";

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

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

App.vue

<template>
  <div>
    <VueCtkDateTimePicker v-model="value"/>
    <p>{{value}}</p>
  </div>
</template>

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

to use it.

We import the VueCtkDateTimePicker component and used it in our code.

Also, we imported the component’s CSS.

v-model binds the selected date and time to the value state.

It also has a dark mode.

The format of the picker can also change.

Other things can also be changed like the first day of the week, input size, shortcut keys, disabling dates and hours, and much more.

vue-croppa

vue-croppa lets us add an image cropper to our Vue app.

We can install it by running:

npm i vue-croppa

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import Croppa from "vue-croppa";
import "vue-croppa/dist/vue-croppa.css";

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

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

App.vue

<template>
  <div>
    <croppa v-model="myCroppa"></croppa>
  </div>
</template>

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

We import the CSS and component so we can use it in our code.

Now we’ll get an image upload placeholder where we can choose the image to manipulate.

There are many other things we can do.

For instance, we can change zoom settings, placeholders, initial images, and more.

It also emits events when a file is chosen, or when there are issues with the file like the file size being too large.

The cropper can also be used programmatically.

vue-snotify

vue-snotify is a notification library for Vue apps.

To use it, we can run:

npm i vue-snotify

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import Snotify from "vue-snotify";
Vue.use(Snotify);
Vue.config.productionTip = false;

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

App.vue

<template>
  <div>
    <vue-snotify></vue-snotify>
  </div>
</template>

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

We have the vue-snotify component to display the notification.

Then we display it with this.$nitify.success .

There are also options we can change.

For instance, we can change the timeout, show a progress bar, and more.

So we can write:

<template>
  <div>
    <vue-snotify></vue-snotify>
  </div>
</template>

<script>
export default {
  mounted() {
    this.$snotify.success("success", {
      timeout: 2000,
      showProgressBar: false,
      closeOnClick: false,
      pauseOnHover: true
    });
  }
};
</script>

We can also write HTML:

<template>
  <div>
    <vue-snotify></vue-snotify>
  </div>
</template>

<script>
export default {
  mounted() {
    this.$snotify.html(`<div><b>bold</b></div>`, {
      timeout: 5000,
      showProgressBar: true,
      closeOnClick: false,
      pauseOnHover: true
    });
  }
};
</script>

Conclusion

vue-json-tree-view is a useful JSON viewer for Vue apps.

VueCtkDateTimePicker lets us add a date time picker.

vue-croppa lets us add an image cropper.

vue-snotify lets us add notifications to our Vue app.

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.