import { length } from 'stringz' export default class CharacterCounter extends PureComponent { static propTypes = { text: PropTypes.string.isRequired, max: PropTypes.number.isRequired, small: PropTypes.bool, } render () { const { text, max, small } = this.props const actualRadius = small ? '10' : '16' const radius = small ? 8 : 12 const circumference = 2 * Math.PI * radius const diff = length(text) / max const dashoffset = circumference * (1 - diff) return (
) } }