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-card-carousel

v1.0.0

Published

A flexible, touch-focused wrapper element that displays cards in a carousel-like manner.

Downloads

334

Readme

Installation

npm i vue-card-carousel

You can choose to install either globally or locally:

Globally:

import Vue from 'vue'
import App from './App.vue'
import VueCardCarousel from "vue-card-carousel";

Vue.use(VueCardCarousel)

new Vue({
  el: '#app',
  render: h => h(App)
})

or locally to a component:

import { VueCardCarousel } from "vue-card-carousel";

export default {
    components: {
        VueCardCarousel
    }
}

Usage

Most basic usage would be adding the component and passing in the array of items you want displayed. Note you will need to set the minimum height of the component, otherwise it won't display. The width will take up 100% by default. These can be easily configured via CSS.

<template>
  <div id="app">
    <VueCardCarousel class="vcc" :items="listOfTodos" />
  </div>
</template>

<script>
import { VueCardCarousel } from "vue-card-carousel";

export default {
  components: {
    VueCardCarousel
  },
  data() {
    return {
      listOfTodos: [{ id: 1 }, { id: 2 }, { id: 3 }]
    };
  }
};
</script>

<style scoped>
  .vcc {
    height: 50vh;
    width: 60vw;
  }
</style>

However this will be relatively uninteresting. To make the most use of this component, you'll want to add customizations via props and slots like below:

<template>
  <div id="app">
    <VueCardCarousel
      class="vcc"
      :items="listOfTodos"
      :header-options="headerOpt"
      :footer-options="footerOpt"
    >
      <template v-slot:header="slotProps">
        <strong>Header. Id: {{ slotProps.headerProp.id }}</strong>
      </template>
      <template v-slot:default="slotProps">
        <div v-for="n in 5" :key="n">
          {{ slotProps.bodyProp.cMainId }}. Hello from the Parent.
        </div>
      </template>
      <template v-slot:footer="slotProps">
        <strong>Footer. Id: {{ slotProps.footerProp.id }}</strong>
      </template>
    </VueCardCarousel>
  </div>
</template>

<script>
import { VueCardCarousel } from "vue-card-carousel";

export default {
  components: {
    VueCardCarousel
  },
  data() {
    return {
      listOfTodos: [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }],
      headerOpt: { isVisible: true, backgroundColor: "green" },
      footerOpt: { isVisible: false }
    };
  }
};
</script>

<style scoped>
  .vcc {
    height: 50vh;
    width: 60vw;
  }
</style>

Props

| Property | Type | Default | Required | Description | | :---------------: | :-----: | :-----: | :------: | :------------------------------------------------------------------------------------ | | items | Array | | true | List of items to used to generate the scrollable cards. | | startIndex | Number | 0 | false | Index of the card you want to be centered on first. Removes trailing digits if found. | | hideBackdrop | Boolean | false | true | Shows/hides the backdrop. Akin to a modal backdrop. | | sideCardOpacity | Number | 0.25 | false | Sets the minimum opacity for the cards on either side of the center card. | | headerOptions | Object | | false | See details below for available properties. | | footerOptions | Object | | false | See details below for available properties. |

headerOptions

| Property | Type | Default | Required | Description | | :---------------: | :-----: | :-----: | :------: | :----------------------------------------------- | | isVisible | Boolean | | true | Controls whether or not the header is displayed. | | backgroundColor | String | | false | Any valid CSS color. |

footerOptions

| Property | Type | Default | Required | Description | | :---------------: | :-----: | :-----: | :------: | :----------------------------------------------- | | isVisible | Boolean | | true | Controls whether or not the footer is displayed. | | backgroundColor | String | | false | Any valid CSS color. |

Slots

Scoped slots are exposed for each sub-section of the card: header, body, and footer. Each slot has slot props which give access to the individual item from the list that was passed in through the items property, so you can use that data to fully customize the card.

| Name | Description | Scope | | :-------: | :---------------------------------------------------------------: | :----------- | | header | Individual item from the list passed in through the items prop. | headerProp | | default | Individual item from the list passed in through the items prop. | bodyProp | | footer | Individual item from the list passed in through the items prop. | footerProp |

In the above example, we have named the object containing all our slot props slotProps, but you can choose to call this anything. More info can be found here: https://vuejs.org/v2/guide/components-slots.html#Scoped-Slots

Demo

Interactive demo located here along with the source code.

License

MIT