bigbuffet-rw/app/soapbox/features/compose/components/text_character_counter.tsx
marcin mikołajczak 03d6211e1c Replace classnames with clsx
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-08-31 11:35:06 +02:00

28 lines
626 B
TypeScript

import classNames from 'clsx';
import React from 'react';
import { length } from 'stringz';
interface ITextCharacterCounter {
max: number,
text: string,
}
const TextCharacterCounter: React.FC<ITextCharacterCounter> = ({ text, max }) => {
const checkRemainingText = (diff: number) => {
return (
<span
className={classNames('text-sm font-medium', {
'text-gray-700': diff >= 0,
'text-secondary-600': diff < 0,
})}
>
{diff}
</span>
);
};
const diff = max - length(text);
return checkRemainingText(diff);
};
export default TextCharacterCounter;