Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 1x 15x 15x 15x 15x 1x 1x | import PropTypes from 'prop-types'
import {ATOM_ICON_SIZES} from '@s-ui/react-atom-icon'
import {BASE_CLASS, DEFAULTS_STAR as DEFAULTS} from './settings.js'
const MoleculeRatingStar = ({
value = DEFAULTS.value,
fullValue = DEFAULTS.fullValue,
halfValue = DEFAULTS.halfValue,
index,
IconStarEmpty = DEFAULTS.IconStarEmpty,
IconStarFilled = DEFAULTS.IconStarFilled,
IconStarHalfFilled = DEFAULTS.IconStarHalfFilled,
size
}) => {
let StarMode = IconStarEmpty
Iif (value >= index + fullValue) StarMode = IconStarFilled
else Iif (value >= index + halfValue) StarMode = IconStarHalfFilled
return (
<div className={BASE_CLASS}>
<StarMode size={size} />
</div>
)
}
MoleculeRatingStar.displayName = 'MoleculeRatingStar'
MoleculeRatingStar.propTypes = {
/** index of the star */
index: PropTypes.number,
/** current value of the star */
value: PropTypes.number,
/** value assigned to the star fully filled */
fullValue: PropTypes.number,
/** value assigned to the star half filled */
halfValue: PropTypes.number,
/** Icon for star filled */
IconStarFilled: PropTypes.node,
/** Icon for star half filled */
IconStarHalfFilled: PropTypes.node,
/** Icon for star empty */
IconStarEmpty: PropTypes.node,
/** size */
size: PropTypes.oneOf(Object.values(ATOM_ICON_SIZES))
}
export default MoleculeRatingStar
|