Skip to content

feat: card list editing, opt-in per field - #1

Open
timBm10c wants to merge 7 commits into
m10c:masterfrom
timBm10c:feat/card-list-editing
Open

feat: card list editing, opt-in per field#1
timBm10c wants to merge 7 commits into
m10c:masterfrom
timBm10c:feat/card-list-editing

Conversation

@timBm10c

@timBm10c timBm10c commented Sep 7, 2026

Copy link
Copy Markdown

A card-based editor for list fields, for the DCG page editor designs. Everything here is opt-in, so Balance renders exactly as it does today.

Ported from markm10c/m10c-content-elements#1, adapted to this repo's flat src/ layout and the @m10c/mui-kit root import.

Schema

  • ListField.variant: 'cards' — each item becomes a summary card with a dialog to edit it: Add capped by maxItems, delete down to minItems, and drag to reorder. inline (the default) is unchanged.
  • ListField.headerFieldKeys — sibling fields of the block rendered under the list's heading, e.g. a subtitle that sits above the cards.
  • ListField.variables — placeholders an admin can type, listed at the top of the item dialog.
  • SimpleField.required / ListField.required — marks the label with an asterisk.
  • BlockType.hideLabel — drops the block heading where its list already provides one.

Props

  • previews — draws a field's saved value on a card. The package can't do this itself: an icon field holds a slug, not a picture.
  • icons — swaps the drag and edit affordances for the app's own icon set.
  • deviceLabels — renames the preview's device sizes, e.g. "Mobile website".

Notes

  • Reordering uses native HTML5 drag rather than dnd-kit: balance-admin is on @dnd-kit/sortable v10 and dcg-admin on v7, so a peer dependency would force one of them to move.
  • ListCardIcons is exported from the barrel, so a consumer can type the icons prop it passes.
  • The first commit bumps @m10c/mui-kit to 0.0.2. ^0.0.1 pinned that version exactly, and 0.0.1 has no root export, so yarn ts and the dts build fail on main as it stands.

timBm10c and others added 7 commits September 7, 2026 11:22
`import { FieldText } from '@m10c/mui-kit'` cannot resolve against
0.0.1, which exports only subpaths, so `yarn ts` and the dts build fail
on a fresh checkout. `^0.0.1` pins that version exactly, being a 0.0.x
range.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A list field could only edit the items its data already held, with every
item's fields listed one after another. Designs for the DCG page editor
call for a card per item, added and deleted by the admin, so `variant:
'cards'` renders each item as a summary card with a dialog to edit it,
capped by `maxItems` and reordered by dragging. Lists left on the
default `inline` render as they always have.

Cards need to show a saved value rather than an input, which the package
cannot always do: an icon field holds a slug, not a picture. `previews`
lets the consumer draw those values, alongside `icons` for the drag and
edit affordances, so an app can use its own icon set.

Fields carry the extras the designs ask of the schema: `required` marks
a label, `hideLabel` drops a heading a block's list already provides,
`headerFieldKeys` pulls a sibling field under the list's heading, and
`variables` lists the placeholders an admin may type. The preview's
device names are overridable too, for sites that call them something
else.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Three follow-ons from fitting the editor to the DCG designs:

A list whose `minItems` equals its `maxItems` cannot grow or shrink, so
it drops the heading, the Add button and the count that only make sense
where an admin chooses how many items there are.

The SEO tab takes `renderers` the way the block editor does, so an app
whose inputs look nothing like these can draw its own without the two
tabs disagreeing.

A renderer is handed the field's `features`, which the schema already
carried but nothing passed on: one rich text field offers lists and
links where another offers bold.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`react` and `react-dom` are already on 19 here while their types were
pinned to 18. The mismatch is invisible to `yarn ts` but surfaces in a
consumer that links this package during development: two copies of
`@types/react` disagree, and the app's own components fail to check.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The DCG designs ask more of a field than text: an image with the
dimensions it should have, a radio group for a review's app store, a
gallery of feature images, a currency prefix on an amount, and a card
that names a part of the page an admin cannot edit at all.

Uploading is the consuming app's, so `image` and `images` pass through
to a renderer, `images` carrying the values it holds alongside the
single value the other kinds use. `choice` and `note` need nothing an
app owns, so they draw themselves.

The preview renders the site at the device's real width and scrolls to
what does not fit, rather than scaling the page down to the pane.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A page that names no image of its own is still shared with one: the
site's default. The preview drew an empty grey block instead, so it
disagreed with what a post would look like.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The chip was a rounded square the favicon filled edge to edge, so the
icon's own corners sat outside it. Search engines draw the favicon inset
inside a circle, so the chip is one too.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant