Categories
Top Vue Packages

Top Vue Packages for Watching Visibility, Embed Vimeo Videos, 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 watching visibility, displaying confetti, toasts, focus trap and embed Vimeo videos.

v-visibility-change

We can use v-visibility-change to watch for visibility changes in our elements.

To use it, we run:

npm i vue-visibility-change

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import visibility from "vue-visibility-change";

Vue.use(visibility);

visibility.change((evt, hidden) => {
  console.log(evt, hidden);
});

Vue.config.productionTip = false;

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

App.vue

<template>
  <div>
    <div v-visibility-change="visibilityChange" v-for="n in 30" :key="n">item {{n}}</div>
  </div>
</template>
<script>
export default {
  methods: {
    visibilityChange(evt, hidden) {
      console.log(hidden);
    }
  }
};
</script>

We have the v-visibility directive that we pass a handler method into that runs when visibility of an element changes.

Also, we have:

visibility.change((evt, hidden) => {
  console.log(evt, hidden);
});

to watch for visibility changes.

Vue wrapper for Vimeo Embed Player

vue-vimeo-player lets us embed videos from Vimeo in our Vue app.

We install it by running:

npm i vue-vimeo-player

Then we can use it by writing:

<template>
  <div>
    <vimeo-player ref="player" :video-id="videoID"/>
  </div>
</template>

<script>
import { vueVimeoPlayer } from "vue-vimeo-player";

export default {
  data() {
    return {
      videoID: 420233198
    };
  },
  components: { vueVimeoPlayer }
};
</script>

We add the vimeo-player component with the video-id prop to set the Vimeo video ID.

Now we see the Vimeo player with the video.

We can set autoplay, player width and height, looping, and control options.

vue-confetti

We can use vue-confetti to display animated confetti in our Vue app.

To use it, we run:

npm i vue-confetti

to install it.

Then we can use it by writing:

<template>
  <div>
    <main>
      <button @click="start">Start</button>
      <button @click="stop">Stop</button>
      <button @click="love">hearts</button>
    </main>
  </div>
</template>

<script>
import Vue from "vue";
import VueConfetti from "vue-confetti";

Vue.use(VueConfetti);

export default {
  methods: {
    start() {
      this.$confetti.start();
    },

    stop() {
      this.$confetti.stop();
    },

    love() {
      this.$confetti.update({
        particles: [
          {
            type: "heart"
          },
          {
            type: "circle"
          }
        ],
        defaultColors: ["red", "pink", "#ba0000"]
      });
    }
  }
};
</script>

We use the this.$cofetti.start method to show confetti.

this.$confetti.stop stops the confetti.

And this.$confetti.update updates the confetti while we’re showing it.

vue2-toast

vue2-toast lets us add toasts to our Vue app.

To use it, we run:

npm i vue2-toast

to install it.

Then we write:

main.js

import Vue from "vue";
import App from "./App.vue";
import "vue2-toast/lib/toast.css";
import Toast from "vue2-toast";
Vue.use(Toast);

Vue.config.productionTip = false;

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

App.vue

<template>
  <div id="app">
    <button @click="openTop()">top</button>
    <button @click="openCenter()">center</button>
    <button @click="openBottom()">bottom</button>
    <button @click="openLoading()">loading</button>
  </div>
</template>

<script>
export default {
  methods: {
    openTop() {
      this.$toast.top("top");
    },
    openCenter() {
      this.$toast.center("center");
    },
    openBottom() {
      this.$toast("bottom");
    },
    openLoading() {
      this.$loading("loading...");
      setTimeout(() =>{
        this.closeLoading();
      }, 2000);
    },
    closeLoading() {
      this.$loading.close();
    }
  }
};
</script>

to use it.

We register the component and import the CSS.

We can use this.$toast to show toasts in various styles.

top to show toast at the top.

center shows toast ar the center.

openLoading shows a toast with a loading indicator.

close close the loading indicator.

We can change the duration, type of toast, and styling options like word wrap and width.

focus-trap-vue

focus-trap-vue lets us keep focus on the element inside the provided component.

We can install it by running:

npm i focus-trap-vue

Then we can use it by writing:

<template>
  <div id="app">
    <focus-trap v-model="isActive">
      <input ref="nameInput">
    </focus-trap>
  </div>
</template>

<script>
import { FocusTrap } from "focus-trap-vue";

export default {
  components: {
    FocusTrap
  },
  data() {
    return {
      isActive: true
    };
  }
};
</script>

