refactor(ui-react): extract shared Alert component#6389
Conversation
|
Claude finished @luannmoreira's task in 9m 39s —— View job Code Review CompleteReviewed 24 files across code quality, security, testing, language patterns, and architecture — no issues found. The code looks good as-is. The Alert component is well-structured: clean variant config pattern, proper ARIA semantics ( Note on merge: this branch was created before If you push additional changes and want a new review, tag |
27 duplicate inline alert blocks across 22 files had no consistent ARIA semantics — success messages used role="alert" or no role at all. The new Alert primitive centralises color, icon, and live-region attributes (role=alert/assertive for error and warning; role=status/ polite for success and info) and ships with 33 unit tests.
e7b2465 to
6c5c6f8
Compare
|
/review |
|
Claude finished @gustavosbarreto's task in 1m 44s —— View job Code Review CompleteReviewed 24 files across code quality, security, testing, language patterns, and architecture — no issues found. The code looks good as-is. The Alert component is well-structured: clean variant config pattern, proper ARIA semantics ( Note on merge: this branch was created before If you've addressed the feedback and want a new review, tag |
What
Added a shared
Alertprimitive tosrc/components/common/Alert.tsxand replaced 27 duplicated inline alert blocks across 22 files with it.Why
Every page that needed to show an error, warning, or status message implemented its own
<div>with duplicated Tailwind classes, icon imports, and inconsistent (or missing) ARIA attributes. Several success alerts usedrole="alert"when they should userole="status", and several others had no live-region semantics at all.Changes
Alert.tsx: supportserror | success | warning | infovariants. Each variant maps to a colour token, icon,role, andaria-livevalue — error/warning userole=alert/assertive, success/info userole=status/polite. Accepts an optionalonDismisscallback that renders a dismiss button withtype="button"andaria-label="Dismiss alert".classNameis for layout overrides only (margins, display).22 consumer files: removed per-file
ExclamationCircleIcon,CheckCircleIcon, andExclamationTriangleIconimports that existed solely to serve the inline alert block. Icons retained where they are used elsewhere in the file (e.g.ExclamationCircleIconinMfaResetCompletefor the expired-token error page,ExclamationTriangleIconinSessionsfor the table decorator).Alert.test.tsx: 33 tests covering variant classes (bg/border/text), ARIA role and aria-live per variant, icon count, dismiss button presence/absence/click/type,classNamepassthrough, and base layout classes.Testing
All pass. Two visual edge cases worth checking in the browser:
/signup?email=test@example.com&sig=fakesig— invite warning (wasitems-start/py-3/rounded-lg; now standardised toitems-center/py-2.5/rounded-md)/profile→ MFA → Disable → wrong OTP — error alert now includesanimate-slide-downwhich the original block lacked