1.0.2 • Published 4 years ago

nuxt-bulma-breakpoints v1.0.2

Weekly downloads
18
License
MIT
Repository
github
Last release
4 years ago

nuxt-bulma-breakpoints

Resize observer breakpoints with Nuxt.js module. Bulma edition

Setup

  1. Add nuxt-bulma-breakpoints dependency to your project
yarn add nuxt-bulma-breakpoints # or npm install nuxt-breakpoints
  1. Add nuxt-bulma-breakpoints to the modules section of nuxt.config.js
{
  modules: [
    // Simple usage
    'nuxt-breakpoints',

    // With options
    ['nuxt-breakpoints', { /* module options */ }]
  ]

  // Another way to use options
  breakpoints: {
    // default options
    tablet: 769,
    desktop: 1024,
    widescreen: 1216,
    fullhd: 1408,
    options: {
      polyfill: true,
      throttle: 200
    }
  }
}

Usage

// components.vue
export default {
  computed: {
    isMobile() {
      return this.$breakpoints.mobile
    },
    untilWidescreen(){
      return this.$breakpoints.untilWidescreen
    }
    current() {
      return this.$breakpoints.current
    }
  }
}

Breakpoints and helpers

HelperNote
mobilewidth < 769px (tablet)
tabletwidth >= 769px (tablet)
tabletOnlywidth >= 769px (tablet) && width < 1024 (desktop)
touchwidth < 1024px (desktop)
desktopwidth >= 1024px (desktop)
desktopOnlywidth >= 1024px (desktop) && width < 1216px (widescreen)
untilWidescreenwidth < 1216px (widescreen)
widescreenwidth >= 1216px (widescreen)
widescreenOnlywidth >= 1216px (widescreen) && width < 1408px (fullhd)
untilFullhdwidth < 1408px (fullhd)
fullhdwidth >= 1408px (fullhd)

Options

PropertyTypeDefault
mobilenonenone
tabletnumber769
desktopnumber1024
widescreennumber1216
fullhdnumber1408
optionsobject{ polyfill: true, throttle: 200 }

Note: polyfill default by true, which means auto-import resize-observer-polyfill when the browser doesn't support ResizeObserver more information below, throttle will slow down when Window has resizing trigger speed.

Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using yarn dev or npm run dev

Ref

Nuxt.js

MDN - ResizeObserver

ResizeObserver Polyfill

License

MIT License

Copyright (c) Steven Ho shockshocksoul@gmail.com