40227-vm/frontend/docs/sign-language-integration.md

4.9 KiB

Sign Language Integration

Purpose

SignLanguage renders backend-owned sign catalog content and current-user learned progress through the three-layer frontend architecture.

View -> Business Logic -> API/Data Access -> Backend

Runtime sign records, teaching tips, video URLs, GIF URLs, step instructions, and page-level teaching reminders belong to backend content catalog payloads. The frontend owns only UI state, filter config, style tokens, and progress interaction wiring.

Frontend Layers

View:

  • frontend/src/components/frameworks/SignLanguage.tsx
  • frontend/src/components/frameworks/SignLanguageVideoModal.tsx
  • frontend/src/components/sign-language/SignLanguageView.tsx
  • frontend/src/components/sign-language/SignLanguageHeader.tsx
  • frontend/src/components/sign-language/SignLanguageManagementPanel.tsx
  • frontend/src/components/sign-language/SignLanguageRememberPanel.tsx
  • frontend/src/components/sign-language/SignLanguageProgressPanel.tsx
  • frontend/src/components/sign-language/SignLanguageFilters.tsx
  • frontend/src/components/sign-language/SignLanguageGrid.tsx
  • frontend/src/components/sign-language/SignLanguagePagination.tsx
  • frontend/src/components/sign-language/SignLanguageCard.tsx
  • frontend/src/components/sign-language/SignLanguageVideoModal.tsx

Business logic:

  • frontend/src/business/sign-language/hooks.ts
  • frontend/src/business/sign-language/selectors.ts
  • frontend/src/business/sign-language/types.ts

Shared contracts and UI config:

  • frontend/src/shared/types/app.ts
  • frontend/src/shared/constants/signLanguage.ts
  • frontend/src/shared/constants/contentCatalog.ts

Backend Contracts

The page reads content from:

  • GET /api/content-catalog/read/sign-language-items
  • GET /api/content-catalog/read/sign-language-page-content
  • GET /api/content-catalog/read/dashboard-sign-of-week
  • PUT /api/content-catalog/sign-language-items
  • PUT /api/content-catalog/dashboard-sign-of-week

Learned progress uses:

  • GET /api/user_progress?progress_type=sign_learned
  • POST /api/user_progress
  • DELETE /api/user_progress/by-item

Content payloads are seeded in:

  • backend/src/db/seeders/content-catalog-data/content-catalog-seed-payloads.ts

Behavior

  • useSignLanguagePage loads sign items, page content, and learned sign progress.
  • Organization-scope users with MANAGE_CONTENT_CATALOG can create, edit, and delete sign cards from the sign language page. The management panel writes the full org-scoped sign-language-items payload through the managed content catalog endpoint.
  • The sign editor supports title, description, category, step-by-step guide, teaching tip, preview image URL or upload, GIF URL or upload, YouTube video URL, and optional YouTube search URL.
  • The Sign of the Week selector stores the selected card in dashboard-sign-of-week by signId, current Sunday-start weekOf, and display fallback fields. Dashboard and notification rendering resolve that selector back to the live sign card, with word-based fallback for older seeded payloads.
  • Learned progress is a personal persisted state. When a parent-scope user is drilled into a child tenant, the page still shows sign content, but it does not load/write learned-sign progress or render "Progress Saved" / "Learned" affordances.
  • Selectors handle category counts, search/category filtering, 12-card pagination, progress percentage, video duration, filter normalization, media URL normalization, and YouTube search URL construction.
  • The grid displays 12 cards per page after search/category filters are applied. Changing search or category resets to page 1. Pagination stays visible for any non-empty result set, with previous/next controls disabled when there is only one page.
  • Sign item media is normalized before rendering:
    • image URLs are trimmed;
    • YouTube watch, short, embed, shorts, and raw video IDs are normalized to embed URLs;
    • Lifeprint GIF absolute and relative paths are normalized to the canonical /asl101/gifs catalog;
    • legacy Lifeprint /asl101/images-signs entries are treated as missing animated demos, so the modal shows the reference image fallback;
    • YouTube search terms are trimmed and URL-encoded.
  • View components receive a prepared page model and do not call API/data access modules.
  • The video modal uses useSignLanguageVideoModalState for GIF/video mode, GIF loading state, and step-guide expansion.
  • Loading, empty, and error states are explicit through StatePanel.

Data Ownership Rules

  • Do not add sign records, teaching tips, page reminders, video URLs, GIF URLs, or step instructions to frontend constants.
  • Do not add frontend fallback sign payloads.
  • Keep frontend constants limited to filter options, category style classes, external URL templates, and UI view modes.
  • Sign of the Week is selected from existing sign cards; do not duplicate dashboard-only sign content.
  • Test-only fixtures may live in selector tests or frontend/src/test-seeds/.