PlotDirector/Docs/UI/AttributesPanel.md

3.6 KiB

Shared Attributes panel standard

The Locations tool palette is the visual standard for Attributes: compact rows, semantic icons, aligned count and Assign columns, modest hover/active styling and independently scrolling panels. Characters and Locations use the same attributes-panel.js renderer and attributes-panel.css. Do not copy either workspace's former palette CSS. Character cards/biographies are outside this component.

Composition

PlotDirectorAttributesPanel.mount(host, options) returns update({counts: true}). Pass groups with {id,label,editable,values}. A value has {value,label,key?,parentKey?,assignable?} and the consumer's icon presentation fields. Optional keys/parents form nested categories. The renderer preserves supplied order; the canonical provider owns ordering. A non-assignable category can still filter its descendants. The expand button operates independently of its filter button and Assign.

Supply these callbacks:

  • icon(value) returns a safe DOM/SVG node. Do not interpolate labels into HTML.
  • count(group,value) and isActive(group,value) derive current filter state.
  • onFilter(group,value) applies a consumer-defined filter and refreshes the workspace.
  • onAssign(group,value) executes the consumer's targeted single/bulk command.
  • onDragStart(event,group,value) supplies that workspace's drag payload/preview.
  • canEdit(), busy(), hasSelection() determine editable controls and drag state.
  • isExpanded(key,fallback) and onExpansion(key,open) use workspace-scoped preferences.

recordLabel customises accessible Assign labels. rowClass is an optional compatibility class. Rows expose data-attribute, data-value and data-assignable; consumers retain their existing record drop handlers. Only data-assignable=true accepts record drops. Consumers supply valid/invalid drop feedback using is-drop-target / is-invalid-target and must enforce server validation. The entire row/filter surface supports dragging; Assign and expansion controls do not start drags.

Keep records, selection, filters, counts, no-op rules, concurrency, ownership, server requests, Undo receipts, context commands and live refresh in the consumer. The shared renderer knows no character/location-specific attribute names. update({counts:false}) updates controls without recomputing aggregates during selection changes. Do not remount after every local record update.

Layout, preferences and themes

Compose with PlotDirectorWorkspaceSurface.split or an existing workspace profile for panel widths and dividers. The palette does not create a second resize/persistence mechanism. The consuming aside owns independent scrolling and collapse/restore. Scope preferences to the author/workspace; project-specific expansion keys must also contain project ID.

Characters retain their existing width/collapse keys and group order. Their expansion map is pd.character.attributes.v1.<user>.<project>.groups. Locations retain pd.locations.workspace.v1.<user>.<project> and the existing divider scope; nested expansion keys are type:<TypeKey>. These do not collide with character group keys.

Shared theme tokens supply colours. A container query adapts indentation, spacing and fixed columns at narrow widths. Labels wrap to two lines with a complete tooltip; count/Assign columns stay aligned. Native details/summary, buttons, pressed states and focus outlines provide keyboard alternatives. Future Assets adoption should supply its own groups, state, commands and drag payload, compose the existing divider, and use this renderer. No Assets implementation is included in this change.