Giter Club home page Giter Club logo

vue-identify-network's Introduction

Vue Identify Network

NPM version NPM downloads CircleCI

  • Identify the Internet Speed ⚡️ your users have.

  • Demo Link -> Click Here

  • This is on GitHub so let me know if I've b0rked it somewhere, give me a star ⭐ if you like it 🍻

Install

yarn add vue-identify-network

CDN: UNPKG | jsDelivr (available as window.VueIdentifyNetwork)

Usage

<template>
  <detected-speed>
    <span slot="unknown">
      REEE! Unable to identify your network type.
    </span>
    <span slot="slow">
      <img src="cat.gif" alt="you got slow internet">
    </span>
    <span slot="fast">
      <video width="400" controls>
        <source src="mov_bbb.mp4" type="video/mp4">
        <source src="mov_bbb.ogg" type="video/ogg">
        Your browser does not support HTML5 video.
      </video>
    </span>
  </detected-speed>
</template>

<script>
import DetectedSpeed from 'vue-identify-network';

export default {
  components: {
    DetectedSpeed,
  },
};
</script>

API

Slots

  • unknown: The slot to show when we are unable to identify network type (navigator.connection.effectiveType === "Unknown")
  • slow: The slot to show when internet is slow (navigator.connection.effectiveType === "2g")
  • fast: The slot to show when internet is fast (navigator.connection.effectiveType !== "2g")

Props

  • unknownClass: Add your own classes to the div
  • slowClass: Add your own classes to the div
  • fastClass: Add your own classes to the div

Events

  • network-type<type>: Emitted after network type is identified
  • network-speed<downlink>: Emitted after network speed is identified
<detected-speed @network-type="handleNetworkIdentified" @network-speed="handleNetworkSpeed"></detected-speed>
function handleNetworkIdentified(type) {
  console.log('connection type: ', type);
}
function handleNetworkSpeed(speed) {
  console.log('downlink: ', speed);
}

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

vue-identify-network © Vinayak, Released under the MIT License.
Authored and maintained by Vinayak Kulkarni with help from contributors (list).

vinayak.pw · GitHub @vinayakkulkarni · Twitter @_vinayak_k

vue-identify-network's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar mikekidder avatar vinayakkulkarni avatar

Watchers

 avatar  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.