Skip to content

Inspector

Everything about a text that is not the text, in tabs beside it or in a bottom sheet on a phone.

<div data-mount="wide"></div>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/inspector.css";

Usage

import { Inspector } from "capsomer/react/inspector";
import "capsomer/inspector.css";

<Inspector
  label="About this post"
  head={<SavePanel />}
  initialTab={searchParams.get("tab")}
  tabs={[
    { value: "details", label: "Details", content: <Details /> },
    { value: "checks", label: "Checks", count: open.length, content: <Checks /> },
    { value: "comments", label: "Comments", content: inRoom ? <Comments /> : null },
  ]}
/>

Examples

Opened on the tab the address asks for

<div data-mount="asked"></div>

API reference

Inspector

PropTypeRequiredDoes
labelstringYesNames the region and the sheet: "About this post".
headReactNodeAbove the tabs, and in the page on a phone: saving, publishing.
tabsInspectorTab[]Yes
defaultTabstring
initialTabstring | nullThe tab asked for by the address (?tab=checks): the inspector opens on it, and on a phone opens the sheet, so a link from a list of flags lands on the checks.
wideQuerystringThe media query from which the tabs sit beside the text. Match it to the page's own grid.
classNamestring

Parts and data attributes

ClassIs
.cap-inspectorthe root
.cap-inspector-opena part
.cap-inspector-panela part
.cap-inspector-tabsa part

Accessibility

KeyDoes
TabInto the tabs (wide) or the row of buttons (phone)
Left and Right arrowsMove between tabs (the tabs' own keys)
Enter or Space on a buttonOpens the sheet on that tab
EscCloses the sheet, focus back on its button
  • The column is an <aside> named by label; the sheet is a dialog named the same.
  • A count is part of the tab's and the button's name ("Checks, 2"), and the total that needs the person is said once beside the buttons ("2 need you").