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

v-eye

v0.4.1-alpha.3

Published

The `v-eye` package provides a set of compound components to create groups of selectable items out of any component. You can see it as the baseline functionality for components like `tabs`, `button-groups`, `accordions`, `carousels` and possibily others.

Downloads

310

Readme

v-eye

The v-eye package provides a set of compound components to create groups of selectable items out of any component. You can see it as the baseline functionality for components like tabs, button-groups, accordions, carousels and possibily others.

It's heavily inspired in Vuetify's v-item-group without all the vuetify wiring attached.

Installation

Using a package package manager

yarn add v-eye

Usage

By default, all components render an un-styled root node div with all bindings attached. If you want to bind the logic to your own custom components, use as-template prop and turn them into renderless/headless providers and all bindings are exposed via default slot-scope. Remember that, due to Vue2 limitation, a single root node must be provided.

Basic: a Disclosure component.

Basically it's an equivalent of <details><summary> native implementation, but state-driven.

<!-- your disclosure.vue -->
<template>
  <v-eye v-model="active">
    <v-eye-switch>Summary toggler</v-eye-switch>
    <v-eye-content>Details</v-eye-content>
  </v-eye>
</template>

<script>
import { VEye, VEyeSwitch, VEyeContent } from 'v-eye'

export default {
  name: 'Disclosure',
  components: { VEye, VEyeSwitch, VEyeContent },
  data: () => ({
    active: false
  })
}

Basic: A password input visibility toggler

<!-- your-password-input.vue -->
<template>
  <div class="your-app-input">
    <input :type="inputType">
    <v-eye v-model="isPasswordVisible">
      <v-eye-switch>
        <your-app-icon :icon="isPasswordVisible ? '🙈 ': '🙉' " />
      </v-eye-switch>   
    </v-eye>   
  </v-eye>
</template>

<script>
export default {
  data: () => ({ isPasswordVisible: false })
  computed: {
    inputType() {
      return this.isPasswordVisible ? 'text' : 'password'
    }
  }
}
</script>

Using a your own custom component

Picking up on the previous example, just use the headless version via as="template prop.

<!-- your-password-input.vue -->
<template>
  <div class="your-app-input">
    <input :type="inputType">
    <v-eye v-model="isPasswordVisible" as-template #default="{ toggle }">
      <your-app-button
        :icon="isPasswordVisible ? '🙈 ': '🙉' " 
        @click="toggle"
      />
    </v-eye>   
  </v-eye>
</template>

Group Usage

Till now, you might be wondering that every example can be easily achievable without any library. Why the heck would you want another package?

The usefulness of this package really shows off when you want each v-eye to be aware its siblings state. For example an accordion, where only one panel can be open at the time: clicking one panel should close the current open sibling. That's when VEyeManager comes handy.

<!-- your disclosure.vue -->
<template>
  <v-eye-manager v-model="active" :multiple="false" :mandatory="true">
    <v-eye :uid="1">
      <v-eye-switch>Summary toggler</v-eye-switch>
      <v-eye-content>Details</v-eye-content>
    </v-eye>
    <v-eye :uid="2">
      <v-eye-switch>Summary toggler</v-eye-switch>
      <v-eye-content>Details</v-eye-content>
    </v-eye>
  </v-eye-manager>
</template>

<script>
import { VEyeManager, VEye, VEyeSwitch, VEyeContent } from 'v-eye'

export default {
  name: 'Disclosure',
  components: { VEyeManager, VEye, VEyeSwitch, VEyeContent },
  data: () => ({
    active: 1
  })
}
  1. You might have noticed the multiple prop is set to false, meaning only one eye can be active at a time.
  2. The mandatory prop, by default is set to false, but setting it to true states that at least one v-eye must be active all the time.
  3. A uid prop was added to each v-eye, so they can be easy to identify at the model property.

Advanced usage

TODO: explain slots, props and all possibilities.

Props

This is a 0.X.Y version this means that the api is subject to changes. Props marked with BETA on the description are most likely candidates to those changes.

VEye

| name | default value | description | |:-------|:--------------|:------------------------------------------------------------------------------------------------------------------------------------------| | as | template | Template means that only the a default scope slot will be rendered (headless) not actual html element. So you need to provide it yourself | | active | false | | | uid | null | unique identifier for each item. Omitting will assign a vue generated _uid |

VEyeManager

| name | default value | description | |:-------------------------------|:--------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | as | template | Template means that only the a default scope slot will be rendered (headless) not actual html element. So you need to provide it yourself | | active | {String|Array} / null | The controlled active state of the managed VEyes. | | defaultActive | {String|Array} / null | The active state when initially rendered. Usefull only if you're not controlling the component state (using v-model) | | mandatory | {Boolean} / false | At least one eye must be active all the time. Good for accordions, tabs. | | multiple | {Boolean} / false | Allows multiple eyes to be active at the same time. Turns v-model into an array of uid | | watchPropsWithModelSideEffects | {Boolean} / false | BETA — if v-model data should react immediately to prop some prop changes. Ex, a multiple instance with 2 items selected. If multiple prop changes to false, the model is updated to keep only one value. |

slot-scope

All components expose two props vis default slot-scope:

  1. isActive matches current instance active state.
  2. toggle the method to toggle that state.

Project setup

yarn install

Compiles and hot-reloads for development

yarn serve

Compiles and minifies for production

yarn build

Run your unit tests

yarn test:unit

Lints and fixes files

yarn lint

Customize configuration

See Configuration Reference.