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

vue3-fortune-wheel

v2.0.5

Published

A Vue 3 Fortune Wheel component

Downloads

545

Readme

vue3-fortune-wheel v2.0.5

👊 An easy-to-use fortune wheel component for Vue.js 3 👊

🔥 Built with Vue 3 + TypeScript 🔥

Codesandbox

Edit joffreyBerrier/vue-fortune-wheel-codesandbox/main

Preview

vue-1

Features

  • Customizable wheel segments
  • Animated spinning
  • Optional center image
  • TypeScript support
  • Accessible (with ARIA attributes)

Installation

pnpm add vue3-fortune-wheel

Usage

<script setup lang="ts">
import { ref } from 'vue'
import { FortuneWheel } from 'vue3-fortune-wheel'
import type { Data, ImgParams } from 'vue3-fortune-wheel'

const gift = ref(2)
const wheel = ref<InstanceType<typeof FortuneWheel> | null>(null)
const data = ref<Data[]>([
  { id: 1, value: 'Gift 1', bgColor: '#7d7db3', color: '#ffffff' },
  { id: 2, value: 'Gift 2', bgColor: '#ffffff', color: '#000000' }
])

// Optional: Center image
const logo: ImgParams = {
  src: 'https://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Vue.js_Logo_2.svg/2367px-Vue.js_Logo_2.svg.png',
  width: 100,
  height: 120
}

const hasMiddleCircle = true

const done = (result: Data) => {
  console.log('Spin completed:', result)
}
</script>

<template>
  <FortuneWheel
    ref="wheel"
    v-model="gift"
    :middle-circle="hasMiddleCircle"
    :img-params="logo"
    :data="data"
    @done="done"
  />
</template>

API

Props

| Prop | Type | Default | Description | | ------------ | ----------- | ------- | ----------------------------------------- | | v-model | number | null | ID of the winning item | | data | Data[] | [] | Array of wheel segments | | animDuration | number | 5000 | Spin animation duration in milliseconds | | imgParams | ImgParams | {} | Configuration for center image (optional) | | middleCircle | boolean | true | Show/hide middle circle |

Events

| Event | Payload | Description | | ----- | ------- | ---------------------------------- | | done | Data | Emitted when the spin is completed |

Methods

| Method | Description | | ------ | --------------------- | | spin() | Starts the wheel spin |

Types

interface Data {
  id: number
  value: string
  color: string
  bgColor: string
}

interface ImgParams {
  src: string
  width: number
  height: number
}

Spinning the Wheel

Use the ref to call the spin method:

const wheel = ref<InstanceType<typeof FortuneWheel> | null>(null)

const launchWheel = () => {
  wheel.value?.spin()
}

Customization

Random Winner Selection

If you need to randomly select a winner, you can use a method like this:

const randomGift = () => {
  return Math.floor(Math.random() * data.value.length) + 1
}

Development

Setup

  1. Fork the repository
  2. Clone your fork: git clone https://github.com/YOUR_USERNAME/vue3-fortune-wheel.git
  3. Install dependencies: pnpm install

Running Tests

pnpm run test:unit

Contributing

  1. Create an issue describing the feature or bug
  2. Fork the repo and create a branch following the gitflow convention:
    • Feature branches: feature/issueId
    • Release branches: release/issueId
    • Hotfix branches: hotfix/issueId
    • Support branches: support/issueId
  3. Make your changes and push to your fork
  4. Open a pull request to the main repository

License

MIT License

Support

If you have any questions or need help, please open an issue on the GitHub repository.


Made with ❤️ by Joffrey Berrier