diff --git a/CHANGELOG.md b/CHANGELOG.md index 52a7c4d3b..ee32cbb92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Reactions: Support custom emoji reactions - Compatbility: Support Mastodon v2 timeline filters. - Posts: Support dislikes on Friendica. +- UI: added a character counter to some textareas. ### Changed - Posts: truncate Nostr pubkeys in reply mentions. diff --git a/app/soapbox/components/ui/textarea/textarea.tsx b/app/soapbox/components/ui/textarea/textarea.tsx index 03ddda81d..2b3f54897 100644 --- a/app/soapbox/components/ui/textarea/textarea.tsx +++ b/app/soapbox/components/ui/textarea/textarea.tsx @@ -1,5 +1,9 @@ import clsx from 'clsx'; import React, { useState } from 'react'; +import { FormattedMessage } from 'react-intl'; + +import Stack from '../stack/stack'; +import Text from '../text/text'; interface ITextarea extends Pick, 'maxLength' | 'onChange' | 'onKeyDown' | 'onPaste' | 'required' | 'disabled' | 'rows' | 'readOnly'> { /** Put the cursor into the input on mount. */ @@ -28,6 +32,8 @@ interface ITextarea extends Pick) => { + const length = value?.length || 0; const [rows, setRows] = useState(autoGrow ? 1 : 4); const handleChange = (event: React.ChangeEvent) => { @@ -70,20 +79,35 @@ const Textarea = React.forwardRef(({ }; return ( -