Search the documentation

Type to search page titles, component names and descriptions.

    Feedback

    HelpDrawer

    Guidance for the current screen.

    import { HelpDrawer } from 'faifo-design'

    HelpDrawer holds one guide owned by the current screen: a modeless panel at the end edge on desktop, a full-screen page on a phone. The shell's help trigger and the shared runtime open it and manage focus.

    #When to use

    • Each screen supplies its own content, usually MarkdownContent.
    • A host with its own runtime wires only the drawers through faifo-design/help/runtime.

    #Examples

    Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.

    #Screen help

    Right-side modeless desktop guidance, fullscreen mobile help, SSR Markdown and the shared Mermaid theme. Hosts supply content and a lazy renderer. Open the connected demo to try the drawer; diagram source remains readable without JavaScript.

    Open screen help demoInspect Mermaid theme
    Order workflow
    View Mermaid source
    flowchart TD
      A[Draft] --> B[Complete]
      class B faifo-positive

    Screen help

    Example screen

    Screen-owned Markdown content
    Show codeHide code
    import { AppSwitcherHelp, HelpDrawer, LinkButton, MermaidDiagram, Stack } from 'faifo-design'
    
    export const Example = () => (
      <Stack
        items={[
          <LinkButton href="/demo2" label="Open screen help demo" />,
          <AppSwitcherHelp label="Screen help in standalone navigation" />,
          <LinkButton href="/help-theme" label="Inspect Mermaid theme" />,
          <MermaidDiagram
            source={'flowchart TD\n  A[Draft] --> B[Complete]\n  class B faifo-positive'}
            labels={{
              diagram: 'Order workflow',
              source: 'View Mermaid source',
              loading: 'Rendering…',
              error: 'Diagram unavailable; view its source.',
            }}
          />,
          <HelpDrawer
            id="catalogue-help-drawer"
            label="Screen help"
            title="Example screen"
            closeLabel="Close help"
            body="Screen-owned Markdown content"
          />,
        ]}
      />
    )

    #Contract

    #Screen help and ecosystem Mermaid

    Field({ type: 'date' | 'datetime-local', locale: 'vi' | 'en' }) forwards the host locale to the public picker, including fields passed through RecordModalForm. Omitting locale retains the existing Vietnamese picker default; native ISO values and input names remain unchanged. See the English host Field in DatePickerExamples.

    When a trigger belongs to a ModalSheet, RecordPage or Peek, help resolves the guide inside that nearest content owner. A background screen's previously bound guide must not override the record guide. Shell triggers retain their screen guide; content-slot navigation resolves replacement guides at request time.

    AppSwitcherHelp({ label }) exports the rail's Help trigger for standalone app navigation. Pair it with a screen-owned HelpDrawer; the existing runtime owns faifo:screen-help-request, association, Escape and focus return. It reuses the same hook and geometry as AppSwitcher.helpLabel, without adding a second rail. Standalone apps that already own their other interactions can attach the same Help producer with attachHelpDrawers(root) from faifo-design/help/runtime. It includes the trigger bridge, Escape/focus and disposal; do not also attach the full runtime to the same root. Hosts with an existing navigation implementation may pass beforeOpen(trigger) as the second argument. Close the host's compact navigation there and return its visible toggle for focus restoration. The DS runtime continues to own the dialog, scroll lock, Escape and modal focus boundary. Keep the trigger and drawer inside the host's data-faifo-design style scope.

    In the Suite shell a List or Workspace page puts no Help trigger in its header: the rail's AppSwitcher.helpLabel is that screen's trigger, passed only when the screen has a guide, and the header keeps the screen's own commands (none when it has none, rather than an empty ActionGroup). Each screen names its own guide, while fragment navigation keeps the rail: a host that swaps the content passes AppSwitcher.helpSlot (a data-ket-slot name) and sends the rail's Help again, as AppSwitcherHelp, in that slot with every navigation, so ? names the screen now shown, Back included. RecordPage, ModalSheet and Peek may carry their own trigger, whose guide resolves inside them. One without a guide of its own opens the screen guide that the content slot renders beside it, so a page-level ? still works on a phone, where the rail's ? is out of reach.

    For shell ownership, persistent navigation and host integration, read the shell integration guide for agents.

    Agents working on any screen must check its guide. If it is missing, author and integrate a real Vietnamese/English Markdown guide in the same task and PR; update existing guides when workflows change. A touched screen is not complete while its guide is missing. Explain implemented tasks, states and relevant recovery; use Mermaid when it clarifies a workflow, with the ecosystem theme below. Render the screen-owned drawer in the changing content slot and enable the shell's AppSwitcher.helpLabel only when that screen's guide works. The shared faifo:screen-help-request hook binds it; do not build a separate drawer or listener. Verify open/close, Escape, focus return, Markdown/diagrams and guide replacement on navigation in the current deployment at desktop/mobile widths. This rule does not require migrating untouched screens as part of an unrelated task.

    HelpDrawer is the standard screen guide: 512px (--faifo-help-width: 32rem) at the right edge on desktop, modeless so the current screen remains interactive. Below 768px it uses a native modal dialog at full viewport width/height; navigation closes first, body scrolling locks, native dialog focus containment applies and closing returns focus to the navigation toggle. Desktop closing returns focus to ?. Escape, the close control and pressing ? again dismiss it, and so does a primary press anywhere outside the guide on desktop; that light dismissal leaves focus where the pointer put it. A text selection dragged out of the guide and keyboard activation elsewhere do not dismiss it. The header stays fixed while only the body scrolls. Fragment navigation disposes the old guide and binds the new screen content; the SSR shell is not replaced.

    Hosts supply the translated id, label, screen title, closeLabel and body. A page-owned public Button/IconButton can also launch the same guide with name="screen-help", the guide ID as value and controls, and expanded={false}. The disposable runtime binds it alongside the application-rail trigger; native Help owns Escape without dismissing an underlying route modal. Use MarkdownContent for the body, with source, a host-supplied GFM lexer (marked.lexer is compatible), localized diagram/source/loading/error/table labels and headingOffset={1} for the drawer's heading hierarchy. The component renders headings, paragraphs, emphasis, lists, tasks, links, images, quotes, tables and code on the server. Raw HTML is text, executable/protocol-relative URLs are rejected, and Mermaid fences retain readable source without JavaScript. Tables and wide SVG diagrams scroll within their own regions instead of widening the drawer. Mermaid renders off-screen; once a diagram is shown the runtime fits its view box to the drawing in place (8px inset), so a box measured off-screen never shifts or clips it. A narrow drawer reads a top-down flow (flowchart TD) without scrolling.

    Mermaid presentation belongs to the public DS runtime, including uses outside help drawers. createMermaidTheme and readMermaidPalette are exported from faifo-design/runtime; every app must use this configuration rather than creating a local theme. It resolves the current DS tokens to hex colors, including alpha and light/dark aliases, uses the interface font (--faifo-font-sans) at 13px, 1.25px flow/sequence strokes, 12px rectangular node corners and rounded connectors. Process nodes use the accent surface; connectors stay muted. Explicit accent/positive/warning/danger classes (faifo-accent, faifo-positive, faifo-warning, faifo-danger) work on rectangles, polygons, circles and path-based shapes such as start/end stadiums. Notes use the warning surface. Flowchart, sequence, state, ER, class, pie, Gantt and graph palettes share these roles; chart categories use soft DS fills and readable foregrounds, never Mermaid's default rainbow.

    Flowcharts use 24px sibling spacing, 32px rank spacing, 12px padding, an 180px label wrapping width and an 80px minimum label width. These are diagram geometry, not app spacing overrides. Labels stay 13px at narrow widths; scroll or the host's expanded viewer preserves readability. Edge labels have rounded neutral pills. The pinned Mermaid 12.1.0 renderer supports curve: 'rounded' for rounded bends.

    Use Q("Question?"):::faifo-decision for compact decisions: an amber, dashed, rounded box plus explicitly named branches. Use S(["Start"]) for start/end stadiums, faifo-positive for a successful outcome, faifo-warning for attention or waiting, and faifo-danger for a blocked/stopped outcome. Wording and dashed decision borders carry meaning alongside colour. Existing diamond syntax remains supported; the theme does not infer business meaning or rewrite diagram source.

    flowchart TD
     A(["Start"]) --> B["Check order"]
     B --> C("Stock available?"):::faifo-decision
     C -->|Yes| D["Reserve inventory"]
     C -->|No| E["Contact customer"]:::faifo-warning
     D --> F(["Complete"]):::faifo-positive
     E --> G(["Stopped"]):::faifo-danger

    Keep a reading diagram within its article column at normal scale where practical: prefer top-to-bottom for long chains, keep recovery branches beside their decision, and split approval from subsequent monitoring when one graph sprawls. Shorten node labels only when adjacent prose preserves the detail. Do not remove conditions, invent process edges for layout, or shrink the type to make a diagram fit. See Mermaid flowchart syntax for shapes and branches; use the DS classes rather than content-level CSS or classDef.

    Help currently pins the older published DS 0.1.41. Its temporary compatibility module is generated byte-for-byte from src/runtime/mermaid-theme.js by the host repository's tools/sync-help-mermaid.mjs; --check detects divergence. Changes to this canonical module must regenerate that adapter in the same change. Help has no separate theme and still builds without a KetSuite checkout. Replace the adapter with public runtime imports after Help upgrades to a DS release containing this contract; no npm publication is implied by a local producer build.

    Apps pin and bundle their renderer, then configure the loader before attaching the shared runtime. The DS keeps its only dependency on ketjs-view; neither the Markdown lexer nor Mermaid is a DS dependency. The catalogue pins marked 18.1.0 and Mermaid 12.1.0 and bundles diagram chunks locally, with no CDN requirement.

    // File: apps/example/client.ts
    import { configureMermaidLoader, attachDesignSystemInteractions } from 'faifo-design/runtime'
    configureMermaidLoader(async () => (await import('mermaid')).default)
    const dispose = attachDesignSystemInteractions(document)
    // Call dispose before replacing this root's fragments.

    Both are also public exports of faifo-design; packages held to the public entry, such as KetSuite (zero-dep-audit), import them from there.

    After inserting a diagram, the runtime shows its canvas and fits the SVG view box to the visible drawing with an 8px inset before setting its natural width. Stale width/height attributes are removed so the fitted view box owns the aspect ratio and text stays at its native size. This prevents off-screen Mermaid measurements from clipping a screen-help diagram.

    Rendering is lazy for closed drawers, serialized because Mermaid configuration is global, and guarded against disposal while a render is pending. Theme changes rerender the active SVGs. Strict Mermaid rendering disables HTML labels and click callbacks. Diagram frontmatter/config/style overrides are rejected so content cannot replace the ecosystem theme; use the semantic classes instead. Invalid syntax or unavailable renderers display a translated status and source fallback. No Markdown content is inserted as trusted HTML.

    The connected preview is /demo2; /help-theme?theme=light and ?theme=dark exercise five diagram families plus invalid-source fallback. Build only the catalogue renderer with node tools/build-design-system-mermaid.mjs when iterating.

    #API

    Generated from the package source. A property without a description has none in the source yet.

    #HelpDrawerComponent

    One screen-owned guide; the shell trigger and shared runtime own opening and focus.

    PropertyDescriptionTypeDefault
    idrequired–string–
    labelrequired–string–
    titlerequired–string–
    closeLabelrequired–string–
    bodyrequired–JSXChild–

    #Types

    #HelpDrawerProps

    The properties of HelpDrawer, listed above.

    #Hooks

    The data-ui values these components render. Select them in tests and behaviour; their look belongs to the design system. See Contract.

    • help-drawer
    • help-head
    • help-heading
    • help-label
    • help-title
    • help-close
    • help-body