1.0.4 • Published 3 years ago

react-simple-poll v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-simple-poll

react-simple-poll is a simple poll component.

npm.io

Install

NPM

npm i --save react-simple-poll

Usage

import * as React from "react";
import { useState } from "react";
import SimplePoll from "./lib/components/SimplePoll";

function App() {
  const pollData = {
    title: "What is the best burger?",
    options: [
      { text: "In-N-Out", votes: 6 },
      { text: "Burger King", votes: 2 },
      { text: "McDonald's", votes: 3 },
    ],
  };

  const { title, options } = pollData;
  const [isVoted, setIsVoted] = useState(false);

  console.log({ title });

  return (
    <SimplePoll
      title={title}
      options={options}
      isVoted={isVoted}
      onVoted={setIsVoted}
    />
  );
}

export default App;

Options

You can pass an options object to influence the type of color it produces. The options object accepts the following properties:

title – Required. Title of the poll.

options – Required. List of options for the poll. Need to use the following format for JSON object: [{"text": "In-N-Out", votes: 6}, {"text": "Burger King", votes: 2}, ...]

isVoted – Required. User will be able to vote if set to false. Otherwise, user won't be able to vote.

onVoted - Required. Action to take when user votes.

barColor – Optional. Specifies the color of each bar. Otherwise, by default, the color of each bar is randomized.

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago