mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-22 15:06:32 +00:00
4346d7f2c1
A help icon on every screen opens a panel with the screen's overview, its sub-screens, task guides with a framed picture per step, search across guides and the wiki, and a switch to any other screen's help. Guides exist for the dashboard, Vacay, Atlas, Collections, Journey (list, journal, studio), Settings (all tabs), Admin (all tabs) and the trip frame; the trip's own screens are in progress. Pictures are produced by Playwright (client/e2e/help), texts in all 23 languages.
19 lines
631 B
TypeScript
19 lines
631 B
TypeScript
import { useEffect } from 'react'
|
|
import { useHelpStore } from '../store/helpStore'
|
|
|
|
/**
|
|
* Tell the help center which screen is showing. Call it from the screen's data
|
|
* hook, or render `<HelpAnchor id>` from a page body; either way the context
|
|
* is set while the screen is mounted and cleared when it goes away, unless
|
|
* another screen has already taken over.
|
|
*/
|
|
export function useHelpContext(id: string): void {
|
|
const setContext = useHelpStore(s => s.setContext)
|
|
useEffect(() => {
|
|
setContext(id)
|
|
return () => {
|
|
if (useHelpStore.getState().contextId === id) setContext(null)
|
|
}
|
|
}, [id, setContext])
|
|
}
|