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

v0.1.5

Published

Helper carousel component for vuetify's carousel.

Downloads

14

Readme

v-extended-carousel

Helper carousel component for vuetify's carousel.

Build and publish

This package uses rollup.js in order to bundle the components to es5 and ssr builds. In case you need to re-build the package and push it to npm:

npm run r:build
npm publish

Installation

npm i v-extended-carousel

Create a new plugin: plugins/v-extended-carousel.js:

import Vue from "vue"
import { Vmic, VNextGenImg } from "v-extended-carousel"

Vue.component("Vmic", Vmic)
Vue.component("VNextGenImg", VNextGenImg)

Register the plugin under assets/configs/nuxt.js (or when using a fresh nuxt install nuxt.conf.js in the main project folder):

import { components as vecComponents, directives as vecDirectives } from "v-extended-carousel/assets/treeshake"
const plugins = [
  ...
  {
    src: "@/plugins/v-extended-carousel.js",
    mode: "client"
  },
  ...
]
..
let treeShakeComponents = [...vscmsComponents, ...vlhComponents, ...vesComponents]
let treeShakeDirectives = [...vscmsDirectives, ...vlhDirectives, ...vesDirectives]

const vuetify = {
  customVariables: ["~/assets/style/variables.scss"],
  treeShake: {
    components: Array.from(new Set(treeShakeComponents)),
    directives: Array.from(new Set(treeShakeDirectives))
  },
  ..
}
..

Vmic - vuetify multi-items carousel

Props

props: {
  items: {
    type: Array as PropType<Array<VmicItem>>,
    required: true
  },
  title: {
    type: String,
    default: ""
  },
  color: {
    type: String,
    default: ""
  },
  name: {
    type: String,
    required: true
  },
  minWidth: {
    type: Number,
    default: 645
  },
  minItems: {
    type: Number,
    default: 1
  },
  maxWidth: {
    type: Number,
    default: 1070
  },
  maxItems: {
    type: Number,
    default: 3
  }
}

VmicItem structure:

interface VmicItem {
  index: number,
  id?: string,
  title: string,
  text: string,
  media: string,
  path: string
}

Remark: media prop could be an image URL or an mdi-icon that is shown at the top of the carouse card.

Vmic is a wrapper to the VMultiItemsCarousel that is passing the VMultiItemsCarouselCard component to the VMultiItemsCarousel. If you wish to change this behavior use the VMultiItemsCarousel component directly instead.

Passing a component slot to VMultiItemsCarousel:

<template slot-scope="cardProps">
  <div class="fill-height">
    <VMultiItemsCarouselCard
      :cid="cardProps.id"
      :title="cardProps.name"
      :text="cardProps.text"
      :media="cardProps.image"
      :group="name"
      :path="cardProps.path"
    />
  </div>
</template>

VMultiItemsCarousel default props:

props: {
  // carousel items passed from vmic
  items: {
    type: Array,
    required: true
  },
  // number of items showen at the same time, passed from vmic
  itemsNum: {
    type: [Number, String],
    default: 3
  },
  // number of items to pass in a single click
  perClick: {
    type: [Number, String],
    defualt: 2
  },
  //
  // v-carousel props 
  //
  interval: {
    type: Number,
    default: 5000
  },
  progressColor: {
    type: String,
    default: "primary"
  },
  cycle: {
    type: Boolean,
    default: true
  },
  hideDelimiters: {
    type: Boolean,
    default: false
  },
  hideCarouselArrows: {
    type: Boolean,
    default: false
  }
}

Rules:

  • items - layout: items are organized in a "loop". Example: 4 items passed to VMultiItemsCarousel (item 1-4) Step 1: (item 1 -> item 2 -> item 3) are visible Step 2: (item 4 -> item 1 -> item 2) are visible ... - size: 1-3 item/s carousel - 4 columns each item 4+ items carousel - parseInt(12 / #items)
  • cycle - active if cycle prop is set to true and the number of items passed to VMultiItemsCarousel is greater than itemsNums+1 (enabled at 4 items or more by default).
  • height - set by the size of the largest item in the VMultiItemsCarousel. The VMultiItemsCarouselCard component emits an event with the height of the component. After each card emitted its height the largest height is then passed as a prop to the VMultiItemsCarousel. Because the card is only loaded after the VMultiItemsCarousel a small delay is required (10ms).
  • delimiters - enabled if hideDelimiters is set to true and if cycle is active.
  • progressBar - an alternative to the delimiters. Enabled if hideDelimiters is set to false and if cycle is active. **

NewsCarousel

A carousel that takes images and news carousel items* and shows the title, tag and a button leading to a slug.

props: {
  items: {
    type: Array as PropType<Array<NewsCarouselItem>>,
    required: true
  },
  images: {
    type: Array as PropType<Array<string>>,
    default: null
  }
}

NewsCarouselItem structure:

export interface NewsCarouselItem {
  index: number,
  id?: string,
  name: string,
  createdAt?: Date,
  updatedAt?: Date,
  createdBy?: string,
  topics: string, // an array string - required JSON.parse to turn to array
  draft?: boolean,
  internal?: boolean,
  short?: string,
  text?: string // markdown string,
  slug: string
}

Remark 1: images prop is an array of URLs.

VNextGenImg

Both types of carousel components use under the hood the VNextGenImg component.

<template>
  <v-img v-bind="$attrs" v-on="$listeners" :src="src" :srcset="imgSrc" />
</template>

<script lang="ts">
import Vue from "vue"

export default Vue.extend({
  name: "VNextGenImg",
  props: {
    src: {
      type: String,
      required: true
    }
  },
  computed: {
    imgSrc (): string {
      const imgSrc = this.src.split(".")
      imgSrc.pop()
      return `${imgSrc.join(".")}.webp`
    }
  }
})
</script>