Skip to content
ContractSpec
Start here

Package manual · examples

·Examples and implementation patterns

example.graph-showcase

Interactive graph-richness showcase for ContractSpec P6 primitives: mini-map, focus-mode, custom renderers, edge labels, animations, and drilldown.

examplesexamplev3.0.5stableservernode
@lssm-tech/example.graph-showcase
bun add @lssm-tech/example.graph-showcase
Package source ↗Manifest ↗

Manifest declarations describe the current workspace; they do not verify registry publication or runtime execution.

Package guide

Showroom-grade interactive showcase — 23 graph demos across 8 categories, 4-engine layout (ELK DAG / Ortho / Tree + d3-force), 3-preset theme system with full dark-mode, pointer/touch/keyboard interactions, and Playwright integration tests.

Graph showcase — Workflow DAG, n8n-card light ↗

What you'll see

CategoryDemo screensDefault preset
TemplatesWorkflow DAG, Agent Tree, Conversation Graph, Engineering Loop, Person Activityn8n-card
FilteringFacet Panel, Filter Chip Rack, Search Overlay, Path Highlightgh-slim
TimeTime Scrub, Diff Animations, Saved View Restoregh-slim
StructureClustering, Heatmap, Minimap, Focus Modegh-slim
AIAI Input, AI Suggest+Confirmn8n-card
AnnotationsAnnotations, Story Modeobsidian-dot
CollabCollab Cursors, Subscribeobsidian-dot
ExportExport Pipelineobsidian-dot

Interactions

ActionPointerTouchKeyboard
Navigate sidebarClick itemTap item↑ / ↓, then Enter
Collapse sidebarClick hamburgerTap hamburger⌘B / Ctrl+B
Pan canvasDrag background1-finger swipeSpace + drag
Zoom in / outScroll wheel2-finger pinch+ / - via ZoomCluster
Fit graph to viewClick Auto-fit—Auto-fit button
Select nodeClickTapTab to node, Space
Deselect / closeClick empty areaTap emptyEscape
Open searchClick search bar—/
Open command paletteClick search bar—⌘K / Ctrl+K
Switch layout engineClick pill in DemoHeader—Click only
Toggle dark modeClick ☾ / ☀ in AppBar—Click only

Shell

The showcase uses a hash-based router (useShowcaseRouter) with 23 SHOWCASE_ROUTES entries (key / label / category / recommendedTheme). Each demo is wrapped in <GraphThemeProvider themeId={recommendedTheme}> — the shell auto-selects the best visual preset per route.

Global keyboard handlers in ShowcaseShell: ⌘K / Ctrl+K → CommandPalette; / → SearchBar.

Theme presets

Three presets ship with WCAG AA 4.5:1 verified tokens in both light and dark.

PresetModeBackgroundNode fillCharacter
n8n-cardlight#FAF4EC warm cream#FFF8F0Rounded cards, warm workflow builder
n8n-carddark#0E0D0B near-black#1C1A17 warmImmersive dark workflow
gh-slimlight#F8FAFC cool white#F1F5F9Compact GitHub-style DAG
gh-slimdark#020617 near-navy#1E293B slateDark compact DAG
obsidian-dotlight#F5F3FF violet tint#EDE9FEKnowledge-graph dot style
obsidian-dotdark#0A0110 deep violet#1A0B2EAtmospheric dark dots

Toggle dark mode via ☾ in the AppBar. This sets DesignSystemThemeProvider mode="dark" and the Tailwind dark class on <html>, updating both chrome surfaces (Tailwind dark: utilities) and graph tokens (--graph-* CSS vars via CanvasVarsInjector).

Architecture

