Coder Social home page Coder Social logo

joaquin6 / v-offline Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vinayakkulkarni/v-offline

0.0 2.0 0.0 207 KB

:electric_plug: Simple VueJS component to detect offline & online changes.

Home Page: https://we-online.site

License: MIT License

JavaScript 74.16% Vue 25.84%

v-offline's Introduction

V-Offline โšก npm version gzip size Build Status npm downloads

  • Detect offline & online events for your vue app.

  • This is on GitHub so let me know if I've b0rked it somewhere, give me a star โญ if you like it ๐Ÿป

  • Demo here -> ๐Ÿ’ฏ Webpackbin Link

Requirements

โœ… Install ๐Ÿ‘Œ

npm install v-offline
# or
yarn add v-offline

CDN: UNPKG | jsDelivr

โœ… Usage ๐ŸŽ“

Register the component globally:

Vue.component('detectNetwork', require('v-offline'));

Or use locally

import detectNetwork from 'v-offline';

โœ… Example 1 ๐Ÿ€

<detect-network v-on:detected-condition="detected">
  <div slot="online">Your Online Content!</div>
  <div slot="offline">Your Offline Content!</div>
</detect-network>
Vue.component('example-component', {
  data() {
    return {
      state: null,
    };
  },
  methods: {
    detected(e) {
      this.state = e;
    },
  },
});

โœ… Example 2 ๐Ÿ€

<detect-network>
  <div slot="online">Your Online Content!</div>
  <div slot="offline">Your Offline Content!</div>
</detect-network>

โœ… ๐Ÿ“– Props

Name Type Required? Description
onlineClass String No Styling the div which you want to give if you're online.
offlineClass String No Styling the div which you want to give if you're offline.

โœ… ๐Ÿ‘‚ Events

Name Description
detected-condition Emits an Boolean value which can be used for multiple purposes in your app.

NPM :octocat:

NPM

v-offline's People

Contributors

vinayakkulkarni avatar probil avatar iyongbudiarso avatar

Watchers

James Cloos avatar Joaquin Briceno avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.