We use the focus-trap component to set focus on the input inside.

isActive indicates that the focus is a trap is active if it’s true .

Conclusion

v-visibility-change is a plugin to watch the visibility status of an element.

Vue wrapper for Vimeo Embed Player lets us embed Vimeo videos to our app.

vue-confetti is a fun plugin to lets us display confetti in our Vue app.

vue2-toast lets us display toasts with ease.

focus-trap-vue lets us focus on an element.

Categories
Top Vue Packages

Top Vue Packages for Adding Tables, Checkboxes, and Manipulating Text

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 tables, checkboxes, and manipulating text.

Vuetable-2

Vuetable-2 is an easy to use table component that can get data directly from an API and display it.

It’s made for Vue apps.

To use it, we run:

npm i vuetable-2

to install it.

Then we can write:

<template>
  <div>
    <vuetable
      ref="vuetable"
      api-url="https://vuetable.ratiw.net/api/users"
      :fields="['name', 'nickname', 'salary']"
    ></vuetable>
  </div>
</template>

<script>
import Vuetable from "vuetable-2/src/components/Vuetable";

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

to use it.

api-url is the URL with the data.

fields is the fields to display.

The items are within the data property of the returned JSON.

fields pick the fields of the entries to display.

vue-table-component

vue-table-component is another handy table component for Vue apps.

To use it, we run:

npm i vue-table-component moment

to install and moment, which is a dependency of this package.

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import { TableComponent, TableColumn } from "vue-table-component";

Vue.component("table-component", TableComponent);
Vue.component("table-column", TableColumn);
Vue.config.productionTip = false;

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

App.vue

<template>
  <div>
    <table-component :data="data" sort-by="songs" sort-order="asc">
      <table-column show="firstName" label="First name"></table-column>
      <table-column show="lastName" label="Last name"></table-column>
    </table-component>
  </div>
</template>

<script>
export default {
  data() {
    return {
      data: [
        {
          firstName: "james",
          lastName: "smith"
        },
        {
          firstName: "alex",
          lastName: "wong"
        }
      ]
    };
  }
};
</script>

We use the built in components to create the table.

table-component lets us populate the data.

table-column display the entries.

Now we have a table with sorting and filtering.

show is the property name of the entry to show.

label is the heading for the column.

vue-nl2br

vue-nl2br turns new line characters to br elements.

To use it, we run:

npm i vue-nl2br

to install it.

Then we write:

<template>
  <nl2br tag="p" :text="`foonbar`"/>
</template>

<script>
import Nl2br from "vue-nl2br";

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

to use the nl2br component.

tag is the tag of the element to render.

text is the text that we want to display.

pretty-checkbox-vue

pretty-checkbox-vue is a package that lets us add a nice looking checkbox into our Vue app.

To use it, we run:

npm i pretty-checkbox-vue

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import PrettyCheckbox from "pretty-checkbox-vue";

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

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

App.vue

<template>
  <div>
    <p-check name="check" color="success" v-model="check">check</p-check>
  </div>
</template>

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

We use the p-check component to add the checkbox.

v-model binds the checked value to the checkbox.

We can style the checkbox and set hover and toggle states and more.

vue-clamp

vue-clamp is a clamp component to truncate text.

To use it, we run:

npm i vue-clamp

Then we can use it by writing:

<template>
  <v-clamp autoresize :max-lines="1">{{ text }}</v-clamp>
</template>

<script>
import VClamp from "vue-clamp";

export default {
  components: {
    VClamp
  },
  data() {
    return {
      text:
        "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent mollis lorem in facilisis lacinia. Fusce tempor nisl non tempor sagittis. Mauris tempor massa sit amet urna dignissim, id scelerisque leo eleifend. Integer consectetur orci nisl, sit amet lobortis risus ultricies et. Suspendisse semper condimentum libero, vitae aliquet nisi rhoncus a. Nulla consectetur tincidunt auctor. Praesent consequat nisl eget eros fermentum auctor. Sed pretium augue at sapien maximus eleifend. In in aliquam felis, vitae mollis nunc. Sed id tellus justo. Nam justo turpis, ultrices ut sagittis ac, accumsan vel augue. Maecenas pulvinar ultricies ipsum sed consectetur. Donec congue nulla eget sapien tempus, vitae placerat urna imperdiet. Pellentesque justo nisl, ultricies vel dignissim nec, finibus ornare dolor."
    };
  }
};
</script>

