Add a character counter to the status composer

React · React · intermediate · modification

Adds a character counter to the status composer on the team home page. `StatusComposer.jsx` counts the text in grapheme clusters with `Intl.Segmenter`, shows how many of the 280 characters are left (or how many over), switches the counter to a warning look at 20 left and a danger look over the limit, and disables Post over the limit. The textarea points at the counter with `aria-describedby`, and a visually hidden `role="status"` region announces entering the warning range and going over the limit. `StatusComposer.css` adds the counter styles, and `StatusComposer.test.jsx` gains tests for the counter, the looks, Post and the announcements.

Team workspace web app: React 18.3 function components, Vite, Vitest 2 with jsdom and @testing-library/react 16. The Vitest config runs with `globals: true`, so Testing Library cleans up after each test; the project does not use jest-dom matchers. `StatusComposer` is rendered once on the team home page as `<StatusComposer onPost={postStatus} />`; `onPost(text)` is synchronous: it queues the post, and the parent shows any send error itself, so the composer clears right after calling it (unchanged). The status API (not in this PR) also enforces the 280-character limit; the counter is there so people see the limit before they hit it. Supported browsers are the latest two versions of Chrome, Edge, Firefox and Safari, which all ship `Intl.Segmenter`, and so does Node 22, which runs the tests. The global stylesheet has a `.visually-hidden` utility class (kept in the accessibility tree, off screen) and the theme tokens used here. Statuses are short; a pasted draft is at most a few thousand characters.

Requirements

Files touched

Review this PR

React practice