open-standards/aac/aac-rs/crates/aac-web/src/app.rs
Transaction Science 38707b2495 Merge aac/integ-1015 into aac/ui-i18n: visual scenes, word finding, optional symbol sets and the rest, with the app's words through the catalogue
Conflicts, settled with the features' behaviour and the catalogue's lookups:

- app.rs: the default title is "AAC — reference app" (the app's name, set by
  the host; not UI).
- edit_bar.rs: the title stays a message; the hint is the features' (it
  follows a scene's marking).
- grid_cell.rs: the cell's name holds the words it shows (WCAG 2.5.3) and
  what it says when that holds them; "Edit: …", the notes in brackets, "Say
  the next line", "Undo: bring the message back" and the action names stay
  messages (grid-cell-*, output-strip-undo-clear-name).
- lock.rs: "Lock again after" is a group of radio choices; its legend and
  choices are the lock-relock-* messages.
- navigation_bar.rs: the bar's name and the partner button's name stay
  messages; the recording dot and the new button size are the features'.
- access_settings.rs: the new "start each pass at the place to press" toggle
  is a message (access-settings-scan-from-way).
- catalogue_sets.rs: a size's description, or what it holds when started with
  its first words, through the page-set catalogue's messages.
- cell_editor.rs: hotspot headings and the hotspot's hide label are new
  messages; Undo's descriptions stay messages, with the features' words shown
  and same-word hides.
- import_export.rs: the record of choices in a backup, and in what a backup
  brings back, are new messages.
- listen_settings.rs, settings.rs: the features' new English, in the existing
  messages (settings-scan-bar-note keeps "Delete last word", the button's
  name).
- profiles.rs: the Active tag and the new Delete button are messages.
- symbol_settings.rs, print_view.rs: the optional sets' licences ("ARASAAC's
  licence: …; our adapted versions are shared under …") and their changes
  are messages; licence names come from aac-core (display_name). The changes'
  English is the symbol catalogue's own (a test checks they agree).
- voice_banking.rs, voice_offer.rs: the English fixes were already in the
  messages; unchanged.
- editing.rs: the undo problem names the words shown.
- visual_scene.rs: deleted (scene_board.rs replaces it); its message
  visual-scene-name goes, from English and from es, fr, de and pt.

Merge fixes: the Find a word panel's title is a message (panels-find-word-
title); print_view.rs's file error is file_failed().

The feature tracks' other English is put through the catalogue in the
commits that follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-15 21:04:16 -04:00

87 lines
3.4 KiB
Rust

use leptos::prelude::*;
use leptos_meta::*;
use leptos_router::{
components::{Route, Router, Routes},
path,
};
use crate::components::shell::AacShell;
/// Where the app is mounted: "" at a site root (aac.transaction.science), or a
/// sub-path such as "/app" when a host serves it under its own site. Fixed at
/// build time so the prerendered shell and the hydrated client agree.
pub const BASE_PATH: &str = match option_env!("AAC_BASE_PATH") {
Some(p) => p,
None => "",
};
/// The service worker to register. A host that serves the app under a
/// sub-path usually runs one worker for its whole site, so this is separate
/// from `BASE_PATH`.
pub const SW_URL: &str = match option_env!("AAC_SW_URL") {
Some(p) => p,
None => "/sw.js",
};
/// Whether to show the session energy meter in the navigation bar. On by
/// default (the standard's energy receipt); a host can hide it with
/// AAC_HIDE_ENERGY=1 at build time.
pub const SHOW_ENERGY: bool = option_env!("AAC_HIDE_ENERGY").is_none();
/// Document title, so a host can present the app under its own name.
pub const APP_TITLE: &str = match option_env!("AAC_APP_TITLE") {
Some(t) => t,
None => "AAC — reference app", // i18n: not UI (the app's name, set by the host)
};
/// Before the first paint: the colours the person chose (Settings → Display,
/// kept as `aac_display`, persistence.rs) on `<html data-color-mode>`, so the
/// starting screen is drawn in them, with no flash of light colours on a dark
/// setting. The app applies them fully once its saved state is restored.
// i18n: not UI (a script)
const COLOR_MODE_SCRIPT: &str = "try{var d=JSON.parse(localStorage.getItem('aac_display')||'null');\
if(d&&typeof d.color_mode==='string')document.documentElement.setAttribute('data-color-mode',d.color_mode)}catch(e){}";
/// HTML document shell for SSR.
pub fn shell(options: LeptosOptions) -> impl IntoView {
view! {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
<meta name="mobile-web-app-capable" content="yes"/>
<script inner_html=COLOR_MODE_SCRIPT></script>
<AutoReload options=options.clone()/>
<HydrationScripts options/>
<MetaTags/>
<link rel="manifest" href=format!("{BASE_PATH}/manifest.json")/>
</head>
<body>
<App/>
</body>
</html>
}
}
/// Root App component.
#[component]
pub fn App() -> impl IntoView {
provide_meta_context();
view! {
<Stylesheet id="leptos" href=format!("{BASE_PATH}/pkg/aac-web.css")/>
<Title text=APP_TITLE/>
<Meta name="description" content="Free augmentative and alternative communication for everyone"/>
<Router>
<Routes fallback=|| "404">
<Route path=path!("/") view=AacShell/>
// The app is one screen: render it wherever it is mounted
// (e.g. /app/), so a host can serve it under a sub-path.
<Route path=path!("/*any") view=AacShell/>
</Routes>
</Router>
}
}