docbrown/app/javascript/articles/components/ReadingTime.jsx
2022-08-19 12:03:57 -04:00

21 lines
496 B
JavaScript

import { h } from 'preact';
import PropTypes from 'prop-types';
export const ReadingTime = ({ readingTime }) => {
// we have ` ... || null` for the case article.reading_time is undefined
return (
<small className="crayons-story__tertiary mr-2 fs-xs">
{`${readingTime < 1 ? 1 : readingTime} min read`}
</small>
);
};
ReadingTime.defaultProps = {
readingTime: null,
};
ReadingTime.propTypes = {
readingTime: PropTypes.number,
};
ReadingTime.displayName = 'ReadingTime';