// Dev only (a plain browser, never in the release bundle): the tray menu panels on fixture data, as the tray would show // them: the root menu with Apps open beside it and a pinned Apps panel, whose values change every few seconds the way a // store read changes them (the panels update in place). import { useEffect, useMemo, useState } from 'react'; import type { MenuNode } from './model'; import { type MenuBridge, type MenuLang, TrayMenu } from './TrayMenu'; const STATES = [ ['App Store: In review · Play: Live', 'App Store: Ready for sale · Play: Live'], ['Play: Rolling out 20%', 'Play: Rolling out 50%', 'Play: Rolling out 100%'], ['App Store: Rejected', 'App Store: Rejected'], ['App Store: Waiting for review', 'App Store: In review'], ]; const NAMES = ['Star Dash', 'Puzzle Garden', 'Pocket Chef', 'Night Runner']; /** The tree tray.rs builds (menu_model), with fixture apps. */ export function demoNodes(tick: number, lang: MenuLang): MenuNode[] { const tr = lang === 'tr'; const item = (id: string, label: string, enabled = true): MenuNode => ({ kind: 'item', id, label, enabled }); return [ item('tray-open', tr ? 'storebound\'u aç' : 'Open storebound'), item('tray-read', tr ? 'Mağazaları şimdi oku' : 'Read the stores now'), { kind: 'sep' }, { kind: 'sub', key: 'apps', label: tr ? 'Uygulamalar' : 'Apps', items: NAMES.map((n, i) => item(`tray-app:k${i}`, `${n} · ${STATES[i]![tick % STATES[i]!.length]}`)) }, { kind: 'sep' }, item('tray-mute', tr ? 'Bildirimleri 1 saat sustur' : 'Mute notifications for 1 hour'), item('tray-update', tr ? 'Güncellemeleri denetle' : 'Check for updates'), item('tray-settings', tr ? 'Ayarlar' : 'Settings'), { kind: 'sep' }, item('tray-quit', tr ? 'storebound\'dan çık' : 'Quit storebound'), ]; } const log = (what: string) => (...a: unknown[]) => console.info('tray menu', what, ...a); const demoBridge: MenuBridge = { ready: () => {}, openSub: log('openSub'), pinSub: log('pinSub'), closeSubs: () => {}, close: log('close'), dismiss: log('dismiss'), pin: log('pin'), select: log('select') }; export function Demo({ lang }: { lang: MenuLang }) { const [tick, setTick] = useState(0); const q = new URLSearchParams(location.search); const still = q.has('still'); useEffect(() => { if (still) return; const t = window.setInterval(() => setTick(n => n + 1), 3000); return () => window.clearInterval(t); }, [still]); const nodes = useMemo(() => demoNodes(tick, lang), [tick, lang]); return ( <>
); }