We import the component and set the max-line prop to set the maximum number of lines to display.

autoresize makes the clamped text resize automatically.

Conclusion

vue-clamp is a component to truncate text.

vue-nl2br lets us convert line breaks to br elements.

Vuetable-2 and vue-table-component are table components.

pretty-checkbox-vue is an easy to use checkbox.

Categories
Top Vue Packages

Top Vue Packages for Adding Text Editors, Animated Numbers, and Tag Input

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 adding text editors, animated numbers, and tag input.

@ckeditor/ckeditor5-vue

This package is the Vue version of CKEditor.

We can install it by running:

npm install --save @ckeditor/ckeditor5-vue @ckeditor/ckeditor5-build-classic

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import CKEditor from "@ckeditor/ckeditor5-vue";

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

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

App.vue

<template>
  <div id="app">
    <ckeditor :editor="editor" v-model="editorData" :config="editorConfig"></ckeditor>
  </div>
</template>

<script>
import ClassicEditor from "@ckeditor/ckeditor5-build-classic";

export default {
  name: "app",
  data() {
    return {
      editor: ClassicEditor,
      editorData: "<p>Content of the editor.</p>",
      editorConfig: {}
    };
  }
};
</script>

The ckeditor component binds to the editorData , which contains HTML content.

By default, the editor has buttons for bold, italic, formatting, links, images, and lists.

We can add plugins as we wish.

This can be done bu building from source.

@braid/vue-formulate

@braid/vue-formulate is a package that lets us add form elements and validation to a form.

To install it, we run:

npm install @braid/vue-formulate

Then we can use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VueFormulate from "@braid/vue-formulate";

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

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

App.vue

<template>
  <div id="app">
    <FormulateInput type="text" v-model="name"/>
    <p>{{name}}</p>
  </div>
</template>

<script>
export default {
  name: "app",
  data() {
    return {
      name: ""
    };
  }
};
</script>

We add an input by using the FormulateInput component.

v-model binds to the name state.

The type can be any type that a regular form input element takes like text and email .

We can add validation by writing:

<template>
  <div id="app">
    <FormulateInput type="email" v-model="email" validation="required|email"/>
    <p>{{email}}</p>
  </div>
</template>

<script>
export default {
  name: "app",
  data() {
    return {
      email: ""
    };
  }
};
</script>

We just add the validation prop with the rules we want to include.

Now we see validation messages when we didn’t type in an email.

It also supports binding a model to multiple inputs.

We can have multiple inputs that bind to one value.

For example, we can write:

<template>
  <div id="app">
    <FormulateInput
      type="text"
      label="favorite fruit"
      validation="not:apple"
      validation-name="favorite fruit"
      error-behavior="live"
      v-model="fruit"
    />
    <FormulateInput
      type="radio"
      v-model="fruit"
      error-behavior="live"
      validation="in:apple,orange"
      :options="{ apple: 'Apple', orange: 'Orange' }"
    />
    <p>{{fruit}}</p>
  </div>
</template>

<script>
export default {
  name: "app",
  data() {
    return {
      fruit: ""
    };
  }
};
</script>

There are many things that we can do with VueFormulate for building forms.

animated-number-vue

animated-number-vue is a Vue plugin that lets us add an animated number to a Vue app.

To use it, we install it by writing:

npm i animated-number-vue

Then we can use it by writing:

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

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

We add the animated-number component to display the number by animating it into the screen.

The formatValue prop lets us format the number the way we like.

The duration is the length of the animation.

It also takes the updare ,run , begin , and complete props, which are all function valued.

They’re run during those phases of the animation.

@frk/vue-tags-input

@frk/vue-tags-input is an input component for letting us add tags.

To install it, we run:

npm i @frk/vue-tags-input

Then we can use it by writing:

<template>
  <div>
    <vue-tags-input v-model="value" :tags="tags" @tags-changed="newTags => tags = newTags"/>
    <p>{{tags}}</p>
  </div>
</template>

<script>
import VueTagsInput from "@frk/vue-tags-input";

export default {
  components: {
    VueTagsInput
  },
  data() {
    return {
      value: "",
      tags: []
    };
  }
};
</script>

We have the vue-tags-input component from the package.

v-model binds to the tag being entered.

tags has the tags entered.

The tags event is emitted, and we can use that to assign the entered tags to the value.

Conclusion

@ckeditor/ckeditor5-vue lets us add a rich text editor that’s customizable.

