Giter VIP home page Giter VIP logo

vue-burger's Introduction

Vue Burger

Vue.js plugin for Tasty CSS-animated hamburgers

About

Vue Burger is a Vue component/plugin that is a wrapper around Tasty CSS-animated hamburgers, wellknown css library for hamburger icons.

Installation

npm install vue-burger
# or
yarn add vue-burger

Initialization

import App from './App.vue';
import VBurger from 'vue-burger';
import Vue from 'vue';

Vue.use(VBurger);

new Vue({
  render: h => h(App),
}).$mount('#app');

VBurger component can be used in without plugin initialization:

<template>
  <v-burger/>
</template>

<script>
import { VBurger } from 'vue-burger';

export default { 
  component: {
    VBurger
  }
}
</script>

Usage

<template>
  <v-burger type="arrow" />
</template>

Props

type

  • type: String,
  • default: 'boring'

burgerStyle

  • type: Object,
  • default: {}

ariaLabel

  • type: String,
  • default: 'Menu'

ariaControls

  • type: String,
  • default: 'navigation'

tabIndex

  • type: Number,
  • default: 0

Types of burger

Available types are:

  • 3dx,
  • 3dx-r,
  • 3dy,
  • 3dy-r,
  • 3dxy,
  • 3dxy-r,
  • arrow,
  • arrow-r,
  • arrowalt,
  • arrowalt-r,
  • arrowturn,
  • arrowturn-r,
  • boring,
  • collapse,
  • collapse-r,
  • elastic,
  • elastic-r,
  • emphatic,
  • emphatic-r,
  • minus,
  • slider,
  • slider-r,
  • spring,
  • spring-r,
  • stand,
  • stand-r,
  • spin,
  • spin-r,
  • squeeze,
  • vortex,
  • vortex-r

You can see all the types in actions on official documentation for Hamburgers.

Styling the burger

For styling regular CSS variables are used. Variables are defined in burgerStyle prop. Available variables:

Variable Description Default value
--padding padding of the hamburger box 15px
--bg-color hamburger background color transparent
--box-width hamburger box width 40px
--box-height hamburger box height 24px
--layer-width width of each hamburger layer 40px
--layer-height height of each hamburger layer 4px
--layer-bg-color layer background color #000000
--active-layer-bg-color layer background color when in active state --layer-bg-color

Example:

<template>
  <v-burger 
    :type="arrow" 
    :burgerStyle="burgerStyle">
  </v-burger>
</template>

<script>
  export default {
    data() {
      return {
        burgerStyle: {
          '--padding': '10px',
          '--layer-bg-color': 'yellow',
          '--active-layer-bg-color': '#ABABAB',
          '--layer-width': '20px',
        }
      }
    }
  }
</script>

Slots

Burger has one named slot for setting label for accessability as suggested by Hamburgers author.

Slot Description
label label for a11y

Example:

  <v-burger>
    <template v-slot:label>
      <span class="hamburger-label">Menu</span>
    </template>
  </v-burger>

Events

Burger components emits updated event that exposes the active state. It fires after the burger button is clicked. Check the example for usage.

Event Description Params
updated fired after the burger button is clicked active (Boolean)

Example with sync modifier:

  <v-burger 
    @update="isActive = $emit
  </v-burger>

Development

# Running examples
npm run serve

# Running tests
npm run test

# Running build
npm run build

Contributing

All contributions are welcome.

License

MIT @ Zdravko Ćurić (zcuric)

Icon made by Freepik from flaticon.

vue-burger's People

Contributors

chrisrowe avatar zcuric avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jerdnica

vue-burger's Issues

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.