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

vue3-br

v1.1.5

Published

Tiny package for creating media query in your vue 3 application and use them as boolean values. This package is a successor to vue3-breakpoint which works the same as this package but depends on vuex to provide the results. Vue3-br is self-contained and e

Downloads

33

Readme

vue3-br

Tiny vue 3 plugin for creating media query breakpoints in your vue 3 application and use them as boolean values. This package is a successor to vue3-breakpoint which works the sameway but depends on vuex to provide the results. Vue3-br is self-contained and exposing its breakpoints variables in a simple and reactive way!

Features

  • Simple
  • Reactive
  • Customizable
  • Realtime height change detection
  • Realtime width change detection
  • Boolean-based
  • Vue3-friendly

Installation

Make sure Vue 3 is installed on your machine before any extra steps! Then run the following commands in your existing vue project to add the package.

yarn add vue3-br
#OR
npm install vue3-br

Install as a plugin to your Vue app. In your main.js file:

import { createApp } from "vue";
import { createBr } from "vue3-br";

const app = createApp({});

const br = createBr();

app.use(br);

Now you will be able to use the package accross your app.

Defining Breakpoints

Defining your breakpoints is as simple as passing an object containing your breakpoints to createBr() function in your main.js file. Each breakpoint is a property with an array of one or two number type elements as pixel unit values.

Syntax of the definition object:

  {
    breakpoint1: [min,max],
    breakpoint2: [min,max],
    breakpoint3: [min],
    breakpoint4: [min,max],
    ...
  }

Example (Main.js)

import { createApp } from "vue";
import { createBr } from "vue3-br";

const app = createApp({});

const br = createBr({
  min: [0, 700],
  mid: [701, 1024],
  somewhere: [900, 1024]
  max: [1025],
});

app.use(br);

Using Inside Vue Components

You can use your breakpoints inside vue components as follows:

Using global $br variable,

<template>
  <div class="column items-center justify-center q-gutter-y-md">
    <!-- breakpoints -->
    <div v-if="$br.min">On smaller screen</div>
    <div v-if="$br.mid" :class="`${$br.somewhere ? 'text-red' : 'text-black'}`">
      On Medium screen
    </div>
    <div v-if="$br.max">On Bigger screen!!</div>
  </div>
</template>

<script>
  ...
</script>

With script setup syntax

<template>
  <div class="column items-center justify-center q-gutter-y-md">
    <!-- breakpoints -->
    <div v-if="min">On smaller screen</div>
    <div v-if="mid" :class="`${somewhere ? 'text-red' : 'text-black'}`">
      On Medium screen
    </div>
    <div v-if="max">On Bigger screen!!</div>
  </div>
</template>

<script setup>
  import { br } from "vue3-br";

  const { min, mid, max, somewhere } = br;
</script>

With setup function syntax

<template>
  <div class="column items-center justify-center q-gutter-y-md">
    <!-- breakpoints -->
    <div v-if="min">On smaller screen</div>
    <div v-if="mid" :class="`${somewhere ? 'text-red' : 'text-black'}`">
      On Medium screen
    </div>
    <div v-if="max">On Bigger screen!!</div>
  </div>
</template>

<script>
  import { br } from "vue3-br";

  export default {
    setup() {
      const { min, mid, max, somewhere } = br;

      return { min, mid, max, somewhere };
    },
  };
</script>

Working With Height

vue3-br is capable of tracking the device height. We work with height the sameway we work with width but the only difference is in naming our breakpoints in the definition object. We suffix our names with H(capital H) to tell vue3-br that the breakpoint should track the device height.

As follows,

import { createApp } from "vue";
import { createBr } from "vue3-br";

const app = createApp({});

const br = createBr({
  minH: [0, 700],
  midH: [701, 1024],
  somewhereH: [900, 1024]
  maxH: [1025],
});

app.use(br);

Default Breakpoints

vue3-br comes with default breakpoints but you are neither tied to them nor unable to redefine them. You can use them, redefine them or even create the new one.

Here is a default definition,

const defns = {
  min: [0, 699],
  mid: [700, 1023],
  mode: [1024, 1299],
  max: [1300],
  xminH: [499],
  minH: [500, 699],
  midH: [700, 849],
  modeH: [850, 999],
  maxH: [1000],
};