import React from 'react' import PropTypes from 'prop-types' import { length } from 'stringz' /** * Renders a character counter * @param {string} props.text - text to use to measure * @param {number} props.max - max text allowed */ class CharacterCounter extends React.PureComponent { render() { const { text, max } = this.props const actualRadius = 16 const radius = 12 const circumference = 2 * Math.PI * radius const diff = Math.min(length(text), max) / max const dashoffset = circumference * (1 - diff) return (