Integrate d32f2dc8 after independent reachability, session and rendered reviews. Keep HTTP-only preview identifiers and integer serialization guards, let Core own policy ranges, and wrap the share controls intrinsically on narrow layouts. The page now uses the shared document-title owner. Full Rust, WASM, protocol and 2382 Web tests passed; subsequent title checks and the final Core/Server suite passed.
34 lines
884 B
TypeScript
34 lines
884 B
TypeScript
import { useEffect } from "react";
|
|
import { useRotatingText } from "./use-text-rotation";
|
|
|
|
const BRAND_TITLE = "Piik";
|
|
|
|
export function composeDocumentTitle(
|
|
...parts: Array<string | null | undefined>
|
|
): string {
|
|
const detail = parts.filter((part): part is string => Boolean(part));
|
|
return detail.length > 0
|
|
? `${BRAND_TITLE} | ${detail.join(" · ")}`
|
|
: BRAND_TITLE;
|
|
}
|
|
|
|
export function useDocumentTitle(
|
|
parts: Array<string | null | undefined>,
|
|
variations: readonly string[],
|
|
context: string,
|
|
): string {
|
|
const decoration = useRotatingText(variations, context, { rotate: false });
|
|
const title = composeDocumentTitle(...parts, decoration);
|
|
usePageTitle(title);
|
|
return title;
|
|
}
|
|
|
|
export function usePageTitle(title: string): void {
|
|
useEffect(() => {
|
|
document.title = title;
|
|
return () => {
|
|
document.title = BRAND_TITLE;
|
|
};
|
|
}, [title]);
|
|
}
|