mermaid
graph TD
    DSP["DesignSystemThemeProvider\nmode: light | dark"]
    Shell["ShowcaseShell\ncontext providers · dark toggle"]
    AppBar["AppBar  48px\nlogo · search · GitHub · CTA · ☾"]
    SidebarNav["SidebarNav  240px\n23 routes · 8 categories · ⌘B"]
    DemoHeader["DemoHeader  56px\nbreadcrumb · role · layout pills"]
    CanvasArea["CanvasArea\nadaptive dot-grid · border"]
    GTP["GraphThemeProvider\nthemeId context"]
    CVI["CanvasVarsInjector\n--graph-* CSS vars"]
    Demo["Demo Screen\nWorkflowDagDemo · AgentTreeDemo …"]
    GC["GraphCanvas\nSVG renderer · useGraphLayout"]
    Atoms["Node / Edge Atoms\nN8nCardNode · GhSlimNode\nObsidianDotNode + edges"]

    DSP -->|wraps| Shell
    Shell --> AppBar
    Shell --> SidebarNav
    Shell --> DemoHeader
    Shell --> CanvasArea
    CanvasArea --> GTP
    GTP --> CVI
    CVI --> Demo
    Demo --> GC
    GC --> Atoms

Token flow: DesignSystemThemeProvider(mode) → useGraphTheme(themeId) inside CanvasVarsInjector → emits --graph-node-fill, --graph-kind-{kind}-{fill|stroke|label|accent} CSS vars on a wrapper <div> → atom components read them as var(--graph-node-fill, <light-fallback>).

Fixture data

All demo screens share synthetic fixtures in src/fixtures.ts:

  • 12 nodes spanning 4 kind values (contract, entity, event, feature)
  • 14 directed edges — mix of labeled and unlabeled
  • A focus sub-graph (6-node cluster) for minimap + focus-mode demos
  • Seed Viewport and selection values

Usage

ts
import { SHOWCASE_ROUTES } from '@lssm-tech/example.graph-showcase';
// Enumerate all 23 route keys:
SHOWCASE_ROUTES.forEach(r => console.log(r.key, r.category, r.recommendedTheme));

Commands

bash
bun run typecheck      # tsgo --noEmit
bun test               # unit + smoke tests (bun test runner)
bun run test:e2e       # Playwright integration tests (showcase config, port 5999)
bun run lint:check     # Biome lint check

Playwright integration tests

SuiteFileCoverage
Accessibilityplaywright/a11y.spec.tsS8.1–S8.5: landmarks, keyboard, reduced-motion
Lighthouseplaywright/lighthouse.spec.tsS9.2: performance + ARIA structure
Touchplaywright/touch.spec.tsS9.3: iPad Mini tap-to-navigate, sidebar
Dark-modeplaywright/template-darkmode.spec.tsS9.4: 10 PNG baselines (5 templates × light/dark)
Responsiveplaywright/responsive.spec.tsE3: phone / tablet / desktop viewports

Regenerate dark-mode baselines:

bash
bun exec playwright test --config playwright.showcase.config.ts \
  template-darkmode.spec.ts --update-snapshots

Declaration builds use build:types through the shared Bun tool; build runs bundle and declaration generation. Declared exports are preserved. Generated artifacts exclude test-only files; tests/typecheck remain separate gates.

Relationships

THIS PACKAGEexample.graph-showcase4 import paths

Arrows point from a package to its direct dependency. Counts are derived from captured workspace manifests.

6 declarations

Declared capabilities

This manifest does not declare a capability catalogue. Use the guide, import map and source to assess the package.

Scripts

  • buildcontractspec-bun-build build
  • typechecktsgo --noEmit
  • testbun test src/
  • lintnode ../../scripts/biome.cjs check --write .
  • lint:checknode ../../scripts/biome.cjs check .
  • cleanrimraf dist .turbo
  • perf:ciplaywright test --config playwright.config.ts
  • perf:serverbun perf/perf-server.ts
  • test:e2eplaywright test --config playwright.showcase.config.ts
  • build:bundlecontractspec-bun-build transpile
  • build:typescontractspec-bun-build types