npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

screen-size-vue

v1.0.2

Published

This is A Vue Package helps you write conditional code based on screen size, or get the screen size value

Downloads

199

Readme

screen-size-vue

This is A Vue Package helps you write conditional code based on screen size, or get the screen size value

Install

Install the npm package:

npm install --save screen-size-vue
#OR
yarn add screen-size-vue

Add the Vue plugin in your main.js:

import Vue from 'vue'
import ScreenSize from 'screen-size-vue'

Vue.use(ScreenSize)

Example

This shows a quick example of displaying your screen width, screen height and current breakpoint

<template>
  <div id="app">
    <h1>{{ $data.$screenSize.width }}px / {{ $data.$screenSize.height }}px</h1>
    <h1>{{ $data.$screenSize.breakPoint }}</h1>
  </div>
</template>

Getters

  1. $data.$screenSize.breakPoint is used to get the quick current breakpoint of the screen

| Name | Size | property | | ----------- | ------- | -------- | | Extra small | <576px | xs | | Small | ≥576px | s | | Medium | ≥768px | m | | Large | ≥992px | l | | Large | ≥1200px | xl |

  1. $data.$screenSize.width its is used to get the width of the screen in pixels

  2. $data.$screenSize.height its is used to get the height of the screen in pixels

Methods

  1. $VHToPX() - This is helpful for iOS devices, that overlaps when using VH, this can be replaced with this

eg

<template>
  <div :style="`height: ${$VHToPX(100)}`">
    <h1>{{ $data.$screenSize.width }}px / {{ $data.$screenSize.height }}px</h1>
    <h1>{{ $data.$screenSize.breakPoint }}</h1>
  </div>
</template>

This shows an advanced example of running conditional actions based on the screen size

<template>
  <div id="app">
    <h1>{{ $data.$screenSize.width }}px / {{ $data.$screenSize.height }}px</h1>
    <h1 :style="{color}">{{ $data.$screenSize.breakPoint.toUpperCase() }} - {{ text }}</h1>
  </div>
</template>

<script>
export default {
  name: 'App',
  computed: {
    color () {
      if (this.$data.$screenSize.breakPoint == this.$data.$breakPoint.xs) {
        return 'red'
      } else if (this.$data.$screenSize.breakPoint === this.$data.$breakPoint.s) {
        return 'blue'
      } else if (this.$data.$screenSize.breakPoint === this.$data.$breakPoint.m) {
        return 'orange'
      } else if (this.$data.$screenSize.breakPoint === this.$data.$breakPoint.l) {
        return 'yellowgreen'
      } else if (this.$data.$screenSize.breakPoint === this.$data.$breakPoint.xl) {
        return 'darkmagenta'
      }
      return 'darkmagenta'
    },
    text () {
      if (this.$data.$screenSize.breakPoint == this.$data.$breakPoint.xs) {
        return 'Extra Small Screen eg Mobile Phones(Portrait Mode)'
      } else if (this.$data.$screenSize.breakPoint === this.$data.$breakPoint.s) {
        return 'Small Screen eg Mobile Phones(Landscape Mode)'
      } else if (this.$data.$screenSize.breakPoint === this.$data.$breakPoint.m) {
        return 'Medium Screen eg Tablet'
      } else if (this.$data.$screenSize.breakPoint === this.$data.$breakPoint.l) {
        return 'Large Screen eg Laptop, PC'
      } else if (this.$data.$screenSize.breakPoint === this.$data.$breakPoint.xl) {
        return 'Extra Large Screen eg Laptop, PC'
      }
      return 'Extra Large Screen eg Laptop, PC'
    }
  }
}
</script>

Follow on Twitter @mrflamez_

License

MIT © kingflamez