animated-number-vue lets us create a number display that are animated.

@frk/vue-tags-input is a useful tags input.

Categories
Top Vue Packages

Top Vue Packages for Truncating Text, and Display Dialogs and Modals

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 dialog boxes, select items from a tree, and display truncated text.

vue-thin-modal

vue-thin-modal is a simple modal component that we can use in our Vue app.

To use it, we run:

npm i vue-thin-modal

to install it.

Then we write:

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](http://twitter.com/click "Twitter profile for @click")="open">Open Modal</button>
    <modal name="hello">
      <div class="basic-modal">
        <h1 class="title">hello</h1>
        <button class="button" type="button" @click="close">Close Modal</button>
      </div>
    </modal>
  </div>
</template>

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

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

We import the component and its CSS.

Then we display the modal with the modal component.

The content is in between the tags.

We call this.$modal.push to display it. The argument is the value of the name prop of the modal.

And we call this.$modal.pop to close it.

vue-clamp

vue-clamp is a simple directive for truncating text.

To use it, we run:

npm i vue-clamp

to install it.

Then we write:

<template>
  <v-clamp autoresize :max-lines="1">{{ text }}</v-clamp>
</template>

<script>
import VClamp from "vue-clamp";

export default {
  components: {
    VClamp
  },
  data() {
    return {
      text: `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis nibh neque, dignissim sit amet libero at, aliquet tempus urna. Aenean luctus accumsan feugiat. Nunc dui purus, imperdiet eu suscipit et, convallis vehicula nulla. Quisque nec nisi elementum, tincidunt est eu, sollicitudin enim. Sed fermentum massa urna, at malesuada leo egestas vitae. Aenean vulputate sem libero, nec sagittis arcu varius et. Donec et felis augue. Nunc euismod gravida nibh, id volutpat mauris placerat nec. Integer sit amet purus non ligula ullamcorper tempor in at massa. Donec pellentesque convallis pharetra.`
    };
  }
};
</script>

to truncate our text.

We use the v-clamp component with the autoresize prop to make it resize automatically.

max-line sets the max number of lines to display.

vue-tree-halower

vue-tree-halower is an input component where we can choose the value from a tree structure.

To use it, we can run:

npm i vue-tree-halower

to install it.

Then we can write:

main.js

import Vue from "vue";
import App from "./App.vue";
import { VTree, VSelectTree } from "vue-tree-halower";
import "vue-tree-halower/dist/halower-tree.min.css";
Vue.use(VTree);
Vue.use(VSelectTree);
Vue.config.productionTip = false;

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

App.vue

<template>
  <div>
    <v-select-tree :data="treeData" v-model="selected"/>
  </div>
</template>

<script>
export default {
  data() {
    return {
      treeData: [
        {
          title: "fruit",
          expanded: true,
          children: [
            {
              title: "apple",
              expanded: true,
              children: [
                {
                  title: "mcintosh"
                },
                {
                  title: "golden delicious"
                }
              ]
            },
            {
              title: "drink",
              children: [
                {
                  title: "<span style='color: red'>beer</span>"
                },
                {
                  title: "<span style='color: green'>wine</span>"
                }
              ]
            }
          ]
        }
      ],
      selected: []
    };
  }
};
</script>

We use the v-select-item component to add the component.

Then we set the data prop to tree data to populate the choices.

title is shown as the name of the node.

children are children of the node.

expanded indicates that the tree node is expanded if it’s true.

v-model binds to the select choices.

It includes many other choices or customizations.

Vuejs Dialog Plugin

Vuejs Dialog Plugin is a plugin that provides us with a promised based dialog box.

To use it, we run:

npm i vuejs-dialog

Then we use it by writing:

main.js

import Vue from "vue";
import App from "./App.vue";
import VuejsDialog from "vuejs-dialog";
import "vuejs-dialog/dist/vuejs-dialog.min.css";
Vue.use(VuejsDialog);
Vue.config.productionTip = false;

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

App.vue

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

<script>
export default {
  async mounted() {
    const dialog = this.$dialog.alert("alert");
    console.log("closed");
  }
};
</script>

We import the plugin and styles.

Then we can call this.$dialog.alert to display the dialog.

Conclusion

vue-thin-modal lets us add a simple modal to our Vue app.

vue-clamp is a component that lets us display truncated text.

vue-tree-halower is a select input that lets us select items from a tree.

Vuejs Dialog Plugin is a promise based dialog plugin.

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.