mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-30 21:36:46 -06: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:
@@ -65,6 +65,18 @@ pub enum PropDef {
|
||||
},
|
||||
}
|
||||
|
||||
/// A component's properties in the order they show: the names in `order` first (as they were
|
||||
/// made; renaming keeps the place), then any others by name (files from before the order was kept).
|
||||
pub fn ordered_props<'a>(props: &'a BTreeMap<String, PropDef>, order: &[String]) -> Vec<(&'a String, &'a PropDef)> {
|
||||
let mut out: Vec<(&String, &PropDef)> = Vec::with_capacity(props.len());
|
||||
for (k, d) in order.iter().filter_map(|k| props.get_key_value(k)).chain(props.iter()) {
|
||||
if !out.iter().any(|(o, _)| *o == k) {
|
||||
out.push((k, d));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// What a node is, with per-type data.
|
||||
// Text sets the size; the lint counts the gap to the next largest variant, which grew only because
|
||||
// Page's guides moved to the node (#1476).
|
||||
@@ -115,6 +127,9 @@ pub enum NodeKind {
|
||||
description: String,
|
||||
#[serde(default)]
|
||||
props: BTreeMap<String, PropDef>,
|
||||
/// The order `props` show in, as they were made: see [`ordered_props`].
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
prop_order: Vec<String>,
|
||||
},
|
||||
ComponentSet {
|
||||
#[serde(default)]
|
||||
|
||||
Reference in New Issue
Block a user