diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0c78f94..ee22521 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,18 @@
# Changelog
+## 2.30.0 — 2026-11-16
+
+- UI, accessibility, modal, typography, and bug-fix improvements (#182, #183, #184, #185, #186, #187, #188, #189, #190, #191, #192, #193, #194, #195, #196, #197, #199):
+ - Bundle SIL Open Font License 1.1 variable **Manrope** typeface locally (`dist/fonts/Manrope-VariableFont_wght.ttf` and inline data-URI `@font-face`), and synchronize `fontFamily` changes (`default`, `legible`, `dyslexia-option`) across `.arap-root`, panels, portals, modals, reading mode, playback bar, and accessible tooltips via `activeFont` / `data-arap-font` (#189).
+ - Add reusable `ModalDialog` and collapsible `FeatureGroup` primitives, default `"experimental"` collapsible group (`smartContrast`, `voiceNavigation`, `translation`), and move search-heavy views (`Profiles`, `Presets`, `Page Navigator`, `Dictionary`, `Keyboard Shortcuts`) into spacious responsive modals (#183, #195, #197).
+ - Widen default desktop panel to `460px` and add desktop-only (`>= 1024px` fine-pointer) transient pointer + keyboard panel resizing with clamped viewport bounds (#185, #186).
+ - Fix `.arap-btn-sm` stepper scoping, `.arap-feature-expandable` flex layout, unstyled `.arap-feature-btn`, duplicate search clear icons, duplicate footer close/revert controls, Read-Aloud `44px` mini-player targets, form-field `id`/`name` compliance, and primary blue CTA hierarchy (#182, #184, #191, #192, #196).
+ - Move Reading Guide and Reading Mask `↑`/`↓` nudge controls out of the panel into external `44px` `` floating buttons (`data-aid="guide"|"mask"`) so mobile/touch users can reposition overlays without reopening the widget panel (#199).
+ - Expand offline local dictionary glossaries (`"voice"`, `"voice navigation"`, `"read aloud"`, `"translation"`, `"keyboard"`, `"landmark"`, etc.) with fuzzy typo suggestions and truthful empty states (#188).
+ - Fix host-content translation boundaries (`[data-arap-ui]`, `.arap-root`, ``/``), BCP-47 subtag normalization, offline multi-language lexicon translation (`[TR] ...`), dynamic DOM observation, live language switching, and visible status banner (#187).
+ - Harden reading guide and reading mask geometry/z-index isolation (`2147482000`), ignore pointer tracking over widget UI, remove duplicate `document` `keydown` listener, preserve vertical mask position across height changes, preserve CSS gradients under `hideImages`, and expand video embed hiding under `hideVideos` (#193, #194).
+ - Clean up examples (`examples/basic-usage` and `examples/next-app`) to remove duplicate controllers, group sections cleanly, and include offline SVG and `` media fixtures (#194, #196, #197).
+
## 2.29.2 — 2026-11-11
- Replace rate-limited Bundlephobia badge in `README.md` with high-reliability edge-rendered `bundlejs` badge.
diff --git a/NOTICE b/NOTICE
index 16fa5d5..0987d91 100644
--- a/NOTICE
+++ b/NOTICE
@@ -11,9 +11,12 @@ https://github.com/prabothcharith/accessibility-plugin
Third-Party Assets & Licensure:
- Zero Runtime Dependencies: This library has no runtime dependencies outside of
peer dependencies on React and React DOM.
-- Fonts: No third-party binary font files (.woff, .woff2, .ttf) are bundled. All font
- presets utilize client-system font stacks (e.g. system-ui, -apple-system, sans-serif)
- with fallback declarations.
+- Fonts: The plugin bundles the variable Manrope typeface
+ (`src/styles/fonts/Manrope-VariableFont_wght.ttf` -> `dist/fonts/Manrope-VariableFont_wght.ttf`
+ and inlined `@font-face` data URI in JS bundles) as the default UI font,
+ licensed under the SIL Open Font License 1.1 (`OFL.txt` included alongside
+ the font asset). Additional font presets (`legible`, `dyslexia-option`)
+ utilize client-system font stacks with zero external network font requests.
- Icons: All decorative icons are authored directly as inline SVG elements under the
package's ISC License.
- Dictionaries: Built-in glossaries (English, Sinhala, Tamil) are compiled in-tree
diff --git a/docs/API.md b/docs/API.md
index a39378a..e3f3d8d 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -11,6 +11,8 @@ All exports are named from `accessibility-plugin-react`. JavaScript consumers re
| AccessibilityList | `footer?: ReactNode` extra fixed actions; `children?: ReactNode` optional; `menuConfig?: MenuCustomizationConfig` optional; `title?: string` visible heading and region name, default Accessibility settings; `description?: string` default Adjust your reading experience; `closeLabel?: string` default Close; `statementUrl?: string`; `largeControls?: boolean`; `locale?: string`; `className?: string`; `style?: CSSProperties` |
| FeatureMenu | `config?: MenuCustomizationConfig`; `grouped?: boolean` default false; `className?: string`. Renders an ordered, validated, and optionally grouped accessibility menu with non-crashing diagnostics and stable rerenders. See docs/MENU_CUSTOMIZATION.md. |
| FeatureCard | `title: ReactNode` required; `children: ReactNode` required; `featureKey?: string`; `icon?: ReactNode`; `description?: ReactNode`; `statusBadge?: string`; `status?: 'idle' \| 'active' \| 'error' \| 'unavailable' \| 'permission-required'`; `errorMessage?: string`; `unavailableMessage?: string`; `permissionMessage?: string`; `onRequestPermission?: () => void`; `largeControls?: boolean` |
+| FeatureGroup | `title: string` required; `id?: string`; `description?: string`; `badge?: string`; `collapsible?: boolean` default false; `defaultExpanded?: boolean` default true; `expanded?: boolean`; `onExpandedChange?: (expanded: boolean) => void`; `children: ReactNode` |
+| ModalDialog | `isOpen: boolean` required; `onClose: () => void` required; `title: string` required; `subtitle?: string`; `icon?: ReactNode`; `closeLabel?: string`; `size?: 'md' \| 'lg' \| 'full'`; `trapFocus?: boolean`; `lockScroll?: boolean`; `footer?: ReactNode`; `children: ReactNode` |
| ToggleControl | `label: ReactNode` required; `checked: boolean` required; `onChange: (checked: boolean) => void` required; `disabled?: boolean`; `unavailable?: boolean`; `unavailableReason?: string`; `largeControls?: boolean` |
| ChoiceControl | `label: string` required; `value: T` required; `options?: ChoiceOption[]`; `groups?: ChoiceGroup[]`; `onChange: (value: T) => void` required; `disabled?: boolean`; `largeControls?: boolean` |
| StepperControl | `label: string` required; `value: number` required; `min: number`; `max: number`; `step: number`; `unit?: string` default '%'; `showSlider?: boolean`; `formatValue?: (val: number) => string`; `onChange: (value: number) => void` required; `disabled?: boolean`; `largeControls?: boolean` |
@@ -58,9 +60,9 @@ Definitions/defaults are immutable for the provider lifetime; the first register
`FeatureRegistration` is `FeatureOptions` plus `defaultValue: unknown`. Use the generic hook instead of manually casting callbacks. Legacy `registerReset(key, fn)` / `unregisterReset(key)` remain available; callbacks run before global state is cleared. They are not the primary effect lifecycle API. Callback owners must unregister their callback on teardown.
-Exported types: `AccessibilityPluginProps`, `AccessibilityButtonProps`, `AccessibilityListProps`, `AccessibilityState`, `AccessibilityContextValue`, `PluginPosition`, `WidgetPlacement`, `FeatureOptions`, `FeatureRegistration`, `ToggleControlProps`, `ChoiceControlProps`, `ChoiceOption`, `ChoiceGroup`, `StepperControlProps`, `FeatureCardProps`, `FeatureStatus`, `SearchCountProps`, `EmptyStateProps`, `ErrorStateProps`, `ProfilePreviewCardProps`, `FontSizeControllerProps`, `TextScaleControllerProps`, `TextScaleStep`, `FontFamilyPreset`, `ContrastModeValue`, `ContrastPalette`, `LineHeightControllerProps`, `LetterSpacingControllerProps`, `WordSpacingControllerProps`, `ParagraphSpacingControllerProps`, `ScriptSpacingConstraints`, `SkipToMainLinkProps`, `HideImagesControllerProps`, `BigCursorControllerProps`, `ReadingMaskControllerProps`, `ReadingGuideControllerProps`, `TooltipsControllerProps`, `PageNavigatorControllerProps`, `HeadingItem`, `LandmarkItem`, `LinkItem`, `ProfilesControllerProps`, `ActiveProfileState`, `UseProfilesResult`, `AccessibilityPreferences`, `ContrastMode`, `CursorSizePreference`, `FontFamilyPreference`, `ProfileDefinition`, `ProfilePresetId`, `ReaderMode`, `SaturationPreference`, `StorageMode`, `TextAlignPreference`, `LocaleStrings`, `SupportedLocale`, `FeatureLocaleLabels`, `PresetsControllerProps`, `CustomPreset`, `PresetsExportV1`, `ImportResult`, `UsePresetsResult`, `ReadingModeControllerProps`, `ArticleContent`, `KeyboardShortcutsControllerProps`, `ShortcutDefinition`, `ValidationResult`, `ReadAloudControllerProps`, `ReadAloudOptions`, `ReadAloudState`, `SaturationControllerProps`, `GrayscaleControllerProps`, `DictionaryControllerProps`, `DictionaryEntry`, `DictionaryLookupResult`, `DictionaryProvider`, `FeatureMenuProps`, `FeatureMenuItemConfig`, `FeatureMenuGroupConfig`, `MenuCustomizationConfig`, `MenuValidationIssue`, `MenuValidationResult`, `NormalizedMenuConfig`, `NormalizedMenuItem`, `NormalizedMenuGroup`, `VoiceNavigationControllerProps`, `VoiceNavigationStatus`, `VoiceCommandId`, `VoiceCommandDefinition`, `VoiceNavigationResult`, `VoiceNavigationOptions`, `VoiceNavigationSession`, `VoiceExecutionContext`, `TranslationControllerProps`, `TranslationAdapter`, `TranslationRequest`, `TranslationResponse`, `TranslatedItem`, `DataRetentionPolicy`, `TranslationConsentStatus`, `TranslationConsentRecord`, `TranslatableNode`, `TranslationSession`, `TranslationErrorCode`, `SmartContrastLevel`, `UnsupportedReason`, `RgbColor`, `RgbaColor`, `UnsupportedElementInfo`, `SmartContrastReport`, `SmartContrastOptions`, `AppliedSmartContrast`, `BackdropResolution`, `DiagnosticsHarnessProps`, `DiagnosticCategory`, `DiagnosticIssue`, `DiagnosticSeverity`, `DiagnosticsConfig`, `DiagnosticsReport`, `DiagnosticsSummary`, `AccessibilityEventType`, `EventTriggerSource`, `BaseAccessibilityEvent`, `FeatureChangeEvent`, `FeatureResetEvent`, `PanelToggleEvent`, `PlacementChangeEvent`, `ProfileApplyEvent`, `PresetApplyEvent`, `AccessibilityFeatureEvent`, `FeatureEventListener`.
+Exported types: `AccessibilityPluginProps`, `AccessibilityButtonProps`, `AccessibilityListProps`, `AccessibilityState`, `AccessibilityContextValue`, `PluginPosition`, `WidgetPlacement`, `FeatureOptions`, `FeatureRegistration`, `ToggleControlProps`, `ChoiceControlProps`, `ChoiceOption`, `ChoiceGroup`, `StepperControlProps`, `FeatureCardProps`, `FeatureGroupProps`, `ModalDialogProps`, `FeatureStatus`, `SearchCountProps`, `EmptyStateProps`, `ErrorStateProps`, `ProfilePreviewCardProps`, `FontSizeControllerProps`, `TextScaleControllerProps`, `TextScaleStep`, `FontFamilyPreset`, `ContrastModeValue`, `ContrastPalette`, `LineHeightControllerProps`, `LetterSpacingControllerProps`, `WordSpacingControllerProps`, `ParagraphSpacingControllerProps`, `ScriptSpacingConstraints`, `SkipToMainLinkProps`, `HideImagesControllerProps`, `BigCursorControllerProps`, `ReadingMaskControllerProps`, `ReadingGuideControllerProps`, `TooltipsControllerProps`, `PageNavigatorControllerProps`, `HeadingItem`, `LandmarkItem`, `LinkItem`, `ProfilesControllerProps`, `ActiveProfileState`, `UseProfilesResult`, `AccessibilityPreferences`, `ContrastMode`, `CursorSizePreference`, `FontFamilyPreference`, `ProfileDefinition`, `ProfilePresetId`, `ReaderMode`, `SaturationPreference`, `StorageMode`, `TextAlignPreference`, `LocaleStrings`, `SupportedLocale`, `FeatureLocaleLabels`, `PresetsControllerProps`, `CustomPreset`, `PresetsExportV1`, `ImportResult`, `UsePresetsResult`, `ReadingModeControllerProps`, `ArticleContent`, `KeyboardShortcutsControllerProps`, `ShortcutDefinition`, `ValidationResult`, `ReadAloudControllerProps`, `ReadAloudOptions`, `ReadAloudState`, `SaturationControllerProps`, `GrayscaleControllerProps`, `DictionaryControllerProps`, `DictionaryEntry`, `DictionaryLookupResult`, `DictionaryProvider`, `FeatureMenuProps`, `FeatureMenuItemConfig`, `FeatureMenuGroupConfig`, `MenuCustomizationConfig`, `MenuValidationIssue`, `MenuValidationResult`, `NormalizedMenuConfig`, `NormalizedMenuItem`, `NormalizedMenuGroup`, `VoiceNavigationControllerProps`, `VoiceNavigationStatus`, `VoiceCommandId`, `VoiceCommandDefinition`, `VoiceNavigationResult`, `VoiceNavigationOptions`, `VoiceNavigationSession`, `VoiceExecutionContext`, `TranslationControllerProps`, `TranslationAdapter`, `TranslationRequest`, `TranslationResponse`, `TranslatedItem`, `DataRetentionPolicy`, `TranslationConsentStatus`, `TranslationConsentRecord`, `TranslatableNode`, `TranslationSession`, `TranslationErrorCode`, `SmartContrastLevel`, `UnsupportedReason`, `RgbColor`, `RgbaColor`, `UnsupportedElementInfo`, `SmartContrastReport`, `SmartContrastOptions`, `AppliedSmartContrast`, `BackdropResolution`, `DiagnosticsHarnessProps`, `DiagnosticCategory`, `DiagnosticIssue`, `DiagnosticSeverity`, `DiagnosticsConfig`, `DiagnosticsReport`, `DiagnosticsSummary`, `AccessibilityEventType`, `EventTriggerSource`, `BaseAccessibilityEvent`, `FeatureChangeEvent`, `FeatureResetEvent`, `PanelToggleEvent`, `PlacementChangeEvent`, `ProfileApplyEvent`, `PresetApplyEvent`, `AccessibilityFeatureEvent`, `FeatureEventListener`.
-Exported control components: `ToggleControl`, `ChoiceControl`, `StepperControl`, `FeatureCard`, `SearchCount`, `EmptyState`, `ErrorState`, `ProfilePreviewCard`, `FontSizeController`, `TextScaleController`, `LineHeightController`, `LetterSpacingController`, `WordSpacingController`, `ParagraphSpacingController`, `FontFamilyController`, `TextAlignController`, `ContrastController`, `ContrastModeController`, `SmartContrastController`, `LinkHighlightController`, `HighlightFocusController`, `FocusHighlightController`, `ReduceMotionController`, `HideImagesController`, `HideDecorativeImagesController`, `BigCursorController`, `ReadingMaskController`, `ReadingGuideController`, `TooltipsController`, `AccessibleTooltipsController`, `PageNavigatorController`, `HeadingsNavigatorController`, `PageStructureController`, `ProfilesController`, `ProfileController`, `AccessibilityProfilesController`, `PresetsController`, `CustomPresetsController`, `SettingsImportExportController`, `PresetsBackupController`, `ReadingModeController`, `KeyboardShortcutsController`, `ReadAloudController`, `DictionaryController`, `VoiceNavigationController`, `TranslationController`, `FeatureMenu`, `SkipToMainLink`, `DiagnosticsHarness`.
+Exported control components: `ToggleControl`, `ChoiceControl`, `StepperControl`, `FeatureCard`, `FeatureGroup`, `ModalDialog`, `SearchCount`, `EmptyState`, `ErrorState`, `ProfilePreviewCard`, `FontSizeController`, `TextScaleController`, `LineHeightController`, `LetterSpacingController`, `WordSpacingController`, `ParagraphSpacingController`, `FontFamilyController`, `TextAlignController`, `ContrastController`, `ContrastModeController`, `SmartContrastController`, `LinkHighlightController`, `HighlightFocusController`, `FocusHighlightController`, `ReduceMotionController`, `HideImagesController`, `HideDecorativeImagesController`, `BigCursorController`, `ReadingMaskController`, `ReadingGuideController`, `TooltipsController`, `AccessibleTooltipsController`, `PageNavigatorController`, `HeadingsNavigatorController`, `PageStructureController`, `ProfilesController`, `ProfileController`, `AccessibilityProfilesController`, `PresetsController`, `CustomPresetsController`, `SettingsImportExportController`, `PresetsBackupController`, `ReadingModeController`, `KeyboardShortcutsController`, `ReadAloudController`, `DictionaryController`, `VoiceNavigationController`, `TranslationController`, `FeatureMenu`, `SkipToMainLink`, `DiagnosticsHarness`.
Exported typography, contrast, reading aids, tooltips, reading mode, read aloud, reflow, and menu customization utilities: `TEXT_SCALE_STEPS`, `TEXT_SCALE_PROTECTED_SELECTOR`, `isProtectedFromTextScale`, `LINE_HEIGHT_STEPS`, `LINE_HEIGHT_RATIOS`, `TEXT_SPACING_EXCLUDED_SELECTOR`, `isProtectedFromTextSpacing`, `getScriptSpacingConstraints`, `FONT_FAMILY_PRESETS`, `LEGIBLE_FONT_STACK`, `DYSLEXIA_FONT_STACK`, `FONT_FAMILY_PROTECTED_SELECTOR`, `isProtectedFromFontFamily`, `TEXT_ALIGN_BLOCK_SELECTOR`, `isProtectedFromTextAlign`, `CONTRAST_MODES`, `isForcedColorsActive`, `subscribeForcedColors`, `isReducedMotionActive`, `subscribeReducedMotion`, `isEligibleDecorativeImage`, `isFunctionalOrMeaningfulImage`, `hasFinePointer`, `subscribeFinePointer`, `nudgeReadingAid`, `DEFAULT_READING_MASK_HEIGHT`, `MIN_READING_MASK_HEIGHT`, `MAX_READING_MASK_HEIGHT`, `READING_MASK_HEIGHT_PRESETS`, `getAuthoredDescription`, `positionTooltip`, `enableAccessibleTooltips`, `scanHeadings`, `scanLandmarks`, `scanLinks`, `navigateToElement`, `subscribePageStructure`, `useProfiles`, `ALL_PROFILE_IDS`, `getProfileDefinition`, `mapProfileSettingsToFeatures`, `mapFeaturesToProfileSettings`, `applyProfileToStore`, `revertProfileFromStore`, `recordProfileOverride`, `usePresets`, `createCustomPreset`, `isValidCustomPreset`, `exportPresetsToJson`, `downloadJsonFile`, `validateAndParseImport`, `applyCustomPresetToStore`, `sanitizePreferences`, `ALLOWED_PREFERENCE_KEYS`, `extractArticleContent`, `findArticleCandidate`, `countWords`, `estimateReadingTime`, `CONTRAST_PROTECTED_SELECTOR`, `isProtectedFromContrast`, `CONTRAST_PALETTES`, `findMainLandmark`, `DEFAULT_SHORTCUTS`, `RESERVED_BROWSER_SHORTCUTS`, `normalizeKeyCombo`, `parseKeyboardEventToCombo`, `isFormFieldOrEditable`, `validateShortcutRemap`, `resolveActiveShortcut`, `isSpeechSynthesisSupported`, `getSpeechVoices`, `subscribeSpeechVoices`, `getActiveSelectionText`, `extractReadAloudText`, `splitTextIntoChunks`, `ReadAloudSession`, `READ_ALOUD_EXCLUDED_SELECTORS`, `sanitizeLookupTerm`, `lookupLocalDictionary`, `lookupWord`, `LOCAL_DICTIONARY_EN`, `LOCAL_DICTIONARY_SI`, `LOCAL_DICTIONARY_TA`, `validateMenuConfig`, `getMenuConfigSignature`, `KNOWN_FEATURE_IDS`, `DEFAULT_MENU_GROUPS`, `DEFAULT_FEATURE_GROUP_MAP`, `SMART_CONTRAST_DISCLAIMER`, `TARGET_RATIOS`, `HIGH_CONTRAST_TOKENS`, `parseColor`, `calculateRelativeLuminance`, `calculateContrastRatio`, `compositeRgba`, `isLargeText`, `resolveEffectiveBackdrop`, `isEligibleForSmartContrast`, `evaluateSmartContrast`, `applySmartContrast`, `VOICE_COMMANDS`, `VOICE_NAVIGATION_DISCLAIMER`, `isSpeechRecognitionSupported`, `normalizeTranscript`, `matchVoiceCommand`, `executeVoiceCommand`, `createVoiceNavigationSession`, `TRANSLATION_ERROR_CODES`, `TRANSLATION_DISCLAIMER`, `MAX_NODES_PER_TRANSLATION_BATCH`, `MAX_TEXT_LENGTH_PER_NODE`, `isSensitiveElement`, `extractTranslatableNodes`, `sanitizeTranslationOutput`, `applyTranslations`, `createOfflineMockTranslationAdapter`, `translateHostContent`, `TranslationError`, `runDiagnostics`, `checkProviderDiagnostics`, `checkStorageDiagnostics`, `checkCspDiagnostics`, `checkHostCssDiagnostics`, `checkDomDiagnostics`, `checkBoundariesDiagnostics`, `DIAGNOSTICS_DISCLAIMER`, `useDiagnostics`, `sanitizeFeatureEvent`, `emitFeatureEvent`.
diff --git a/docs/CSP.md b/docs/CSP.md
index 76a24e1..df7fdc2 100644
--- a/docs/CSP.md
+++ b/docs/CSP.md
@@ -37,6 +37,15 @@ This guide explains how `accessibility-plugin-react` operates under Content Secu
```
If `data:` is omitted from `img-src`, the browser will fall back to native system cursors.
+### D. Bundled Manrope UI Typography (`font-src`)
+
+- **Default UI font:** The library bundles the variable **Manrope** typeface locally (`dist/fonts/Manrope-VariableFont_wght.ttf` for standalone CSS imports, and inlined `data:font/ttf;base64,...` within the runtime injected styles in `dist/index.mjs` / `dist/index.js`) with zero external font CDN calls.
+- **Recommended directive:**
+ ```text
+ font-src 'self' data:;
+ ```
+ If `data:` is omitted from `font-src`, import `accessibility-plugin-react/style.css` so your bundler serves `dist/fonts/Manrope-VariableFont_wght.ttf` from `'self'`.
+
---
## 2. Next.js App Router Strict CSP Recipe
@@ -54,7 +63,7 @@ const cspHeader = `
style-src 'self' 'unsafe-inline';
style-src-attr 'unsafe-inline';
img-src 'self' data:;
- font-src 'self';
+ font-src 'self' data:;
object-src 'none';
base-uri 'self';
form-action 'self';
@@ -106,7 +115,7 @@ export function middleware(request: NextRequest) {
style-src 'self' 'nonce-${nonce}';
style-src-attr 'unsafe-inline';
img-src 'self' data:;
- font-src 'self';
+ font-src 'self' data:;
base-uri 'self';
form-action 'self';
`
@@ -159,7 +168,7 @@ For Vite applications, configure CSP headers either through your production web
style-src 'self' 'unsafe-inline';
style-src-attr 'unsafe-inline';
img-src 'self' data:;
- font-src 'self';
+ font-src 'self' data:;
"
/>
diff --git a/docs/DESIGN.md b/docs/DESIGN.md
index b40e224..5d87ce6 100644
--- a/docs/DESIGN.md
+++ b/docs/DESIGN.md
@@ -4,7 +4,7 @@ The owner selected the Clean light concept on 2026-10-13. It establishes the def
## Principles implemented
-- 400px maximum panel width, rounded border and soft shadow. The panel fits narrow screens, safe areas and existing four placements.
+- 460px default desktop panel width (380–720px pointer/keyboard resizable on fine-pointer desktop viewports >=1024px wide; non-resizable and full-bleed responsive down to 320px/400% zoom), rounded border, Manrope default UI typography synced with `fontFamily` presets (`default`, `legible`, `dyslexia-option`), and spacious full-viewport dialogs (`ModalDialog`) for search-heavy views.
- Strong heading with optional supporting description; the close control keeps its accessible name and 44px target.
- Compact label/value rows on desktop. Steppers stack below labels on small screens so neither labels nor targets are squeezed.
- Cohesive decorative SVG icons. Existing names and native controls remain the semantic interface.
diff --git a/docs/SECURITY_AUDIT.md b/docs/SECURITY_AUDIT.md
index bc9abdb..7d75269 100644
--- a/docs/SECURITY_AUDIT.md
+++ b/docs/SECURITY_AUDIT.md
@@ -6,14 +6,14 @@ This document provides a comprehensive security review, dependency audit, Conten
## 1. Executive summary and audit results
-| Audit Area | Standard / Requirement | Current Verification Result | Status |
-| :------------------- | :---------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------ | :------- |
-| **Dependencies** | 0 runtime dependencies; peerDependencies only | Clean `package.json`; 0 runtime dependencies. Only peer dependencies: React (`^18.3.1 \|\| ^19.0.0`) and React DOM. | **PASS** |
-| **Vulnerabilities** | `npm audit` 0 findings across direct and transitive tooling | `npm audit` returns 0 vulnerabilities across all installed packages. | **PASS** |
-| **Script Injection** | No dynamic code execution (`eval`, `new Function`) | Automated AST scan verifies 0 instances of `eval` or `Function` constructors across all `src/` modules. | **PASS** |
-| **Network Requests** | No unauthorized telemetry, tracking, or background calls | 0 `fetch()`, 0 `XMLHttpRequest`, 0 `navigator.sendBeacon`, 0 `WebSocket` calls. | **PASS** |
-| **Data Residency** | All state stored locally; zero external exfiltration | Preferences persist strictly in `localStorage` under `react-accessibility-plugin:state`. Zero cloud sync. | **PASS** |
-| **Licensing** | Permissive ISC license; clean IP attribution | Dedicated `LICENSE` and `NOTICE` files committed; zero GPL/copyleft or proprietary binary assets. | **PASS** |
+| Audit Area | Standard / Requirement | Current Verification Result | Status |
+| :------------------- | :---------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- |
+| **Dependencies** | 0 runtime dependencies; peerDependencies only | Clean `package.json`; 0 runtime dependencies. Only peer dependencies: React (`^18.3.1 \|\| ^19.0.0`) and React DOM. | **PASS** |
+| **Vulnerabilities** | `npm audit` 0 findings across direct and transitive tooling | `npm audit` returns 0 vulnerabilities across all installed packages. | **PASS** |
+| **Script Injection** | No dynamic code execution (`eval`, `new Function`) | Automated AST scan verifies 0 instances of `eval` or `Function` constructors across all `src/` modules. | **PASS** |
+| **Network Requests** | No unauthorized telemetry, tracking, or background calls | 0 `fetch()`, 0 `XMLHttpRequest`, 0 `navigator.sendBeacon`, 0 `WebSocket` calls. | **PASS** |
+| **Data Residency** | All state stored locally; zero external exfiltration | Preferences persist strictly in `localStorage` under `react-accessibility-plugin:state`. Zero cloud sync. | **PASS** |
+| **Licensing** | Permissive ISC license + SIL OFL 1.1 font attribution | Dedicated `LICENSE` and `NOTICE` files committed; bundles SIL OFL 1.1 `Manrope-VariableFont_wght.ttf` with zero GPL/copyleft or proprietary binary assets. | **PASS** |
---
@@ -78,6 +78,6 @@ Features that inspect or transform DOM elements (such as host translation, read
- **License**: Released under the open-source **ISC License** (permissive, GPL-compatible).
- **Attribution**: Derived from the original vanilla JavaScript accessibility plugin; attribution is documented in `NOTICE` and `README.md`.
- **Assets**:
- - **Fonts**: No binary font files (`.woff`, `.woff2`, `.ttf`) are bundled. Presets rely entirely on standard system font stacks.
+ - **Fonts**: Bundles the open-source variable **Manrope** font (`Manrope-VariableFont_wght.ttf`) under the **SIL Open Font License 1.1** (`dist/fonts/OFL.txt` and `NOTICE`), with offline client-system fallback stacks for legible and dyslexia presets. Zero external Google Fonts or remote CDN requests.
- **Icons**: Authored in-tree as native inline SVG icons under ISC.
- **Glossary Data**: Built-in dictionary entries (English, Sinhala, Tamil) are compiled in-tree under ISC for offline accessibility lookup.
diff --git a/examples/basic-usage/main.tsx b/examples/basic-usage/main.tsx
index 586ee47..12e0cf7 100644
--- a/examples/basic-usage/main.tsx
+++ b/examples/basic-usage/main.tsx
@@ -4,7 +4,7 @@ import {
AccessibilityPlugin,
AccessibilityButton,
AccessibilityList,
- TextScaleController,
+ FeatureGroup,
FontSizeController,
LineHeightController,
LetterSpacingController,
@@ -12,11 +12,9 @@ import {
ParagraphSpacingController,
FontFamilyController,
TextAlignController,
- ContrastController,
ContrastModeController,
SaturationController,
InvertColorsController,
- GrayscaleController,
LinkHighlightController,
HighlightFocusController,
ReduceMotionController,
@@ -39,6 +37,18 @@ import {
ResetController,
} from "accessibility-plugin-react";
+const DECORATIVE_BANNER_SVG =
+ "data:image/svg+xml;utf8," +
+ encodeURIComponent(
+ 'Decorative divider pattern ',
+ );
+
+const INFORMATIVE_DIAGRAM_SVG =
+ "data:image/svg+xml;utf8," +
+ encodeURIComponent(
+ '44px Min Target Contrast 7.2:1 Informative graphic (preserved) ',
+ );
+
function App() {
const [dark, setDark] = useState(false);
const [activeTab, setActiveTab] = useState<"overview" | "article">(
@@ -60,38 +70,80 @@ function App() {
description="Adjust display settings"
/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -144,7 +196,10 @@ function App() {
- Decorative Images
+ Decorative & Informative Media
- Decorative images below are eligible to be hidden when the Hide
- Images mode is activated:
+ Hide Images conceals purely decorative visuals below while keeping
+ informative diagrams visible. Hide Videos hides video players
+ while preserving layout space.
-
+ >
+
+
+
+
+
+
+
+
) : (
-
+
Simulated Route: Long Article
This view simulates navigating to a reading-heavy page to test
@@ -191,7 +285,13 @@ function App() {
how the container adjusts naturally without layout truncation or
unintended scrollbars.
-
+ Section 2: Semantic Landmarks & Reading Mode
+
+ Semantic landmarks and structured headings allow Page Navigator
+ and Reading Mode to isolate primary prose cleanly even when
+ toggling between dark mode, custom typography, and live routes.
+
+
)}
diff --git a/examples/next-app/app/components/AccessibilitySettings.tsx b/examples/next-app/app/components/AccessibilitySettings.tsx
index 5ea4a88..b47d15f 100644
--- a/examples/next-app/app/components/AccessibilitySettings.tsx
+++ b/examples/next-app/app/components/AccessibilitySettings.tsx
@@ -4,7 +4,7 @@ import {
AccessibilityPlugin,
AccessibilityButton,
AccessibilityList,
- TextScaleController,
+ FeatureGroup,
FontSizeController,
LineHeightController,
LetterSpacingController,
@@ -12,11 +12,9 @@ import {
ParagraphSpacingController,
FontFamilyController,
ContrastModeController,
- ContrastController,
SmartContrastController,
SaturationController,
InvertColorsController,
- GrayscaleController,
LinkHighlightController,
HighlightFocusController,
ReduceMotionController,
@@ -47,38 +45,80 @@ export function AccessibilitySettings() {
description="Adjust your display and reading preferences"
/>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/next-app/next.config.mjs b/examples/next-app/next.config.mjs
index 7abaf57..93946de 100644
--- a/examples/next-app/next.config.mjs
+++ b/examples/next-app/next.config.mjs
@@ -5,7 +5,7 @@ const cspHeader = `
style-src 'self' 'unsafe-inline';
style-src-attr 'unsafe-inline';
img-src 'self' data:;
- font-src 'self';
+ font-src 'self' data:;
object-src 'none';
base-uri 'self';
form-action 'self';
diff --git a/package-lock.json b/package-lock.json
index 21f1d90..2bc85cd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "accessibility-plugin-react",
- "version": "2.29.2",
+ "version": "2.30.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "accessibility-plugin-react",
- "version": "2.29.2",
+ "version": "2.30.0",
"license": "ISC",
"devDependencies": {
"@axe-core/playwright": "^4.13.0",
diff --git a/package.json b/package.json
index 1baafef..82924a4 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "accessibility-plugin-react",
- "version": "2.29.2",
+ "version": "2.30.0",
"description": "A composable React display-preference widget with a clean light design, persistent settings and movable accessible controls.",
"main": "dist/index.js",
"module": "dist/index.mjs",
@@ -17,7 +17,8 @@
}
},
"./dist/style.css": "./dist/style.css",
- "./style.css": "./dist/style.css"
+ "./style.css": "./dist/style.css",
+ "./fonts/*": "./dist/fonts/*"
},
"files": [
"dist",
diff --git a/scripts/build-css.mjs b/scripts/build-css.mjs
index ea2dc59..84be8e8 100644
--- a/scripts/build-css.mjs
+++ b/scripts/build-css.mjs
@@ -1,3 +1,29 @@
-import { copyFile, mkdir } from "node:fs/promises";
-await mkdir("dist", { recursive: true });
+import { copyFile, cp, mkdir, readFile, writeFile } from "node:fs/promises";
+import assert from "node:assert/strict";
+
+await mkdir("dist/fonts", { recursive: true });
await copyFile("src/styles/tailwind.css", "dist/style.css");
+await cp("src/styles/fonts", "dist/fonts", { recursive: true });
+
+// tsup injects CSS as a raw string without resolving font url() assets; inline base64
+// into the runtime JS bundles while leaving dist/style.css referencing dist/fonts/.
+const ttfBytes = await readFile(
+ "src/styles/fonts/Manrope-VariableFont_wght.ttf",
+);
+const fontDataUri = `data:font/ttf;base64,${ttfBytes.toString("base64")}`;
+const fontUrlPattern =
+ /url\(\s*(?:"\.\/fonts\/Manrope-VariableFont_wght\.ttf"|'\.\/fonts\/Manrope-VariableFont_wght\.ttf'|\.\/fonts\/Manrope-VariableFont_wght\.ttf)\s*\)/g;
+
+for (const bundleFile of ["dist/index.mjs", "dist/index.js"]) {
+ const source = await readFile(bundleFile, "utf8");
+ assert(
+ fontUrlPattern.test(source),
+ `Expected Manrope font URL placeholder in ${bundleFile}`,
+ );
+ fontUrlPattern.lastIndex = 0;
+ await writeFile(
+ bundleFile,
+ source.replace(fontUrlPattern, `url(${fontDataUri})`),
+ "utf8",
+ );
+}
diff --git a/scripts/check-package.mjs b/scripts/check-package.mjs
index 6778fcd..d24b578 100644
--- a/scripts/check-package.mjs
+++ b/scripts/check-package.mjs
@@ -27,6 +27,8 @@ for (const file of [
"dist/index.d.ts",
"dist/index.d.mts",
"dist/style.css",
+ "dist/fonts/Manrope-VariableFont_wght.ttf",
+ "dist/fonts/OFL.txt",
"LICENSE",
"NOTICE",
])
@@ -43,8 +45,21 @@ for (const file of ["dist/index.mjs", "dist/index.js"]) {
`Missing automatic CSS injection: ${file}`,
);
assert(bundle.includes(".arap-root"), `Missing bundled widget CSS: ${file}`);
+ assert(bundle.includes("Manrope"), `Missing bundled Manrope font: ${file}`);
+ assert(
+ bundle.includes("data:font/ttf;base64,"),
+ `Missing inlined Manrope data URI in ${file}`,
+ );
+ assert(
+ !bundle.includes("./fonts/Manrope-VariableFont_wght.ttf"),
+ `Relative Manrope font URL leaked into ${file}`,
+ );
}
const css = await readFile("dist/style.css", "utf8");
+assert(
+ css.includes("./fonts/Manrope-VariableFont_wght.ttf"),
+ "Standalone dist/style.css should reference ./fonts/Manrope-VariableFont_wght.ttf",
+);
assert(
!/(^|\})\s*(html|body|:root|\*)\s*\{/.test(css),
"Global reset detected",
diff --git a/src/core/AccessibilityList.tsx b/src/core/AccessibilityList.tsx
index 3de06e7..34b5b33 100644
--- a/src/core/AccessibilityList.tsx
+++ b/src/core/AccessibilityList.tsx
@@ -1,5 +1,14 @@
"use client";
-import { useContext, useEffect, useRef, useState } from "react";
+import {
+ useCallback,
+ useContext,
+ useEffect,
+ useRef,
+ useState,
+ useSyncExternalStore,
+ type KeyboardEvent as ReactKeyboardEvent,
+ type PointerEvent as ReactPointerEvent,
+} from "react";
import { AccessibilityContext } from "./AccessibilityContext";
import { PanelActionsContext } from "./PanelActionsContext";
import { PositionControls } from "./PositionControls";
@@ -14,6 +23,25 @@ import { resolveLocaleStrings, isRtlLocale } from "./i18n";
import { FeatureMenu } from "../features/FeatureMenu";
import type { AccessibilityListProps } from "./types";
+const finePointerSubscribe = (callback: () => void) => {
+ if (
+ typeof window === "undefined" ||
+ typeof window.matchMedia !== "function"
+ ) {
+ return () => {};
+ }
+ const mq = window.matchMedia("(pointer: fine) and (hover: hover)");
+ mq.addEventListener?.("change", callback);
+ return () => mq.removeEventListener?.("change", callback);
+};
+
+const finePointerSnapshot = () =>
+ typeof window !== "undefined" && typeof window.matchMedia === "function"
+ ? window.matchMedia("(pointer: fine) and (hover: hover)").matches
+ : true;
+
+const finePointerServerSnapshot = () => true;
+
function Panel({
children,
footer,
@@ -52,6 +80,119 @@ function Panel({
ctx.widgetPlacement?.kind === "corner"
? ctx.widgetPlacement.corner
: defaultCorner(ctx.position);
+
+ // Desktop-only resizable panel bounds (transient UI state; not persisted into storage)
+ const hasFinePointer = useSyncExternalStore(
+ finePointerSubscribe,
+ finePointerSnapshot,
+ finePointerServerSnapshot,
+ );
+
+ const isDesktopResizable =
+ viewport[0] >= 1024 && viewport[1] >= 520 && hasFinePointer;
+ const minPanelWidth = 380;
+ const maxPanelWidth = Math.min(
+ 720,
+ Math.max(minPanelWidth, viewport[0] - 48),
+ );
+ const minPanelHeight = 420;
+ const maxPanelHeight = Math.max(minPanelHeight, viewport[1] - 48);
+
+ const [panelSize, setPanelSize] = useState<{
+ width: number;
+ height: number;
+ } | null>(null);
+ const [isResizing, setIsResizing] = useState(false);
+
+ const clampPanelSize = useCallback(
+ (nextW: number, nextH: number) => ({
+ width: Math.max(
+ minPanelWidth,
+ Math.min(maxPanelWidth, Math.round(nextW)),
+ ),
+ height: Math.max(
+ minPanelHeight,
+ Math.min(maxPanelHeight, Math.round(nextH)),
+ ),
+ }),
+ [maxPanelHeight, maxPanelWidth],
+ );
+
+ const effectivePanelSize =
+ isDesktopResizable && panelSize
+ ? clampPanelSize(panelSize.width, panelSize.height)
+ : null;
+
+ const effectiveDesktopWidth = effectivePanelSize
+ ? effectivePanelSize.width
+ : 460;
+ const pointPlacementStyle = panelStyle(
+ ctx.widgetPlacement,
+ viewport,
+ triggerSize,
+ effectiveDesktopWidth,
+ );
+ const isRightAnchored =
+ ctx.widgetPlacement?.kind === "point" ? false : corner.endsWith("right");
+ const isTopAnchored =
+ ctx.widgetPlacement?.kind === "point"
+ ? Boolean(pointPlacementStyle?.top && pointPlacementStyle.top !== "auto")
+ : corner.startsWith("top");
+
+ const startPointerResize = (event: ReactPointerEvent) => {
+ if (!isDesktopResizable || !panel.current || event.button !== 0) return;
+ event.preventDefault();
+ event.stopPropagation();
+ const rect = panel.current.getBoundingClientRect();
+ const startX = event.clientX;
+ const startY = event.clientY;
+ const startW = rect.width;
+ const startH = rect.height;
+ setIsResizing(true);
+
+ const onMove = (moveEvent: PointerEvent) => {
+ const dx = moveEvent.clientX - startX;
+ const dy = moveEvent.clientY - startY;
+ const rawW = isRightAnchored ? startW - dx : startW + dx;
+ const rawH = isTopAnchored ? startH + dy : startH - dy;
+ setPanelSize(clampPanelSize(rawW, rawH));
+ };
+
+ const onEnd = () => {
+ setIsResizing(false);
+ window.removeEventListener("pointermove", onMove);
+ window.removeEventListener("pointerup", onEnd);
+ window.removeEventListener("pointercancel", onEnd);
+ };
+
+ window.addEventListener("pointermove", onMove);
+ window.addEventListener("pointerup", onEnd);
+ window.addEventListener("pointercancel", onEnd);
+ };
+
+ const handleResizeKeyDown = (event: ReactKeyboardEvent) => {
+ if (!isDesktopResizable) return;
+ const step = event.shiftKey ? 48 : 24;
+ const rect = panel.current?.getBoundingClientRect();
+ const currentW = effectivePanelSize?.width ?? rect?.width ?? 460;
+ const currentH = effectivePanelSize?.height ?? rect?.height ?? 560;
+
+ if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
+ event.preventDefault();
+ const dir = event.key === "ArrowLeft" ? -1 : 1;
+ const deltaW = isRightAnchored ? -dir * step : dir * step;
+ setPanelSize(clampPanelSize(currentW + deltaW, currentH));
+ } else if (event.key === "ArrowUp" || event.key === "ArrowDown") {
+ event.preventDefault();
+ const dir = event.key === "ArrowUp" ? -1 : 1;
+ const deltaH = isTopAnchored ? dir * step : -dir * step;
+ setPanelSize(clampPanelSize(currentW, currentH + deltaH));
+ } else if (event.key === "Home" || event.key === "Enter") {
+ event.preventDefault();
+ setPanelSize(null);
+ }
+ };
+
const previous = useRef(null);
useEffect(() => {
if (ctx.isOpen) {
@@ -75,14 +216,23 @@ function Panel({
@@ -191,6 +342,24 @@ function Panel({
({strings.openInNewTab})
+ {isDesktopResizable && (
+
+ )}
);
}
diff --git a/src/core/AccessibilityPlugin.tsx b/src/core/AccessibilityPlugin.tsx
index 4b95db2..9e25391 100644
--- a/src/core/AccessibilityPlugin.tsx
+++ b/src/core/AccessibilityPlugin.tsx
@@ -314,6 +314,14 @@ export function AccessibilityPlugin({
: undefined) ||
undefined;
+ const rawFont = getFeatureState("fontFamily", "default");
+ const activeFont =
+ rawFont === "legible" ||
+ rawFont === "dyslexia-option" ||
+ rawFont === "dyslexia"
+ ? rawFont
+ : "default";
+
useBuiltinEffects(active, handleDisable, { effectScope, nonce });
const value = useMemo(
() => ({
@@ -334,6 +342,7 @@ export function AccessibilityPlugin({
locale: effectiveLocale,
statementUrl,
largeControls,
+ activeFont,
effectScope,
nonce,
}),
@@ -355,6 +364,7 @@ export function AccessibilityPlugin({
effectiveLocale,
statementUrl,
largeControls,
+ activeFont,
effectScope,
nonce,
],
diff --git a/src/core/DiagnosticsHarness.tsx b/src/core/DiagnosticsHarness.tsx
index 6c12c43..0067252 100644
--- a/src/core/DiagnosticsHarness.tsx
+++ b/src/core/DiagnosticsHarness.tsx
@@ -1,6 +1,7 @@
"use client";
-import React, { useCallback, useEffect, useState } from "react";
+import React, { useCallback, useContext, useEffect, useState } from "react";
+import { AccessibilityContext } from "./AccessibilityContext";
import {
type DiagnosticIssue,
type DiagnosticsConfig,
@@ -30,6 +31,7 @@ export function DiagnosticsHarness({
process.env &&
process.env.NODE_ENV === "production";
+ const ctx = useContext(AccessibilityContext);
const [isOpen, setIsOpen] = useState(defaultOpen);
const [activeCategory, setActiveCategory] = useState("all");
const [report, setReport] = useState(() => {
@@ -90,6 +92,8 @@ export function DiagnosticsHarness({
{!isOpen ? (
() => {};
const clientSnapshot = () => true;
const serverSnapshot = () => false;
export function WidgetPortal({ children }: { children: ReactNode }) {
+ const ctx = useContext(AccessibilityContext);
const mounted = useSyncExternalStore(
subscribe,
clientSnapshot,
@@ -11,7 +13,11 @@ export function WidgetPortal({ children }: { children: ReactNode }) {
);
return mounted
? createPortal(
-
+
{children}
,
document.body,
diff --git a/src/core/controls/FeatureGroup.tsx b/src/core/controls/FeatureGroup.tsx
new file mode 100644
index 0000000..a985acf
--- /dev/null
+++ b/src/core/controls/FeatureGroup.tsx
@@ -0,0 +1,120 @@
+"use client";
+
+import { useId, useState, type ReactNode } from "react";
+
+export interface FeatureGroupProps {
+ id?: string;
+ title: string;
+ description?: string;
+ badge?: string;
+ collapsible?: boolean;
+ defaultExpanded?: boolean;
+ expanded?: boolean;
+ onExpandedChange?: (expanded: boolean) => void;
+ className?: string;
+ role?: "group" | "region";
+ "data-group"?: string;
+ children: ReactNode;
+}
+
+export function FeatureGroup({
+ id,
+ title,
+ description,
+ badge,
+ collapsible = false,
+ defaultExpanded = true,
+ expanded: controlledExpanded,
+ onExpandedChange,
+ className = "",
+ role,
+ "data-group": dataGroup,
+ children,
+}: FeatureGroupProps) {
+ const autoId = useId();
+ const baseId = id ?? `arap-group-${autoId}`;
+ const headingId = `${baseId}-heading`;
+ const contentId = `${baseId}-content`;
+
+ const [internalExpanded, setInternalExpanded] = useState(defaultExpanded);
+ const isControlled = controlledExpanded !== undefined;
+ const isExpanded = collapsible
+ ? isControlled
+ ? controlledExpanded
+ : internalExpanded
+ : true;
+
+ const handleToggle = () => {
+ const next = !isExpanded;
+ if (!isControlled) {
+ setInternalExpanded(next);
+ }
+ onExpandedChange?.(next);
+ };
+
+ return (
+
+ {collapsible ? (
+
+
+
+
+ {title}
+ {badge && {badge} }
+
+ {description && (
+ {description}
+ )}
+
+
+
+
+
+
+ ) : (
+
+
+
+
+ {title}
+
+ {badge && {badge} }
+
+ {description &&
{description}
}
+
+
+ )}
+
+
+ {children}
+
+
+ );
+}
+
+export default FeatureGroup;
diff --git a/src/core/controls/ModalDialog.tsx b/src/core/controls/ModalDialog.tsx
new file mode 100644
index 0000000..96a5fb8
--- /dev/null
+++ b/src/core/controls/ModalDialog.tsx
@@ -0,0 +1,207 @@
+"use client";
+
+import {
+ useEffect,
+ useId,
+ useRef,
+ type ReactNode,
+ type RefObject,
+} from "react";
+import { WidgetPortal } from "../WidgetPortal";
+
+export interface ModalDialogProps {
+ isOpen: boolean;
+ onClose: () => void;
+ id?: string;
+ title: string;
+ subtitle?: string;
+ icon?: ReactNode;
+ closeLabel?: string;
+ size?: "md" | "lg" | "full";
+ trapFocus?: boolean;
+ lockScroll?: boolean;
+ closeOnBackdrop?: boolean;
+ ariaModal?: boolean;
+ disableEscapeClose?: boolean;
+ initialFocusRef?: RefObject
;
+ returnFocusTo?: RefObject;
+ footer?: ReactNode;
+ className?: string;
+ children: ReactNode;
+}
+
+const FOCUSABLE_SELECTOR =
+ 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
+
+export function ModalDialog({
+ isOpen,
+ onClose,
+ id,
+ title,
+ subtitle,
+ icon,
+ closeLabel = "Close",
+ size = "full",
+ trapFocus = true,
+ lockScroll = true,
+ closeOnBackdrop = true,
+ ariaModal = true,
+ disableEscapeClose = false,
+ initialFocusRef,
+ returnFocusTo,
+ footer,
+ className = "",
+ children,
+}: ModalDialogProps) {
+ const autoId = useId();
+ const titleId = `${id ?? autoId}-title`;
+ const descId = subtitle ? `${id ?? autoId}-desc` : undefined;
+ const dialogRef = useRef(null);
+ const closeBtnRef = useRef(null);
+ const onCloseRef = useRef(onClose);
+ const wasOpenRef = useRef(false);
+
+ useEffect(() => {
+ onCloseRef.current = onClose;
+ }, [onClose]);
+
+ useEffect(() => {
+ if (isOpen && !wasOpenRef.current) {
+ wasOpenRef.current = true;
+ const focusTimer = window.setTimeout(() => {
+ if (initialFocusRef?.current) {
+ initialFocusRef.current.focus();
+ } else if (closeBtnRef.current) {
+ closeBtnRef.current.focus();
+ } else {
+ dialogRef.current?.focus();
+ }
+ }, 20);
+ return () => window.clearTimeout(focusTimer);
+ }
+
+ if (!isOpen && wasOpenRef.current) {
+ wasOpenRef.current = false;
+ const target = returnFocusTo?.current;
+ if (target && target.isConnected) {
+ target.focus();
+ }
+ }
+ }, [isOpen, initialFocusRef, returnFocusTo]);
+
+ useEffect(() => {
+ if (!isOpen || !lockScroll || typeof document === "undefined") return;
+ const prevOverflow = document.body.style.overflow;
+ document.body.style.overflow = "hidden";
+ return () => {
+ document.body.style.overflow = prevOverflow;
+ };
+ }, [isOpen, lockScroll]);
+
+ useEffect(() => {
+ if (!isOpen) return;
+
+ const handleKeyDown = (event: KeyboardEvent) => {
+ if (event.key === "Escape") {
+ if (disableEscapeClose) return;
+ event.preventDefault();
+ event.stopPropagation();
+ onCloseRef.current();
+ return;
+ }
+
+ if (trapFocus && event.key === "Tab") {
+ const dialog = dialogRef.current;
+ if (!dialog) return;
+
+ const focusable = Array.from(
+ dialog.querySelectorAll(FOCUSABLE_SELECTOR),
+ ).filter(
+ (el) => el.offsetParent !== null || el === document.activeElement,
+ );
+
+ if (focusable.length === 0) return;
+
+ const first = focusable[0];
+ const last = focusable[focusable.length - 1];
+
+ if (event.shiftKey && document.activeElement === first) {
+ event.preventDefault();
+ last.focus();
+ } else if (!event.shiftKey && document.activeElement === last) {
+ event.preventDefault();
+ first.focus();
+ } else if (!dialog.contains(document.activeElement)) {
+ event.preventDefault();
+ first.focus();
+ }
+ }
+ };
+
+ document.addEventListener("keydown", handleKeyDown, { capture: true });
+ return () => {
+ document.removeEventListener("keydown", handleKeyDown, { capture: true });
+ };
+ }, [isOpen, trapFocus, disableEscapeClose]);
+
+ if (!isOpen) return null;
+
+ return (
+
+ {
+ if (closeOnBackdrop && e.target === e.currentTarget) {
+ onClose();
+ }
+ }}
+ >
+
+
+
+ {icon && (
+
+ {icon}
+
+ )}
+
+
+ {title}
+
+ {subtitle && (
+
+ {subtitle}
+
+ )}
+
+
+
+ ×
+
+
+
+
{children}
+
+ {footer &&
{footer}
}
+
+
+
+ );
+}
+
+export default ModalDialog;
diff --git a/src/core/controls/ProfilePreviewCard.tsx b/src/core/controls/ProfilePreviewCard.tsx
index 40d855d..b5bde97 100644
--- a/src/core/controls/ProfilePreviewCard.tsx
+++ b/src/core/controls/ProfilePreviewCard.tsx
@@ -16,6 +16,78 @@ export interface ProfilePreviewCardProps {
style?: CSSProperties;
}
+export function formatPreferenceKey(key: string): string {
+ switch (key) {
+ case "fontScale":
+ case "fontSize":
+ return "Font Size";
+ case "fontFamily":
+ return "Font Family";
+ case "lineHeight":
+ return "Line Height";
+ case "letterSpacing":
+ return "Letter Spacing";
+ case "wordSpacing":
+ return "Word Spacing";
+ case "paragraphSpacing":
+ return "Paragraph Spacing";
+ case "contrastMode":
+ case "contrast":
+ return "Contrast";
+ case "reduceMotion":
+ return "Reduce Motion";
+ case "textAlign":
+ return "Text Align";
+ case "highlightLinks":
+ case "linkHighlight":
+ return "Highlight Links";
+ case "highlightFocus":
+ case "focusOutline":
+ return "Focus Outline";
+ case "cursorSize":
+ case "bigCursor":
+ return "Big Cursor";
+ case "readerMode":
+ case "readingMode":
+ return "Reading Mode";
+ case "readingGuide":
+ return "Reading Guide";
+ case "readingMask":
+ return "Reading Mask";
+ case "saturation":
+ return "Saturation";
+ case "grayscale":
+ return "Grayscale";
+ case "hideDecorativeImages":
+ case "hideImages":
+ return "Hide Images";
+ case "hideVideos":
+ return "Hide Videos";
+ case "tooltips":
+ case "accessibleTooltips":
+ return "Tooltips";
+ default: {
+ const spaced = key.replace(/([A-Z])/g, " $1").trim();
+ return spaced.charAt(0).toUpperCase() + spaced.slice(1);
+ }
+ }
+}
+
+export function formatPreferenceValue(
+ key: keyof AccessibilityPreferences,
+ val: unknown,
+): string {
+ if (typeof val === "boolean") return val ? "On" : "Off";
+ if (key === "fontScale" && typeof val === "number")
+ return `${Math.round(val * 100)}%`;
+ if (key === "lineHeight" && typeof val === "number")
+ return `${Math.round(val * 100)}%`;
+ if (val === null || val === undefined) return "Original";
+ const str = String(val);
+ if (str === "dyslexia-option" || str === "dyslexia") return "Dyslexia";
+ return str.includes("-") ? str.replace(/-/g, " ") : str;
+}
+
export function ProfilePreviewCard({
profile,
isActive,
@@ -29,48 +101,6 @@ export function ProfilePreviewCard({
profile.settings,
) as (keyof AccessibilityPreferences)[];
- const formatKeyName = (key: string): string => {
- switch (key) {
- case "fontScale":
- return "Font Size";
- case "lineHeight":
- return "Line Height";
- case "contrastMode":
- return "Contrast";
- case "reduceMotion":
- return "Reduce Motion";
- case "textAlign":
- return "Text Align";
- case "highlightLinks":
- return "Highlight Links";
- case "highlightFocus":
- return "Highlight Focus";
- case "cursorSize":
- return "Cursor Size";
- case "readerMode":
- return "Reading Mode";
- case "saturation":
- return "Saturation";
- case "hideDecorativeImages":
- return "Hide Images";
- default:
- return key.replace(/([A-Z])/g, " $1").trim();
- }
- };
-
- const formatSettingValue = (
- key: keyof AccessibilityPreferences,
- val: unknown,
- ): string => {
- if (typeof val === "boolean") return val ? "On" : "Off";
- if (key === "fontScale" && typeof val === "number")
- return `${Math.round(val * 100)}%`;
- if (key === "lineHeight" && typeof val === "number")
- return `${Math.round(val * 100)}%`;
- if (val === null || val === undefined) return "Original";
- return String(val);
- };
-
return (
-
{formatKeyName(key)}: {" "}
- {formatSettingValue(key, val)}
+
{formatPreferenceKey(key)}: {" "}
+ {formatPreferenceValue(key, val)}
);
})}
@@ -112,7 +142,7 @@ export function ProfilePreviewCard({
{isActive ? (
@@ -121,7 +151,7 @@ export function ProfilePreviewCard({
) : (
onApply(profile)}
aria-label={`Apply ${profile.label} profile`}
>
diff --git a/src/core/controls/index.ts b/src/core/controls/index.ts
index fc66985..cd0bc8f 100644
--- a/src/core/controls/index.ts
+++ b/src/core/controls/index.ts
@@ -23,3 +23,9 @@ export type {
export { ProfilePreviewCard } from "./ProfilePreviewCard";
export type { ProfilePreviewCardProps } from "./ProfilePreviewCard";
+
+export { ModalDialog } from "./ModalDialog";
+export type { ModalDialogProps } from "./ModalDialog";
+
+export { FeatureGroup } from "./FeatureGroup";
+export type { FeatureGroupProps } from "./FeatureGroup";
diff --git a/src/core/dictionary.ts b/src/core/dictionary.ts
index afc1e0a..4d4b9b1 100644
--- a/src/core/dictionary.ts
+++ b/src/core/dictionary.ts
@@ -142,6 +142,321 @@ export const LOCAL_DICTIONARY_EN: Record<
"The site targets WCAG 2.1 Level AA conformance across all interactive features.",
language: "en",
},
+ voice: {
+ phonetic: "/vɔɪs/",
+ partOfSpeech: "noun",
+ definition:
+ "Spoken human sound or synthetic speech used to control interfaces via voice commands or listen to page content aloud.",
+ example:
+ "Voice navigation lets hands-free users trigger display adjustments with simple spoken phrases.",
+ language: "en",
+ },
+ "voice navigation": {
+ phonetic: "/vɔɪs ˌnævɪˈɡeɪʃn/",
+ partOfSpeech: "noun",
+ definition:
+ "An assistive control method that maps spoken commands via browser speech recognition to trigger UI actions without a keyboard or pointer.",
+ example:
+ "Say 'increase text' or 'high contrast' after granting microphone consent to adjust the display.",
+ language: "en",
+ },
+ "read aloud": {
+ phonetic: "/riːd əˈlaʊd/",
+ partOfSpeech: "noun phrase",
+ definition:
+ "Text-to-speech playback that reads selected text or main page articles audibly using browser speech synthesis.",
+ example:
+ "Activate Read Aloud to listen to an article while following along with adjustable playback speed.",
+ language: "en",
+ },
+ "text to speech": {
+ phonetic: "/tekst tə spiːtʃ/",
+ partOfSpeech: "noun",
+ definition:
+ "Assistive technology (TTS) that converts written digital text on screen into synthesized spoken audio.",
+ example:
+ "Text to speech supports readers with low vision, dyslexia, or auditory learning preferences.",
+ language: "en",
+ },
+ tts: {
+ phonetic: "/ˌtiː.tiːˈes/",
+ partOfSpeech: "abbreviation",
+ definition:
+ "Text-to-Speech; computerized voice synthesis that reads digital content aloud.",
+ example:
+ "The Read Aloud controller uses native Web Speech API TTS locally in the browser.",
+ language: "en",
+ },
+ speech: {
+ phonetic: "/spiːtʃ/",
+ partOfSpeech: "noun",
+ definition:
+ "Vocalized language used as either input (speech recognition) or output (speech synthesis) in accessible computing.",
+ example:
+ "Adjusting speech rate slows playback so dense technical passages are easier to follow.",
+ language: "en",
+ },
+ translation: {
+ phonetic: "/trænzˈleɪʃn/",
+ partOfSpeech: "noun",
+ definition:
+ "Converting visible host text content into another target language while leaving interactive controls and sensitive values untouched.",
+ example:
+ "Page translation restores original text nodes seamlessly when disabled.",
+ language: "en",
+ },
+ keyboard: {
+ phonetic: "/ˈkiːbɔːrd/",
+ partOfSpeech: "noun",
+ definition:
+ "A physical or on-screen input device enabling non-pointer navigation through Tab, Enter, Space, Escape, and arrow keys.",
+ example:
+ "Every interactive plugin control must remain fully operable using only a keyboard.",
+ language: "en",
+ },
+ "keyboard navigation": {
+ phonetic: "/ˈkiːbɔːrd ˌnævɪˈɡeɪʃn/",
+ partOfSpeech: "noun",
+ definition:
+ "Moving focus and activating controls across links, buttons, forms, and dialogs exclusively via keystrokes.",
+ example:
+ "Press Escape to dismiss dialogs and return focus reliably to the opening button.",
+ language: "en",
+ },
+ landmark: {
+ phonetic: "/ˈlændmɑːrk/",
+ partOfSpeech: "noun",
+ definition:
+ "A programmatic region on a web page (such as main, nav, header, footer, or aside) allowing assistive technology users to jump quickly between sections.",
+ example:
+ "Page Navigator lists all semantic landmarks alongside document headings and links.",
+ language: "en",
+ },
+ heading: {
+ phonetic: "/ˈhedɪŋ/",
+ partOfSpeech: "noun",
+ definition:
+ "A hierarchical section title (h1 to h6) that structures a document outline for visual scanning and screen reader navigation.",
+ example:
+ "Screen readers can jump directly from one heading level to the next.",
+ language: "en",
+ },
+ "skip link": {
+ phonetic: "/skɪp lɪŋk/",
+ partOfSpeech: "noun",
+ definition:
+ "An internal anchor link typically placed first in tab order so keyboard users can bypass repeated navigation menus straight to main content.",
+ example:
+ "Pressing Tab once reveals the Skip to main content link at the top of the page.",
+ language: "en",
+ },
+ tooltip: {
+ phonetic: "/ˈtuːltɪp/",
+ partOfSpeech: "noun",
+ definition:
+ "A supplementary label box displayed when hovering or focusing an interface element with a descriptive name or title attribute.",
+ example:
+ "Accessible tooltips reveal supplemental labels reliably on keyboard focus as well as hover.",
+ language: "en",
+ },
+ "big cursor": {
+ phonetic: "/bɪɡ ˈkɜːrsər/",
+ partOfSpeech: "noun",
+ definition:
+ "An enlarged high-contrast pointer appearance designed to make tracking mouse position easier for users with low vision.",
+ example:
+ "Choose Black or White Big Cursor variants to keep the pointer visible against any page background.",
+ language: "en",
+ },
+ cursor: {
+ phonetic: "/ˈkɜːrsər/",
+ partOfSpeech: "noun",
+ definition:
+ "The movable visual indicator tracking pointer movement or text insertion position on screen.",
+ example:
+ "Enlarging the cursor helps prevent losing track of links on dense web pages.",
+ language: "en",
+ },
+ "reading guide": {
+ phonetic: "/ˈriːdɪŋ ɡaɪd/",
+ partOfSpeech: "noun",
+ definition:
+ "A horizontal tracking bar that follows pointer or keyboard position across lines of text to aid line-by-line focus.",
+ example:
+ "Readers with tracking difficulties use the reading guide to stay anchored to the active line.",
+ language: "en",
+ },
+ "reading mask": {
+ phonetic: "/ˈriːdɪŋ mæsk/",
+ partOfSpeech: "noun",
+ definition:
+ "A dimmed page overlay that leaves a bright horizontal reading band uncovered to minimize visual distraction above and below.",
+ example:
+ "Resize the reading mask height to highlight one or two sentences at a time.",
+ language: "en",
+ },
+ "reading mode": {
+ phonetic: "/ˈriːdɪŋ moʊd/",
+ partOfSpeech: "noun",
+ definition:
+ "A stripped-down, distraction-free article view that isolates sanitized main prose with customizable font, theme, and width.",
+ example:
+ "Open Reading Mode when surrounding sidebars and banners make long articles tiring to read.",
+ language: "en",
+ },
+ "font size": {
+ phonetic: "/fɒnt saɪz/",
+ partOfSpeech: "noun",
+ definition:
+ "The vertical scale of rendered typography across text elements, configurable from 100% up to 200%.",
+ example:
+ "Increasing font size preserves layout integrity while making body copy comfortable to read.",
+ language: "en",
+ },
+ "line height": {
+ phonetic: "/laɪn haɪt/",
+ partOfSpeech: "noun",
+ definition:
+ "The vertical spacing (leading) between consecutive lines of text inside a paragraph.",
+ example:
+ "WCAG text spacing benchmarks recommend at least 1.5 times font size for line height.",
+ language: "en",
+ },
+ "letter spacing": {
+ phonetic: "/ˈletər ˌspeɪsɪŋ/",
+ partOfSpeech: "noun",
+ definition:
+ "Horizontal kerning or tracking added between individual characters in rendered words.",
+ example:
+ "Modest letter spacing reduces visual crowding for readers experiencing letter-swapping.",
+ language: "en",
+ },
+ "word spacing": {
+ phonetic: "/wɜːrd ˌspeɪsɪŋ/",
+ partOfSpeech: "noun",
+ definition:
+ "The horizontal whitespace gap separating adjacent words along a line of text.",
+ example:
+ "Wider word spacing helps delineate word boundaries cleanly on mobile displays.",
+ language: "en",
+ },
+ "paragraph spacing": {
+ phonetic: "/ˈpærəɡræf ˌspeɪsɪŋ/",
+ partOfSpeech: "noun",
+ definition:
+ "Vertical separation inserted after or between blocks of paragraphs to clarify document chunks.",
+ example:
+ "Clear paragraph spacing prevents multi-paragraph essays from fusing into a dense wall of text.",
+ language: "en",
+ },
+ "text align": {
+ phonetic: "/tekst əˈlaɪn/",
+ partOfSpeech: "noun",
+ definition:
+ "The horizontal justification rule of text lines (left, right, center, or justified).",
+ example:
+ "Switching justified text to left-aligned eliminates irregular rivers of whitespace.",
+ language: "en",
+ },
+ "reduce motion": {
+ phonetic: "/rɪˈduːs ˈmoʊʃn/",
+ partOfSpeech: "verb phrase",
+ definition:
+ "A preference that minimizes non-essential transitions, scrolling animations, and parallax motion.",
+ example:
+ "Reducing motion helps prevent vestibular discomfort, dizziness, and motion sickness.",
+ language: "en",
+ },
+ "focus outline": {
+ phonetic: "/ˈfoʊkəs ˈaʊtlaɪn/",
+ partOfSpeech: "noun",
+ definition:
+ "A high-visibility ring or border drawn around whichever control presently holds keyboard focus.",
+ example:
+ "Strong focus outlines remain clearly discernible across both light and dark page surfaces.",
+ language: "en",
+ },
+ "link highlight": {
+ phonetic: "/lɪŋk ˈhaɪlaɪt/",
+ partOfSpeech: "noun",
+ definition:
+ "Visual emphasis added to hyperlinks so interactive destinations stand out clearly from static body copy.",
+ example:
+ "Highlighting links avoids relying solely on subtle color differences within paragraphs.",
+ language: "en",
+ },
+ invert: {
+ phonetic: "/ɪnˈvɜːrt/",
+ partOfSpeech: "verb",
+ definition:
+ "A display contrast adjustment reversing dark and light tones across the page surface while keeping embedded media natural where safe.",
+ example:
+ "Invert colors swaps black-on-white pages into light-on-dark surfaces for light sensitivity.",
+ language: "en",
+ },
+ "high contrast": {
+ phonetic: "/haɪ ˈkɒntrɑːst/",
+ partOfSpeech: "noun",
+ definition:
+ "A theme mode maximizing luminance separation between foreground text, borders, controls, and surfaces.",
+ example:
+ "High contrast themes improve legibility outdoors and for users with low contrast sensitivity.",
+ language: "en",
+ },
+ "alt text": {
+ phonetic: "/ɔːlt tekst/",
+ partOfSpeech: "noun",
+ definition:
+ "Alternative text supplied via HTML alt attributes describing the meaning or function of an image for screen readers or failed loads.",
+ example:
+ "Decorative images use empty alt='' so assistive tools skip them while informative graphics retain clear alt text.",
+ language: "en",
+ },
+ profile: {
+ phonetic: "/ˈproʊfaɪl/",
+ partOfSpeech: "noun",
+ definition:
+ "A curated multi-setting bundle tailored to specific accessibility needs such as Low Vision, Dyslexia Friendly, or Seizure Safe.",
+ example:
+ "Applying an accessibility profile configures several coordinated display settings in one click.",
+ language: "en",
+ },
+ preset: {
+ phonetic: "/ˈpriːset/",
+ partOfSpeech: "noun",
+ definition:
+ "A user-saved or exported JSON configuration snapshot of active accessibility preferences.",
+ example:
+ "Save your custom settings as a preset to restore or share your setup across devices.",
+ language: "en",
+ },
+ zoom: {
+ phonetic: "/zuːm/",
+ partOfSpeech: "noun",
+ definition:
+ "Optical or browser viewport magnification (such as 200% or 400%) requiring responsive content reflow.",
+ example:
+ "Well-designed accessibility controls remain usable without horizontal clipping at 400% zoom.",
+ language: "en",
+ },
+ caption: {
+ phonetic: "/ˈkæpʃn/",
+ partOfSpeech: "noun",
+ definition:
+ "Synchronized visible text representing spoken dialogue, narration, and important sound cues in video media.",
+ example:
+ "Adding WebVTT captions makes instructional videos accessible to deaf and hard-of-hearing viewers.",
+ language: "en",
+ },
+ "assistive technology": {
+ phonetic: "/əˈsɪstɪv tekˈnɒlədʒi/",
+ partOfSpeech: "noun",
+ definition:
+ "Hardware or software tools (such as screen readers, switch devices, magnifiers, and voice control) used by people with disabilities.",
+ example:
+ "Standard HTML semantics ensure compatibility with diverse assistive technologies.",
+ language: "en",
+ },
};
export const LOCAL_DICTIONARY_SI: Record<
@@ -214,6 +529,22 @@ export const LOCAL_DICTIONARY_SI: Record<
"අළු පරිමාණ මාදිලිය මඟින් දීප්තිමත් වර්ණ නිසා ඇතිවන අපහසුතා මඟහරවා ගත හැක.",
language: "si",
},
+ voice: {
+ phonetic: "හඬ",
+ partOfSpeech: "නාම පදය",
+ definition:
+ "හඬ විධාන මඟින් පාලනය කිරීමට හෝ පිටුවේ අන්තර්ගතය ශබ්ද නඟා ඇසීමට භාවිතා කරන කථන මාධ්යය.",
+ example: "හඬ සංචාලනය මඟින් අත් රහිතව ප්රවේශ්යතා සැකසුම් වෙනස් කළ හැක.",
+ language: "si",
+ },
+ translation: {
+ phonetic: "පරිවර්තනය",
+ partOfSpeech: "නාම පදය",
+ definition: "පිටුවේ ප්රධාන පෙළ වෙනත් භාෂාවකට පරිවර්තනය කර පෙන්වීම.",
+ example:
+ "පිටු පරිවර්තනය මඟින් ඉංග්රීසි ලිපි සිංහලෙන් හෝ දෙමළෙන් කියවීමට පහසු වේ.",
+ language: "si",
+ },
};
export const LOCAL_DICTIONARY_TA: Record<
@@ -286,6 +617,24 @@ export const LOCAL_DICTIONARY_TA: Record<
"சாம்பல் நிற முறை அதிகப்படியான வண்ண ஒளிர்தலைத் தவிர்க்க உதவுகிறது.",
language: "ta",
},
+ voice: {
+ phonetic: "குரல்",
+ partOfSpeech: "பெயர்ச்சொல்",
+ definition:
+ "குரல் கட்டளைகள் மூலம் கட்டுப்படுத்தவோ பக்க உரையைச் சத்தமாகக் கேட்கவோ பயன்படும் பேச்சு ஊடகம்.",
+ example:
+ "குரல் வழிசெலுத்தல் கைகள் இன்றி காட்சி அமைப்புகளை மாற்ற உதவுகிறது.",
+ language: "ta",
+ },
+ translation: {
+ phonetic: "மொழிபெயர்ப்பு",
+ partOfSpeech: "பெயர்ச்சொல்",
+ definition:
+ "பக்கத்தின் முதன்மை உரையை மற்றொரு மொழியில் மாற்றி காண்பிக்கும் வசதி.",
+ example:
+ "பக்க மொழிபெயர்ப்பு உள்ளடக்கத்தைத் தேர்ந்தெடுத்த மொழியில் படிக்க உதவுகிறது.",
+ language: "ta",
+ },
};
/** Patterns that indicate sensitive, token, or private content that must never be sent or looked up. */
@@ -352,6 +701,77 @@ export function sanitizeLookupTerm(term: unknown): {
return { valid: true, sanitized: clean.toLowerCase() };
}
+function levenshtein(a: string, b: string): number {
+ const m = a.length;
+ const n = b.length;
+ if (m === 0) return n;
+ if (n === 0) return m;
+ const dp: number[] = Array.from({ length: n + 1 }, (_, j) => j);
+ for (let i = 1; i <= m; i++) {
+ let prev = dp[0];
+ dp[0] = i;
+ for (let j = 1; j <= n; j++) {
+ const temp = dp[j];
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
+ dp[j] = Math.min(dp[j] + 1, dp[j - 1] + 1, prev + cost);
+ prev = temp;
+ }
+ }
+ return dp[n];
+}
+
+function collectDictionarySuggestions(
+ query: string,
+ candidateKeys: string[],
+): string[] {
+ const normalizedQuery = query
+ .replace(/[-_]+/g, " ")
+ .replace(/\s+/g, " ")
+ .trim();
+ const queryTokens = normalizedQuery.split(" ").filter((t) => t.length >= 2);
+ const scored: { key: string; score: number }[] = [];
+
+ for (const rawKey of candidateKeys) {
+ const key = rawKey.toLowerCase();
+ if (key === normalizedQuery) continue;
+
+ let score = 0;
+ if (key.startsWith(normalizedQuery)) {
+ score = 100 - Math.abs(key.length - normalizedQuery.length);
+ } else if (key.includes(normalizedQuery)) {
+ score = 80 - Math.abs(key.length - normalizedQuery.length);
+ } else {
+ const keyTokens = key.split(/[\s-]+/).filter((t) => t.length >= 2);
+ const tokenOverlap = queryTokens.some((qt) =>
+ keyTokens.some((kt) => kt === qt || kt.startsWith(qt)),
+ );
+ if (tokenOverlap) {
+ score = 65;
+ } else {
+ const dist = levenshtein(normalizedQuery, key);
+ const maxDist = normalizedQuery.length <= 5 ? 1 : 2;
+ if (dist <= maxDist && normalizedQuery.length >= 3) {
+ score = 50 - dist * 10;
+ }
+ }
+ }
+
+ if (score > 0) {
+ scored.push({ key: rawKey, score });
+ }
+ }
+
+ scored.sort((a, b) => b.score - a.score || a.key.localeCompare(b.key));
+ const unique: string[] = [];
+ for (const item of scored) {
+ if (!unique.includes(item.key)) {
+ unique.push(item.key);
+ }
+ if (unique.length >= 5) break;
+ }
+ return unique;
+}
+
/**
* Looks up a term in the built-in local static dictionary.
* Guaranteed 100% offline, zero network requests, zero hallucination.
@@ -369,44 +789,59 @@ export function lookupLocalDictionary(
};
}
- const query = check.sanitized;
+ const query = check.sanitized.replace(/\s+/g, " ").trim();
+ const hyphenToSpace = query.replace(/[-_]+/g, " ").trim();
+ const candidates = Array.from(
+ new Set([
+ query,
+ hyphenToSpace,
+ ...(query.endsWith("s") && query.length > 3 ? [query.slice(0, -1)] : []),
+ ...(query.endsWith("es") && query.length > 4 ? [query.slice(0, -2)] : []),
+ ]),
+ );
const lang = locale.toLowerCase().split("-")[0];
let dict = LOCAL_DICTIONARY_EN;
if (lang === "si") dict = LOCAL_DICTIONARY_SI;
else if (lang === "ta") dict = LOCAL_DICTIONARY_TA;
- // 1. Direct match in selected locale
- if (dict[query]) {
- return {
- found: true,
- term: query,
- entry: {
- word: query,
- ...dict[query],
- source: "local",
- },
- };
+ // 1. Direct or normalized match in selected locale
+ for (const candidate of candidates) {
+ if (dict[candidate]) {
+ return {
+ found: true,
+ term: candidate,
+ entry: {
+ word: candidate,
+ ...dict[candidate],
+ source: "local",
+ },
+ };
+ }
}
// 2. Fallback to English dictionary if not found in translated glossary
- if (dict !== LOCAL_DICTIONARY_EN && LOCAL_DICTIONARY_EN[query]) {
- return {
- found: true,
- term: query,
- entry: {
- word: query,
- ...LOCAL_DICTIONARY_EN[query],
- source: "local",
- },
- };
+ if (dict !== LOCAL_DICTIONARY_EN) {
+ for (const candidate of candidates) {
+ if (LOCAL_DICTIONARY_EN[candidate]) {
+ return {
+ found: true,
+ term: candidate,
+ entry: {
+ word: candidate,
+ ...LOCAL_DICTIONARY_EN[candidate],
+ source: "local",
+ },
+ };
+ }
+ }
}
- // 3. Find suggestions (terms containing or starting with query)
- const allKeys = Object.keys(LOCAL_DICTIONARY_EN);
- const suggestions = allKeys
- .filter((k) => k.includes(query) || query.includes(k))
- .slice(0, 4);
+ // 3. Find ranked prefix/substring/token/typo suggestions across active and English dictionaries
+ const allKeys = Array.from(
+ new Set([...Object.keys(dict), ...Object.keys(LOCAL_DICTIONARY_EN)]),
+ );
+ const suggestions = collectDictionarySuggestions(query, allKeys);
return {
found: false,
diff --git a/src/core/effects.ts b/src/core/effects.ts
index 0ef82c8..e77c74c 100644
--- a/src/core/effects.ts
+++ b/src/core/effects.ts
@@ -573,6 +573,11 @@ export function getScriptSpacingConstraints(
*/
export function isFunctionalOrMeaningfulImage(el: Element): boolean {
try {
+ // Never hide widget or diagnostic UI assets
+ if (el.closest("[data-arap-ui], [data-arap-diagnostics], .arap-root")) {
+ return true;
+ }
+
// 1. Linked or interactive controls: images inside buttons, links, inputs, or interactive roles
if (
el.closest(
@@ -1082,15 +1087,21 @@ function applyToElements(
if (values.hideImages) {
if (isEligibleDecorativeImage(el)) {
set(el, "visibility", "hidden");
+ if (el.matches("picture")) {
+ const childImg = el.querySelector("img");
+ if (childImg instanceof HTMLElement) {
+ set(childImg, "visibility", "hidden");
+ }
+ }
}
if (!isFunctionalOrMeaningfulImage(el)) {
const inlineBg = el.style.backgroundImage;
- if (inlineBg && inlineBg !== "none") {
+ if (inlineBg && /url\(/i.test(inlineBg)) {
set(el, "background-image", "none");
} else {
try {
const computedBg = getComputedStyle(el).backgroundImage;
- if (computedBg && computedBg !== "none") {
+ if (computedBg && /url\(/i.test(computedBg)) {
set(el, "background-image", "none");
}
} catch {
@@ -1103,7 +1114,7 @@ function applyToElements(
if (
values.hideVideos &&
el.matches(
- 'video, iframe[src*="youtube.com/embed/"], iframe[src*="youtube-nocookie.com/embed/"], iframe[src*="player.vimeo.com/video/"]',
+ 'video, iframe[src*="youtube.com/embed/"], iframe[src*="youtube-nocookie.com/embed/"], iframe[src*="youtu.be/"], iframe[src*="player.vimeo.com/video/"], iframe[src*="player.twitch.tv/"], iframe[src*="dailymotion.com/embed/"], iframe[src*="loom.com/embed/"], iframe[src*="wistia."], iframe[data-src*="youtube"], iframe[data-src*="vimeo"], iframe[data-src*="twitch.tv"], iframe[data-src*="dailymotion"], iframe[data-src*="loom.com"]',
)
)
set(el, "visibility", "hidden");
@@ -1506,6 +1517,8 @@ export function nudgeReadingAid(
}
}
+const readingAidLastY: Record = {};
+
function readingAid(
mask: boolean,
height: number = 100,
@@ -1527,11 +1540,19 @@ function readingAid(
const aidHeight = mask ? Math.max(40, Math.min(400, height)) : 4;
const halfHeight = mask ? aidHeight / 2 : 0;
- el.style.cssText = `position:fixed;left:0;right:0;top:50%;height:${aidHeight}px;pointer-events:none;z-index:2147482999;${
+ // Hardened inline resets so host global `div` styles cannot deform reading aids.
+ el.style.cssText = `position:fixed;left:0;right:0;top:50%;width:100vw;max-width:none;min-width:0;min-height:0;height:${aidHeight}px;margin:0;padding:0;outline:none;transform:none;filter:none;opacity:1;transition:none;animation:none;box-sizing:border-box;pointer-events:none;z-index:2147482000;${
mask
- ? "background:transparent;box-shadow:0 0 0 200vmax rgba(0,0,0,.65)"
- : "background:#2563eb;border:1px solid white"
+ ? "border:none;background:transparent;box-shadow:0 0 0 200vmax rgba(0,0,0,.65)"
+ : "background:#2563eb;border:1px solid #ffffff;box-shadow:0 1px 4px rgba(0,0,0,.28)"
}`;
+ el.style.setProperty("position", "fixed", "important");
+ el.style.setProperty("margin", "0", "important");
+ el.style.setProperty("padding", "0", "important");
+ el.style.setProperty("transform", "none", "important");
+ el.style.setProperty("filter", "none", "important");
+ el.style.setProperty("opacity", "1", "important");
+ el.style.setProperty("z-index", "2147482000", "important");
el.style.setProperty("pointer-events", "none", "important");
el.style.setProperty("user-select", "none", "important");
el.style.setProperty("-webkit-user-select", "none", "important");
@@ -1539,10 +1560,14 @@ function readingAid(
document.body.appendChild(el);
- let currentY =
+ const defaultY =
typeof window !== "undefined" && window.innerHeight
? window.innerHeight / 2
: 300;
+ let currentY =
+ typeof readingAidLastY[featureKey] === "number"
+ ? readingAidLastY[featureKey]
+ : defaultY;
let trackedFocusEl: HTMLElement | null = null;
const clampY = (y: number) => {
@@ -1555,13 +1580,22 @@ function readingAid(
const move = (y: number) => {
currentY = clampY(y);
+ readingAidLastY[featureKey] = currentY;
el.style.top = `${Math.max(0, currentY - halfHeight)}px`;
};
- // Center immediately
+ // Apply initial/preserved Y immediately
move(currentY);
const pointer = (event: MouseEvent | PointerEvent) => {
+ if (
+ event.target instanceof Element &&
+ event.target.closest(
+ "[data-arap-ui], [data-arap-diagnostics], .arap-root",
+ )
+ ) {
+ return;
+ }
if (typeof event.clientY === "number" && !isNaN(event.clientY)) {
trackedFocusEl = null;
move(event.clientY);
@@ -1569,6 +1603,14 @@ function readingAid(
};
const touch = (event: TouchEvent) => {
+ if (
+ event.target instanceof Element &&
+ event.target.closest(
+ "[data-arap-ui], [data-arap-diagnostics], .arap-root",
+ )
+ ) {
+ return;
+ }
if (event.touches && event.touches.length > 0) {
trackedFocusEl = null;
move(event.touches[0].clientY);
@@ -1641,7 +1683,6 @@ function readingAid(
document.addEventListener("touchstart", touch, { passive: true });
document.addEventListener("focusin", focus);
document.addEventListener("arap:nudge-reading-aid", nudge);
- document.addEventListener("keydown", keydown);
window.addEventListener("scroll", scroll, { passive: true });
window.addEventListener("resize", viewport, { passive: true });
window.addEventListener("keydown", keydown);
@@ -1658,7 +1699,6 @@ function readingAid(
document.removeEventListener("touchstart", touch);
document.removeEventListener("focusin", focus);
document.removeEventListener("arap:nudge-reading-aid", nudge);
- document.removeEventListener("keydown", keydown);
window.removeEventListener("scroll", scroll);
window.removeEventListener("resize", viewport);
window.removeEventListener("keydown", keydown);
@@ -1727,6 +1767,15 @@ export function useBuiltinEffects(
record.target === targetRoot
) {
hasRootAttributeChange = true;
+ } else if (
+ (values.hideImages || values.hideVideos) &&
+ record.target instanceof HTMLElement &&
+ !record.target.closest(
+ "[data-arap-ui], [data-arap-diagnostics], .arap-root",
+ ) &&
+ record.target.matches("img, picture, video, iframe")
+ ) {
+ added.push(record.target);
}
} else if (record.type === "childList") {
if (
@@ -1758,11 +1807,23 @@ export function useBuiltinEffects(
}
});
+ const attributeFilter = ["class", "data-theme", "dir", "lang"];
+ if (values.hideImages || values.hideVideos) {
+ attributeFilter.push(
+ "src",
+ "data-src",
+ "alt",
+ "role",
+ "aria-hidden",
+ "data-decorative",
+ );
+ }
+
const observerOptions: MutationObserverInit = {
childList: true,
subtree: true,
attributes: true,
- attributeFilter: ["class", "data-theme", "dir", "lang"],
+ attributeFilter,
};
if (targetRoot) {
@@ -1831,7 +1892,10 @@ export function useBuiltinEffects(
}, [values, optionsOrScope]);
useEffect(() => {
- if (!values.readingMask) return;
+ if (!values.readingMask) {
+ delete readingAidLastY.readingMask;
+ return;
+ }
const height =
typeof values.readingMaskHeight === "number"
? values.readingMaskHeight
@@ -1842,14 +1906,21 @@ export function useBuiltinEffects(
}, [values.readingMask, values.readingMaskHeight, onDisable]);
useEffect(() => {
- if (!values.readingGuide) return;
+ if (!values.readingGuide) {
+ delete readingAidLastY.readingGuide;
+ return;
+ }
return readingAid(false, 4, onDisable);
}, [values.readingGuide, onDisable]);
useEffect(() => {
if (!values.tooltips && !values.accessibleTooltips) return;
- return enableAccessibleTooltips();
- }, [values.tooltips, values.accessibleTooltips]);
+ const activeFont =
+ typeof values.fontFamily === "string" && values.fontFamily.trim()
+ ? values.fontFamily.trim()
+ : "default";
+ return enableAccessibleTooltips(activeFont);
+ }, [values.tooltips, values.accessibleTooltips, values.fontFamily]);
}
/**
@@ -2012,14 +2083,24 @@ export function positionTooltip(tooltip: HTMLElement, target: Element) {
tooltip.setAttribute("data-placement", placement);
}
-export function enableAccessibleTooltips(): () => void {
+export function enableAccessibleTooltips(
+ fontFamily: string = "default",
+): () => void {
if (typeof document === "undefined") return () => {};
+ const safeFont =
+ fontFamily === "legible" ||
+ fontFamily === "dyslexia-option" ||
+ fontFamily === "dyslexia"
+ ? fontFamily
+ : "default";
+
let tooltipEl: HTMLDivElement | null = document.createElement("div");
- tooltipEl.className = "arap-accessible-tooltip";
+ tooltipEl.className = "arap-root arap-accessible-tooltip";
tooltipEl.setAttribute("role", "presentation");
tooltipEl.setAttribute("aria-hidden", "true");
tooltipEl.setAttribute("data-arap-ui", "true");
+ tooltipEl.setAttribute("data-arap-font", safeFont);
document.body.appendChild(tooltipEl);
let activeTarget: Element | null = null;
@@ -2035,10 +2116,11 @@ export function enableAccessibleTooltips(): () => void {
activeTarget = target;
if (!tooltipEl || !document.body.contains(tooltipEl)) {
tooltipEl = document.createElement("div");
- tooltipEl.className = "arap-accessible-tooltip";
+ tooltipEl.className = "arap-root arap-accessible-tooltip";
tooltipEl.setAttribute("role", "presentation");
tooltipEl.setAttribute("aria-hidden", "true");
tooltipEl.setAttribute("data-arap-ui", "true");
+ tooltipEl.setAttribute("data-arap-font", safeFont);
document.body.appendChild(tooltipEl);
}
tooltipEl.textContent = text;
diff --git a/src/core/i18n/en.ts b/src/core/i18n/en.ts
index 9297dcd..fba31fb 100644
--- a/src/core/i18n/en.ts
+++ b/src/core/i18n/en.ts
@@ -151,7 +151,7 @@ export const enLocale: Readonly = Object.freeze({
dictionaryStatusSearching: "Searching...",
dictionaryStatusFound: (word: string) => `Definition found for "${word}".`,
dictionaryStatusNotFound: (word: string) =>
- `No definition found for "${word}". Check your spelling or try a suggestion below.`,
+ `No definition found for "${word}". Check your spelling or try a related accessibility term.`,
dictionarySuggestionsTitle: "Did you mean:",
dictionarySourceLocal: "Built-in Glossary",
dictionarySourceProvider: "Configured Provider",
diff --git a/src/core/i18n/si.ts b/src/core/i18n/si.ts
index 8199f63..7be50a3 100644
--- a/src/core/i18n/si.ts
+++ b/src/core/i18n/si.ts
@@ -156,7 +156,7 @@ export const siLocale: Readonly = Object.freeze({
dictionaryStatusFound: (word: string) =>
`"${word}" සඳහා අර්ථ දැක්වීම හමු විය.`,
dictionaryStatusNotFound: (word: string) =>
- `"${word}" සඳහා අර්ථ දැක්වීමක් හමු නොවීය. අක්ෂර වින්යාසය පරීක්ෂා කරන්න හෝ පහත යෝජනාවක් උත්සාහ කරන්න.`,
+ `"${word}" සඳහා අර්ථ දැක්වීමක් හමු නොවීය. අක්ෂර වින්යාසය පරීක්ෂා කරන්න හෝ වෙනත් වචනයක් උත්සාහ කරන්න.`,
dictionarySuggestionsTitle: "ඔබ අදහස් කළේ මෙයද:",
dictionarySourceLocal: "පද්ධතියේ පාරිභාෂික ශබ්දකෝෂය",
dictionarySourceProvider: "වින්යාසගත සේවාව",
diff --git a/src/core/i18n/ta.ts b/src/core/i18n/ta.ts
index 0aa9325..5b37ff9 100644
--- a/src/core/i18n/ta.ts
+++ b/src/core/i18n/ta.ts
@@ -161,7 +161,7 @@ export const taLocale: Readonly = Object.freeze({
dictionaryStatusFound: (word: string) =>
`"${word}" என்பதற்கான விளக்கம் கண்டறியப்பட்டது.`,
dictionaryStatusNotFound: (word: string) =>
- `"${word}" என்பதற்கான விளக்கம் கிடைக்கவில்லை. எழுத்துப் பிழையைச் சரிபார்க்கவும் அல்லது பரிந்துரையைத் தேர்ந்தெடுக்கவும்.`,
+ `"${word}" என்பதற்கான விளக்கம் கிடைக்கவில்லை. எழுத்துப் பிழையைச் சரிபார்க்கவும் அல்லது வேறு சொல்லைத் தேடவும்.`,
dictionarySuggestionsTitle: "நீங்கள் தேடியது இதையா:",
dictionarySourceLocal: "உள்ளமைக்கப்பட்ட சொற்களஞ்சியம்",
dictionarySourceProvider: "கட்டமைக்கப்பட்ட வழங்குநர்",
diff --git a/src/core/menuCustomization.ts b/src/core/menuCustomization.ts
index a978f9b..1f884e7 100644
--- a/src/core/menuCustomization.ts
+++ b/src/core/menuCustomization.ts
@@ -197,6 +197,14 @@ export const DEFAULT_MENU_GROUPS: FeatureMenuGroupConfig[] = [
description: "Accessibility profiles and preset management",
order: 50,
},
+ {
+ id: "experimental",
+ title: "Experimental Prototypes",
+ description: "Optional research features isolated from stable controls",
+ order: 60,
+ collapsible: true,
+ defaultExpanded: false,
+ },
];
/** Mapping of built-in features to default groups */
@@ -226,8 +234,6 @@ export const DEFAULT_FEATURE_GROUP_MAP: Record = {
readingMode: "reading",
readAloud: "reading",
dictionary: "reading",
- voiceNavigation: "reading",
- translation: "reading",
reduceMotion: "media",
hideImages: "media",
@@ -237,6 +243,10 @@ export const DEFAULT_FEATURE_GROUP_MAP: Record = {
presets: "preferences",
keyboardShortcuts: "preferences",
reset: "preferences",
+
+ smartContrast: "experimental",
+ voiceNavigation: "experimental",
+ translation: "experimental",
};
/**
@@ -274,6 +284,8 @@ export function validateMenuConfig(config: unknown): MenuValidationResult {
itemIds: defaultItems
.filter((i) => i.group === g.id)
.map((i) => i.id),
+ collapsible: g.collapsible,
+ defaultExpanded: g.defaultExpanded,
})),
showProfiles: true,
showStatement: true,
@@ -411,6 +423,8 @@ export function validateMenuConfig(config: unknown): MenuValidationResult {
description: g.description,
order: g.order ?? 0,
itemIds: [],
+ collapsible: g.collapsible,
+ defaultExpanded: g.defaultExpanded,
};
groupsList.push(normGroup);
groupMap.set(g.id, normGroup);
@@ -526,7 +540,10 @@ export function getMenuConfigSignature(
? item
: `${item.id}:${item.enabled ?? true}:${item.order ?? 0}:${item.group ?? ""}`,
),
- groups: config.groups?.map((g) => `${g.id}:${g.order ?? 0}`),
+ groups: config.groups?.map(
+ (g) =>
+ `${g.id}:${g.order ?? 0}:${Boolean(g.collapsible)}:${g.defaultExpanded ?? ""}`,
+ ),
showProfiles: config.showProfiles,
showReset: config.showReset,
showStatement: config.showStatement,
diff --git a/src/core/translationAdapter.ts b/src/core/translationAdapter.ts
index 8c30106..78df45b 100644
--- a/src/core/translationAdapter.ts
+++ b/src/core/translationAdapter.ts
@@ -156,6 +156,9 @@ export function isSensitiveElement(element: Element | null): boolean {
// Widget UI elements (must not translate widget UI through host adapter)
if (
+ curr.hasAttribute("data-arap-ui") ||
+ curr.hasAttribute("data-arap-diagnostics") ||
+ curr.classList.contains("arap-root") ||
curr.hasAttribute("data-arap-portal") ||
curr.hasAttribute("data-arap-widget") ||
curr.classList.contains("arap-widget-container") ||
@@ -164,6 +167,17 @@ export function isSensitiveElement(element: Element | null): boolean {
return true;
}
+ // Native selects and free-text form fields whose option labels/values should not mutate
+ if (
+ tag === "select" ||
+ tag === "option" ||
+ tag === "optgroup" ||
+ tag === "textarea" ||
+ tag === "datalist"
+ ) {
+ return true;
+ }
+
// Explicit opt-out attributes
if (
curr.getAttribute("translate") === "no" ||
@@ -301,8 +315,13 @@ export function applyTranslations(
if (trans && item.node.isConnected) {
const sanitized = sanitizeTranslationOutput(trans);
if (sanitized) {
- item.node.textContent = sanitized;
- item.translatedText = sanitized;
+ const leading =
+ item.node.previousSibling && /^\s/.test(item.originalText) ? " " : "";
+ const trailing =
+ item.node.nextSibling && /\s$/.test(item.originalText) ? " " : "";
+ const finalText = `${leading}${sanitized}${trailing}`;
+ item.node.textContent = finalText;
+ item.translatedText = finalText;
appliedList.push({ node: item.node, original: item.originalText });
}
}
@@ -321,6 +340,383 @@ export function applyTranslations(
};
}
+const OFFLINE_PHRASE_LEXICON: Record> = {
+ si: {
+ "skip to main content": "ප්රධාන අන්තර්ගතයට යන්න",
+ overview: "සමාලෝචනය",
+ about: "අප ගැන",
+ news: "පුවත්",
+ contact: "සම්බන්ධ වන්න",
+ home: "මුල් පිටුව",
+ "accessibility plugin react": "ප්රවේශ්යතා ප්ලගිනය (React)",
+ "welcome to the accessibility demo":
+ "ප්රවේශ්යතා ආදර්ශනයට සාදරයෙන් පිළිගනිමු",
+ "accessibility controls showcase": "ප්රවේශ්යතා පාලන ප්රදර්ශනය",
+ "hello accessibility": "ආයුබෝවන් ප්රවේශ්යතාව",
+ "sample content": "නියැදි අන්තර්ගතය",
+ "secondary section": "ද්විතීයික කොටස",
+ "read more": "තව කියවන්න",
+ "learn more": "තව දැනගන්න",
+ "example landscape": "නියැදි භූ දර්ශනය",
+ "decorative divider": "අලංකාර බෙදුම",
+ },
+ ta: {
+ "skip to main content": "முதன்மை உள்ளடக்கத்திற்குச் செல்லவும்",
+ overview: "கண்ணோட்டம்",
+ about: "எங்களைப் பற்றி",
+ news: "செய்திகள்",
+ contact: "தொடர்பு கொள்ள",
+ home: "முகப்பு",
+ "accessibility plugin react": "அணுகல்தன்மை செருகுநிரல் (React)",
+ "welcome to the accessibility demo":
+ "அணுகல்தன்மை செயல்முறைக்கு வரவேற்கிறோம்",
+ "accessibility controls showcase": "அணுகல்தன்மை கட்டுப்பாடுகள் காட்சி",
+ "hello accessibility": "வணக்கம் அணுகல்தன்மை",
+ "sample content": "மாதிரி உள்ளடக்கம்",
+ "secondary section": "இரண்டாம் பிரிவு",
+ "read more": "மேலும் படிக்கவும்",
+ "learn more": "மேலும் அறிய",
+ },
+ es: {
+ "skip to main content": "Saltar al contenido principal",
+ overview: "Resumen",
+ about: "Acerca de",
+ news: "Noticias",
+ contact: "Contacto",
+ home: "Inicio",
+ "accessibility plugin react": "Complemento de Accesibilidad React",
+ "welcome to the accessibility demo":
+ "Bienvenido a la demostración de accesibilidad",
+ "accessibility controls showcase":
+ "Exhibición de controles de accesibilidad",
+ "hello accessibility": "Hola Accesibilidad",
+ "sample content": "Contenido de ejemplo",
+ "secondary section": "Sección secundaria",
+ "read more": "Leer más",
+ "learn more": "Más información",
+ },
+ fr: {
+ "skip to main content": "Aller au contenu principal",
+ overview: "Aperçu",
+ about: "À propos",
+ news: "Actualités",
+ contact: "Contact",
+ home: "Accueil",
+ "accessibility plugin react": "Extension d'accessibilité React",
+ "welcome to the accessibility demo":
+ "Bienvenue dans la démonstration d'accessibilité",
+ "accessibility controls showcase":
+ "Présentation des contrôles d'accessibilité",
+ "hello accessibility": "Bonjour l'accessibilité",
+ "sample content": "Contenu d'exemple",
+ "secondary section": "Section secondaire",
+ "read more": "Lire la suite",
+ "learn more": "En savoir plus",
+ },
+ de: {
+ "skip to main content": "Zum Hauptinhalt springen",
+ overview: "Übersicht",
+ about: "Über uns",
+ news: "Neuigkeiten",
+ contact: "Kontakt",
+ home: "Startseite",
+ "accessibility plugin react": "Barrierefreiheits-Plugin React",
+ "welcome to the accessibility demo":
+ "Willkommen zur Barrierefreiheits-Demo",
+ "accessibility controls showcase":
+ "Präsentation der Barrierefreiheits-Steuerung",
+ "hello accessibility": "Hallo Barrierefreiheit",
+ "sample content": "Beispielinhalt",
+ "secondary section": "Sekundärer Abschnitt",
+ "read more": "Mehr lesen",
+ "learn more": "Mehr erfahren",
+ },
+ ja: {
+ "skip to main content": "メインコンテンツへスキップ",
+ overview: "概要",
+ about: "概要",
+ news: "ニュース",
+ contact: "お問い合わせ",
+ home: "ホーム",
+ "accessibility plugin react": "アクセシビリティプラグイン React",
+ "welcome to the accessibility demo": "アクセシビリティデモへようこそ",
+ "hello accessibility": "こんにちは アクセシビリティ",
+ "read more": "続きを読む",
+ "learn more": "詳細を見る",
+ },
+ zh: {
+ "skip to main content": "跳至主要内容",
+ overview: "概览",
+ about: "关于",
+ news: "新闻",
+ contact: "联系我们",
+ home: "首页",
+ "accessibility plugin react": "无障碍插件 React",
+ "welcome to the accessibility demo": "欢迎来到无障碍演示",
+ "hello accessibility": "你好,无障碍",
+ "read more": "阅读更多",
+ "learn more": "了解更多",
+ },
+};
+
+const OFFLINE_WORD_LEXICON: Record> = {
+ si: {
+ accessibility: "ප්රවේශ්යතාව",
+ accessible: "ප්රවේශ්ය",
+ article: "ලිපිය",
+ button: "බොත්තම",
+ close: "වසන්න",
+ color: "වර්ණය",
+ colors: "වර්ණ",
+ content: "අන්තර්ගතය",
+ contrast: "ප්රතිවිරෝධතාව",
+ control: "පාලනය",
+ controls: "පාලන",
+ custom: "අභිරුචි",
+ dark: "අඳුරු",
+ demo: "ආදර්ශනය",
+ design: "නිර්මාණය",
+ display: "දර්ශනය",
+ documentation: "ලේඛන",
+ example: "උදාහරණය",
+ feature: "විශේෂාංගය",
+ features: "විශේෂාංග",
+ focus: "අවධානය",
+ font: "අකුරු",
+ guide: "මාර්ගෝපදේශය",
+ heading: "ශීර්ෂය",
+ headings: "ශීර්ෂ",
+ help: "උදව්",
+ high: "ඉහළ",
+ image: "රූපය",
+ images: "රූප",
+ keyboard: "යතුරුපුවරුව",
+ language: "භාෂාව",
+ layout: "පිරිසැලසුම",
+ light: "ආලෝක",
+ link: "සබැඳිය",
+ links: "සබැඳි",
+ main: "ප්රධාන",
+ menu: "මෙනුව",
+ mode: "මාදිලිය",
+ motion: "චලනය",
+ navigation: "සංචාලනය",
+ page: "පිටුව",
+ paragraph: "ඡේදය",
+ plugin: "ප්ලගිනය",
+ preferences: "මනාපයන්",
+ profile: "පැතිකඩ",
+ reading: "කියවීම",
+ reset: "යළි පිහිටුවන්න",
+ sample: "නියැදි",
+ screen: "තිරය",
+ search: "සෙවීම",
+ section: "කොටස",
+ settings: "සැකසුම්",
+ size: "ප්රමාණය",
+ text: "පෙළ",
+ theme: "තේමාව",
+ tools: "මෙවලම්",
+ translation: "පරිවේශනය",
+ video: "වීඩියෝ",
+ videos: "වීඩියෝ",
+ voice: "හඬ",
+ welcome: "සාදරයෙන් පිළිගනිමු",
+ },
+ ta: {
+ accessibility: "அணுகல்தன்மை",
+ accessible: "அணுகக்கூடிய",
+ article: "கட்டுரை",
+ content: "உள்ளடக்கம்",
+ contrast: "மாறுபாடு",
+ controls: "கட்டுப்பாடுகள்",
+ demo: "செயல்முறை",
+ example: "உதாரணம்",
+ features: "அம்சங்கள்",
+ focus: "கவனம்",
+ font: "எழுத்துரு",
+ guide: "வழிகாட்டி",
+ heading: "தலைப்பு",
+ help: "உதவி",
+ high: "உயர்",
+ image: "படம்",
+ images: "படங்கள்",
+ keyboard: "விசைப்பலகை",
+ language: "மொழி",
+ light: "ஒளி",
+ links: "இணைப்புகள்",
+ main: "முதன்மை",
+ menu: "பட்டியல்",
+ mode: "பயன்முறை",
+ navigation: "வழிசெலுத்தல்",
+ page: "பக்கம்",
+ reading: "வாசிப்பு",
+ sample: "மாதிரி",
+ section: "பிரிவு",
+ settings: "அமைப்புகள்",
+ text: "உரை",
+ tools: "கருவிகள்",
+ video: "காணொளி",
+ voice: "குரல்",
+ welcome: "வரவேற்கிறோம்",
+ },
+ es: {
+ accessibility: "accesibilidad",
+ article: "artículo",
+ content: "contenido",
+ contrast: "contraste",
+ controls: "controles",
+ demo: "demostración",
+ example: "ejemplo",
+ features: "funciones",
+ focus: "enfoque",
+ font: "fuente",
+ guide: "guía",
+ heading: "encabezado",
+ help: "ayuda",
+ high: "alto",
+ image: "imagen",
+ images: "imágenes",
+ keyboard: "teclado",
+ language: "idioma",
+ light: "claro",
+ links: "enlaces",
+ main: "principal",
+ mode: "modo",
+ navigation: "navegación",
+ page: "página",
+ reading: "lectura",
+ sample: "ejemplo",
+ section: "sección",
+ settings: "ajustes",
+ text: "texto",
+ tools: "herramientas",
+ video: "vídeo",
+ voice: "voz",
+ welcome: "bienvenido",
+ },
+ fr: {
+ accessibility: "accessibilité",
+ article: "article",
+ content: "contenu",
+ contrast: "contraste",
+ controls: "contrôles",
+ demo: "démonstration",
+ example: "exemple",
+ features: "fonctionnalités",
+ focus: "focus",
+ font: "police",
+ guide: "guide",
+ heading: "titre",
+ help: "aide",
+ image: "image",
+ keyboard: "clavier",
+ language: "langue",
+ light: "clair",
+ links: "liens",
+ main: "principal",
+ mode: "mode",
+ navigation: "navigation",
+ page: "page",
+ reading: "lecture",
+ sample: "exemple",
+ section: "section",
+ settings: "paramètres",
+ text: "texte",
+ tools: "outils",
+ video: "vidéo",
+ voice: "voix",
+ welcome: "bienvenue",
+ },
+ de: {
+ accessibility: "Barrierefreiheit",
+ article: "Artikel",
+ content: "Inhalt",
+ contrast: "Kontrast",
+ controls: "Steuerung",
+ demo: "Demo",
+ example: "Beispiel",
+ features: "Funktionen",
+ focus: "Fokus",
+ font: "Schriftart",
+ guide: "Leitfaden",
+ heading: "Überschrift",
+ help: "Hilfe",
+ image: "Bild",
+ keyboard: "Tastatur",
+ language: "Sprache",
+ light: "hell",
+ links: "Links",
+ main: "Haupt",
+ mode: "Modus",
+ navigation: "Navigation",
+ page: "Seite",
+ reading: "Lesen",
+ sample: "Beispiel",
+ section: "Abschnitt",
+ settings: "Einstellungen",
+ text: "Text",
+ tools: "Werkzeuge",
+ video: "Video",
+ voice: "Sprache",
+ welcome: "Willkommen",
+ },
+ ja: {
+ accessibility: "アクセシビリティ",
+ article: "記事",
+ content: "コンテンツ",
+ contrast: "コントラスト",
+ demo: "デモ",
+ features: "機能",
+ help: "ヘルプ",
+ navigation: "ナビゲーション",
+ page: "ページ",
+ reading: "リーディング",
+ settings: "設定",
+ text: "テキスト",
+ welcome: "ようこそ",
+ },
+ zh: {
+ accessibility: "无障碍",
+ article: "文章",
+ content: "内容",
+ contrast: "对比度",
+ demo: "演示",
+ features: "功能",
+ help: "帮助",
+ navigation: "导航",
+ page: "页面",
+ reading: "阅读",
+ settings: "设置",
+ text: "文本",
+ welcome: "欢迎",
+ },
+};
+
+function translateOfflineText(raw: string, targetLanguage: string): string {
+ const baseLang = targetLanguage.trim().toLowerCase().split("-")[0];
+ const trimmed = raw.trim();
+ const lower = trimmed.toLowerCase().replace(/\s+/g, " ");
+ const phrases = OFFLINE_PHRASE_LEXICON[baseLang];
+ if (phrases && phrases[lower]) {
+ return phrases[lower];
+ }
+ const words = OFFLINE_WORD_LEXICON[baseLang];
+ if (!words) {
+ return trimmed;
+ }
+ let matchedCount = 0;
+ const converted = trimmed.replace(/\b([A-Za-z]+)\b/g, (word) => {
+ const replacement = words[word.toLowerCase()];
+ if (replacement) {
+ matchedCount += 1;
+ return replacement;
+ }
+ return word;
+ });
+ return matchedCount > 0 ? converted : trimmed;
+}
+
/**
* Creates an offline, mock translation adapter for development and testing.
* Operates 100% locally with zero network requests.
@@ -331,6 +727,7 @@ export function createOfflineMockTranslationAdapter(options?: {
supportedLanguages?: string[];
}): TranslationAdapter {
const latency = options?.latencyMs ?? 10;
+ const hasCustomPrefix = options?.prefix !== undefined;
const prefix = options?.prefix ?? "[TR]";
const supported = options?.supportedLanguages ?? [
"es",
@@ -367,7 +764,9 @@ export function createOfflineMockTranslationAdapter(options?: {
const translations: TranslatedItem[] = request.texts.map((t) => ({
original: t,
- translated: `${prefix} ${t}`,
+ translated: hasCustomPrefix
+ ? `${prefix} ${t}`
+ : `${prefix} ${translateOfflineText(t, request.targetLanguage)}`,
detectedSourceLanguage: request.sourceLanguage || "en",
}));
@@ -428,9 +827,14 @@ export async function translateHostContent(options: {
? await provider.supportedTargetLanguages()
: provider.supportedTargetLanguages;
+ const normalizedTarget = targetLanguage.trim().toLowerCase();
+ const baseTarget = normalizedTarget.split("-")[0];
+ const supportedNormalized = supported.map((s) => s.trim().toLowerCase());
+
if (
supported.length > 0 &&
- !supported.includes(targetLanguage.toLowerCase())
+ !supportedNormalized.includes(normalizedTarget) &&
+ !supportedNormalized.includes(baseTarget)
) {
throw new TranslationError(
TRANSLATION_ERROR_CODES.UNSUPPORTED_LANGUAGE,
diff --git a/src/core/types.ts b/src/core/types.ts
index e6aec35..2567346 100644
--- a/src/core/types.ts
+++ b/src/core/types.ts
@@ -32,6 +32,7 @@ export interface AccessibilityContextValue {
locale?: string;
statementUrl?: string;
largeControls?: boolean;
+ activeFont?: string;
effectScope?: string | HTMLElement | { current: HTMLElement | null } | null;
nonce?: string;
}
diff --git a/src/core/widgetPlacement.ts b/src/core/widgetPlacement.ts
index 9f40dec..8541ad7 100644
--- a/src/core/widgetPlacement.ts
+++ b/src/core/widgetPlacement.ts
@@ -109,6 +109,7 @@ export function panelStyle(
p: WidgetPlacement | null,
viewport: number[],
size = [56, 56],
+ panelWidth = 460,
): CSSProperties | undefined {
if (p?.kind !== "point") return undefined;
const [width, height] = viewport;
@@ -119,7 +120,7 @@ export function panelStyle(
opposite = below ? "bottom" : "top";
const offsetCss = `max(${offset}px, calc(max(16px, env(safe-area-inset-${side})) + ${size[1] + 12}px))`;
return {
- left: `clamp(max(16px, env(safe-area-inset-left)), ${left}px, max(16px, calc(100vw - ${Math.min(400, width - 32)}px - max(16px, env(safe-area-inset-right)))))`,
+ left: `clamp(max(16px, env(safe-area-inset-left)), ${left}px, max(16px, calc(100vw - ${Math.min(panelWidth, width - 32)}px - max(16px, env(safe-area-inset-right)))))`,
right: "auto",
top: below ? offsetCss : "auto",
bottom: below ? "auto" : offsetCss,
diff --git a/src/features/DictionaryController.tsx b/src/features/DictionaryController.tsx
index ce0818b..3103e9c 100644
--- a/src/features/DictionaryController.tsx
+++ b/src/features/DictionaryController.tsx
@@ -1,7 +1,8 @@
"use client";
-import { useState, useEffect, useRef, useCallback, useContext } from "react";
+import { useState, useRef, useCallback, useContext, useId } from "react";
import { FeatureIcon } from "../core/FeatureIcon";
+import { ModalDialog } from "../core/controls/ModalDialog";
import { AccessibilityContext } from "../core/AccessibilityContext";
import { resolveLocaleStrings } from "../core/i18n";
import {
@@ -55,8 +56,8 @@ export function DictionaryController({
const [liveStatus, setLiveStatus] = useState("");
const triggerRef = useRef(null);
- const dialogRef = useRef(null);
const searchInputRef = useRef(null);
+ const searchInputId = useId();
const handleOpen = useCallback(() => {
setIsOpen(true);
@@ -64,61 +65,8 @@ export function DictionaryController({
const handleClose = useCallback(() => {
setIsOpen(false);
- // Return focus to trigger button
- setTimeout(() => {
- triggerRef.current?.focus();
- }, 0);
}, []);
- // Focus search input when dialog opens
- useEffect(() => {
- if (isOpen) {
- setTimeout(() => {
- searchInputRef.current?.focus();
- }, 50);
- }
- }, [isOpen]);
-
- // Focus trap and Escape key listener
- useEffect(() => {
- if (!isOpen) return;
-
- const handleKeyDown = (event: KeyboardEvent) => {
- if (event.key === "Escape") {
- event.preventDefault();
- event.stopPropagation();
- handleClose();
- return;
- }
-
- if (event.key === "Tab") {
- const dialog = dialogRef.current;
- if (!dialog) return;
-
- const focusable = dialog.querySelectorAll(
- 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',
- );
- if (focusable.length === 0) return;
-
- const first = focusable[0];
- const last = focusable[focusable.length - 1];
-
- if (event.shiftKey && document.activeElement === first) {
- event.preventDefault();
- last.focus();
- } else if (!event.shiftKey && document.activeElement === last) {
- event.preventDefault();
- first.focus();
- }
- }
- };
-
- document.addEventListener("keydown", handleKeyDown, { capture: true });
- return () => {
- document.removeEventListener("keydown", handleKeyDown, { capture: true });
- };
- }, [isOpen, handleClose]);
-
const performLookup = useCallback(
async (termToLookup: string) => {
const sanitized = sanitizeLookupTerm(termToLookup);
@@ -210,193 +158,188 @@ export function DictionaryController({
{/* Accessible Modal Dialog */}
- {isOpen && (
- {
- if (e.target === e.currentTarget) {
- handleClose();
- }
- }}
- >
+
}
+ closeLabel={strings.dictionaryCloseDialog ?? "Close dictionary"}
+ size="full"
+ lockScroll={false}
+ initialFocusRef={searchInputRef}
+ returnFocusTo={triggerRef}
+ >
+
+ {/* Live status announcements */}
- {/* Header */}
-
-
-
-
-
-
-
- {displayLabel}
-
-
- {displayDesc}
-
-
-
-
- ✕
-
-
+ {liveStatus}
+
- {/* Live status announcements */}
-
- {liveStatus}
+ {/* Search Form */}
+
-
- {/* Content Area */}
-
- {result?.found && result.entry && (
-
-
- {result.entry.word}
- {result.entry.phonetic && (
-
- {result.entry.phonetic}
-
- )}
- {result.entry.partOfSpeech && (
-
- {result.entry.partOfSpeech}
-
- )}
-
- {result.entry.source === "local"
- ? (strings.dictionarySourceLocal ?? "Built-in Glossary")
- : (provider?.name ??
- strings.dictionarySourceProvider ??
- "Configured Provider")}
+
+ {isSearching
+ ? (strings.dictionaryStatusSearching ?? "Searching...")
+ : (strings.dictionaryLookupButton ?? "Look up")}
+
+
+
+ {/* Content Area */}
+
+ {result?.found && result.entry && (
+
+
+ {result.entry.word}
+ {result.entry.phonetic && (
+
+ {result.entry.phonetic}
-
-
-
- {result.entry.definition}
-
-
- {result.entry.example && (
-
-
- {strings.dictionaryExampleLabel ?? "Example"}:
- {" "}
- “{result.entry.example}”
-
)}
-
- )}
-
- {result && !result.found && (
-
-
- {result.error ??
- (strings.dictionaryStatusNotFound
- ? strings.dictionaryStatusNotFound(
- result.term ?? searchTerm,
- )
- : `No definition found for "${result.term ?? searchTerm}".`)}
-
-
- {result.suggestions && result.suggestions.length > 0 && (
-
-
- {strings.dictionarySuggestionsTitle ?? "Did you mean:"}
-
-
- {result.suggestions.map((suggestion) => (
- handleSuggestionClick(suggestion)}
- >
- {suggestion}
-
- ))}
-
-
+ {result.entry.partOfSpeech && (
+
+ {result.entry.partOfSpeech}
+
)}
+
+ {result.entry.source === "local"
+ ? (strings.dictionarySourceLocal ?? "Built-in Glossary")
+ : (provider?.name ??
+ strings.dictionarySourceProvider ??
+ "Configured Provider")}
+
+
+
+
+ {result.entry.definition}
+
+
+ {result.entry.example && (
+
+
+ {strings.dictionaryExampleLabel ?? "Example"}:
+ {" "}
+ “{result.entry.example}”
+
+ )}
+
+ )}
+
+ {result && !result.found && (
+
+
+ {result.error ??
+ (strings.dictionaryStatusNotFound
+ ? strings.dictionaryStatusNotFound(
+ result.term ?? searchTerm,
+ )
+ : `No definition found for "${result.term ?? searchTerm}".`)}
+
+
+ {result.suggestions && result.suggestions.length > 0 && (
+
+
+ {strings.dictionarySuggestionsTitle ?? "Did you mean:"}
+
+
+ {result.suggestions.map((suggestion) => (
+ handleSuggestionClick(suggestion)}
+ >
+ {suggestion}
+
+ ))}
+
+
+ )}
+
+ )}
+
+ {!result && (
+
+
+ {strings.dictionaryDescription ??
+ "Look up definitions and accessibility terminology"}
+
+
+
+ Popular terms:
+
+
+ {[
+ "accessibility",
+ "contrast",
+ "dyslexia",
+ "voice",
+ "wcag",
+ "screen reader",
+ ].map((chip) => (
+ handleSuggestionClick(chip)}
+ >
+ {chip}
+
+ ))}
+
- )}
-
- {!result && (
-
-
- {strings.dictionaryDescription ??
- "Look up definitions and accessibility terminology"}
-
-
- {provider
- ? `Using ${provider.name}. Queries are rate-limited and sanitized.`
- : "Using local offline glossary. Zero network transmission."}
-
-
- )}
-
+
+ {provider
+ ? `Using ${provider.name}. Queries are rate-limited and sanitized.`
+ : "Using local offline glossary. Zero network transmission."}
+
+
+ )}
- )}
+
);
}
diff --git a/src/features/FeatureMenu.tsx b/src/features/FeatureMenu.tsx
index 46bffbd..fd20565 100644
--- a/src/features/FeatureMenu.tsx
+++ b/src/features/FeatureMenu.tsx
@@ -1,6 +1,7 @@
"use client";
import React, { useMemo } from "react";
+import { FeatureGroup } from "../core/controls/FeatureGroup";
import {
type MenuCustomizationConfig,
type NormalizedMenuItem,
@@ -154,26 +155,34 @@ export function FeatureMenu({
if (groupItems.length === 0) return null;
- const headingId = `arap-grp-${group.id}`;
+ if (group.title) {
+ return (
+
+
+ {groupItems.map((item) => renderItem(item))}
+
+
+ );
+ }
return (
- {group.title && (
-
-
- {group.title}
-
- {group.description && (
-
{group.description}
- )}
-
- )}
{groupItems.map((item) => renderItem(item))}
diff --git a/src/features/KeyboardShortcutsController.tsx b/src/features/KeyboardShortcutsController.tsx
index 6b34e00..62d94e8 100644
--- a/src/features/KeyboardShortcutsController.tsx
+++ b/src/features/KeyboardShortcutsController.tsx
@@ -1,17 +1,9 @@
"use client";
-import {
- useState,
- useEffect,
- useRef,
- useContext,
- useId,
- type ReactNode,
- useSyncExternalStore,
-} from "react";
-import { createPortal } from "react-dom";
+import { useState, useEffect, useRef, useContext, useId } from "react";
import { AccessibilityContext } from "../core/AccessibilityContext";
import { FeatureIcon } from "../core/FeatureIcon";
+import { ModalDialog } from "../core/controls/ModalDialog";
import { resolveLocaleStrings } from "../core/i18n";
import { useAccessibility } from "../core/useAccessibility";
import {
@@ -29,8 +21,6 @@ export interface KeyboardShortcutsControllerProps {
description?: string;
}
-const emptySubscribe = () => () => {};
-
export function KeyboardShortcutsController({
className = "",
label,
@@ -55,16 +45,10 @@ export function KeyboardShortcutsController({
const [isError, setIsError] = useState(false);
const triggerRef = useRef(null);
- const dialogRef = useRef(null);
const remapInputRef = useRef(null);
- const previousActiveElement = useRef(null);
-
- const titleId = useId();
- const isClient = useSyncExternalStore(
- emptySubscribe,
- () => true,
- () => false,
- );
+ const enabledCheckboxId = useId();
+ const searchInputId = useId();
+ const remapInputId = useId();
const controllerLabel =
label ?? strings.shortcutsTitle ?? "Keyboard Shortcuts";
@@ -76,10 +60,6 @@ export function KeyboardShortcutsController({
const closeLabel = strings.shortcutsClose ?? "Close Keyboard Shortcuts";
const handleOpen = () => {
- if (typeof document !== "undefined") {
- previousActiveElement.current =
- document.activeElement as HTMLElement | null;
- }
setStatusMessage(null);
setRemapTargetId(null);
setIsOpen(true);
@@ -89,65 +69,8 @@ export function KeyboardShortcutsController({
setIsOpen(false);
setRemapTargetId(null);
setStatusMessage(null);
- if (previousActiveElement.current) {
- previousActiveElement.current.focus();
- } else {
- triggerRef.current?.focus();
- }
};
- const handleCloseRef = useRef(handleClose);
- useEffect(() => {
- handleCloseRef.current = handleClose;
- });
-
- // Focus management and Escape key in dialog
- useEffect(() => {
- if (!isOpen || !dialogRef.current) return;
-
- dialogRef.current.focus();
-
- const handleKeyDown = (event: KeyboardEvent) => {
- if (event.key === "Escape") {
- event.stopPropagation();
- if (remapTargetId) {
- setRemapTargetId(null);
- setStatusMessage("Remapping cancelled.");
- setIsError(false);
- } else {
- handleCloseRef.current();
- }
- return;
- }
-
- if (event.key === "Tab") {
- const dialog = dialogRef.current;
- if (!dialog) return;
-
- const focusable = dialog.querySelectorAll(
- 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',
- );
- if (focusable.length === 0) return;
-
- const first = focusable[0];
- const last = focusable[focusable.length - 1];
-
- if (event.shiftKey && document.activeElement === first) {
- event.preventDefault();
- last.focus();
- } else if (!event.shiftKey && document.activeElement === last) {
- event.preventDefault();
- first.focus();
- }
- }
- };
-
- document.addEventListener("keydown", handleKeyDown, { capture: true });
- return () => {
- document.removeEventListener("keydown", handleKeyDown, { capture: true });
- };
- }, [isOpen, remapTargetId]);
-
// Focus remap input when remap mode activates
useEffect(() => {
if (remapTargetId && remapInputRef.current) {
@@ -297,278 +220,249 @@ export function KeyboardShortcutsController({
{ id: "tools", label: "Tools" },
];
- const dialogPortal: ReactNode =
- isClient && isOpen && typeof document !== "undefined"
- ? createPortal(
- {
- if (e.target === e.currentTarget) {
- handleClose();
- }
- }}
+ return (
+ <>
+
+
+
+
+
+ {controllerLabel}
+ {controllerDescription}
+
+
+
+ {isOpen ? "Close" : "Open"}
+
+
+
+
+
}
+ closeLabel={closeLabel}
+ size="full"
+ lockScroll={false}
+ disableEscapeClose={Boolean(remapTargetId)}
+ returnFocusTo={triggerRef}
+ footer={
+
+
+ {strings.shortcutsReset ?? "Reset to Defaults"}
+
+
+ }
+ >
+
+ {/* Global shortcut toggle switch */}
+
+
+ setShortcutsEnabled(e.target.checked)}
+ className="arap-checkbox"
+ />
+
+
+ {strings.shortcutsEnabledLabel ??
+ "Enable Global Keyboard Shortcuts"}
+
+
+ Allows triggering accessibility tools with keyboard keys from
+ anywhere on the page
+
+
+
+
+
+ {/* Filter controls */}
+
-
-
-
-
- {controllerLabel}
-
-
- {controllerDescription}
-
-
+ {categories.map((c) => (
setActiveCategory(c.id)}
>
- ×
+ {c.label}
-
-
- {/* Global shortcut toggle switch */}
-
-
- setShortcutsEnabled(e.target.checked)}
- className="arap-checkbox"
- />
-
-
- {strings.shortcutsEnabledLabel ??
- "Enable Global Keyboard Shortcuts"}
-
-
- Allows triggering accessibility tools with keyboard keys
- from anywhere on the page
-
-
-
-
-
- {/* Filter controls */}
-
-
- {categories.map((c) => (
- setActiveCategory(c.id)}
- >
- {c.label}
-
- ))}
-
-
-
- setSearch(e.target.value)}
- aria-label="Filter shortcuts"
- />
-
-
-
- {/* Status announcement */}
- {statusMessage && (
-
- {statusMessage}
-
- )}
-
- {/* Remap Active Input Card */}
- {remapTargetId && (
-
-
-
- Remapping:{" "}
- {stringMap[
- DEFAULT_SHORTCUTS.find((s) => s.id === remapTargetId)
- ?.labelKey || ""
- ] ?? remapTargetId}
-
- setRemapTargetId(null)}
- >
- {strings.shortcutsCancel ?? "Cancel"}
-
-
-
-
- Press your new combination or Escape to cancel. Reserved
- browser keys (e.g. Ctrl+U, Ctrl+R) are protected.
-
-
- )}
-
- {/* Shortcuts List */}
-
- {filteredShortcuts.length === 0 ? (
-
- No shortcuts match your search.
-
- ) : (
-
- )}
-
+ ))}
+
- {/* Footer */}
-
+
+ setSearch(e.target.value)}
+ aria-label="Filter shortcuts"
+ />
+ {search && (
setSearch("")}
+ aria-label="Clear shortcut filter"
>
- {strings.shortcutsReset ?? "Reset to Defaults"}
+ ×
+ )}
+
+
+
+ {/* Status announcement */}
+ {statusMessage && (
+
+ {statusMessage}
+
+ )}
+
+ {/* Remap Active Input Card */}
+ {remapTargetId && (
+
+
+
+ Remapping:{" "}
+ {stringMap[
+ DEFAULT_SHORTCUTS.find((s) => s.id === remapTargetId)
+ ?.labelKey || ""
+ ] ?? remapTargetId}
+
setRemapTargetId(null)}
>
- {closeLabel}
+ {strings.shortcutsCancel ?? "Cancel"}
+
+
+ Press your new combination or Escape to cancel. Reserved browser
+ keys (e.g. Ctrl+U, Ctrl+R) are protected.
+
-
,
- document.body,
- )
- : null;
-
- return (
- <>
-
-
-
-
- {controllerLabel}
-
- {controllerDescription}
-
-
-
-
- {openLabel}
-
-
+ )}
- {dialogPortal}
+ {/* Shortcuts List */}
+
+ {filteredShortcuts.length === 0 ? (
+
+ No shortcuts match your search.
+
+ ) : (
+
+ )}
+
+
+
>
);
}
diff --git a/src/features/PageNavigatorController.tsx b/src/features/PageNavigatorController.tsx
index 5451c67..718f8b4 100644
--- a/src/features/PageNavigatorController.tsx
+++ b/src/features/PageNavigatorController.tsx
@@ -1,7 +1,8 @@
"use client";
-import { useState, useEffect, useRef, useCallback } from "react";
+import { useState, useEffect, useRef, useCallback, useId } from "react";
import { FeatureIcon } from "../core/FeatureIcon";
+import { ModalDialog } from "../core/controls/ModalDialog";
import {
scanHeadings,
scanLandmarks,
@@ -40,6 +41,9 @@ export function PageNavigatorController({
const [landmarks, setLandmarks] = useState
([]);
const [links, setLinks] = useState([]);
const [search, setSearch] = useState("");
+ const [activeNavKey, setActiveNavKey] = useState(null);
+ const [navStatus, setNavStatus] = useState("");
+ const searchInputId = useId();
const triggerRef = useRef(null);
const dialogRef = useRef(null);
@@ -52,6 +56,7 @@ export function PageNavigatorController({
const handleOpen = () => {
refreshStructure();
+ setNavStatus("");
setIsOpen(true);
};
@@ -66,14 +71,13 @@ export function PageNavigatorController({
return subscribePageStructure(refreshStructure);
}, [isOpen, refreshStructure]);
- // Focus management when opening dialog
- useEffect(() => {
- if (isOpen) {
- dialogRef.current?.focus();
- }
- }, [isOpen]);
-
- const handleNavigate = (element: HTMLElement) => {
+ const handleNavigate = (
+ element: HTMLElement,
+ navKey: string,
+ announceText: string,
+ ) => {
+ setActiveNavKey(navKey);
+ setNavStatus(`Navigated to ${announceText}`);
navigateToElement(element, {
onComplete: () => {
if (closeOnNavigate) {
@@ -109,37 +113,21 @@ export function PageNavigatorController({
role="group"
aria-label={label}
>
-
+
- {label}
+ {label}
{description && (
-
- {description}
-
+ {description}
)}
{
@@ -154,7 +142,21 @@ export function PageNavigatorController({
- {isOpen && (
+
}
+ closeLabel="Close Page Navigator"
+ size="full"
+ trapFocus={false}
+ lockScroll={false}
+ ariaModal={false}
+ initialFocusRef={dialogRef}
+ returnFocusTo={triggerRef}
+ >
setSearch(e.target.value)}
aria-label={`Filter ${activeTab}`}
/>
+ {search && (
+ setSearch("")}
+ aria-label={`Clear ${activeTab} filter`}
+ >
+ ×
+
+ )}
+ {navStatus && (
+
+ {navStatus}
+
+ )}
+
{activeTab === "headings" && (
) : (
- {filteredHeadings.map((h, i) => (
-
- handleNavigate(h.element)}
- >
- {
+ const navKey = `h-${h.id}-${i}`;
+ const isActive = activeNavKey === navKey;
+ return (
+
+
+ handleNavigate(
+ h.element,
+ navKey,
+ `H${h.level}: ${h.text}`,
+ )
+ }
>
- H{h.level}
-
-
- {h.text}
-
-
-
- ))}
+
+ H{h.level}
+
+
+ {h.text}
+
+
+
+ );
+ })}
)}
@@ -300,25 +335,36 @@ export function PageNavigatorController({
) : (
- {filteredLandmarks.map((l, i) => (
-
- handleNavigate(l.element)}
- >
- {
+ const navKey = `l-${l.id}-${i}`;
+ const isActive = activeNavKey === navKey;
+ return (
+
+
+ handleNavigate(
+ l.element,
+ navKey,
+ `${l.type} landmark: ${l.label}`,
+ )
+ }
>
- {l.type.toUpperCase()}
-
-
- {l.label}
-
-
-
- ))}
+
+ {l.type.toUpperCase()}
+
+
+ {l.label}
+
+
+
+ );
+ })}
)}
@@ -338,53 +384,61 @@ export function PageNavigatorController({
) : (
- {filteredLinks.map((lnk, i) => (
-
- handleNavigate(lnk.element)}
- >
- {
+ const navKey = `lnk-${lnk.id}-${i}`;
+ const isActive = activeNavKey === navKey;
+ return (
+
+
+ handleNavigate(
+ lnk.element,
+ navKey,
+ `link: ${lnk.text}`,
+ )
+ }
>
- {lnk.isExternal
- ? "EXT"
- : lnk.isHash
- ? "ANCHOR"
- : "LINK"}
-
-
- {lnk.text}
- {lnk.isAmbiguous && (
-
- Ambiguous
-
- )}
- {lnk.href}
+ {lnk.isExternal
+ ? "EXT"
+ : lnk.isHash
+ ? "ANCHOR"
+ : "LINK"}
+
+
+ {lnk.text}
+ {lnk.isAmbiguous && (
+
+ Ambiguous
+
+ )}
+
+ {lnk.href}
+
-
-
-
- ))}
+
+
+ );
+ })}
)}
)}
- )}
+
);
}
diff --git a/src/features/PresetsController.tsx b/src/features/PresetsController.tsx
index 4c542c6..5d119f4 100644
--- a/src/features/PresetsController.tsx
+++ b/src/features/PresetsController.tsx
@@ -3,6 +3,11 @@
import { useContext, useId, useRef, useState, type ChangeEvent } from "react";
import { FeatureIcon } from "../core/FeatureIcon";
import { EmptyState } from "../core/controls/FeatureStatusState";
+import { ModalDialog } from "../core/controls/ModalDialog";
+import {
+ formatPreferenceKey,
+ formatPreferenceValue,
+} from "../core/controls/ProfilePreviewCard";
import { usePresets } from "../core/usePresets";
import { AccessibilityContext } from "../core/AccessibilityContext";
import { resolveLocaleStrings } from "../core/i18n";
@@ -32,6 +37,7 @@ export function PresetsController({
const [errorMessage, setErrorMessage] = useState("");
const dialogId = "arap-presets-dialog";
const nameInputId = useId();
+ const fileInputId = useId();
const fileInputRef = useRef(null);
const triggerRef = useRef(null);
@@ -110,76 +116,19 @@ export function PresetsController({
}
};
- const formatKeyName = (key: string): string => {
- switch (key) {
- case "fontScale":
- return "Font Size";
- case "lineHeight":
- return "Line Height";
- case "contrastMode":
- return "Contrast";
- case "reduceMotion":
- return "Reduce Motion";
- case "textAlign":
- return "Text Align";
- case "highlightLinks":
- return "Highlight Links";
- case "highlightFocus":
- return "Highlight Focus";
- case "cursorSize":
- return "Cursor Size";
- case "readerMode":
- return "Reading Mode";
- case "saturation":
- return "Saturation";
- case "hideDecorativeImages":
- return "Hide Images";
- default:
- return key.replace(/([A-Z])/g, " $1").trim();
- }
- };
-
- const formatSettingValue = (
- key: keyof AccessibilityPreferences,
- val: unknown,
- ): string => {
- if (typeof val === "boolean") return val ? "On" : "Off";
- if (key === "fontScale" && typeof val === "number")
- return `${Math.round(val * 100)}%`;
- if (key === "lineHeight" && typeof val === "number")
- return `${Math.round(val * 100)}%`;
- if (val === null || val === undefined) return "Original";
- return String(val);
- };
-
return (
-
+
- {effectiveLabel}
+ {effectiveLabel}
{description && (
-
+
{presets.length > 0
? `${presets.length} custom preset${presets.length === 1 ? "" : "s"} saved`
: description}
@@ -189,101 +138,61 @@ export function PresetsController({
setIsOpen(!isOpen)}
+ title="Manage saved presets and JSON import/export"
>
{isOpen ? "Close" : "Presets"}
- {isOpen && (
+
setIsOpen(false)}
+ id="arap-presets-modal"
+ title={effectiveLabel}
+ subtitle={description}
+ icon={ }
+ closeLabel="Close presets dialog"
+ size="full"
+ lockScroll={false}
+ returnFocusTo={triggerRef}
+ >
{
- if (e.key === "Escape") {
- e.stopPropagation();
- setIsOpen(false);
- triggerRef.current?.focus();
- }
- }}
>
{/* Live Status and Error Announcements */}
-
+
{statusMessage && (
-
+
✓ {statusMessage}
)}
{errorMessage && (
-
{/* Save Current Configuration as New Preset */}
-
-
+
+
Save current settings as preset:
-
+
{
setPresetName(e.target.value);
@@ -300,7 +209,7 @@ export function PresetsController({
/>
@@ -310,20 +219,10 @@ export function PresetsController({
{/* Backup & Transfer (Export / Import) */}
-
+
@@ -331,8 +230,7 @@ export function PresetsController({
fileInputRef.current?.click()}
aria-label="Import settings and presets from JSON file"
>
@@ -340,6 +238,8 @@ export function PresetsController({
-
+
Saved Presets ({presets.length}):
@@ -367,13 +260,7 @@ export function PresetsController({
description="Configure your preferences and save them above for quick 1-click access."
/>
) : (
-
+
{presets.map((p) => {
const affectedKeys = Object.keys(
p.settings,
@@ -385,50 +272,20 @@ export function PresetsController({
className="arap-preset-card"
role="group"
aria-label={`${p.name} preset`}
- style={{
- padding: "8px 10px",
- borderRadius: "6px",
- backgroundColor: "var(--arap-bg, #ffffff)",
- border: "1px solid var(--arap-border, #e2e8f0)",
- }}
>
-
-
-
+
+
+
{p.name}
-
+
Saved {new Date(p.createdAt).toLocaleDateString()}
-
+
handleApply(p)}
aria-label={`Apply preset ${p.name}`}
>
@@ -436,12 +293,9 @@ export function PresetsController({
handleDelete(p)}
aria-label={`Delete preset ${p.name}`}
- style={{
- color: "var(--arap-error, #dc2626)",
- }}
>
Delete
@@ -449,16 +303,13 @@ export function PresetsController({
{affectedKeys.length > 0 && (
-
+
{affectedKeys.map((key) => {
const val = p.settings[key];
return (
- {formatKeyName(key)}: {" "}
- {formatSettingValue(key, val)}
+ {formatPreferenceKey(key)}: {" "}
+ {formatPreferenceValue(key, val)}
);
})}
@@ -471,7 +322,7 @@ export function PresetsController({
)}
- )}
+
);
}
diff --git a/src/features/ProfilesController.tsx b/src/features/ProfilesController.tsx
index 2e1945a..de46e3c 100644
--- a/src/features/ProfilesController.tsx
+++ b/src/features/ProfilesController.tsx
@@ -2,6 +2,7 @@
import { useContext, useId, useMemo, useRef, useState } from "react";
import { FeatureIcon } from "../core/FeatureIcon";
+import { ModalDialog } from "../core/controls/ModalDialog";
import { ProfilePreviewCard } from "../core/controls/ProfilePreviewCard";
import { EmptyState, SearchCount } from "../core/controls/FeatureStatusState";
import { useProfiles } from "../core/useProfiles";
@@ -82,35 +83,15 @@ export function ProfilesController({
role="group"
aria-label={effectiveLabel}
>
-
+
- {effectiveLabel}
+ {effectiveLabel}
{description && (
-
+
{activeProfile ? (
-
+
Active: {activeProfile.label}
{hasOverrides && " (Customized)"}
@@ -121,11 +102,11 @@ export function ProfilesController({
)}
-
+
{activeProfile && (
setIsOpen(!isOpen)}
+ title="Browse 8 curated accessibility profiles"
>
{isOpen ? "Close" : "Browse"}
- {isOpen && (
-
+
setIsOpen(false)}
+ id={dialogId}
+ title={effectiveLabel}
+ subtitle={description}
+ icon={ }
+ closeLabel="Close profiles dialog"
+ size="full"
+ lockScroll={false}
+ returnFocusTo={triggerRef}
+ >
+
{activeProfile && (
-
+
-
+
✓ Current Profile: {activeProfile.label}
-
+
{hasOverrides
? "Your custom adjustments survive alongside this profile."
- : "Neutral suggestion applied. Adjust any setting freely."}
+ : "Neutral suggestion applied. Adjust any setting freely, or revert below."}
-
- Revert to Custom
-
)}
-
+
Filter profiles
@@ -241,15 +191,7 @@ export function ProfilesController({
query={search}
/>
-
+
{filteredProfiles.length === 0 ? (
- )}
+
);
}
diff --git a/src/features/ReadAloudController.tsx b/src/features/ReadAloudController.tsx
index ad4f95d..78f3421 100644
--- a/src/features/ReadAloudController.tsx
+++ b/src/features/ReadAloudController.tsx
@@ -7,10 +7,9 @@ import {
useId,
useContext,
useCallback,
- useSyncExternalStore,
} from "react";
-import { createPortal } from "react-dom";
import { FeatureIcon } from "../core/FeatureIcon";
+import { WidgetPortal } from "../core/WidgetPortal";
import { useAccessibility } from "../core/useAccessibility";
import { AccessibilityContext } from "../core/AccessibilityContext";
import { resolveLocaleStrings } from "../core/i18n";
@@ -23,15 +22,6 @@ import {
type ReadAloudState,
} from "../core/readAloud";
-const emptySubscribe = () => () => {};
-function useMounted(): boolean {
- return useSyncExternalStore(
- emptySubscribe,
- () => true,
- () => false,
- );
-}
-
export interface ReadAloudControllerProps {
className?: string;
label?: string;
@@ -78,7 +68,6 @@ export function ReadAloudController({
const [statusMessage, setStatusMessage] = useState
(null);
const sessionRef = useRef(null);
- const mounted = useMounted();
const titleId = useId();
const voiceSelectId = useId();
@@ -268,7 +257,7 @@ export function ReadAloudController({
{!isActive ? (
@@ -296,7 +285,7 @@ export function ReadAloudController({
) : (
@@ -385,7 +374,7 @@ export function ReadAloudController({
setVoiceUri(e.target.value || null)}
>
@@ -404,10 +393,8 @@ export function ReadAloudController({
)}
{/* Floating Read-Aloud Mini-Player Bar (shown when active) */}
- {mounted &&
- isActive &&
- typeof document !== "undefined" &&
- createPortal(
+ {isActive && (
+
-
,
- document.body,
- )}
+
+
+ )}
);
}
diff --git a/src/features/ReadingGuideController.tsx b/src/features/ReadingGuideController.tsx
index f637e82..4116f6c 100644
--- a/src/features/ReadingGuideController.tsx
+++ b/src/features/ReadingGuideController.tsx
@@ -1,6 +1,7 @@
"use client";
import { FeatureIcon } from "../core/FeatureIcon";
+import { WidgetPortal } from "../core/WidgetPortal";
import { useAccessibility } from "../core/useAccessibility";
import { nudgeReadingAid } from "../core/effects";
@@ -28,79 +29,63 @@ export function ReadingGuideController({
};
return (
-
-
-
-
- Reading Guide
-
- setValue(!value)}
- aria-label="Reading Guide"
- aria-pressed={value}
- type="button"
- >
-
-
-
-
- {value && (
+ <>
+
-
- Move Guide
+
+
+ Reading Guide
-
+ setValue(!value)}
+ aria-label="Reading Guide"
+ aria-pressed={value}
+ type="button"
+ >
+
+
+
+
+
+ {value && (
+
+
↑
↓
-
+
)}
-
+ >
);
}
diff --git a/src/features/ReadingMaskController.tsx b/src/features/ReadingMaskController.tsx
index fe12eeb..b9dded6 100644
--- a/src/features/ReadingMaskController.tsx
+++ b/src/features/ReadingMaskController.tsx
@@ -1,6 +1,7 @@
"use client";
import { FeatureIcon } from "../core/FeatureIcon";
+import { WidgetPortal } from "../core/WidgetPortal";
import { useAccessibility } from "../core/useAccessibility";
import { nudgeReadingAid } from "../core/effects";
@@ -51,129 +52,123 @@ export function ReadingMaskController({
};
return (
-
+ <>
-
-
- Reading Mask
-
- setValue(!value)}
- aria-label="Reading Mask"
- aria-pressed={value}
- type="button"
- >
-
-
-
-
- {value && (
+
+
+ Reading Mask
+
+ setValue(!value)}
+ aria-label="Reading Mask"
+ aria-pressed={value}
+ type="button"
+ >
+
+
+
+
+ {value && (
-
- Window Height
-
-
-
- −
-
-
- {currentHeight}px
-
-
= maxHeight}
- aria-label="Increase reading mask height"
- type="button"
+
- +
-
+ Window Height
+
+
+
+ −
+
+
+ {currentHeight}px
+
+ = maxHeight}
+ aria-label="Increase reading mask height"
+ type="button"
+ >
+ +
+
+
+ )}
+
+ {value && (
+
-
- Move Window
-
-
-
- ↑
-
-
- ↓
-
-
+ ↑
+
+
+ ↓
+
-
+
)}
-
+ >
);
}
diff --git a/src/features/ReadingModeController.tsx b/src/features/ReadingModeController.tsx
index 19c04f8..ed77c12 100644
--- a/src/features/ReadingModeController.tsx
+++ b/src/features/ReadingModeController.tsx
@@ -6,11 +6,10 @@ import {
useRef,
useId,
useContext,
- useSyncExternalStore,
type ReactNode,
} from "react";
-import { createPortal } from "react-dom";
import { FeatureIcon } from "../core/FeatureIcon";
+import { WidgetPortal } from "../core/WidgetPortal";
import { useAccessibility } from "../core/useAccessibility";
import { AccessibilityContext } from "../core/AccessibilityContext";
import { resolveLocaleStrings } from "../core/i18n";
@@ -22,15 +21,6 @@ import {
const FEATURE_KEY = "readingMode";
const DEFAULT_VALUE = false;
-const emptySubscribe = () => () => {};
-function useMounted(): boolean {
- return useSyncExternalStore(
- emptySubscribe,
- () => true,
- () => false,
- );
-}
-
export interface ReadingModeControllerProps {
className?: string;
label?: string;
@@ -69,7 +59,6 @@ export function ReadingModeController({
"light",
);
const [readerScale, setReaderScale] = useState
(100);
- const mounted = useMounted();
const triggerRef = useRef(null);
const dialogRef = useRef(null);
@@ -196,158 +185,138 @@ export function ReadingModeController({
: `${activeArticle.readingTimeMinutes} min read`
: "";
- const readerDialog: ReactNode =
- mounted && activeArticle && typeof document !== "undefined"
- ? createPortal(
- {
- if (e.target === e.currentTarget) {
- handleClose();
- }
- }}
- >
+ const readerDialog: ReactNode = activeArticle ? (
+
+ {
+ if (e.target === e.currentTarget) {
+ handleClose();
+ }
+ }}
+ >
+
{
+ if (e.key === "Escape") {
+ e.stopPropagation();
+ handleClose();
+ }
+ }}
+ >
+
+
+
+ {featureLabel}
+
+ {wordCountDisplay}
+
+ •
+
+
+ {readingTimeDisplay}
+
+
+
{
- if (e.key === "Escape") {
- e.stopPropagation();
- handleClose();
- }
- }}
+ className="arap-reading-mode-toolbar"
+ role="toolbar"
+ aria-label="Reader tools"
>
-
-
-
- {featureLabel}
-
-
- {wordCountDisplay}
-
-
- •
-
-
- {readingTimeDisplay}
-
-
-
-
+
setReaderTheme("light")}
+ aria-pressed={readerTheme === "light"}
+ aria-label="Light theme"
+ >
+ Light
+
+
setReaderTheme("sepia")}
+ aria-pressed={readerTheme === "sepia"}
+ aria-label="Sepia theme"
+ >
+ Sepia
+
+
setReaderTheme("dark")}
+ aria-pressed={readerTheme === "dark"}
+ aria-label="Dark theme"
>
-
- setReaderTheme("light")}
- aria-pressed={readerTheme === "light"}
- aria-label="Light theme"
- >
- Light
-
- setReaderTheme("sepia")}
- aria-pressed={readerTheme === "sepia"}
- aria-label="Sepia theme"
- >
- Sepia
-
- setReaderTheme("dark")}
- aria-pressed={readerTheme === "dark"}
- aria-label="Dark theme"
- >
- Dark
-
-
-
-
-
- A-
-
- = 160}
- >
- A+
-
-
-
-
- ×
-
-
+ Dark
+
-
-
- {activeArticle.title}
-
- {activeArticle.byline && (
-
- {activeArticle.byline}
-
- )}
-
-
-
-
-
,
- document.body,
- )
- : null;
+
+
+
+
+ {activeArticle.title}
+
+ {activeArticle.byline && (
+ {activeArticle.byline}
+ )}
+
+
+
+
+
+ ) : null;
return (
<>
diff --git a/src/features/ResetController.tsx b/src/features/ResetController.tsx
index 946fd77..cf532d9 100644
--- a/src/features/ResetController.tsx
+++ b/src/features/ResetController.tsx
@@ -21,7 +21,11 @@ export function ResetController() {
const button = (
-
+
{strings.resetAll}
diff --git a/src/features/SmartContrastController.tsx b/src/features/SmartContrastController.tsx
index 74e1789..946beec 100644
--- a/src/features/SmartContrastController.tsx
+++ b/src/features/SmartContrastController.tsx
@@ -52,7 +52,11 @@ export function SmartContrastController() {
const isActive = value === "aa" || value === "aaa" || value === true;
return (
-
+
Smart Contrast
diff --git a/src/features/TranslationController.tsx b/src/features/TranslationController.tsx
index 9a96959..fb9d8f3 100644
--- a/src/features/TranslationController.tsx
+++ b/src/features/TranslationController.tsx
@@ -56,11 +56,23 @@ export const TranslationController: React.FC
= ({
const [showConsentModal, setShowConsentModal] = useState(false);
const sessionRef = useRef(null);
+ const extraRestoresRef = useRef void>>([]);
+ const isApplyingMutationRef = useRef(false);
useEffect(() => {
sessionRef.current = session;
}, [session]);
+ const restoreAllActive = () => {
+ while (extraRestoresRef.current.length > 0) {
+ const fn = extraRestoresRef.current.pop();
+ fn?.();
+ }
+ if (sessionRef.current?.active) {
+ sessionRef.current.restore();
+ }
+ };
+
const displayLabel = label ?? "Page Translation";
const displayDesc =
description ??
@@ -69,21 +81,132 @@ export const TranslationController: React.FC = ({
// Teardown and restore on unmount
useEffect(() => {
return () => {
- if (sessionRef.current?.active) {
- sessionRef.current.restore();
- }
+ restoreAllActive();
};
}, []);
// Listen to external reset preference
useEffect(() => {
if (!isTranslationEnabled && sessionRef.current?.active) {
- sessionRef.current.restore();
+ restoreAllActive();
setSession(null);
setLiveStatus("Translations restored to original content.");
}
}, [isTranslationEnabled]);
+ const runTranslation = async (
+ nextLang: string,
+ consentRecord: TranslationConsentRecord = consent,
+ ) => {
+ setErrorMessage(null);
+ setIsTranslating(true);
+ setLiveStatus(`Extracting and translating page text to ${nextLang}...`);
+
+ try {
+ isApplyingMutationRef.current = true;
+ restoreAllActive();
+
+ const newSession = await translateHostContent({
+ provider,
+ targetLanguage: nextLang,
+ consentRecord,
+ });
+
+ setSession(newSession);
+ sessionRef.current = newSession;
+ setIsTranslationEnabled(true);
+ const langLabel =
+ DEFAULT_TARGET_LANGUAGES.find((l) => l.code === nextLang)?.label ??
+ nextLang;
+ setLiveStatus(
+ `Translated ${newSession.translatedCount} text segments to ${langLabel}.`,
+ );
+ } catch (err: unknown) {
+ const msg = err instanceof Error ? err.message : String(err);
+ setErrorMessage(msg);
+ setLiveStatus(`Translation failed: ${msg}`);
+ } finally {
+ isApplyingMutationRef.current = false;
+ setIsTranslating(false);
+ }
+ };
+
+ // Observe newly inserted host DOM nodes while translation session is active
+ useEffect(() => {
+ if (
+ !session?.active ||
+ consent.status !== "granted" ||
+ typeof MutationObserver === "undefined"
+ ) {
+ return;
+ }
+
+ let pendingTimer: number | null = null;
+ const pendingRoots = new Set();
+
+ const flushPending = async () => {
+ const roots = Array.from(pendingRoots).filter(
+ (el) =>
+ el.isConnected &&
+ !el.closest("[data-arap-ui], [data-arap-diagnostics], .arap-root"),
+ );
+ pendingRoots.clear();
+ if (roots.length === 0 || !sessionRef.current?.active) return;
+
+ isApplyingMutationRef.current = true;
+ try {
+ for (const rootEl of roots) {
+ const addedSession = await translateHostContent({
+ rootElement: rootEl,
+ provider,
+ targetLanguage: targetLang,
+ consentRecord: consent,
+ });
+ if (addedSession.active) {
+ extraRestoresRef.current.push(addedSession.restore);
+ }
+ }
+ } catch {
+ // Ignore transient dynamic DOM translation errors
+ } finally {
+ isApplyingMutationRef.current = false;
+ }
+ };
+
+ const observer = new MutationObserver((mutations) => {
+ if (isApplyingMutationRef.current) return;
+ let queued = false;
+ for (const m of mutations) {
+ if (m.type !== "childList") continue;
+ m.addedNodes.forEach((node) => {
+ const el =
+ node.nodeType === Node.ELEMENT_NODE
+ ? (node as Element)
+ : node.parentElement;
+ if (
+ el &&
+ !el.closest("[data-arap-ui], [data-arap-diagnostics], .arap-root")
+ ) {
+ pendingRoots.add(el);
+ queued = true;
+ }
+ });
+ }
+ if (queued) {
+ if (pendingTimer !== null) window.clearTimeout(pendingTimer);
+ pendingTimer = window.setTimeout(() => {
+ void flushPending();
+ }, 60);
+ }
+ });
+
+ observer.observe(document.body, { childList: true, subtree: true });
+ return () => {
+ if (pendingTimer !== null) window.clearTimeout(pendingTimer);
+ observer.disconnect();
+ };
+ }, [session?.active, consent, provider, targetLang]);
+
const handleGrantConsent = () => {
setConsent({
status: "granted",
@@ -106,10 +229,8 @@ export const TranslationController: React.FC = ({
};
const handleRevokeConsent = () => {
- if (session?.active) {
- session.restore();
- setSession(null);
- }
+ restoreAllActive();
+ setSession(null);
setConsent({
status: "revoked",
userAcknowledgedRisks: false,
@@ -124,39 +245,19 @@ export const TranslationController: React.FC = ({
return;
}
- setErrorMessage(null);
- setIsTranslating(true);
- setLiveStatus(`Extracting and translating page text to ${targetLang}...`);
-
- try {
- // Revert previous session if active
- if (session?.active) {
- session.restore();
- }
-
- const newSession = await translateHostContent({
- provider,
- targetLanguage: targetLang,
- consentRecord: consent,
- });
+ await runTranslation(targetLang, consent);
+ };
- setSession(newSession);
- setIsTranslationEnabled(true);
- setLiveStatus(
- `Successfully translated ${newSession.translatedCount} elements to ${targetLang}.`,
- );
- } catch (err: unknown) {
- const msg = err instanceof Error ? err.message : String(err);
- setErrorMessage(msg);
- setLiveStatus(`Translation failed: ${msg}`);
- } finally {
- setIsTranslating(false);
+ const handleLanguageChange = (nextLang: string) => {
+ setTargetLang(nextLang);
+ if (session?.active && consent.status === "granted") {
+ void runTranslation(nextLang, consent);
}
};
const handleRestoreClick = () => {
if (session?.active) {
- session.restore();
+ restoreAllActive();
setSession(null);
setIsTranslationEnabled(false);
setLiveStatus("Page content restored to original text.");
@@ -217,7 +318,7 @@ export const TranslationController: React.FC = ({
setShowConsentModal(true)}
aria-expanded={showConsentModal}
>
@@ -257,14 +358,14 @@ export const TranslationController: React.FC = ({
Grant Consent
Deny
@@ -285,9 +386,9 @@ export const TranslationController: React.FC = ({
setTargetLang(e.target.value)}
+ onChange={(e) => handleLanguageChange(e.target.value)}
disabled={isTranslating}
>
{DEFAULT_TARGET_LANGUAGES.map((lang) => (
@@ -301,7 +402,7 @@ export const TranslationController: React.FC = ({
@@ -309,7 +410,7 @@ export const TranslationController: React.FC = ({
@@ -320,7 +421,7 @@ export const TranslationController: React.FC = ({
Revoke Translation Consent
@@ -336,9 +437,9 @@ export const TranslationController: React.FC = ({
)}
- {/* Screen-reader Live Status */}
+ {/* Visible & Screen-reader Live Status */}
setShowCommands((prev) => !prev)}
aria-expanded={showCommands}
>
@@ -230,7 +230,7 @@ export function VoiceNavigationController({
Retry Permission
@@ -280,7 +280,7 @@ export function VoiceNavigationController({
>
handleManualAction("next_heading")}
title="Jump to the next heading on the page"
>
@@ -288,7 +288,7 @@ export function VoiceNavigationController({
handleManualAction("previous_heading")}
title="Jump to the previous heading on the page"
>
@@ -296,7 +296,7 @@ export function VoiceNavigationController({
handleManualAction("scroll_down")}
title="Scroll down 75% of viewport"
>
@@ -304,7 +304,7 @@ export function VoiceNavigationController({
handleManualAction("scroll_up")}
title="Scroll up 75% of viewport"
>
@@ -312,7 +312,7 @@ export function VoiceNavigationController({
handleManualAction("scroll_top")}
title="Scroll to top of page"
>
@@ -320,7 +320,7 @@ export function VoiceNavigationController({
handleManualAction("scroll_bottom")}
title="Scroll to bottom of page"
>
diff --git a/src/index.ts b/src/index.ts
index 3138d6d..d96d950 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -300,6 +300,8 @@ export {
EmptyState,
ErrorState,
ProfilePreviewCard,
+ ModalDialog,
+ FeatureGroup,
} from "./core/controls";
export type {
ToggleControlProps,
@@ -313,6 +315,8 @@ export type {
EmptyStateProps,
ErrorStateProps,
ProfilePreviewCardProps,
+ ModalDialogProps,
+ FeatureGroupProps,
} from "./core/controls";
// Menu Customization & Reordering (A11Y-404)
diff --git a/src/styles/fonts/Manrope-VariableFont_wght.ttf b/src/styles/fonts/Manrope-VariableFont_wght.ttf
new file mode 100644
index 0000000..1ae1283
Binary files /dev/null and b/src/styles/fonts/Manrope-VariableFont_wght.ttf differ
diff --git a/src/styles/fonts/OFL.txt b/src/styles/fonts/OFL.txt
new file mode 100644
index 0000000..9082cba
--- /dev/null
+++ b/src/styles/fonts/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2018 The Manrope Project Authors (https://github.com/googlefonts/manrope)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+https://openfontlicense.org
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/src/styles/tailwind.css b/src/styles/tailwind.css
index 7d49d98..9629d15 100644
--- a/src/styles/tailwind.css
+++ b/src/styles/tailwind.css
@@ -1,31 +1,66 @@
/* Historical filename retained: scoped plain CSS, no Tailwind runtime or reset. */
+@font-face {
+ font-family: "Manrope";
+ src: url("./fonts/Manrope-VariableFont_wght.ttf") format("truetype");
+ font-weight: 200 800;
+ font-style: normal;
+ font-display: swap;
+}
.arap-root {
- --arap-surface: #fff;
- --arap-text: #111827;
+ --arap-surface: #ffffff;
+ --arap-text: #0f172a;
--arap-muted: #475569;
--arap-border: #cbd5e1;
--arap-divider: #e2e8f0;
--arap-accent: #1d4ed8;
--arap-accent-hover: #1e40af;
+ --arap-primary: #1d4ed8;
--arap-selected: #eff6ff;
--arap-control: #f8fafc;
+ --arap-bg: #ffffff;
+ --arap-card-bg: #f8fafc;
+ --arap-success: #15803d;
+ --arap-error: #b91c1c;
+ --arap-focus: #1d4ed8;
+ --arap-font-default:
+ "Manrope", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
+ "Noto Sans Sinhala", "Iskoola Pota", "Noto Sans Tamil", "Latha",
+ "Nirmala UI", sans-serif;
+ --arap-font-legible:
+ "Atkinson Hyperlegible", "Segoe UI", "Helvetica Neue", Arial, system-ui,
+ -apple-system, "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif;
+ --arap-font-dyslexia:
+ "OpenDyslexic", "Comic Sans MS", "Trebuchet MS", Verdana,
+ "Noto Sans Sinhala", "Noto Sans Tamil", sans-serif;
+ --arap-font-family: var(--arap-font-default);
color-scheme: light;
- font:
- 15px/1.5 system-ui,
- -apple-system,
- BlinkMacSystemFont,
- "Segoe UI",
- Roboto,
- "Noto Sans Sinhala",
- "Iskoola Pota",
- "Noto Sans Tamil",
- "Latha",
- "Nirmala UI",
- sans-serif;
+ font-family: var(--arap-font-family);
+ font-size: 15px;
+ line-height: 1.5;
color: var(--arap-text);
text-align: start;
letter-spacing: normal;
}
+.arap-root[data-arap-font="legible"] {
+ --arap-font-family: var(--arap-font-legible);
+}
+.arap-root[data-arap-font="dyslexia-option"],
+.arap-root[data-arap-font="dyslexia"] {
+ --arap-font-family: var(--arap-font-dyslexia);
+}
+.arap-root input,
+.arap-root select,
+.arap-root textarea,
+.arap-root output {
+ font-family: inherit;
+}
+.arap-root input[type="search"]::-webkit-search-decoration,
+.arap-root input[type="search"]::-webkit-search-cancel-button,
+.arap-root input[type="search"]::-webkit-search-results-button,
+.arap-root input[type="search"]::-webkit-search-results-decoration {
+ -webkit-appearance: none;
+ appearance: none;
+}
.arap-root *,
.arap-root *::before,
.arap-root *::after {
@@ -85,7 +120,13 @@
z-index: 2147483000;
bottom: max(88px, calc(env(safe-area-inset-bottom) + 72px));
right: max(16px, env(safe-area-inset-right));
- width: min(400px, calc(100vw - 32px));
+ width: min(
+ 460px,
+ calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right))
+ );
+ max-width: calc(
+ 100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)
+ );
max-height: calc(100vh - 120px);
max-height: calc(100dvh - 120px - env(safe-area-inset-bottom));
overflow: auto;
@@ -124,9 +165,10 @@
}
.arap-heading h2 {
margin: 0;
- font:
- 700 22px/1.3 system-ui,
- sans-serif;
+ font-family: var(--arap-font-family);
+ font-weight: 700;
+ font-size: 22px;
+ line-height: 1.3;
letter-spacing: -0.025em;
color: var(--arap-text);
overflow-wrap: anywhere;
@@ -134,26 +176,38 @@
.arap-description {
margin: 6px 0 0;
color: var(--arap-muted);
- font:
- 14px/1.5 system-ui,
- sans-serif;
+ font-family: var(--arap-font-family);
+ font-size: 14px;
+ line-height: 1.5;
overflow-wrap: anywhere;
}
-.arap-heading button {
+.arap-heading button,
+.arap-root .arap-close-btn {
flex: none;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
width: 44px;
height: 44px;
- margin-top: -6px;
- border: 1px solid transparent;
- border-radius: 8px;
- background: transparent;
- color: var(--arap-muted);
- font-size: 28px;
+ min-width: 44px;
+ min-height: 44px;
+ padding: 0;
+ border: 1px solid var(--arap-divider);
+ border-radius: 10px;
+ background: var(--arap-control);
+ color: var(--arap-text);
+ font-size: 24px;
+ font-weight: 500;
line-height: 1;
}
-.arap-heading button:hover {
- background: var(--arap-control);
- border-color: var(--arap-border);
+.arap-heading button {
+ margin-top: -4px;
+}
+.arap-heading button:hover,
+.arap-root .arap-close-btn:hover {
+ background: var(--arap-selected);
+ border-color: var(--arap-accent);
+ color: var(--arap-accent);
}
.arap-feature {
display: grid;
@@ -191,15 +245,41 @@
background: var(--arap-control);
}
.arap-root .arap-btn-sm {
+ flex: none;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ min-width: 44px;
+ min-height: 44px;
+ padding: 8px 14px;
+ border: 1px solid var(--arap-border);
+ border-radius: 10px;
+ background: var(--arap-surface);
+ color: var(--arap-text);
+ font-family: var(--arap-font-family);
+ font-size: 13px;
+ font-weight: 600;
+ line-height: 1.25;
+}
+.arap-root .arap-btn-sm:hover:not(:disabled) {
+ background: var(--arap-selected);
+ border-color: var(--arap-accent);
+ color: var(--arap-accent);
+}
+.arap-root .arap-controls .arap-btn-sm {
flex: none;
width: 44px;
height: 44px;
+ padding: 0;
border: 0;
border-radius: 0;
background: transparent;
+ color: inherit;
font-size: 22px;
+ font-weight: 400;
}
-.arap-root .arap-btn-sm:hover:not(:disabled) {
+.arap-root .arap-controls .arap-btn-sm:hover:not(:disabled) {
background: var(--arap-selected);
color: var(--arap-accent);
}
@@ -318,16 +398,20 @@
gap: 10px;
width: 100%;
min-height: 48px;
- padding: 10px;
- border: 1px solid var(--arap-border);
+ padding: 10px 16px;
+ border: 1px solid var(--arap-accent);
border-radius: 10px;
- background: var(--arap-control);
- color: var(--arap-accent);
+ background: var(--arap-accent);
+ color: #ffffff;
font-weight: 600;
}
+.arap-root .arap-reset-btn .arap-icon {
+ color: #ffffff;
+ stroke: currentColor;
+}
.arap-root .arap-reset-btn:hover {
- background: var(--arap-selected);
- border-color: var(--arap-accent);
+ background: var(--arap-accent-hover);
+ border-color: var(--arap-accent-hover);
}
@media (max-width: 380px) {
.arap-root .arap-panel {
@@ -583,7 +667,7 @@
font-size: 0.9375rem;
font-weight: 600;
text-decoration: none;
- color: var(--arap-accent, #008060);
+ color: var(--arap-accent, #1d4ed8);
background: var(--arap-surface, #ffffff);
border-radius: 8px;
box-shadow:
@@ -601,8 +685,8 @@
overflow: visible;
white-space: normal;
pointer-events: auto;
- border: 2px solid var(--arap-accent, #008060);
- outline: 3px solid var(--arap-accent, #008060);
+ border: 2px solid var(--arap-accent, #1d4ed8);
+ outline: 3px solid var(--arap-accent, #1d4ed8);
outline-offset: 3px;
display: inline-flex;
align-items: center;
@@ -723,7 +807,7 @@
min-height: 48px;
font-size: 32px;
}
-.arap-root .arap-panel[data-large-controls="true"] .arap-btn-sm {
+.arap-root .arap-panel[data-large-controls="true"] .arap-controls .arap-btn-sm {
width: 48px;
height: 48px;
min-width: 48px;
@@ -1108,27 +1192,55 @@
position: fixed !important;
left: 0 !important;
right: 0 !important;
+ width: 100vw !important;
+ max-width: none !important;
+ min-width: 0 !important;
+ min-height: 0 !important;
+ margin: 0 !important;
+ padding: 0 !important;
+ transform: none !important;
+ filter: none !important;
+ opacity: 1 !important;
+ transition: none !important;
+ animation: none !important;
+ box-sizing: border-box !important;
pointer-events: none !important;
user-select: none !important;
-webkit-user-select: none !important;
touch-action: none !important;
- z-index: 2147482999 !important;
+ z-index: 2147482000 !important;
}
.arap-reading-guide {
position: fixed !important;
left: 0 !important;
right: 0 !important;
+ width: 100vw !important;
+ max-width: none !important;
+ min-width: 0 !important;
+ min-height: 0 !important;
+ margin: 0 !important;
+ padding: 0 !important;
+ transform: none !important;
+ filter: none !important;
+ opacity: 1 !important;
+ transition: none !important;
+ animation: none !important;
+ box-sizing: border-box !important;
pointer-events: none !important;
user-select: none !important;
-webkit-user-select: none !important;
touch-action: none !important;
- z-index: 2147482999 !important;
+ z-index: 2147482000 !important;
}
.arap-feature-expandable {
+ display: flex !important;
+ grid-template-columns: none !important;
flex-direction: column !important;
align-items: stretch !important;
+ gap: 10px !important;
+ min-width: 0;
}
/* Accessible Tooltips (A11Y-302) */
@@ -1141,9 +1253,13 @@
padding: 6px 12px !important;
background: #0f172a !important;
color: #ffffff !important;
- font-family:
- -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
- Arial, sans-serif !important;
+ font-family: var(
+ --arap-font-family,
+ "Manrope",
+ system-ui,
+ -apple-system,
+ sans-serif
+ ) !important;
font-size: 13px !important;
line-height: 1.4 !important;
font-weight: 500 !important;
@@ -1229,8 +1345,8 @@
}
.arap-navigator-tab-active {
- color: var(--arap-accent, #008060) !important;
- background: var(--arap-selected, #f0fdf4) !important;
+ color: var(--arap-accent, #1d4ed8) !important;
+ background: var(--arap-selected, #eff6ff) !important;
}
.arap-navigator-search-box {
@@ -1249,7 +1365,7 @@
}
.arap-navigator-search:focus {
- outline: 2px solid var(--arap-accent, #008060);
+ outline: 2px solid var(--arap-accent, #1d4ed8);
outline-offset: 1px;
}
@@ -1295,9 +1411,9 @@
.arap-navigator-jump-btn:hover,
.arap-navigator-jump-btn:focus-visible {
- background: var(--arap-selected, #f0fdf4);
- border-color: var(--arap-accent, #008060);
- outline: 2px solid var(--arap-accent, #008060);
+ background: var(--arap-selected, #eff6ff);
+ border-color: var(--arap-accent, #1d4ed8);
+ outline: 2px solid var(--arap-accent, #1d4ed8);
outline-offset: -1px;
}
@@ -1345,9 +1461,12 @@
}
.arap-navigator-item-text {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
+ flex: 1 1 auto;
+ min-width: 0;
+ white-space: normal;
+ overflow-wrap: anywhere;
+ text-align: start;
+ line-height: 1.45;
}
.arap-navigator-empty {
@@ -1553,16 +1672,24 @@
.arap-search-clear {
position: absolute;
- inset-inline-end: 8px;
+ inset-inline-end: 4px;
top: 50%;
transform: translateY(-50%);
- border: none;
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 36px;
+ height: 36px;
+ min-width: 36px;
+ min-height: 36px;
+ border: 1px solid transparent;
background: transparent;
cursor: pointer;
- padding: 2px 6px;
- font-size: 14px;
- color: var(--arap-muted, #64748b);
- border-radius: 4px;
+ padding: 0;
+ font-size: 16px;
+ line-height: 1;
+ color: var(--arap-muted, #475569);
+ border-radius: 6px;
}
.arap-search-clear:hover {
@@ -1608,15 +1735,7 @@
flex-direction: column;
outline: none;
box-sizing: border-box;
- font-family:
- system-ui,
- -apple-system,
- BlinkMacSystemFont,
- "Segoe UI",
- Roboto,
- "Noto Sans Sinhala",
- "Noto Sans Tamil",
- sans-serif;
+ font-family: var(--arap-font-family, "Manrope", system-ui, sans-serif);
transition:
background-color 0.2s ease,
color 0.2s ease;
@@ -2003,9 +2122,9 @@
}
.arap-category-pill-active {
- background: var(--arap-selected, #f0fdf4);
- color: var(--arap-accent, #008060);
- border-color: var(--arap-accent, #008060);
+ background: var(--arap-selected, #eff6ff);
+ color: var(--arap-accent, #1d4ed8);
+ border-color: var(--arap-accent, #1d4ed8);
font-weight: 600;
}
@@ -2052,7 +2171,7 @@
font-family: ui-monospace, monospace;
background: #ffffff;
color: #0f172a;
- border: 2px solid var(--arap-accent, #008060);
+ border: 2px solid var(--arap-accent, #1d4ed8);
border-radius: 6px;
outline: none;
}
@@ -2156,7 +2275,7 @@
.arap-btn-link {
background: transparent;
border: none;
- color: var(--arap-accent, #008060);
+ color: var(--arap-accent, #1d4ed8);
cursor: pointer;
font-size: 0.8125rem;
text-decoration: underline;
@@ -2220,8 +2339,8 @@
display: inline-flex;
align-items: center;
gap: 6px;
- background: rgba(0, 128, 96, 0.12);
- color: var(--arap-accent, #008060);
+ background: var(--arap-selected, #eff6ff);
+ color: var(--arap-accent, #1d4ed8);
padding: 3px 10px;
border-radius: 9999px;
font-size: 0.75rem;
@@ -2234,11 +2353,12 @@
height: 8px;
border-radius: 50%;
background: currentColor;
- box-shadow: 0 0 0 2px rgba(0, 128, 96, 0.25);
+ box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.25);
}
.arap-read-aloud-controls {
display: flex;
+ flex-wrap: wrap;
gap: 8px;
margin-bottom: 12px;
}
@@ -2246,12 +2366,12 @@
.arap-read-aloud-play-btn,
.arap-read-aloud-pause-btn,
.arap-read-aloud-resume-btn {
- flex: 1;
+ flex: 1 1 140px;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
- background: var(--arap-accent, #008060);
+ background: var(--arap-accent, #1d4ed8);
color: #ffffff;
border: none;
border-radius: 6px;
@@ -2330,7 +2450,7 @@
.arap-read-aloud-pill-active {
background: var(--arap-surface, #ffffff);
- color: var(--arap-accent, #008060);
+ color: var(--arap-accent, #1d4ed8);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
@@ -2354,10 +2474,10 @@
/* Floating Mini-Player Bar */
.arap-read-aloud-bar {
position: fixed;
- bottom: 24px;
+ bottom: max(16px, env(safe-area-inset-bottom));
left: 50%;
transform: translateX(-50%);
- z-index: 2147483645;
+ z-index: 2147483050;
background: var(--arap-surface, #ffffff);
color: var(--arap-text, #0f172a);
border: 1px solid var(--arap-border, #cbd5e1);
@@ -2366,7 +2486,7 @@
0 10px 25px -5px rgba(0, 0, 0, 0.2),
0 8px 10px -6px rgba(0, 0, 0, 0.1);
padding: 8px 14px;
- max-width: 90vw;
+ max-width: calc(100vw - 32px);
width: 440px;
animation: arapFadeSlideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@@ -2378,7 +2498,7 @@
}
.arap-read-aloud-bar-icon {
- color: var(--arap-accent, #008060);
+ color: var(--arap-accent, #1d4ed8);
display: flex;
align-items: center;
}
@@ -2415,9 +2535,12 @@
background: var(--arap-control, #f1f5f9);
color: var(--arap-text, #0f172a);
border: 1px solid var(--arap-border, #cbd5e1);
- border-radius: 6px;
- width: 36px;
- height: 36px;
+ border-radius: 8px;
+ width: 44px;
+ height: 44px;
+ min-width: 44px;
+ min-height: 44px;
+ font-family: var(--arap-font-family);
display: flex;
align-items: center;
justify-content: center;
@@ -2430,8 +2553,13 @@
background: var(--arap-border, #e2e8f0);
}
+.arap-read-aloud-bar-btn:focus-visible {
+ outline: 3px solid var(--arap-accent, #1d4ed8);
+ outline-offset: 2px;
+}
+
.arap-read-aloud-bar-btn.astop:hover {
- color: #ef4444;
+ color: #b91c1c;
}
@keyframes arapFadeSlideUp {
@@ -2454,7 +2582,7 @@
inset: 0;
background-color: rgba(15, 23, 42, 0.45);
backdrop-filter: blur(2px);
- z-index: 100000;
+ z-index: 2147483100;
display: flex;
align-items: center;
justify-content: center;
@@ -3273,6 +3401,8 @@
display: flex;
flex-direction: column;
gap: 8px;
+ min-width: 0;
+ max-width: 100%;
}
.arap-voice-toggle-row {
@@ -3413,7 +3543,7 @@
.arap-action-grid {
display: grid;
- grid-template-columns: repeat(2, 1fr);
+ grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr));
gap: 6px;
}
@@ -3603,3 +3733,1064 @@
border: 1px solid CanvasText;
}
}
+
+/* ==========================================================================
+ Unified Clean Light Buttons, Inputs, Cards, Modals & Desktop Resizing
+ ========================================================================== */
+
+.arap-root .arap-panel,
+.arap-root .arap-tools {
+ overflow-x: clip;
+}
+
+.arap-root .arap-feature-row-between {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ width: 100%;
+ min-width: 0;
+}
+
+.arap-root .arap-nav-actions {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ flex-shrink: 0;
+}
+
+.arap-root .arap-label-title {
+ display: block;
+ font-size: 15px;
+ font-weight: 600;
+ color: var(--arap-text);
+ line-height: 1.35;
+}
+
+.arap-root .arap-label-sub {
+ display: block;
+ font-size: 12px;
+ font-weight: 400;
+ color: var(--arap-muted);
+ margin-top: 2px;
+ line-height: 1.45;
+}
+
+.arap-root .arap-profile-inline-active {
+ color: var(--arap-accent);
+ font-weight: 600;
+}
+
+.arap-root .arap-btn-primary,
+.arap-root .arap-btn-action,
+.arap-root .arap-button.arap-voice-toggle-btn {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 8px;
+ min-height: 44px;
+ min-width: 44px;
+ padding: 10px 16px;
+ border: 1px solid var(--arap-accent);
+ border-radius: 10px;
+ background: var(--arap-accent);
+ color: #ffffff;
+ font-family: var(--arap-font-family);
+ font-size: 14px;
+ font-weight: 600;
+ line-height: 1.25;
+ text-decoration: none;
+ cursor: pointer;
+}
+
+.arap-root .arap-btn-primary .arap-icon,
+.arap-root .arap-btn-action .arap-icon,
+.arap-root .arap-button.arap-voice-toggle-btn .arap-icon {
+ color: #ffffff;
+ stroke: currentColor;
+}
+
+.arap-root .arap-btn-primary:hover:not(:disabled),
+.arap-root .arap-btn-action:hover:not(:disabled),
+.arap-root .arap-button.arap-voice-toggle-btn:hover:not(:disabled) {
+ background: var(--arap-accent-hover);
+ border-color: var(--arap-accent-hover);
+ color: #ffffff;
+}
+
+.arap-root .arap-btn-secondary,
+.arap-root .arap-action-btn:not(.arap-btn-primary),
+.arap-root .arap-button:not(.arap-btn-primary) {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ min-height: 44px;
+ min-width: 44px;
+ padding: 8px 14px;
+ border: 1px solid var(--arap-border);
+ border-radius: 10px;
+ background: var(--arap-surface);
+ color: var(--arap-text);
+ font-family: var(--arap-font-family);
+ font-size: 13px;
+ font-weight: 600;
+ line-height: 1.25;
+ cursor: pointer;
+}
+
+.arap-root .arap-btn-secondary:hover:not(:disabled),
+.arap-root .arap-action-btn:not(.arap-btn-primary):hover:not(:disabled),
+.arap-root .arap-button:not(.arap-btn-primary):hover:not(:disabled) {
+ background: var(--arap-selected);
+ border-color: var(--arap-accent);
+ color: var(--arap-accent);
+}
+
+.arap-root .arap-btn-danger {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ min-height: 44px;
+ min-width: 44px;
+ padding: 8px 14px;
+ border: 1px solid #fecaca;
+ border-radius: 10px;
+ background: #fef2f2;
+ color: #b91c1c;
+ font-family: var(--arap-font-family);
+ font-size: 13px;
+ font-weight: 600;
+ line-height: 1.25;
+ cursor: pointer;
+}
+
+.arap-root .arap-btn-danger:hover:not(:disabled) {
+ background: #fee2e2;
+ border-color: #dc2626;
+ color: #991b1b;
+}
+
+.arap-root .arap-btn-compact {
+ min-height: 44px;
+ min-width: 44px;
+ width: auto;
+ height: auto;
+ padding: 8px 14px;
+ font-size: 13px;
+ font-weight: 600;
+ white-space: nowrap;
+ flex: none;
+}
+
+.arap-root .arap-btn-ghost,
+.arap-root .arap-unsupported-toggle {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ width: 100%;
+ min-height: 44px;
+ padding: 8px 12px;
+ border: 1px dashed var(--arap-border);
+ border-radius: 10px;
+ background: transparent;
+ color: var(--arap-accent);
+ font-family: var(--arap-font-family);
+ font-size: 13px;
+ font-weight: 600;
+ text-decoration: none;
+ cursor: pointer;
+}
+
+.arap-root .arap-btn-ghost:hover:not(:disabled),
+.arap-root .arap-unsupported-toggle:hover:not(:disabled) {
+ background: var(--arap-selected);
+ border-style: solid;
+ border-color: var(--arap-accent);
+}
+
+.arap-root .arap-feature-btn {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ width: 100%;
+ min-height: 52px;
+ padding: 10px 14px;
+ border: 1.5px solid var(--arap-border);
+ border-radius: 12px;
+ background: var(--arap-control);
+ color: var(--arap-text);
+ font-family: var(--arap-font-family);
+ text-align: start;
+}
+
+.arap-root .arap-feature-btn:hover:not(:disabled) {
+ background: var(--arap-selected);
+ border-color: var(--arap-accent);
+}
+
+.arap-root .arap-feature-btn-icon {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 36px;
+ height: 36px;
+ flex: none;
+ border-radius: 10px;
+ background: var(--arap-selected);
+ color: var(--arap-accent);
+}
+
+.arap-root .arap-feature-btn-content {
+ flex: 1 1 auto;
+ min-width: 0;
+}
+
+.arap-root .arap-feature-btn-label {
+ display: block;
+ font-size: 15px;
+ font-weight: 600;
+ color: var(--arap-text);
+ line-height: 1.35;
+}
+
+.arap-root .arap-feature-btn-desc {
+ display: block;
+ font-size: 12px;
+ color: var(--arap-muted);
+ line-height: 1.45;
+ margin-top: 2px;
+}
+
+.arap-root .arap-feature-item {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ padding: 16px 0;
+ border-bottom: 1px solid var(--arap-divider);
+ min-width: 0;
+}
+
+.arap-root .arap-feature-item:last-child {
+ border-bottom: 0;
+ padding-bottom: 0;
+}
+
+.arap-root .arap-feature-item > .arap-feature-header {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ min-width: 0;
+}
+
+.arap-root .arap-feature-title-row {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 8px;
+}
+
+.arap-root .arap-feature-name {
+ font-size: 15px;
+ font-weight: 600;
+ color: var(--arap-text);
+}
+
+.arap-root .arap-feature-desc {
+ margin: 0;
+ font-size: 12px;
+ color: var(--arap-muted);
+ line-height: 1.45;
+}
+
+.arap-root .arap-prototype-notice {
+ margin: 0;
+ padding: 10px 12px;
+ border-radius: 10px;
+ border: 1px solid #bfdbfe;
+ background: #eff6ff;
+ color: #1e3a8a;
+ font-size: 12px;
+ line-height: 1.45;
+}
+
+.arap-root .arap-translation-status-banner {
+ padding: 9px 12px;
+ border-radius: 10px;
+ border: 1px solid var(--arap-divider);
+ background: var(--arap-control);
+ color: var(--arap-muted);
+ font-size: 12px;
+ font-weight: 500;
+ line-height: 1.45;
+}
+
+.arap-root .arap-translation-status-banner.arap-is-active {
+ background: #f0fdf4;
+ border-color: #bbf7d0;
+ color: #166534;
+ font-weight: 600;
+}
+
+.arap-root .arap-input,
+.arap-root .arap-select,
+.arap-root .arap-search-input,
+.arap-root .arap-dict-input,
+.arap-root .arap-translation-select,
+.arap-root .arap-read-aloud-select {
+ width: 100%;
+ max-width: 100%;
+ min-height: 44px;
+ padding: 10px 14px;
+ border: 1.5px solid var(--arap-border);
+ border-radius: 10px;
+ background: var(--arap-surface);
+ color: var(--arap-text);
+ font-family: var(--arap-font-family);
+ font-size: 14px;
+ line-height: 1.4;
+}
+
+.arap-root .arap-navigator-search,
+.arap-root .arap-navigator-search-box,
+.arap-root .arap-shortcuts-search,
+.arap-root .arap-dict-search-wrapper {
+ position: relative;
+ display: flex;
+ align-items: center;
+ width: 100%;
+ min-width: 0;
+}
+
+.arap-root .arap-navigator-search > .arap-search-input,
+.arap-root .arap-navigator-search-box > .arap-search-input,
+.arap-root .arap-shortcuts-search > .arap-search-input,
+.arap-root .arap-dict-search-wrapper > .arap-dict-input {
+ padding-inline-end: 48px;
+}
+
+.arap-root .arap-navigator-search-box > input.arap-navigator-search {
+ padding-inline-end: 48px;
+}
+
+.arap-root .arap-search-clear {
+ width: 44px;
+ height: 44px;
+ min-width: 44px;
+ min-height: 44px;
+ inset-inline-end: 2px;
+}
+
+.arap-root .arap-input:focus-visible,
+.arap-root .arap-select:focus-visible,
+.arap-root .arap-search-input:focus-visible,
+.arap-root .arap-dict-input:focus-visible,
+.arap-root .arap-translation-select:focus-visible,
+.arap-root .arap-read-aloud-select:focus-visible {
+ outline: 3px solid var(--arap-accent);
+ outline-offset: 2px;
+ border-color: var(--arap-accent);
+}
+
+/* Feature Groups & Collapsible Accordions (#197) */
+.arap-root .arap-feature-group {
+ margin: 14px 0;
+ padding: 12px 14px;
+ border: 1px solid var(--arap-divider);
+ border-radius: 14px;
+ background: var(--arap-surface);
+ min-width: 0;
+}
+
+.arap-root .arap-feature-group:first-child {
+ margin-top: 8px;
+}
+
+.arap-root .arap-group-header {
+ margin: 0;
+}
+
+.arap-root .arap-group-header-static {
+ padding-bottom: 8px;
+ border-bottom: 1px solid var(--arap-divider);
+ margin-bottom: 4px;
+}
+
+.arap-root .arap-group-toggle {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ width: 100%;
+ min-height: 44px;
+ padding: 4px 2px;
+ border: 0;
+ border-radius: 8px;
+ background: transparent;
+ color: var(--arap-text);
+ text-align: start;
+}
+
+.arap-root .arap-group-toggle:hover {
+ background: var(--arap-control);
+}
+
+.arap-root .arap-group-heading-block {
+ flex: 1 1 auto;
+ min-width: 0;
+}
+
+.arap-root .arap-group-title-row {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 8px;
+}
+
+.arap-root .arap-group-title {
+ margin: 0;
+ font-family: var(--arap-font-family);
+ font-size: 14px;
+ font-weight: 700;
+ color: var(--arap-text);
+ letter-spacing: -0.01em;
+}
+
+.arap-root .arap-group-badge {
+ display: inline-flex;
+ align-items: center;
+ padding: 2px 8px;
+ border-radius: 999px;
+ font-size: 11px;
+ font-weight: 600;
+ background: var(--arap-selected);
+ color: var(--arap-accent);
+ border: 1px solid #bfdbfe;
+}
+
+.arap-root .arap-group-desc {
+ display: block;
+ margin: 2px 0 0;
+ font-size: 12px;
+ font-weight: 400;
+ color: var(--arap-muted);
+ line-height: 1.4;
+}
+
+.arap-root .arap-group-chevron {
+ width: 18px;
+ height: 18px;
+ flex: none;
+ color: var(--arap-muted);
+ transition: transform 0.15s ease;
+}
+
+.arap-root .arap-group-chevron.arap-is-open {
+ transform: rotate(180deg);
+}
+
+.arap-root .arap-group-body {
+ padding-top: 4px;
+}
+
+.arap-root .arap-group-body[hidden] {
+ display: none !important;
+}
+
+/* Shared Spacious Modal Dialog (#183, #185, #195, #197) */
+.arap-root .arap-modal-overlay {
+ position: fixed;
+ inset: 0;
+ z-index: 2147483100;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: max(16px, env(safe-area-inset-top))
+ max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom))
+ max(16px, env(safe-area-inset-left));
+ background: rgba(15, 23, 42, 0.48);
+ backdrop-filter: blur(3px);
+ overscroll-behavior: contain;
+}
+
+.arap-root .arap-modal {
+ width: 100%;
+ max-height: calc(100dvh - 32px);
+ display: flex;
+ flex-direction: column;
+ border: 1px solid var(--arap-divider);
+ border-radius: 18px;
+ background: var(--arap-surface);
+ color: var(--arap-text);
+ font-family: var(--arap-font-family);
+ box-shadow:
+ 0 20px 25px -5px rgba(15, 23, 42, 0.16),
+ 0 8px 10px -6px rgba(15, 23, 42, 0.08);
+ overflow: hidden;
+ outline: none;
+}
+
+.arap-root .arap-modal-md {
+ max-width: 560px;
+}
+
+.arap-root .arap-modal-lg {
+ max-width: 780px;
+}
+
+.arap-root .arap-modal-full {
+ width: min(960px, 100%);
+ height: min(760px, calc(100dvh - 32px));
+}
+
+.arap-root .arap-modal-header {
+ flex: none;
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 14px;
+ padding: 18px 22px;
+ border-bottom: 1px solid var(--arap-divider);
+ background: var(--arap-control);
+}
+
+.arap-root .arap-modal-title-group {
+ display: flex;
+ align-items: flex-start;
+ gap: 12px;
+ min-width: 0;
+ flex: 1 1 auto;
+}
+
+.arap-root .arap-modal-header-icon {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ width: 40px;
+ height: 40px;
+ flex: none;
+ border-radius: 10px;
+ background: var(--arap-selected);
+ color: var(--arap-accent);
+}
+
+.arap-root .arap-modal-heading-text {
+ min-width: 0;
+}
+
+.arap-root .arap-modal-title {
+ margin: 0;
+ font-family: var(--arap-font-family);
+ font-size: 20px;
+ font-weight: 700;
+ line-height: 1.3;
+ color: var(--arap-text);
+}
+
+.arap-root .arap-modal-subtitle {
+ margin: 2px 0 0;
+ font-size: 13px;
+ color: var(--arap-muted);
+ line-height: 1.45;
+}
+
+.arap-root .arap-modal-body {
+ flex: 1 1 auto;
+ min-height: 0;
+ overflow-y: auto;
+ overflow-x: hidden;
+ overscroll-behavior: contain;
+ padding: 20px 22px;
+}
+
+.arap-root .arap-modal-footer {
+ flex: none;
+ padding: 14px 22px;
+ border-top: 1px solid var(--arap-divider);
+ background: var(--arap-control);
+}
+
+/* Modal Interiors: Profiles, Presets, Navigator, Dictionary, Shortcuts */
+.arap-root .arap-profiles-panel,
+.arap-root .arap-presets-panel,
+.arap-root .arap-shortcuts-dialog-body,
+.arap-root .arap-dict-dialog-body {
+ display: flex;
+ flex-direction: column;
+ gap: 14px;
+ min-width: 0;
+}
+
+.arap-root .arap-profile-active-banner {
+ padding: 12px 14px;
+ border-radius: 12px;
+ background: var(--arap-selected);
+ border: 1px solid #bfdbfe;
+}
+
+.arap-root .arap-profile-active-banner-title {
+ display: block;
+ font-size: 14px;
+ font-weight: 700;
+ color: var(--arap-accent);
+}
+
+.arap-root .arap-profile-active-banner-sub {
+ display: block;
+ font-size: 12px;
+ color: var(--arap-muted);
+ margin-top: 2px;
+}
+
+.arap-root .arap-profiles-grid,
+.arap-root .arap-presets-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
+ gap: 12px;
+}
+
+.arap-root .arap-profile-apply-btn,
+.arap-root .arap-profile-revert-btn {
+ width: 100%;
+ margin-top: 8px;
+}
+
+.arap-root .arap-presets-save-row {
+ display: flex;
+ align-items: stretch;
+ gap: 8px;
+ flex-wrap: wrap;
+}
+
+.arap-root .arap-presets-save-row > .arap-input {
+ flex: 1 1 200px;
+}
+
+.arap-root .arap-presets-transfer-section {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
+ gap: 10px;
+}
+
+.arap-root .arap-field-label {
+ display: block;
+ font-size: 13px;
+ font-weight: 600;
+ margin-bottom: 6px;
+ color: var(--arap-text);
+}
+
+.arap-root .arap-preset-card {
+ padding: 14px;
+ border-radius: 12px;
+ border: 1px solid var(--arap-border);
+ background: var(--arap-surface);
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+}
+
+.arap-root .arap-preset-card-top {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 10px;
+ flex-wrap: wrap;
+}
+
+.arap-root .arap-preset-card-title {
+ display: block;
+ font-size: 14px;
+ font-weight: 700;
+ color: var(--arap-text);
+}
+
+.arap-root .arap-preset-card-date {
+ display: block;
+ font-size: 11px;
+ color: var(--arap-muted);
+}
+
+.arap-root .arap-preset-card-actions {
+ display: inline-flex;
+ gap: 8px;
+ flex-wrap: wrap;
+}
+
+.arap-root .arap-presets-status-success {
+ padding: 8px 12px;
+ border-radius: 8px;
+ background: #f0fdf4;
+ border: 1px solid #bbf7d0;
+ color: #166534;
+ font-size: 13px;
+ font-weight: 600;
+}
+
+.arap-root .arap-presets-status-error {
+ padding: 8px 12px;
+ border-radius: 8px;
+ background: #fef2f2;
+ border: 1px solid #fecaca;
+ color: #b91c1c;
+ font-size: 13px;
+ font-weight: 600;
+}
+
+.arap-root .arap-navigator-dialog {
+ margin: 0;
+ padding: 0;
+ border: 0;
+ background: transparent;
+ max-height: none;
+ display: flex;
+ flex-direction: column;
+ gap: 14px;
+}
+
+.arap-root .arap-navigator-tabs {
+ gap: 8px;
+ flex-wrap: wrap;
+}
+
+.arap-root .arap-navigator-tab {
+ min-height: 44px;
+ padding: 8px 14px;
+ font-size: 13px;
+}
+
+.arap-root .arap-navigator-content {
+ max-height: none;
+ overflow: visible;
+}
+
+.arap-root .arap-navigator-jump-btn {
+ min-height: 44px;
+ padding: 10px 14px;
+ font-size: 14px;
+ border-radius: 10px;
+}
+
+.arap-root .arap-navigator-jump-btn.arap-is-active {
+ background: var(--arap-selected);
+ border-color: var(--arap-accent);
+ box-shadow: 0 0 0 1px var(--arap-accent);
+}
+
+.arap-root .arap-navigator-status {
+ padding: 8px 12px;
+ border-radius: 8px;
+ background: var(--arap-selected);
+ border: 1px solid #bfdbfe;
+ color: var(--arap-accent);
+ font-size: 13px;
+ font-weight: 500;
+}
+
+.arap-root .arap-dict-starter-chips {
+ margin-top: 12px;
+}
+
+.arap-root .arap-dict-suggestion-chip {
+ min-height: 44px;
+ padding: 8px 14px;
+ border-radius: 999px;
+ border: 1px solid var(--arap-border);
+ background: var(--arap-control);
+ color: var(--arap-text);
+ font-size: 13px;
+ font-weight: 500;
+}
+
+.arap-root .arap-dict-suggestion-chip:hover {
+ background: var(--arap-selected);
+ border-color: var(--arap-accent);
+ color: var(--arap-accent);
+}
+
+.arap-root .arap-reading-mode-backdrop,
+.arap-root .arap-shortcuts-backdrop {
+ z-index: 2147483100;
+}
+
+.arap-root .arap-reading-mode-dialog {
+ font-family: var(--arap-font-family);
+}
+
+.arap-root .arap-shortcuts-toolbar {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 10px;
+ align-items: center;
+ justify-content: space-between;
+}
+
+.arap-root .arap-shortcuts-categories {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 6px;
+}
+
+.arap-root .arap-category-pill {
+ min-height: 44px;
+ padding: 8px 14px;
+ border-radius: 999px;
+ border: 1px solid var(--arap-border);
+ background: var(--arap-surface);
+ color: var(--arap-text);
+ font-size: 13px;
+ font-weight: 600;
+}
+
+.arap-root .arap-category-pill.arap-category-pill-active {
+ background: var(--arap-accent);
+ border-color: var(--arap-accent);
+ color: #ffffff;
+}
+
+.arap-root .arap-shortcuts-list-container {
+ max-height: none;
+ overflow: visible;
+}
+
+.arap-root .arap-shortcuts-footer {
+ display: flex;
+ justify-content: flex-end;
+ gap: 10px;
+ padding: 0;
+ border: 0;
+ background: transparent;
+}
+
+/* Desktop-only Panel Resize Handle (#186) */
+.arap-root
+ .arap-panel[data-resizable="true"][data-corner$="right"]
+ .arap-heading-copy {
+ padding-inline-start: 16px;
+}
+
+.arap-root .arap-resize-handle {
+ position: absolute;
+ width: 24px;
+ height: 24px;
+ border-radius: 6px;
+ z-index: 5;
+ touch-action: none;
+ background: transparent;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+
+.arap-root .arap-resize-handle[data-anchor-x="left"] {
+ left: 6px;
+}
+
+.arap-root .arap-resize-handle[data-anchor-x="right"] {
+ right: 6px;
+}
+
+.arap-root .arap-resize-handle[data-anchor-y="top"] {
+ top: 6px;
+}
+
+.arap-root .arap-resize-handle[data-anchor-y="bottom"] {
+ bottom: 6px;
+}
+
+.arap-root .arap-resize-handle[data-anchor-x="left"][data-anchor-y="top"],
+.arap-root .arap-resize-handle[data-anchor-x="right"][data-anchor-y="bottom"] {
+ cursor: nwse-resize;
+}
+
+.arap-root .arap-resize-handle[data-anchor-x="left"][data-anchor-y="bottom"],
+.arap-root .arap-resize-handle[data-anchor-x="right"][data-anchor-y="top"] {
+ cursor: nesw-resize;
+}
+
+.arap-root .arap-resize-handle::after {
+ content: "";
+ width: 10px;
+ height: 10px;
+ border-inline-start: 2px solid var(--arap-muted);
+ border-top: 2px solid var(--arap-muted);
+ border-radius: 2px 0 0 0;
+ opacity: 0.7;
+}
+
+.arap-root .arap-resize-handle[data-anchor-x="right"]::after {
+ border-inline-start: 0;
+ border-inline-end: 2px solid var(--arap-muted);
+}
+
+.arap-root .arap-resize-handle[data-anchor-y="bottom"]::after {
+ border-top: 0;
+ border-bottom: 2px solid var(--arap-muted);
+}
+
+.arap-root .arap-resize-handle:hover::after,
+.arap-root .arap-resize-handle:focus-visible::after {
+ border-color: var(--arap-accent);
+ opacity: 1;
+}
+
+.arap-root .arap-resize-handle:focus-visible {
+ outline: 3px solid var(--arap-accent);
+ outline-offset: 2px;
+}
+
+@media (max-width: 1023px), (hover: none) {
+ .arap-root .arap-resize-handle {
+ display: none !important;
+ }
+}
+
+@media (max-width: 640px) {
+ .arap-root .arap-modal-overlay {
+ padding: 0;
+ }
+
+ .arap-root .arap-modal-full,
+ .arap-root .arap-modal-lg,
+ .arap-root .arap-modal-md {
+ width: 100vw;
+ max-width: 100vw;
+ height: 100dvh;
+ max-height: 100dvh;
+ border-radius: 0;
+ border: 0;
+ }
+
+ .arap-root .arap-modal-header,
+ .arap-root .arap-modal-body,
+ .arap-root .arap-modal-footer {
+ padding: 14px 16px;
+ }
+
+ .arap-root .arap-profiles-grid,
+ .arap-root .arap-presets-grid {
+ grid-template-columns: minmax(0, 1fr);
+ }
+
+ .arap-root .arap-dict-search-form {
+ flex-direction: column;
+ align-items: stretch;
+ }
+
+ .arap-root .arap-dict-submit-btn {
+ width: 100%;
+ }
+
+ .arap-root .arap-feature-row-between {
+ flex-wrap: wrap;
+ }
+
+ .arap-root .arap-shortcut-item {
+ flex-direction: column;
+ align-items: stretch;
+ gap: 8px;
+ }
+
+ .arap-root .arap-shortcut-actions {
+ justify-content: space-between;
+ }
+}
+
+/* External Reading Aid Nudge Controls (#199) */
+.arap-root .arap-reading-aid-nudge {
+ position: fixed;
+ inset-inline-end: max(16px, env(safe-area-inset-right));
+ top: 50%;
+ transform: translateY(-50%);
+ z-index: 2147482999;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ padding: 6px;
+ border: 1px solid var(--arap-border);
+ border-radius: 14px;
+ background: var(--arap-surface);
+ box-shadow:
+ 0 8px 16px rgba(15, 23, 42, 0.08),
+ 0 16px 32px rgba(15, 23, 42, 0.12);
+}
+
+.arap-root .arap-reading-aid-nudge[data-aid="guide"] {
+ top: 38%;
+}
+
+.arap-root .arap-reading-aid-nudge[data-aid="mask"] {
+ top: 62%;
+}
+
+.arap-root .arap-reading-aid-nudge-btn {
+ width: 44px;
+ height: 44px;
+ min-width: 44px;
+ min-height: 44px;
+ padding: 0;
+ font-size: 16px;
+ font-weight: 700;
+}
+
+@media (max-height: 480px) {
+ .arap-root .arap-reading-aid-nudge {
+ flex-direction: row;
+ transform: none;
+ }
+
+ .arap-root .arap-reading-aid-nudge[data-aid="guide"] {
+ top: max(16px, env(safe-area-inset-top));
+ }
+
+ .arap-root .arap-reading-aid-nudge[data-aid="mask"] {
+ top: max(80px, calc(env(safe-area-inset-top) + 64px));
+ }
+
+ .arap-root .arap-modal-overlay {
+ padding: 0;
+ }
+
+ .arap-root .arap-modal,
+ .arap-root .arap-modal-full,
+ .arap-root .arap-modal-lg,
+ .arap-root .arap-modal-md {
+ max-height: 100dvh;
+ height: 100dvh;
+ }
+
+ .arap-root .arap-modal-header,
+ .arap-root .arap-modal-body,
+ .arap-root .arap-modal-footer {
+ padding: 10px 14px;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .arap-root .arap-group-chevron {
+ transition: none !important;
+ }
+}
+
+@media (forced-colors: active) {
+ .arap-root .arap-btn-primary,
+ .arap-root .arap-reset-btn,
+ .arap-root .arap-btn-action,
+ .arap-root .arap-button.arap-voice-toggle-btn {
+ background: Highlight;
+ color: HighlightText;
+ border: 1px solid ButtonText;
+ forced-color-adjust: none;
+ }
+
+ .arap-root .arap-btn-secondary,
+ .arap-root .arap-btn-danger,
+ .arap-root .arap-btn-ghost,
+ .arap-root .arap-close-btn,
+ .arap-root .arap-feature-btn,
+ .arap-root .arap-modal {
+ border: 1px solid CanvasText;
+ }
+}
diff --git a/tests/browser/widget.spec.ts b/tests/browser/widget.spec.ts
index 01ab72b..2902ff5 100644
--- a/tests/browser/widget.spec.ts
+++ b/tests/browser/widget.spec.ts
@@ -304,6 +304,9 @@ test("A11Y-304 accessibility profiles: previews eight suggestions, applies atomi
const host = page.locator("#host");
await expect(host).toHaveCSS("background-color", "rgb(0, 0, 0)");
+ // Close Profiles modal to adjust individual settings in main panel
+ await page.getByRole("button", { name: "Close profiles dialog" }).click();
+
// User independent override: change contrastMode to dark
const darkBtn = page
.getByRole("group", { name: "Contrast Mode" })
@@ -311,7 +314,8 @@ test("A11Y-304 accessibility profiles: previews eight suggestions, applies atomi
await darkBtn.click();
await expect(host).toHaveCSS("background-color", "rgb(15, 23, 42)");
- // Revert profile
+ // Reopen Profiles modal and revert profile
+ await browseBtn.click();
const revertBtn = page.getByRole("button", {
name: "Revert Color Blind profile",
});
@@ -339,7 +343,7 @@ test("A11Y-305 custom presets: saves named preset, persists across display reset
const host = page.locator("#host");
await expect(host).toHaveCSS("background-color", "rgb(15, 23, 42)");
- // Open PresetsController
+ // Open PresetsController modal
const presetsBtn = page.locator(
"button[aria-controls='arap-presets-dialog']",
);
@@ -357,11 +361,15 @@ test("A11Y-305 custom presets: saves named preset, persists across display reset
).toBeVisible();
await expect(page.getByText("Night Preset", { exact: true })).toBeVisible();
+ // Close Presets modal before clicking Reset All in panel footer
+ await page.getByRole("button", { name: "Close presets dialog" }).click();
+
// Reset All display preferences
await page.getByRole("button", { name: "Reset All", exact: true }).click();
await expect(host).toHaveCSS("background-color", "rgba(0, 0, 0, 0)");
- // Night Preset survived Reset All!
+ // Reopen Presets modal: Night Preset survived Reset All!
+ await presetsBtn.click();
await expect(page.getByText("Night Preset", { exact: true })).toBeVisible();
// Apply saved preset
@@ -1969,3 +1977,296 @@ test("A11Y-501: full supported matrix verification - zoom reflow, forced-colors,
await expect(trigger).toBeFocused();
await page.emulateMedia({ forcedColors: "none" });
});
+
+test("bundled Manrope default UI font and fontFamily synchronization (#189)", async ({
+ page,
+}) => {
+ await page.goto("/");
+ await page.getByLabel("Accessibility", { exact: true }).click();
+
+ const root = page.locator(".arap-root").first();
+ await expect(root).toHaveAttribute("data-arap-font", "default");
+ const defaultFont = await root.evaluate(
+ (el) => getComputedStyle(el).fontFamily,
+ );
+ expect(defaultFont.toLowerCase()).toContain("manrope");
+ const loadedManropeFonts = await page.evaluate(async () => {
+ await document.fonts.ready;
+ return Array.from(document.fonts)
+ .filter((font) => font.family.toLowerCase().includes("manrope"))
+ .map((font) => ({ family: font.family, status: font.status }));
+ });
+ expect(loadedManropeFonts.some((font) => font.status === "loaded")).toBe(
+ true,
+ );
+ expect(loadedManropeFonts.some((font) => font.status === "error")).toBe(
+ false,
+ );
+
+ const fontGroup = page.getByRole("group", {
+ name: /Readable Font|Font Family/i,
+ });
+ await fontGroup.getByRole("button", { name: "Legible" }).click();
+ await expect(root).toHaveAttribute("data-arap-font", "legible");
+ const legibleFont = await root.evaluate(
+ (el) => getComputedStyle(el).fontFamily,
+ );
+ expect(legibleFont).not.toBe(defaultFont);
+
+ await fontGroup.getByRole("button", { name: "Dyslexia" }).click();
+ await expect(root).toHaveAttribute("data-arap-font", "dyslexia-option");
+ const dyslexiaFont = await root.evaluate(
+ (el) => getComputedStyle(el).fontFamily,
+ );
+ expect(dyslexiaFont.toLowerCase()).toContain("opendyslexic");
+});
+
+test("desktop-only resizable panel via keyboard/handle and mobile non-resizable (#186, #185)", async ({
+ page,
+}, info) => {
+ if (info.project.name === "mobile") {
+ await page.goto("/");
+ await page.getByLabel("Accessibility", { exact: true }).click();
+ const panel = page.getByRole("region", { name: "Accessibility settings" });
+ await expect(
+ page.getByRole("separator", { name: "Resize accessibility panel" }),
+ ).not.toBeVisible();
+ const noOverflow = await panel.evaluate(
+ (el) => el.scrollWidth <= el.clientWidth + 1,
+ );
+ expect(noOverflow).toBe(true);
+ return;
+ }
+
+ await page.setViewportSize({ width: 1280, height: 800 });
+ await page.goto("/");
+ await page.getByLabel("Accessibility", { exact: true }).click();
+
+ const panel = page.getByRole("region", { name: "Accessibility settings" });
+ const initialBox = await panel.boundingBox();
+ expect(initialBox!.width).toBeGreaterThanOrEqual(440);
+
+ const resizeHandle = page.getByRole("separator", {
+ name: "Resize accessibility panel",
+ });
+ await expect(resizeHandle).toBeVisible();
+ await resizeHandle.focus();
+ await page.keyboard.press("ArrowLeft");
+ const widenedBox = await panel.boundingBox();
+ expect(widenedBox!.width).toBeGreaterThan(initialBox!.width);
+
+ await page.keyboard.press("Home");
+ const resetBox = await panel.boundingBox();
+ expect(Math.round(resetBox!.width)).toBe(Math.round(initialBox!.width));
+
+ // Narrow viewport (< 1024px) hides resize handle cleanly without horizontal overflow
+ await page.setViewportSize({ width: 320, height: 640 });
+ await expect(resizeHandle).not.toBeVisible();
+ const noOverflow = await panel.evaluate(
+ (el) => el.scrollWidth <= el.clientWidth + 1,
+ );
+ expect(noOverflow).toBe(true);
+});
+
+test("reading aid isolation against aggressive host CSS and higher modal z-index (#193)", async ({
+ page,
+}) => {
+ await page.goto("/");
+ await page.addStyleTag({
+ content: `div { margin: 24px !important; padding: 20px !important; border: 6px solid red !important; transform: rotate(3deg) !important; }`,
+ });
+
+ await page.getByLabel("Accessibility", { exact: true }).click();
+ await page.getByRole("button", { name: "Reading Guide" }).click();
+
+ const guide = page.locator(".arap-reading-guide");
+ await expect(guide).toBeVisible();
+ const styles = await guide.evaluate((el) => {
+ const cs = getComputedStyle(el);
+ return {
+ margin: cs.margin,
+ padding: cs.padding,
+ transform: cs.transform,
+ zIndex: Number(cs.zIndex),
+ };
+ });
+ expect(styles.margin).toBe("0px");
+ expect(styles.padding).toBe("0px");
+ expect(styles.transform).toBe("none");
+ expect(styles.zIndex).toBe(2147482000);
+
+ // Panel sits cleanly above reading guide
+ const panelZ = await page
+ .getByRole("region", { name: "Accessibility settings" })
+ .evaluate((el) => Number(getComputedStyle(el).zIndex));
+ expect(panelZ).toBeGreaterThan(styles.zIndex);
+});
+
+test("dictionary looks up 'voice' and Sinhala host translation skips widget UI (#187, #188)", async ({
+ page,
+}) => {
+ await page.goto("/");
+ await page.getByLabel("Accessibility", { exact: true }).click();
+
+ // Dictionary lookup for 'voice'
+ await page.getByRole("button", { name: /Dictionary/i }).click();
+ const dictDialog = page.getByRole("dialog", { name: /Dictionary/i });
+ await expect(dictDialog).toBeVisible();
+ await dictDialog.getByRole("searchbox").fill("voice");
+ await dictDialog.getByRole("button", { name: "Look up" }).click();
+ await expect(
+ dictDialog.getByRole("heading", { level: 3, name: "voice" }),
+ ).toBeVisible();
+ await dictDialog.getByRole("button", { name: /close dictionary/i }).click();
+ await expect(dictDialog).not.toBeVisible();
+
+ // Expand Experimental Prototypes group if collapsed (e.g. next-app demo)
+ const expToggle = page.getByRole("button", {
+ name: /Experimental Prototypes/i,
+ });
+ if ((await expToggle.count()) > 0) {
+ const expanded = await expToggle.getAttribute("aria-expanded");
+ if (expanded === "false") {
+ await expToggle.click();
+ }
+ }
+
+ // Sinhala host translation leaves widget UI untouched
+ const translationGroup = page.getByTestId("translation-controller");
+ await translationGroup
+ .getByRole("button", { name: "Review & Grant Consent" })
+ .click();
+ await translationGroup
+ .getByRole("button", { name: "Grant Consent", exact: true })
+ .click();
+ await translationGroup.getByLabel(/Target Language/i).selectOption("si");
+ await translationGroup
+ .getByRole("button", { name: "Translate Page" })
+ .click();
+
+ const hostSample = page.locator("main p, #host p").first();
+ await expect(hostSample).toContainText("[TR]");
+ await expect(
+ translationGroup.getByRole("button", { name: "Restore Original" }),
+ ).toBeVisible();
+});
+
+test("read-aloud mini-player 44px targets, form field id/name compliance, and 320x200 zoom layout (#185, #191, #192)", async ({
+ page,
+}) => {
+ await page.addInitScript(() => {
+ if (!("speechSynthesis" in window)) return;
+ window.speechSynthesis.speak = (utterance: SpeechSynthesisUtterance) => {
+ utterance.onstart?.(new Event("start") as SpeechSynthesisEvent);
+ };
+ window.speechSynthesis.cancel = () => {};
+ window.speechSynthesis.pause = () => {};
+ window.speechSynthesis.resume = () => {};
+ });
+ await page.goto("/");
+ await page.getByLabel("Accessibility", { exact: true }).click();
+
+ // Check Read Aloud floating bar targets >= 44px and sits below modals
+ const readAloudCard = page.getByRole("group", { name: "Read aloud" });
+ const playBtn = readAloudCard.getByRole("button", { name: "Read aloud" });
+ if (await playBtn.isVisible().catch(() => false)) {
+ await playBtn.click();
+ const playbackBar = page.getByRole("region", {
+ name: "Read aloud playback bar",
+ });
+ await expect(playbackBar).toBeVisible();
+ const barZ = await playbackBar.evaluate((el) =>
+ Number(getComputedStyle(el).zIndex),
+ );
+ expect(barZ).toBeGreaterThan(2147483000);
+ expect(barZ).toBeLessThan(2147483100);
+ const barBtns = playbackBar.locator("button");
+ const btnCount = await barBtns.count();
+ for (let i = 0; i < btnCount; i++) {
+ const box = await barBtns.nth(i).boundingBox();
+ expect(box!.width).toBeGreaterThanOrEqual(44);
+ expect(box!.height).toBeGreaterThanOrEqual(44);
+ }
+ await playbackBar.getByRole("button", { name: /Stop/i }).click();
+ await expect(playbackBar).not.toBeVisible();
+ }
+
+ // Verify modal inputs carry id or name attributes
+ const openShortcutsBtn = page.getByRole("button", {
+ name: "Open Keyboard Shortcuts",
+ });
+ if ((await openShortcutsBtn.count()) > 0) {
+ await openShortcutsBtn.click();
+ const dialog = page.getByRole("dialog", { name: /Keyboard Shortcuts/i });
+ await expect(dialog).toBeVisible();
+ const missingIds = await dialog.evaluate(
+ (el) =>
+ Array.from(el.querySelectorAll("input, select, textarea")).filter(
+ (field) => !field.getAttribute("id") && !field.getAttribute("name"),
+ ).length,
+ );
+ expect(missingIds).toBe(0);
+ await dialog.getByRole("button", { name: /Close/i }).click();
+ }
+
+ // 400%-zoom equivalent CSS viewport (320x200) keeps modals and panel overflow-free
+ await page.setViewportSize({ width: 320, height: 200 });
+ const dictBtn = page.getByRole("button", { name: /Dictionary/i });
+ await dictBtn.click();
+ const dictDialog = page.getByRole("dialog", { name: /Dictionary/i });
+ await expect(dictDialog).toBeVisible();
+ const dictBox = await dictDialog.boundingBox();
+ expect(dictBox!.width).toBeLessThanOrEqual(320);
+ const dictOverflow = await dictDialog.evaluate(
+ (el) => el.scrollWidth <= el.clientWidth + 1,
+ );
+ expect(dictOverflow).toBe(true);
+ await dictDialog.getByRole("button", { name: /close dictionary/i }).click();
+});
+
+test("reading guide and mask nudge arrows render outside the plugin panel and work when closed (#199)", async ({
+ page,
+}) => {
+ await page.goto("/");
+ await page.getByLabel("Accessibility", { exact: true }).click();
+
+ const panel = page.getByRole("region", { name: "Accessibility settings" });
+ await panel.getByRole("button", { name: "Reading Guide" }).click();
+ await expect(panel.getByText("Move Guide")).toHaveCount(0);
+
+ // Close panel so only external floating controls remain visible
+ await page.getByLabel("Close accessibility settings").click();
+ await expect(panel).not.toBeVisible();
+
+ const guide = page.locator(".arap-reading-guide");
+ await expect(guide).toBeVisible();
+ const topBefore = await guide.evaluate((el) => parseFloat(el.style.top));
+
+ const guideUp = page.getByRole("button", { name: "Move reading guide up" });
+ const guideDown = page.getByRole("button", {
+ name: "Move reading guide down",
+ });
+ await expect(guideUp).toBeVisible();
+ await expect(guideDown).toBeVisible();
+ const upBox = (await guideUp.boundingBox())!;
+ expect(upBox.width).toBeGreaterThanOrEqual(44);
+ expect(upBox.height).toBeGreaterThanOrEqual(44);
+
+ await guideDown.click();
+ const topAfterDown = await guide.evaluate((el) => parseFloat(el.style.top));
+ expect(topAfterDown).toBeGreaterThan(topBefore);
+
+ await guideUp.click();
+ const topAfterUp = await guide.evaluate((el) => parseFloat(el.style.top));
+ expect(topAfterUp).toBeLessThan(topAfterDown);
+
+ // Also verify Reading Mask external nudge arrows + internal height-only control
+ await page.getByLabel("Accessibility", { exact: true }).click();
+ await panel.getByRole("button", { name: "Reading Mask" }).click();
+ await expect(panel.getByText("Move Window")).toHaveCount(0);
+ await expect(panel.getByText("Window Height")).toBeVisible();
+ await page.getByLabel("Close accessibility settings").click();
+
+ const maskDown = page.getByRole("button", { name: "Move reading mask down" });
+ await expect(maskDown).toBeVisible();
+});
diff --git a/tests/decorativeImages.test.tsx b/tests/decorativeImages.test.tsx
index 4f80bbe..cac9f81 100644
--- a/tests/decorativeImages.test.tsx
+++ b/tests/decorativeImages.test.tsx
@@ -7,6 +7,7 @@ import {
AccessibilityList,
HideImagesController,
HideDecorativeImagesController,
+ HideVideosController,
ResetController,
isEligibleDecorativeImage,
isFunctionalOrMeaningfulImage,
@@ -382,4 +383,38 @@ describe("HideImagesController & HideDecorativeImagesController integration", ()
(host.querySelector("#deco-bg") as HTMLElement).style.backgroundImage,
).toContain("banner.png");
});
+
+ it("preserves CSS gradient backgrounds and widget UI icons while hiding decorative and video embeds", () => {
+ const { host } = renderFixture(
+ <>
+
+
+ >,
+ );
+
+ const gradientBox = document.createElement("div");
+ gradientBox.style.backgroundImage = "linear-gradient(to right, #fff, #000)";
+ const pic = document.createElement("picture");
+ const picImg = document.createElement("img");
+ picImg.setAttribute("alt", "");
+ pic.appendChild(picImg);
+
+ const ytEmbed = document.createElement("iframe");
+ ytEmbed.src = "https://youtu.be/dQw4w9WgXcQ";
+ const mapEmbed = document.createElement("iframe");
+ mapEmbed.src = "https://maps.google.com/maps?q=colombo";
+ host.append(gradientBox, pic, ytEmbed, mapEmbed);
+
+ fireEvent.click(screen.getByRole("button", { name: "Hide Images" }));
+ expect(gradientBox.style.backgroundImage).toContain("linear-gradient");
+ expect(pic.style.visibility).toBe("hidden");
+ expect(picImg.style.visibility).toBe("hidden");
+
+ const widgetIcon = document.querySelector("[data-arap-ui]");
+ expect(isFunctionalOrMeaningfulImage(widgetIcon!)).toBe(true);
+
+ fireEvent.click(screen.getByRole("button", { name: "Hide Videos" }));
+ expect(ytEmbed.style.visibility).toBe("hidden");
+ expect(mapEmbed.style.visibility).toBe("");
+ });
});
diff --git a/tests/dictionary.test.ts b/tests/dictionary.test.ts
index 75a6c24..cbf1820 100644
--- a/tests/dictionary.test.ts
+++ b/tests/dictionary.test.ts
@@ -175,5 +175,27 @@ describe("A11Y-403: Dictionary Core & Sanitization", () => {
expect(result.entry?.word).toBe("focus");
expect(result.entry?.source).toBe("local");
});
+
+ it("resolves plugin accessibility terms like voice, hyphenated forms, plurals, and fuzzy typos", async () => {
+ const voiceRes = await lookupWord("voice");
+ expect(voiceRes.found).toBe(true);
+ expect(voiceRes.entry?.definition.toLowerCase()).toContain("speech");
+
+ const hyphenRes = await lookupWord("voice-navigation");
+ expect(hyphenRes.found).toBe(true);
+ expect(hyphenRes.entry?.word).toBe("voice navigation");
+
+ const pluralRes = await lookupWord("landmarks");
+ expect(pluralRes.found).toBe(true);
+ expect(pluralRes.entry?.word).toBe("landmark");
+
+ const typoRes = await lookupWord("voise");
+ expect(typoRes.found).toBe(false);
+ expect(typoRes.suggestions).toContain("voice");
+
+ const gibberishRes = await lookupWord("zzzzunknownword");
+ expect(gibberishRes.found).toBe(false);
+ expect(gibberishRes.suggestions).toBeUndefined();
+ });
});
});
diff --git a/tests/dictionaryWidget.test.tsx b/tests/dictionaryWidget.test.tsx
index f5df149..d2aca02 100644
--- a/tests/dictionaryWidget.test.tsx
+++ b/tests/dictionaryWidget.test.tsx
@@ -193,4 +193,31 @@ describe("A11Y-403: DictionaryController Component", () => {
screen.queryByRole("heading", { level: 3, name: /focus/i }),
).toBeNull();
});
+
+ it("displays starter chips when idle and truthfully omits nonexistent suggestion copy on unknown terms", async () => {
+ renderFeatures( );
+ fireEvent.click(screen.getByRole("button", { name: /dictionary/i }));
+
+ const dialog = screen.getByRole("dialog");
+ const voiceChip = within(dialog).getByRole("button", { name: "voice" });
+ fireEvent.click(voiceChip);
+
+ await waitFor(() => {
+ expect(
+ within(dialog).getByRole("heading", { level: 3, name: /voice/i }),
+ ).toBeDefined();
+ });
+
+ const input = screen.getByRole("searchbox");
+ fireEvent.change(input, { target: { value: "zzzznotaword" } });
+ fireEvent.click(within(dialog).getByRole("button", { name: /^look up$/i }));
+
+ await waitFor(() => {
+ const alert = within(dialog).getByRole("alert");
+ expect(alert.textContent).toContain(
+ 'No definition found for "zzzznotaword"',
+ );
+ expect(alert.textContent).not.toContain("try a suggestion below");
+ });
+ });
});
diff --git a/tests/launcherAndPanel.test.tsx b/tests/launcherAndPanel.test.tsx
index 27793b0..2d782cb 100644
--- a/tests/launcherAndPanel.test.tsx
+++ b/tests/launcherAndPanel.test.tsx
@@ -172,4 +172,34 @@ describe("A11Y-104 Accessible launcher and non-modal widget panel", () => {
expect(screen.queryByRole("region")).toBeNull();
expect(trigger).toHaveFocus();
});
+
+ it("propagates data-arap-font from FontFamilyController onto .arap-root and supports collapsible FeatureGroup", () => {
+ render(
+
+
+
+
+
+
+
+ ,
+ );
+
+ fireEvent.click(screen.getByLabelText("Accessibility"));
+ const root = document.querySelector(".arap-root") as HTMLElement;
+ expect(root.getAttribute("data-arap-font")).toBe("default");
+
+ fireEvent.click(screen.getByRole("button", { name: "Dyslexia" }));
+ expect(root.getAttribute("data-arap-font")).toBe("dyslexia-option");
+
+ const expToggle = screen.getByRole("button", { name: /Experimental/i });
+ expect(expToggle).toHaveAttribute("aria-expanded", "false");
+ fireEvent.click(expToggle);
+ expect(expToggle).toHaveAttribute("aria-expanded", "true");
+ });
});
diff --git a/tests/menuCustomizationWidget.test.tsx b/tests/menuCustomizationWidget.test.tsx
index 58a57f8..e5d6fdb 100644
--- a/tests/menuCustomizationWidget.test.tsx
+++ b/tests/menuCustomizationWidget.test.tsx
@@ -182,4 +182,17 @@ describe("FeatureMenu and AccessibilityList menu customization (A11Y-404)", () =
consoleWarnSpy.mockRestore();
});
+
+ it("renders built-in Experimental Prototypes group collapsed by default when grouped", () => {
+ render(
+
+
+ ,
+ );
+
+ const expToggle = screen.getByRole("button", {
+ name: /Experimental Prototypes/i,
+ });
+ expect(expToggle).toHaveAttribute("aria-expanded", "false");
+ });
});
diff --git a/tests/readingAids.test.tsx b/tests/readingAids.test.tsx
index e9eca4c..6fc3480 100644
--- a/tests/readingAids.test.tsx
+++ b/tests/readingAids.test.tsx
@@ -345,7 +345,9 @@ describe("A11Y-301: Cursor enlargement, reading mask and reading guide", () => {
it("allows adjusting mask window height via stepper buttons", () => {
render(
-
+
+
+
,
);
@@ -470,5 +472,38 @@ describe("A11Y-301: Cursor enlargement, reading mask and reading guide", () => {
expect(document.querySelector(".arap-reading-guide")).toBeNull();
expect(document.querySelector(".arap-reading-mask")).toBeNull();
});
+
+ it("ignores pointer events over [data-arap-ui], isolates geometry/z-index, and preserves mask Y position across height updates", () => {
+ render(
+
+
+
+
+ ,
+ );
+
+ fireEvent.click(screen.getByRole("button", { name: "Reading Mask" }));
+ const mask = document.querySelector(".arap-reading-mask") as HTMLElement;
+ expect(mask.style.zIndex).toBe("2147482000");
+ expect(mask.style.margin).toBe("0px");
+
+ // Move mask to clientY = 200 (halfHeight = 50 -> top = 150)
+ fireEvent.mouseMove(document, { clientY: 200 });
+ expect(parseInt(mask.style.top, 10)).toBe(150);
+
+ // Pointer event originating inside [data-arap-ui] must not yank mask position
+ const uiBtn = screen.getByRole("button", {
+ name: "Increase reading mask height",
+ });
+ fireEvent.mouseMove(uiBtn, { clientY: 420 });
+ expect(parseInt(mask.style.top, 10)).toBe(150);
+
+ // Increase height to 120px: Y=200 center stays preserved (200 - 60 = 140px)
+ fireEvent.click(uiBtn);
+ const updatedMask = document.querySelector(
+ ".arap-reading-mask",
+ ) as HTMLElement;
+ expect(parseInt(updatedMask.style.top, 10)).toBe(140);
+ });
});
});
diff --git a/tests/translationAdapter.test.ts b/tests/translationAdapter.test.ts
index 8fd5c59..e303958 100644
--- a/tests/translationAdapter.test.ts
+++ b/tests/translationAdapter.test.ts
@@ -300,5 +300,48 @@ describe("A11Y-409: Host-Content Translation Adapter Architecture", () => {
session.restore();
expect(p.textContent).toBe("Accessible web application");
});
+
+ it("excludes [data-arap-ui], .arap-root, select/option elements, normalizes BCP-47 tags, and translates offline Sinhala phrases", async () => {
+ const widgetRoot = document.createElement("div");
+ widgetRoot.setAttribute("data-arap-ui", "");
+ widgetRoot.className = "arap-root";
+ widgetRoot.innerHTML = `Target UI Button `;
+
+ const selectEl = document.createElement("select");
+ const optEl = document.createElement("option");
+ optEl.value = "si";
+ optEl.textContent = "Sinhala Option";
+ selectEl.appendChild(optEl);
+
+ const hostHeading = document.createElement("h1");
+ hostHeading.textContent = "Accessibility Plugin React";
+
+ document.body.append(widgetRoot, selectEl, hostHeading);
+
+ expect(isSensitiveElement(widgetRoot.firstElementChild!)).toBe(true);
+ expect(isSensitiveElement(optEl)).toBe(true);
+
+ const adapter = createOfflineMockTranslationAdapter({ latencyMs: 0 });
+ const consentRecord: TranslationConsentRecord = {
+ status: "granted",
+ userAcknowledgedRisks: true,
+ };
+
+ const session = await translateHostContent({
+ rootElement: document.body,
+ provider: adapter,
+ targetLanguage: "si-LK",
+ consentRecord,
+ });
+
+ expect(session.active).toBe(true);
+ expect(widgetRoot.textContent).toBe("Target UI Button");
+ expect(optEl.textContent).toBe("Sinhala Option");
+ expect(hostHeading.textContent).toContain("[TR]");
+ expect(hostHeading.textContent).toMatch(/[\u0D80-\u0DFF]/);
+
+ session.restore();
+ expect(hostHeading.textContent).toBe("Accessibility Plugin React");
+ });
});
});
diff --git a/tests/translationWidget.test.tsx b/tests/translationWidget.test.tsx
index 479cc20..42f0938 100644
--- a/tests/translationWidget.test.tsx
+++ b/tests/translationWidget.test.tsx
@@ -163,4 +163,32 @@ describe("A11Y-409: TranslationController Widget Integration", () => {
screen.getByText("Consent revoked. No translations will be performed."),
).toBeInTheDocument();
});
+
+ it("re-translates host content immediately when changing target language while active and updates status banner", async () => {
+ const adapter = createOfflineMockTranslationAdapter({ latencyMs: 0 });
+ renderWidget( );
+
+ fireEvent.click(
+ screen.getByRole("button", { name: /^review & grant consent$/i }),
+ );
+ fireEvent.click(screen.getByRole("button", { name: /^grant consent$/i }));
+
+ await act(async () => {
+ fireEvent.click(
+ screen.getByRole("button", { name: /^translate page$/i }),
+ );
+ });
+ expect(hostPara.textContent).toContain("[TR]");
+
+ const langSelect = screen.getByLabelText(/target language/i);
+ await act(async () => {
+ fireEvent.change(langSelect, { target: { value: "si" } });
+ });
+
+ expect(hostPara.textContent).toMatch(/[\u0D80-\u0DFF]/);
+ const statusBanner = screen
+ .getByTestId("translation-controller")
+ .querySelector(".arap-translation-status-banner");
+ expect(statusBanner?.textContent).toContain("Sinhala");
+ });
});
diff --git a/tsup.config.ts b/tsup.config.ts
index ae0527b..a38d85d 100644
--- a/tsup.config.ts
+++ b/tsup.config.ts
@@ -11,4 +11,10 @@ export default defineConfig({
banner: { js: '"use client";' },
splitting: false,
injectStyle: true,
+ esbuildOptions(options) {
+ options.loader = {
+ ...options.loader,
+ ".ttf": "dataurl",
+ };
+ },
});