mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-17 15:47:34 +00:00
M3: component properties keep their order on rename; Make slot asks for the name (#1536, #1537) (#1565)
Properties were listed by name, so a rename moved one. Components now keep prop_order (the names as they were made; a rename keeps the place) and every listing follows it. Make slot opens a name field under the frame's Slot row; Enter makes the slot, Escape cancels, a taken name keeps the field open.
This commit is contained in:
1 parent
3c1718bf86
commit
7d76b0c673
56 files changed
+589
-135
No files matched your search
@@ -76,8 +76,8 @@ impl<'d> Exporter<'d> {
|
||||
// A name used with two types is two properties (their definitions have their own ids).
|
||||
let mut seen: BTreeMap<(String, &'static str), PropDef> = BTreeMap::new();
|
||||
for v in &variants {
|
||||
let NodeKind::Component { props, .. } = &v.kind else { continue };
|
||||
for (name, d) in props {
|
||||
let NodeKind::Component { props, prop_order, .. } = &v.kind else { continue };
|
||||
for (name, d) in figcraft_doc::ordered_props(props, prop_order) {
|
||||
let Some(ty) = prop_type(d) else { continue };
|
||||
match seen.get(&(name.clone(), ty)) {
|
||||
Some(first) if first != d => self.warn("variants with different defaults for one property were written with the first variant's"),
|
||||
|
||||
@@ -109,7 +109,7 @@ impl<'d> Exporter<'d> {
|
||||
self.warn("boolean groups whose layers combine in different ways use the group's operation");
|
||||
}
|
||||
}
|
||||
NodeKind::Component { description, props } if !nested => {
|
||||
NodeKind::Component { description, props, prop_order } if !nested => {
|
||||
if let Some(set) = self.set_of(n.id) {
|
||||
// A variant: its set holds the definitions; the variant has its own copy of
|
||||
// each (pointing at the set's), and its values of the variant properties.
|
||||
@@ -136,7 +136,11 @@ impl<'d> Exporter<'d> {
|
||||
f.push(("variantPropSpecs", arr(specs)));
|
||||
}
|
||||
} else {
|
||||
let defs: Vec<Kv> = props.iter().enumerate().filter_map(|(i, (name, d))| self.prop_def(n.id, name, d, i)).collect();
|
||||
let defs: Vec<Kv> = figcraft_doc::ordered_props(props, prop_order)
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, (name, d))| self.prop_def(n.id, name, d, i))
|
||||
.collect();
|
||||
if !defs.is_empty() {
|
||||
f.push(("componentPropDefs", arr(defs)));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user