Add a list slot
A section has to hold a repeating thing — slides, features, comparable sales — and the count is the property's, not yours.
Goal
A gallery whose slides are items the user can edit one at a time: a photo and a caption per slide, chosen and written by the platform, rendered as a marked item each — and, beside it, a list that is the property's own table.
Prerequisites
- The workspace Start leaves you with, and
concrete devrunning. - Slots for the kinds of list, emptiness and the marked-empty branch, and The marker contract for why an item is marked at all.
Steps
1. Choose the source, then the item
A list answers two questions, and each has its own option. Its source says
which elements the list holds and in what order. Its item says what each
item is made of.
The source is any list:
- a table of the property,
fact.property.units— every row, live, and the list edits the table; - another list slot — a sibling's const, or another section's list, read off its
slots; - a list-valued member of a row,
unit.floor_plans; - a
compute()returning a list; - a fill:
fill.pick()picks from its item's candidates,fill.write()writes values of the item's kind,fill.find()finds places or addresses.
With no source, the user builds the list by hand. A gallery of the property's
photos is a pick: the property's media lists are never a list's source, so
fill.pick() chooses out of the one the item names as its from,
item: image({ from: fact.property.property_media }).
The item is a plain slot (item: image()), or a function of the element,
(el) => …, called once to declare the shape every item takes: a value slot
reading the element, or an object() grouping several fields. Leave item out
and the items are the elements themselves. A list fill.pick fills takes a plain
item, never a function: the item itself, or exactly one field of its object,
holds the candidates the pick chooses out of — a media slot's, a select's or a
row's by its from — and a picked list whose item is a
row of a table is a selection of that table's rows.
The item decides the editing. A list of single values is edited as one card, the whole list at once; a list of objects is edited item by item, each a card of its own fields. Reach for an object whenever an item has two things a user would want to change separately.
Depth is fixed: an item is never a list, an object's field is never an object, and
a list of objects as an object's field — a unit's floor plans in a unit card — nests
one level and is one field of that card
(Nest a list inside an object;
contract/list-scalar,
contract/object).
2. Declare a list the platform fills
import { fact, fill, image, list, object, text } from "@homepages/concrete";
const photo = image({ label: "Photo", crop: { mode: "locked", aspect: 4 / 3 }, from: fact.property.property_media });
const slides = list({
label: "Slides",
min: 3,
max: 8,
source: fill.pick({
brief: "The rooms that sell this home, exterior first, no two of the same room.",
}),
item: object({
label: text.short({ cap: 80, source: fill.write({ reads: [fact.property.description, photo], brief: "Name the single subject of this photo — the room, space or view it is of. Answer with the bare value alone, never a sentence. Plain and concrete, never salesy." }) }),
fields: { photo },
}),
});The list's fill decides the set; the item decides each slide. The
fill.pick on the list chooses which photos, in what order — its brief is where
"exterior first" and "no two of the same room" belong, and its candidates are the
item's one media field's, photo's — the property's photos, by its from —
as every pick's are its holder's. A pick never
repeats a candidate; unique: false lifts that. A filled list is an open supply,
so it declares max (contract/fill-verb); min
and max are the only count there is, and a min above max is
contract/list-scalar.
The item's photo field holds the element — one picked photo — and every other
field reads it by that const: the caption's write puts photo in its
reads, so each caption is written against the photo it sits under. The caption
is the object's label, a text slot whose source is a fill.write — the slot is
the kind the write produces, its cap the budget. The editor titles each card with
it, and it is stored as the item's locked field keyed label, read in render as item.label. A caption the user edits is instead
one of the item's fields, which the label names by its const. Without a label, the
sidebar shows "Slide 1", "Slide 2". An object's fields appear in the order you declare them,
and two adjacent short fields share one row, exactly as a section's slots do.
A list of single values takes the same source and a plain item:
import { fact, fill, image, list, text } from "@homepages/concrete";
const gallery = list({
label: "Gallery",
max: 12,
source: fill.pick({ brief: "The strongest twelve photos, exterior first." }),
item: image({ from: fact.property.property_media }),
});
const features = list({
label: "Features",
max: 8,
source: fill.write({ reads: [fact.property.description], brief: "What sells this home, one short phrase each." }),
item: text.short({ cap: 40 }),
});A written list's item is the kind it writes, with the cap every item is written
to, as a picked list's item holds the candidates it picks out of — a fill names no kind
or candidates of its own, because both are its holder's
(AI fill).
3. Declare a list that is the property's table
A list sourced by a table has no set to decide: the items are the property's own
rows, and adding, removing or reordering one edits the table. Its item function
receives each row's element; row({ from: fact.property.units, source: el })
holds it — its from restating the list's table — and is the only way to read
its members:
import { fact, list, number, object, row, text } from "@homepages/concrete";
const units = list({
label: "Units",
source: fact.property.units,
item: (el) => {
const unit = row({ label: "Unit", from: fact.property.units, source: el });
const name = text.medium({ label: "Unit name", cap: 40, source: unit.label });
return object({
label: name,
fields: {
unit,
name,
beds: number({ label: "Beds", source: unit.beds }),
},
});
},
});The row sits among the object's own fields, and its members are read only there
(contract/row-rule). The row is the item card's
bar in the editor and owes the canvas no marker; locked: true hides the bar, and
the fields still read the row. A property fact is the same value in every item,
so it is never an item field's source:; it goes in a field fill's reads.
A pick of a table's rows, its item a row of that table, is a selection, and
another list can take it as its source and show each selected row:
import { fact, fill, list, object, row, text } from "@homepages/concrete";
const selected = list({
label: "Shown comparables",
max: 8,
source: fill.pick({ brief: "The nearest sold comparables, closest first." }),
item: row({ label: "Comparable", from: fact.property.comparables }),
});
const rivals = list({
label: "Competing listings",
source: selected,
item: (el) => {
const comp = row({ label: "Comparable", from: fact.property.comparables, source: el, locked: true });
return object({
label: comp.address.street,
fields: { comp, listed: text.short({ label: "Listed", source: comp.listed_date }) },
});
},
});Both are slots of one section, selected beside rivals; the source is the
sibling's own const (contract/list-source).
4. Render it — the list, the items, the fields
Three primitives, one worked example. Slot.List marks the list, bindItems
turns it into one binding per item, and Slot.Object over an item is what makes
that item an editor card:
import { bindItems, fact, fill, image, list, object, Section, section, Slot, text } from "@homepages/concrete";
const photo = image({ label: "Photo", from: fact.property.property_media });
export const Gallery = section(
{
key: "gallery",
label: "Gallery",
slots: {
slides: list({
label: "Slides",
max: 8,
source: fill.pick({ brief: "The rooms that sell this home." }),
item: object({
label: text.short({ cap: 80, source: fill.write({ reads: [fact.property.description, photo], brief: "Name what it shows." }) }),
fields: { photo },
}),
}),
},
},
({ slot }) => (
<Section>
<Slot.List slot={slot.slides} as="ul" className="grid grid-cols-3 gap-4">
{bindItems(slot.slides).map((item) => (
<Slot.Object key={item.index} slot={item} as="li">
<Slot.Image slot={item.photo} className="aspect-[4/3] w-full" />
<Slot.Text slot={item.label} as="figcaption" />
</Slot.Object>
))}
</Slot.List>
</Section>
),
);Iteration itself is plain React — a filter, a slice, two layout branches are all
fine — because an item binding is an ordinary value. What is not optional is
going through bindItems: an index into the raw value carries no identity, and a
Slot.* handed a bare value has no marker to emit
(render/missing-slot-marker). Every field
of an object item renders through its own binding, item.<field>, inside
its own item's Slot.Object
(render/group-ancestry), or is declared
locked: true.
Slot.Object takes the item's binding and nothing else — an item's identity is
its index, and its card's title is the object's label. It accepts only an object
item: a list of single values has no per-item card in the editor, so an item
of one is a compile error there. Render those items as plain elements and let
Image, Video or Tour draw the value.
5. State a couple of items in the fixture
A list of objects takes an array of items in a content fixture, each stating the fields it sets, graded against the section's own declaration (Write a fixture). The field holding the element states the element — here, the photo, as a pick of one of the property's uploads. For a gallery placed once:
{
"$schema": "../.concrete/schema/content-fixture.schema.json",
"property": "properties/starter/property.json",
"content": {
"gallery-1": {
"slots": {
"slides": [
{ "photo": { "media": "exterior-front" }, "label": "The front, from the street" },
{ "photo": { "media": "kitchen" }, "label": "The kitchen island" }
]
}
}
}
}A list sourced by a table states only the fields a fill writes, item by item in the table's own order; the fields its row binds stay the property's.
Verify
Run concrete dev. The sidebar shows one card per slide, titled by its caption,
with add and remove controls at any count (min and max withhold neither, so the
render shows every item); selecting a photo on the
canvas selects that item's field, not the whole list.
Then run concrete check. The contracts stage grades the source, the item, the
bounds and the fill, and the render stage grades the markers over every fixture
and its synthesized empties:
concrete check passed: 13 stages.Add an address slot
A section shows where the home is — two postal lines, a short label, the city — and the parts must never disagree with each other or with the pin.
Nest a list inside an object
Each card holds a few things of its own — a unit's floor plans, each with its floor — and they belong to that card, not to the section.
