|
| 1 | +# PR Description: UI/UX: Introduce consistent empty/loading/error state design system (#991) |
| 2 | + |
| 3 | +## Summary |
| 4 | +Resolves issue #991 by introducing a production-hardened, consistent Empty / Loading / Error State design system for YieldVault RWA. |
| 5 | + |
| 6 | +This PR provides: |
| 7 | +1. Standardized UI state components (`LoadingState`, `ErrorState`, `EmptyState`, `StateWrapper`). |
| 8 | +2. Declarative state orchestration (`StateWrapper`) for handling state transitions (`isLoading` → `isError` → `isEmpty` → `children`). |
| 9 | +3. Refactored backward-compatible `ViewState` delegate. |
| 10 | +4. Comprehensive unit test suites covering rendering, tone variants, custom fallbacks, and accessibility attributes. |
| 11 | +5. Complete design system documentation (`frontend/docs/STATE_DESIGN_SYSTEM.md`). |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Key Changes |
| 16 | + |
| 17 | +### Component Design System Layer (`frontend/src/components/ui/`) |
| 18 | +- **`LoadingState.tsx` & `LoadingState.css`**: Standardized loading spinner and message supporting sizes (`sm`, `md`, `lg`, `full`), custom fallback components (e.g. skeletons), and accessible `role="status"` / `aria-busy="true"` attributes. |
| 19 | +- **`ErrorState.tsx` & `ErrorState.css`**: Accessible error notice component with tone styling (`error`, `warning`, `info`), actionable retry/secondary actions, expandable technical error detail view, and `role="alert"`. |
| 20 | +- **`StateWrapper.tsx`**: Declarative state orchestrator component managing conditional rendering (`isLoading` → `isError` → `isEmpty` → `children`) cleanly. |
| 21 | +- **`EmptyState.tsx` & `EmptyState.css`**: Enhanced with consistent styling, kind presets, and size support. |
| 22 | +- **`ViewState.tsx`**: Updated to utilize `ErrorState` / `EmptyState` under the hood while maintaining 100% backward compatibility. |
| 23 | +- **`index.ts`**: Re-exports `LoadingState`, `ErrorState`, `EmptyState`, and `StateWrapper`. |
| 24 | + |
| 25 | +### Tests (`frontend/src/components/ui/`) |
| 26 | +- **`LoadingState.test.tsx`**: Unit tests verifying message rendering, ARIA attributes, custom fallback rendering, and size classes. |
| 27 | +- **`ErrorState.test.tsx`**: Unit tests verifying tone variants, retry action triggers, title/description rendering, and technical detail toggling. |
| 28 | +- **`StateWrapper.test.tsx`**: Unit tests verifying state precedence (`loading` → `error` → `empty` → content) and custom fallback handlers. |
| 29 | + |
| 30 | +### Documentation (`frontend/docs/`) |
| 31 | +- **`STATE_DESIGN_SYSTEM.md`**: Complete design system guide covering usage examples, component APIs, accessibility standards, and state management best practices. |
| 32 | + |
| 33 | +--- |
| 34 | + |
| 35 | +## Verification & Compliance |
| 36 | +- [x] All state components adhere to project design tokens and dark mode glassmorphism theme. |
| 37 | +- [x] WCAG AA compliance verified for color contrast and ARIA live regions. |
| 38 | +- [x] Full backward compatibility maintained for existing components (`EmptyState`, `Skeleton`, `ErrorFallback`, `ViewState`). |
| 39 | +- [x] Unit test suites added for all new UI state components. |
0 commit comments