import React from 'react'; import PropTypes from 'prop-types'; import styles from './meter.css'; const Meter = props => { const { level, width, height } = props; const nGreen = 11; const nYellow = 5; const nRed = 3; const nBars = nGreen + nYellow + nRed; const barSpacing = 2.5; const barRounding = 3; const barHeight = (height - (barSpacing * (nBars + 1))) / nBars; const nBarsToMask = nBars - Math.floor(level * nBars); const scale = ((nBarsToMask * (barHeight + barSpacing)) + (barSpacing / 2)) / height; return (
{Array(nBars).fill(0) .map((value, index) => ( ))}
); }; Meter.propTypes = { height: PropTypes.number, level: PropTypes.number, width: PropTypes.number }; export default Meter;