0.0.8 • Published 2 years ago

@perrychi/mark-score v0.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

@perrychi/mark-score

A React-based component for scoring by selecting the number of stars.

Interaction

demo demo

đŸ“¦ Install

npm install @perrychi/mark-score --save
yarn add @perrychi/mark-score

đŸ”¨ Usage

A simple example

import React from 'react';
import MarkScore from '@perrychi/mark-score';

function App() {
  const handleChange = (score) => {
    console.log('This is the score: ', score);
  }
  return (
    <div className="App">
      <MarkScore onChange={handleChange} />
    </div>
  );
}

export default App;

A complex example

import React from 'react';
import MarkScore from '@perrychi/mark-score';

function App() {
  const handleChange = (score) => {
    console.log('This is the score: ', score);
  }
  return (
    <div className="App">
      <MarkScore
        {...{
          starCount: 6,
          allowHalf: true,
          value: 3.5,
          onChange: handleChange,
          size: 'm',
          style: {
            color: '#e1251b'
          }
        }}
      />
    </div>
  );
}

export default App;

UI display

demo demo

Props

PropDescriptionTypeDefault
starCountTotal number of starsnumber5
allowClearWhether to allow clearing the value when the last clicked star is clicked againbooleantrue
allowHalfWhether to allow half starsbooleanfalse
disabledIs it possible to operatebooleanfalse
valueThe current valuenumber0
onChangeThe callback when the score value changes, the latest score value will be passed to the callback(value) => {}-
sizexxs | xs | s | m | l | xl | xxl | xxxl | xxxxlstringm
styleThe custom style objectCSSProperties-
0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago