{"_id":"@agile-casino/react-custom-roulette","name":"@agile-casino/react-custom-roulette","dist-tags":{"latest":"1.4.1"},"versions":{"1.4.1":{"name":"@agile-casino/react-custom-roulette","version":"1.4.1","description":"Customizable React roulette wheel with spinning animation","main":"./dist/bundle.js","repository":{"type":"git","url":"git+https://github.com/agile-casino/react-custom-roulette.git"},"keywords":["react","custom","roulette","spinning","wheel","fortune","prize"],"license":"MIT","types":"./dist/index.d.ts","private":false,"peerDependencies":{"react":"^18.2.0","react-dom":"^18.2.0"},"devDependencies":{"@testing-library/jest-dom":"^5.9.0","@testing-library/react":"^10.0.6","@testing-library/user-event":"^11.0.0","@types/jest":"^25.2.3","@types/node":"^14.0.9","@types/react":"^18.0.28","@types/react-dom":"^18.0.11","@types/webfontloader":"^1.6.34","@typescript-eslint/eslint-plugin":"^4.16.1","@typescript-eslint/parser":"^4.16.1","babel-cli":"^6.26.0","babel-core":"^6.26.3","babel-loader":"8.1.0","babel-plugin-transform-object-rest-spread":"^6.26.0","babel-plugin-transform-react-jsx":"^6.24.1","babel-preset-env":"^1.7.0","css-loader":"^3.5.3","eslint":"^7.21.0","eslint-config-airbnb-typescript-prettier":"^2.1.1","eslint-plugin-react":"^7.22.0","husky":"^4.2.5","jest-canvas-mock":"^2.2.0","prettier":"^2.0.5","react-scripts":"^4.0.3","styled-components":"^5.1.1","ts-loader":"8.0.7","typescript":"^4.6.2","url-loader":"^4.1.0","webfontloader":"^1.6.28","webpack":"4.44.2","webpack-cli":"^3.3.11","webpack-dev-server":"3.11.1"},"scripts":{"start-server":"react-scripts start","start":"webpack --watch","build":"webpack && tsc && cp -R ./src/assets ./dist","test":"react-scripts test","coverage":"CI=true npm test -- --env=jsdom --coverage","eject":"react-scripts eject","format":"prettier --write src/**/*.{js,ts,tsx}","lint":"eslint src/**/*.{js,ts,tsx}","link-react":"cd example/node_modules/react && yarn link && cd ../react-dom && yarn link && cd ../../.. && yarn link react react-dom"},"husky":{"hooks":{"pre-commit":"yarn format && yarn lint"}},"jest":{"coveragePathIgnorePatterns":["src/serviceWorker.ts"]},"eslintConfig":{"extends":"react-app"},"browserslist":{"production":[">0.2%","not dead","not op_mini all"],"development":["last 1 chrome version","last 1 firefox version","last 1 safari version"]},"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","_id":"@agile-casino/react-custom-roulette@1.4.1","gitHead":"0049461cb3bf89a754d9c40e167518b6996cf732","bugs":{"url":"https://github.com/agile-casino/react-custom-roulette/issues"},"homepage":"https://github.com/agile-casino/react-custom-roulette#readme","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-9Vbn5wQT5Mu4uBvFhdH+7mSw6A0+waVlDQQc73IanlWMlPA4qsckISU4szH7uheSmINmAa0tcfFRHGopk19MwA==","shasum":"076e145f2682e66a26b8032a2f9076c585c14a5b","tarball":"https://registry.npmjs.org/@agile-casino/react-custom-roulette/-/react-custom-roulette-1.4.1.tgz","fileCount":40,"unpackedSize":130957,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIA/sV0nRX9HN/gW7Im/fCx1ux7/+xQtecOn7kCu1IQiPAiBp8d9/LdZRKfxDLeOMOapFPVWZ7p7D9emvoKNU1pR6Bg=="}]},"_npmUser":{"name":"archerax","email":"aarcher@gmail.com"},"directories":{},"maintainers":[{"name":"archerax","email":"aarcher@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react-custom-roulette_1.4.1_1740539127576_0.49423031481031976"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-26T03:05:27.515Z","1.4.1":"2025-02-26T03:05:27.776Z","modified":"2025-02-26T03:05:28.091Z"},"maintainers":[{"name":"archerax","email":"aarcher@gmail.com"}],"description":"Customizable React roulette wheel with spinning animation","homepage":"https://github.com/agile-casino/react-custom-roulette#readme","keywords":["react","custom","roulette","spinning","wheel","fortune","prize"],"repository":{"type":"git","url":"git+https://github.com/agile-casino/react-custom-roulette.git"},"bugs":{"url":"https://github.com/agile-casino/react-custom-roulette/issues"},"license":"MIT","readme":"<h1 align=\"center\">React Custom Roulette</h1>\n\n<div align=\"center\">\n\n  [![npm version](https://img.shields.io/npm/v/react-custom-roulette)](https://www.npmjs.com/package/react-custom-roulette)\n  [![Types](https://img.shields.io/npm/types/react-custom-roulette)](https://www.typescriptlang.org/index.html)\n  [![npm downloads](https://img.shields.io/npm/dm/react-custom-roulette)](https://www.npmjs.com/package/react-custom-roulette)\n\n</div>\n\n<p align=\"center\">Customizable React roulette wheel with spinning animation</p>\n\n<div align=\"center\">\n\n  ![React Custom Roulette](https://github.com/effectussoftware/react-custom-roulette/raw/master/demo/roulette-demo.gif)\n\n</div>\n\n## Features\n\n- Customizable design\n- Prize selection with props\n- Spinning animation (customizable spin duration)\n- **[NEW!]** Images as items (see [Types](#types))\n- **[NEW!]** Customizable pointer image\n- Multiple consecutive spins (see [Multi Spin](#multi-spin))\n- Compatible with TypeScript\n\n## Install\n\n    $ npm install react-custom-roulette\n\nor\n\n    $ yarn add react-custom-roulette\n\n## Quickstart\n\n#### Wheel Component\n\n```jsx\nimport React from 'react'\nimport { Wheel } from 'react-custom-roulette'\n\nconst data = [\n  { option: '0', style: { backgroundColor: 'green', textColor: 'black' } },\n  { option: '1', style: { backgroundColor: 'white' } },\n  { option: '2' },\n]\n\nexport default () => (\n  <>\n    <Wheel\n      mustStartSpinning={mustSpin}\n      prizeNumber={3}\n      data={data}\n      backgroundColors={['#3e3e3e', '#df3428']}\n      textColors={['#ffffff']}\n    />\n  </>\n)\n```\n\n#### Props\n\n| **Prop**                        | **Type**           | **Default**               | **Description**                                                    |\n|---------------------------------|--------------------|---------------------------|--------------------------------------------------------------------|\n| mustStartSpinning _(required)_  | `boolean`          | -                         | Sets when the roulette must start the spinning animation                                              |\n| prizeNumber _(required)_        | `number`           | -                         | Sets the winning option. It's value must be between 0 and data.lenght-1                                               |\n| data _(required)_               | `Array<WheelData>` | -                         | Array of options. Can contain styling information for a specific option (see [WheelData](#wheeldata))                          |\n| onStopSpinning                  | `function`         | () => null                | Callback function that is called when the roulette ends the spinning animation                                              |\n| backgroundColors                | `Array<string>`    | ['darkgrey', 'lightgrey'] | Array of colors that will fill the background of the roulette options, starting from option 0                                 |\n| textColors                      | `Array<string>`    | ['black']                 | Array of colors that will fill the text of the roulette options, starting from option 0                                 |\n| outerBorderColor                | `string`           | 'black'                   | Color of the roulette's outer border line                                                   |\n| outerBorderWidth                | `number`           | 5                         | Width of the roulette's outer border line (0 represents no outer border line)                                                  |\n| innerRadius                     | `number [0..100]`  | 0                         | Distance of the inner radius from the center of the roulette                                               |\n| innerBorderColor                | `string`           | 'black'                   | Color of the roulette's inner border line                                                   |\n| innerBorderWidth                | `number`           | 0                         | Width of the roulette's inner border line (0 represents no inner border line)                                                  |\n| radiusLineColor                 | `string`           | 'black'                   | Color of the radial lines that separate each option                                                 |\n| radiusLineWidth                 | `number`           | 5                         | Width of the radial lines that separate each option (0 represents no radial lines)                                          |\n| fontFamily                      | `string`           | 'Helvetica, Arial'        | Global font family of the option string. Non-Web safe fonts are fetched from https://fonts.google.com/. All available fonts can be found there.            |\n| fontSize                        | `number`           | 20                        | Global font size of the option string                            |\n| fontWeight                      | `number | string`  | 'bold'                    | Global font weight of the option string                          |\n| fontStyle                       | `string`           | 'normal'                  | Global font style of the option string                           |\n| perpendicularText               | `boolean`          | false                     | When 'true', sets the option texts perpendicular to the roulette's radial lines                                           |\n| textDistance                    | `number [0..100]`  | 60                        | Distance of the option texts from the center of the roulette     |\n| spinDuration                    | `number [0.01 ..]` | 1.0                       | Coefficient to adjust the default spin duration                  |\n| startingOptionIndex             | `number`           | -                         | Set which option (through its index in the `data` array) will be initially selected by the roulette (before spinning). If not specified the roulette will render without choosing a starting option                    |\n| pointerProps                    | `PointerProps`     | { src: roulettePointer }  | Image source and CSS styling to apply to the pointer image.                                                 |\n| disableInitialAnimation         | `boolean`          | false                     | When 'true', disables the initial backwards wheel animation      |\n\n## Types\n\n#### WheelData\n\n```jsx\ninterface WheelData {\n  option?: string;\n  image?: ImageProps;\n  style?: StyleType; // Optional\n  optionSize?: number; // Optional\n}\n```\n\n| **Prop**   | **Type**     | **Default** | **Description**                                                                                       |\n|------------|--------------|-------------|-------------------------------------------------------------------------------------------------------|\n| option     | `string`     | ''          | String to be rendered inside an option.                                                               |\n| image      | `ImageProps` | -           | Image to be rendered inside an option. It is configured through [ImageProps](#imageprops)             |\n| style      | `StyleType`  | -           | Styles for option. It is configured through [StyleType](#styletype)                                   |\n| optionSize | `number`     | 1           | Integer that sets the size of the option measured in roulette pieces. For example: if `data` provides 2 options A and B, and you set A's `optionSize` to `2`, B's `optionSize` to `1`, the roulette will render `3` pieces: 2 corresponding to A and 1 corresponding to B. Therefore, A will appear to be twice as big as B. |\n\n#### StyleType\n\n```jsx\ninterface StyleType {\n  backgroundColor?: string; // Optional\n  textColor?: string; // Optional\n  fontFamily?: string; // Optional\n  fontSize?: number; // Optional\n  fontWeight?: number | string; // Optional\n  fontStyle?: string; // Optional\n}\n```\n\n| **Prop**        | **Type**          | **Default**               | **Description**                                                    |\n|-----------------|-------------------|---------------------------|--------------------------------------------------------------------|\n| backgroundColor | `string`          | 'darkgrey' or 'lightgrey' | Background color for option                                        |\n| textColor       | `string`          | 'black'                   | Text color                                                         |\n| fontFamily      | `string`          | 'Helvetica, Arial'        | String containing text font and its fallbacks separated by commas  |\n| fontSize        | `number`          | 20                        | Font size number                                                   |\n| fontWeight      | `number | string` | 'bold'                    | Font weight string or number                                       |\n| fontStyle       | `string`          | 'normal'                  | Font style string                                                  |\n\n#### ImageProps\n\n```jsx\ninterface ImageProps {\n  uri: string;\n  offsetX?: number; // Optional\n  offsetY?: number; // Optional\n  sizeMultiplier?: number; // Optional\n  landscape?: boolean; // Optional\n}\n```\n\n| **Prop**       | **Type**  | **Default** | **Description**                                                                       |\n|----------------|-----------|-------------|---------------------------------------------------------------------------------------|\n| uri            | `string`  | -           | Image source. It can be url or path.                                                  |\n| offsetX        | `number`  | 0           | Image offset in its X axis                                                            |\n| offsetY        | `number`  | 0           | Image offset in its Y axis                                                            |\n| sizeMultiplier | `number`  | 1           | A value of 1 means image height is calculated as `200px * sizeMultiplier` and width will be calculated to keep aspect ratio. |\n| landscape      | `boolean` | false       | If true, image will be rotated 90 degrees so as to render in a landscape orientation. |\n\n#### PointerProps\n\n```jsx\ninterface PointerProps {\n  src?: string; // Optional\n  style?: React.CSSProperties; // Optional\n}\n```\n\n| **Prop** | **Type**              | **Default**               | **Description**             |\n|----------|-----------------------|---------------------------|-----------------------------|\n| src      | `string`              | -                         | Image src.                  |\n| style    | `React.CSSProperties` | -                         | Styling for pointer image.  |\n\n## Multi Spin\n\n#### Example (using useState)\n\n```jsx\nimport React, { useState } from 'react'\nimport { Wheel } from 'react-custom-roulette'\n\nconst data = [\n  { option: '0' },\n  { option: '1' },\n  { option: '2' },\n]\n\nexport default () => {\n  const [mustSpin, setMustSpin] = useState(false);\n  const [prizeNumber, setPrizeNumber] = useState(0);\n\n  const handleSpinClick = () => {\n    if (!mustSpin) {\n      const newPrizeNumber = Math.floor(Math.random() * data.length);\n      setPrizeNumber(newPrizeNumber);\n      setMustSpin(true);\n    }\n  }\n\n  return (\n    <>\n      <Wheel\n        mustStartSpinning={mustSpin}\n        prizeNumber={prizeNumber}\n        data={data}\n\n        onStopSpinning={() => {\n          setMustSpin(false);\n        }}\n      />\n      <button onClick={handleSpinClick}>SPIN</button>\n    </>\n  )\n}\n```\n\n## Contributors\n\nThis project exists thanks to all the people who contribute!\n\n<ul>\n    <li><a href=\"https://github.com/luchozamora1\">Luis Felipe Zamora</a></li>\n    <li><a href=\"https://github.com/nazabalm20\">Martin Nazabal</a></li>\n    <li><a href=\"https://github.com/jpmazza\">JP Mazza</a></li>\n    <li><a href=\"https://github.com/TakeshiOnishi\">TakeshiOnishi</a></li>\n    <li><a href=\"https://github.com/Gaston-Gonzalez\">Gastón González</a></li>\n    <li><a href=\"https://github.com/jpmartinezeff\">Juan Pablo Martinez</a></li>\n    <li><a href=\"https://github.com/Acarvajal904\">Andres Carvajal</a></li>\n</ul>\n\n## License\n\nThis project is licensed under the MIT license, Copyright (c) 2023 <a href=\"https://effectussoftware.com\">Effectus Software</a>. [[License](LICENSE)]\n","readmeFilename":"README.md"}