M3: clarify what creating a variant property does (#3020) (#3036)

This commit is contained in:
skylar taylor
2026-12-05 04:05:53 -06:00
committed by GitHub
parent a751ae968d
commit 3cd554df51
4 changed files with 29 additions and 1 deletions
+1
View File
@@ -2012,6 +2012,7 @@ name = "English"
"Variables JSON…" = "Variables JSON…"
"Variables store reusable values (colours, numbers, strings, booleans) with modes such as Light and Dark." = "Variables store reusable values (colours, numbers, strings, booleans) with modes such as Light and Dark."
"Variant" = "Variant"
"Variant (creates a component set)" = "Variant (creates a component set)"
"Vector" = "Vector"
"Vectors" = "Vectors"
"Version" = "Version"
@@ -60,6 +60,32 @@ fn a_component_sets_properties_fit_the_narrowest_panel() {
assert!(!fields.iter().any(|v| v == "Tonal" || v == "Hover"), "no value fields in the panel: {fields:?}");
}
#[test]
fn the_create_property_menu_offers_boolean_first_and_leaves_the_component_on_its_own() {
let mut s = Session::new();
let frame = id(s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 80, "height": 40, "name": "Button"})).unwrap());
let main = id(s.execute("component.create", &json!({"ids": [frame]})).unwrap());
s.execute("select.set", &json!({"ids": [main]})).unwrap();
let mut u = Ui::new(s);
u.ctx.enable_accesskit();
let nodes = tree(&mut u);
let create = nodes.iter().find(|n| n.label() == Some("Create component property") && n.bounds().is_some()).expect("the create button");
click(&mut u, centre(create));
let nodes = tree(&mut u);
let item =
|text| nodes.iter().find(|n| n.role() == Role::MenuItem && n.label() == Some(text) && n.bounds().is_some()).expect("the property menu item");
let boolean = item("Boolean");
let variant = item("Variant (creates a component set)");
assert!(centre(boolean).y < centre(variant).y, "Boolean precedes Variant in the property menu");
click(&mut u, centre(boolean));
let doc = u.app.session.doc().unwrap();
let node = doc.node(main).unwrap();
assert_eq!(node.name, "Button", "the component keeps its name");
assert!(figcraft_engine::components::variant_set(doc, main).is_none(), "the component is still on its own");
assert!(figcraft_engine::components::prop_list(doc, main).iter().any(|(_, def)| matches!(def, figcraft_doc::PropDef::Boolean { .. })));
}
#[test]
fn the_edit_property_window_renames_a_value_and_adds_one() {
let (mut u, set, variants) = button_set();
+1 -1
View File
@@ -344,8 +344,8 @@ fn properties_ui(app: &mut FigApp, ui: &mut Ui, doc: &Document, owner: NodeId) {
menu_popup(&plus).width(180.0).show(|ui| {
let swap_default = comps.iter().map(|(c, _)| *c).find(|c| *c != owner && first != Some(*c));
let items: [(&str, &str, Value); 4] = [
(tr("Variant"), "variant", json!("Default")),
(tr("Boolean"), "boolean", json!(true)),
(if is_set { tr("Variant") } else { tr("Variant (creates a component set)") }, "variant", json!("Default")),
(tr("Text"), "text", json!("Text")),
(tr("Instance swap"), "instanceSwap", swap_default.map(|c| json!(c.0)).unwrap_or(Value::Null)),
];
+1
View File
@@ -85,6 +85,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`.
| Date | Change | Summary |
|---|---|---|
| 2026-12-04 | patch | M3, #3020: the Create component property menu offers Boolean first and says that Variant creates a component set when used on a lone component. Test: `component_set_narrow_tests::the_create_property_menu_offers_boolean_first_and_leaves_the_component_on_its_own`. |
| 2026-12-04 | patch | M3, #3030: a file imported from Figma keeps the mains of library components on its hidden library page, bound to the file's own variables. Deleting such a variable, its collection or a mode was refused as an edit of a library copy, so the variables couldn't be removed. Those three deletions now also drop the copies' references to what they delete; the copies keep the values they show, and every other edit of a library copy, or of a library variable, stays refused. Test: `variables_editor_tests::deleting_local_variables_reaches_library_copies_using_them`. |
| 2026-12-04 | patch | M3, #3020: one variant of a set selected showed only its variant properties, so a boolean, text or instance swap property added to the set looked missing until an instance was selected. The Current variant section now also lists the set's boolean, text and instance swap properties, each with its type icon and default (True / False, the text, the component's name), read out with the property's name; a slot, which has no default, isn't listed. They are still edited on the set, which the section's button selects (#2346). Test: `component_set_narrow_tests::a_selected_variant_lists_the_sets_boolean_and_text_properties`. |
| 2026-12-04 | patch | M3: an instance scaled with the Scale tool (an 18 × 18 icon from a 24 × 24 set) lost its scale when it switched to another variant or was swapped to another main: the box kept its size, but the new main's layers showed at the main's scale and ran out of it. The scale lives in the instance's layers as overrides (#922), which the other main's layers don't have. The rebuild after a switch now takes a scaled instance back to its main's scale, rebuilds it, slot content included, and scales it again about its top-left corner, so every layer shows at the instance's scale and its `scale_factor` stays. An instance whose factor stayed 1 (scaled in a file from Figma, or before instances kept a factor) is read by its layers: when its box and every layer share one factor against the old main's layers, that factor is the scale it keeps. The same held when the main changed under a scaled instance, in its file or through a library update: a layer the main gained showed at the main's scale, and a layer the main resized kept its old size, its scaled size being an override. Every rebuild of a scaled instance now goes through its main's scale, dropping the overrides only the scale made (sizes, places, stroke weights, corner radii equal to the main's), and the patch that carries geometry, strokes, corners or effects to copies leaves an instance scaled in the document before the edit to that rebuild. Tests: `variant_scale_tests` (6). |