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

vue-badger-accordion

v2.0.2

Published

Badger-Accordion Component for Vue

Downloads

2,221

Readme

vue-badger-accordion

Badger-Accordion Component for Vue 2.0

This package is a wrapper for the badger-accordion made by Stuart Nelson

Badger-Accordion-Repository:

https://github.com/stuartjnelson/badger-accordion


Installation

Install package

npm install vue-badger-accordion --save

Setup

import { BadgerAccordion, BadgerAccordionItem } from 'vue-badger-accordion'

Implement globally

Vue.component('BadgerAccordion', BadgerAccordion)
Vue.component('BadgerAccordionItem', BadgerAccordionItem)

Implement locally

export default {
  components: {
    BadgerAccordion,
    BadgerAccordionItem
  }
}

Example

<badger-accordion>
  <badger-accordion-item>
    <template slot="header">First Accordion Header</template>
    <template slot="content">First Accordion Content</template>
  </badger-accordion-item>

  <badger-accordion-item>
    <template slot="header">Second Accordion Header</template>
    <template slot="content">Second Accordion Content</template>
  </badger-accordion-item>
</badger-accordion>

Note: You can replace the template-tag with all regular html-tags, just remember to add the slot-parameter.

Options

Options can be implemented by component property "option".

<badger-accordion :options="{...}">
  ...
</badger-accordion>

A list of available options could be found in the badger-accordion repository

https://github.com/stuartjnelson/badger-accordion#options

Events

You can handle open/close-Events for each AccordionItem

<badger-accordion>
  <badger-accordion-item @open="onOpenItem" @close="onCloseItem">
    <template slot="header">First Accordion Header</template>
    <template slot="content">First Accordion Content</template>
  </badger-accordion-item>
</badger-accordion>
methods: {
    ...
    onOpenItem() {
        // Item opened
    },
    onCloseItem() {
        // Item closed
    }
}

Thanks to elbojoloco for that change.

Custom state-indicators/-icons

By default the Accordion-Header shows an state-indicator (+/-). You can easily disable or replace them with images or your favorite icon-font by set the icon-property.

Set Icons - Basic

with font-library e.g. font-awesome

<badger-accordion :icons="{opened: '<i class="fas fa-chevron-down"></i>',
closed: '<i class="fas fa-chevron-up"></i>'}">

with images

<badger-accordion :icons="{opened: '<img src="opened.png" />', closed: '<img
  src="closed.png"
/>'}">

Set Icons - Advanced

Sometimes you may want greater control of your the state icon renders. In this case you can pass a vue component in directly to the badger accordion:

const MyComponent = {
  template: `
        <span class="my-icon">{{ opened ? 'I am open' : ' I am closed' }}</span>
    `,
  props: {
    opened: {
      type: Boolean,
      default: false
    }
  }
}

export default {
  components: {
    BadgerAccodion,
    BadgerAccordionItem
  },
  data() {
    return {
      iconComponent: MyComponent
    }
  }
}
<badger-accordion iconComponent="iconComponent"></badger-accordion>

Disable Icons

<badger-accordion :icons="false"></badger-accordion>

Methods

All Methods of badger-accordion are also available. Just add a ref to you accordion and you can access them.

<badger-accordion ref="myAccordion"></badger-accordion>
this.$refs.myAccordion.open(0)

A list of available methods could be found in the badger-accordion repository

https://github.com/stuartjnelson/badger-accordion#methods