AncrelDocumentationv0.3.0

Search documentation

    Documentation / frontend

    WorkspaceShell

    Give the parent a definite height. Place page content in children, side panels in sidebar and inspector, and navigation in rail. The optional title bar uses --ac-sys-size-titleBar. The status bar stays beneath the pane area.

    Live example

    Open playground ↗
    Report

    Overview

    Ready

    App.tsx

    import '@ancrel/tokens/css'
    import '@ancrel/workspace/styles.css'
    import './example.css'
    import { WorkspaceShell } from '@ancrel/workspace'
    
    export default function App() {
      return <section aria-label="Report workspace" className="report-workspace">
        <WorkspaceShell titleBar="Report" sidebar={<button>Contents</button>}
          inspector="Revision 2" statusBar="Ready" theme="light" density="compact">
          <h1>Overview</h1>
        </WorkspaceShell>
      </section>
    }
    

    Expected behavior

    A light, compact workspace shows Contents, Overview and Revision 2 in separate wide panes. Below 768px the title bar offers Show sidebar and Show inspector. Show sidebar focuses Contents. Back to main restores focus to Show sidebar.

    At container widths of 768px and above, the shell passes its panes and split options to ResizableSplit. Each pane scrolls independently. Use mainAs="div" inside an existing main landmark. Theme and density apply to this shell and its descendants, so nested previews can set either axis independently.

    Below narrowBreakpoint, the title bar provides buttons for the available side panes. Opening a pane focuses its first available control or the pane itself. Returning to the main pane restores focus to the corresponding title-bar button. Supply labels to translate those buttons.

    For local state, choose the starting pane with defaultNarrowPane. For controlled navigation, pass narrowPane and update it in onNarrowPaneChange. Install the appearance with @ancrel/tokens/css and @ancrel/workspace/styles.css.

    Props

    PropTypeRequiredDefault
    childrenReactNodeYes—
    classNamestringNo—
    defaultNarrowPaneShellPaneNo—
    densityDensityNo—
    inspectorReactNodeNo—
    keyReact.Key | null | undefinedNo—
    labelsPartial<{ showSidebar: string; showInspector: string; backToMain: string; }>No—
    mainAs'main' | 'div'No—
    narrowBreakpointnumberNo—
    narrowPaneShellPaneNo—
    onNarrowPaneChange((pane: ShellPane) => void) | undefinedNo—
    railReactNodeNo—
    refReact.Ref<HTMLDivElement> | undefinedNo—
    sidebarReactNodeNo—
    splitPick<ResizableSplitProps, 'leftConfig' | 'rightConfig' | 'minCenterWidth' | 'persistKey' | 'storage' | 'labels' | 'onWidthsChange'>No—
    statusBarReactNodeNo—
    themeThemeNo—
    titleBarReactNodeNo—

    State matrix

    StateTheme / density
    defaultdark/compact, dark/comfortable, light/compact, light/comfortable
    focus-visibledark/compact, dark/comfortable, light/compact, light/comfortable

    Constraints

    • Give the parent a definite height.
    • Use mainAs="div" when embedding the shell in an existing main landmark.

    Anti-patterns

    • Using viewport width to select the narrow pane.
    • Setting document-wide theme attributes for a local preview.