Skip to content

feat(joint-react): set sensible Paper defaults and refine theme#3245

Merged
kumilingus merged 5 commits intoclientIO:devfrom
kumilingus:feat/paper-defaults
Mar 25, 2026
Merged

feat(joint-react): set sensible Paper defaults and refine theme#3245
kumilingus merged 5 commits intoclientIO:devfrom
kumilingus:feat/paper-defaults

Conversation

@kumilingus
Copy link
Contributor

@kumilingus kumilingus commented Mar 24, 2026

Summary

Paper defaults via PresetPaper base class

  • Extract all Paper defaults into a new PresetPaper class (dia.Paper.extend(...)) that PortalPaper now extends
  • Required (not overridable): async, sorting, frozen, autoFreeze, viewManagement
  • Overridable defaults: linkPinning=false, gridSize=10, clickThreshold=5, snapLinks={radius:15}, markAvailable=true, drawGrid=true, preventDefaultBlankAction=false, defaultConnectionPoint, measureNode
  • Remove ~40 lines of default-merging logic from PaperStore constructor — it now just passes paperOptions through
  • Inject --jr-paper-grid-color CSS custom property into all built-in grid patterns

Highlighting presets

  • Move highlighting config from PaperStore to PresetPaper as DEFAULT_HIGHLIGHTING
  • Default highlight uses CSS-driven stroke highlighter with --jr-paper-highlight-color
  • Magnet/element availability now use addClass highlighter (jr-available-magnet, jr-available-element) instead of stroke — enables CSS-only theming

Theme CSS updates

  • Link wrapper default width: 010 (clickable hit area)
  • Link line: add stroke-linecap fallback ('butt'), remove stroke-linejoin (handled by markup)
  • Port outline defaults: transparent/0#EFF2F5/2 (visible outline)
  • Add .jr-port-body.jr-available-magnet rule with --jr-port-available-color
  • Add .jr-available-element .jr-element rule with --jr-element-available-border

Portal link markup cleanup

  • Remove redundant inline stroke: 'transparent' and strokeLinecap: 'round' from wrapper markup — now handled by CSS theme

Consolidate duplicated data mappers

  • flatMapDataToElementAttributes / flatMapLinkAttributesToData (internal) now delegate to flatElementDataToAttributes / flatAttributesToElementData (public), eliminating ~150 lines of copy-pasted logic
  • Internal wrappers add only id (forward) or default-value filtering (reverse)
  • Fixes divergence: attrs.root.magnet: false for ports is now applied consistently (was missing in internal mapper)
  • Remove stray debugger statement

Minor cleanup

  • Rename createPortDefaultscreatePortGroupsDefault
  • import { dia, mvc }import type { dia } in portal-paper (remove unused mvc)
  • (keyof T)[]Array<keyof T>, rename abbreviated variables in useFlatElementData

Storybook: dark theme demo

  • Add dark theme toggle to with-default-element story
  • New dark-theme.css with CSS variable overrides demonstrating full theme customization

Test plan

  • Verify Paper renders with new defaults (grid visible, links not pinnable, click threshold feels responsive)
  • Verify paperOptions overrides still take effect (e.g. gridSize={1})
  • Verify port/element availability highlighting uses CSS classes
  • Verify highlighting={false} still disables all highlighting
  • Verify link wrapper is clickable (10px hit area)
  • Verify port outlines are visible by default
  • Verify elements with ports have attrs.root.magnet: false set consistently
  • Verify dark theme toggle works in with-default-element storybook
  • data-mapper.test.ts and use-flat-link-data.test.ts pass

🤖 Generated with Claude Code

Set overridable defaults for Paper: linkPinning=false, gridSize=10,
clickThreshold=5, snapLinks={radius:15}, markAvailable=true. Simplify
highlighting merge logic. Update theme CSS with port availability
styling and link wrapper defaults.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kumilingus kumilingus marked this pull request as draft March 24, 2026 21:14
@kumilingus kumilingus requested a review from samuelgja March 24, 2026 23:10
@kumilingus kumilingus marked this pull request as ready for review March 24, 2026 23:10
@kumilingus kumilingus merged commit 6d2a31f into clientIO:dev Mar 25, 2026
@kumilingus kumilingus deleted the feat/paper-defaults branch March 25, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants