mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-29 01:34:37 +01:00
Merge pull request #2660 from storytold/feat/2343-page-background-variable
M7: a page's background can follow a colour variable in the page's mode
This commit is contained in:
9 files changed
+196
-29
No files matched your search
@@ -24,6 +24,37 @@ fn settle(s: &mut Session, cmd: &str) -> crate::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// `page.setBackground`: a colour, or a colour variable the page's background follows in the
|
||||
/// page's variable mode (#2343). Setting a colour detaches the variable.
|
||||
fn set_background(s: &mut Session, p: &Value) -> crate::Result<Value> {
|
||||
let cmd = "page.setBackground";
|
||||
let var = match p.get("color") {
|
||||
Some(Value::Object(o)) => match (o.len(), o.get("$var").and_then(Value::as_str)) {
|
||||
(1, Some(name)) if !name.is_empty() => Some(name),
|
||||
_ => return Err(bad(cmd, "`color`: a `$var` wrapper takes only `$var`, a variable id or name")),
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
let c = if var.is_some() { None } else { Some(color(p, "color").ok_or_else(|| bad(cmd, "`color`: a colour or {$var: variable}"))?) };
|
||||
let id = page_target(s, cmd, p)?;
|
||||
let doc = s.doc_mut()?;
|
||||
match (var, c) {
|
||||
(Some(name), _) => {
|
||||
let vid = super::variables::resolve_strict(cmd, doc, name)?;
|
||||
super::styles::bind_variable(cmd, doc, &[id], "background", Some(&vid))?;
|
||||
super::styles::apply_bindings_to(doc, Some(&std::iter::once(id).collect()));
|
||||
}
|
||||
(None, Some(c)) => {
|
||||
super::styles::bind_variable(cmd, doc, &[id], "background", None)?;
|
||||
if let NodeKind::Page { background, .. } = &mut doc.get_mut(id)?.kind {
|
||||
*background = c;
|
||||
}
|
||||
}
|
||||
(None, None) => {}
|
||||
}
|
||||
ok()
|
||||
}
|
||||
|
||||
/// The page a command targets: the explicit `id` (which must be a page) or the open page.
|
||||
fn page_target(s: &Session, cmd: &str, p: &Value) -> crate::Result<NodeId> {
|
||||
let target = match p.get("id") {
|
||||
@@ -137,14 +168,13 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
doc.pages.insert(k, id);
|
||||
ok()
|
||||
}),
|
||||
spec!("page.setBackground", "Page background", "{id?, color}", true, |s, p| {
|
||||
let c = color(p, "color").ok_or_else(|| bad("page.setBackground", "`color` required"))?;
|
||||
let id = page_target(s, "page.setBackground", p)?;
|
||||
if let NodeKind::Page { background, .. } = &mut s.doc_mut()?.get_mut(id)?.kind {
|
||||
*background = c;
|
||||
}
|
||||
ok()
|
||||
}),
|
||||
spec!(
|
||||
"page.setBackground",
|
||||
"Page background",
|
||||
"{id?, color (a colour, or {$var: colour variable id or name} to bind it; a colour detaches a bound one)}",
|
||||
true,
|
||||
set_background
|
||||
),
|
||||
spec!(
|
||||
"page.setOpening",
|
||||
"Set as opening page",
|
||||
|
||||
@@ -1107,7 +1107,24 @@ pub fn apply_bindings(doc: &mut Document) {
|
||||
|
||||
/// [`apply_bindings`] for the layers `only` (every bound layer when `None`).
|
||||
pub fn apply_bindings_to(doc: &mut Document, only: Option<&std::collections::BTreeSet<NodeId>>) {
|
||||
apply_bindings_matching(doc, only, |_| true);
|
||||
apply_bindings_matching(doc, only, |field| field != "background");
|
||||
apply_page_backgrounds(doc, only);
|
||||
}
|
||||
|
||||
/// Pages whose background is bound to a colour variable (#2343) show its value in the page's own
|
||||
/// variable mode.
|
||||
fn apply_page_backgrounds(doc: &mut Document, only: Option<&std::collections::BTreeSet<NodeId>>) {
|
||||
let bound: Vec<(NodeId, String)> = doc
|
||||
.pages
|
||||
.iter()
|
||||
.filter(|p| only.is_none_or(|o| o.contains(p)))
|
||||
.filter_map(|p| doc.node(*p)?.bound.get("background").map(|v| (*p, v.clone())))
|
||||
.collect();
|
||||
for (page, var) in bound {
|
||||
if let Some(VariableValue::Color(c)) = doc.variables.resolve(&var, &doc.modes_for(page)) {
|
||||
set_page_background(doc, page, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The layers `ids` before an explicit edit, for [`detach_edited`] (only those with bindings).
|
||||
@@ -1454,6 +1471,17 @@ fn apply_bindings_matching(doc: &mut Document, only: Option<&std::collections::B
|
||||
}
|
||||
}
|
||||
|
||||
/// Set page `id`'s background to `c`, leaving the page untouched when it already shows it.
|
||||
fn set_page_background(doc: &mut Document, id: NodeId, c: Color) {
|
||||
let shows = |doc: &Document| matches!(doc.node(id).map(|n| &n.kind), Some(NodeKind::Page { background, .. }) if *background == c);
|
||||
if !shows(doc)
|
||||
&& let Ok(n) = doc.get_mut(id)
|
||||
&& let NodeKind::Page { background, .. } = &mut n.kind
|
||||
{
|
||||
*background = c;
|
||||
}
|
||||
}
|
||||
|
||||
/// Set paint `i`'s colour (or its gradient stop `stop`'s) to a bound colour; a first paint that
|
||||
/// isn't there yet is added.
|
||||
pub(crate) fn set_paint_color(list: &mut Vec<Paint>, i: usize, stop: Option<usize>, c: Color) {
|
||||
|
||||
@@ -764,6 +764,8 @@ pub fn field_scope(doc: &Document, node: NodeId, field: &str) -> Option<&'static
|
||||
"characters" => "TEXT_CONTENT",
|
||||
"fontFamily" => "FONT_FAMILY",
|
||||
"fontStyle" => "FONT_STYLE",
|
||||
// What shows behind a page's frames is filled like a frame.
|
||||
"background" => "FRAME_FILL",
|
||||
f => match super::lists::list_binding(f)? {
|
||||
(BoundList::Strokes, _, _) => "STROKE_COLOR",
|
||||
(BoundList::Effects, _, "color") => "EFFECT_COLOR",
|
||||
@@ -789,6 +791,11 @@ fn effect_field(doc: &Document, node: NodeId, i: usize, field: &str) -> Option<V
|
||||
/// `effects/<i>/<field>` when its effect `i` has that field (a drop shadow has no `refraction`),
|
||||
/// and an `effects…` key naming no effect's field (`effects/x/radius`, `effects/0`) has none.
|
||||
pub fn has_field(doc: &Document, node: NodeId, field: &str) -> bool {
|
||||
// A page's background colour (#2343) is the only field a page binds, and only a page has it.
|
||||
let page = doc.node(node).is_some_and(|n| matches!(n.kind, NodeKind::Page { .. }));
|
||||
if field == "background" || page {
|
||||
return field == "background" && page;
|
||||
}
|
||||
match super::lists::list_binding(field) {
|
||||
Some((BoundList::Effects, i, f)) => effect_field(doc, node, i, f).is_some(),
|
||||
_ => field.split('/').next() != Some(BoundList::Effects.prefix()),
|
||||
|
||||
@@ -479,6 +479,8 @@ mod open_issues_tests;
|
||||
#[cfg(test)]
|
||||
mod outline_options_tests;
|
||||
#[cfg(test)]
|
||||
mod page_background_variable_tests;
|
||||
#[cfg(test)]
|
||||
mod page_clipboard_tests;
|
||||
#[cfg(test)]
|
||||
mod page_copy_navigation_tests;
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
//! A page's background can follow a colour variable in the page's own variable mode (#2343), so
|
||||
//! switching a page to a dark mode turns its canvas dark along with what's on it.
|
||||
|
||||
use figcraft_color::Color;
|
||||
use figcraft_doc::{NodeId, NodeKind};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::Session;
|
||||
|
||||
fn ex(s: &mut Session, cmd: &str, p: Value) {
|
||||
s.execute(cmd, &p).unwrap_or_else(|e| panic!("{cmd}: {e}"));
|
||||
}
|
||||
|
||||
fn background(s: &Session, page: NodeId) -> Color {
|
||||
match s.doc().unwrap().node(page).map(|n| &n.kind) {
|
||||
Some(NodeKind::Page { background, .. }) => *background,
|
||||
_ => panic!("not a page"),
|
||||
}
|
||||
}
|
||||
|
||||
/// A session with a Light/Dark `page-bg` colour variable, and its current page.
|
||||
fn themed() -> (Session, NodeId, Color, Color) {
|
||||
let mut s = Session::new();
|
||||
ex(&mut s, "variable.createCollection", json!({"name": "Theme", "modes": ["Light", "Dark"]}));
|
||||
ex(&mut s, "variable.create", json!({"collection": "Theme", "name": "page-bg", "type": "color", "value": "#F5F4F1"}));
|
||||
ex(&mut s, "variable.set", json!({"variable": "page-bg", "mode": "Dark", "value": "#141413"}));
|
||||
let page = s.page().unwrap();
|
||||
let (light, dark) = (Color::from_hex_or_name("#F5F4F1").unwrap(), Color::from_hex_or_name("#141413").unwrap());
|
||||
(s, page, light, dark)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bound_page_background_follows_the_pages_mode() {
|
||||
let (mut s, page, light, dark) = themed();
|
||||
ex(&mut s, "page.setBackground", json!({"color": {"$var": "page-bg"}}));
|
||||
assert_eq!(background(&s, page), light, "the collection's default mode");
|
||||
|
||||
ex(&mut s, "variable.setMode", json!({"ids": [page.0], "collection": "Theme", "mode": "Dark"}));
|
||||
assert_eq!(background(&s, page), dark, "the page's own mode");
|
||||
|
||||
// A new value for the mode the page shows reaches the page too.
|
||||
ex(&mut s, "variable.set", json!({"variable": "page-bg", "mode": "Dark", "value": "#202020"}));
|
||||
assert_ne!(background(&s, page), dark);
|
||||
assert_eq!(background(&s, page), Color::from_hex_or_name("#202020").unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_colour_detaches_the_variable_and_undo_brings_it_back() {
|
||||
let (mut s, page, _, dark) = themed();
|
||||
ex(&mut s, "page.setBackground", json!({"color": {"$var": "page-bg"}}));
|
||||
ex(&mut s, "page.setBackground", json!({"color": "#FF0000"}));
|
||||
let red = Color::from_hex_or_name("#FF0000").unwrap();
|
||||
assert_eq!(background(&s, page), red);
|
||||
// Detached: a mode switch leaves the colour alone.
|
||||
ex(&mut s, "variable.setMode", json!({"ids": [page.0], "collection": "Theme", "mode": "Dark"}));
|
||||
assert_eq!(background(&s, page), red);
|
||||
|
||||
s.undo().unwrap();
|
||||
s.undo().unwrap();
|
||||
assert!(s.doc().unwrap().node(page).unwrap().bound.contains_key("background"), "the binding is back");
|
||||
ex(&mut s, "variable.setMode", json!({"ids": [page.0], "collection": "Theme", "mode": "Dark"}));
|
||||
assert_eq!(background(&s, page), dark);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_a_colour_variable_binds_and_only_a_page_has_a_background() {
|
||||
let (mut s, page, _, _) = themed();
|
||||
ex(&mut s, "variable.create", json!({"collection": "Theme", "name": "gap", "type": "number", "value": 8}));
|
||||
assert!(s.execute("page.setBackground", &json!({"color": {"$var": "gap"}})).is_err());
|
||||
assert!(s.execute("page.setBackground", &json!({"color": {"$var": "nope"}})).is_err());
|
||||
assert!(s.execute("page.setBackground", &json!({"color": {"$var": "page-bg", "x": 1}})).is_err());
|
||||
assert!(!s.doc().unwrap().node(page).unwrap().bound.contains_key("background"), "a refused call binds nothing");
|
||||
|
||||
// The same binding through `variable.bind`, as the Design panel's variable button runs it.
|
||||
ex(&mut s, "variable.bind", json!({"ids": [page.0], "field": "background", "variable": "page-bg"}));
|
||||
assert!(s.doc().unwrap().node(page).unwrap().bound.contains_key("background"));
|
||||
let frame = s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap();
|
||||
let frame = frame["id"].as_u64().unwrap();
|
||||
assert!(s.execute("variable.bind", &json!({"ids": [frame], "field": "background", "variable": "page-bg"})).is_err());
|
||||
}
|
||||
@@ -357,10 +357,18 @@ fn page_section(app: &mut FigApp, ui: &mut Ui, doc: &Document) {
|
||||
widgets::section_header(ui, tr("Page"), &[], false);
|
||||
// The new colour and, from a scrub, whether the scrub is over (live edits stay one undo step).
|
||||
let mut new_color: Option<(figcraft_color::Color, Option<bool>)> = None;
|
||||
// The colour variable the background follows in the page's mode (#2343), as a fill shows one.
|
||||
let bound = crate::variable_ui::bound_name(doc, &[page], "background");
|
||||
row(ui, 32.0, |ui| {
|
||||
let p = Paint::solid(bg);
|
||||
let mut hex_area = None;
|
||||
let (sw, opacity) =
|
||||
widgets::paint_field(ui, Id::unique("pagebg_swatch"), Id::unique("pagebg_a"), &p, ui.available_width(), |child, text_r| {
|
||||
if let Some(name) = &bound {
|
||||
crate::variable_ui::paint_chip(app, child, &[page], "background", name, text_r, Id::unique("pagebg_bound"));
|
||||
return;
|
||||
}
|
||||
hex_area = Some(text_r);
|
||||
// A typed colour keeps the page's opacity unless it carries one: 4 or 8 hex digits
|
||||
// (`FF000080`; `FF0000FF` asks for opaque).
|
||||
if let Some(h) = widgets::text_field_inline(child, Id::unique("pagebg"), &bg.to_hex(), text_r.shrink2(vec2(0.0, 4.0)), regular(11.0))
|
||||
@@ -371,6 +379,9 @@ fn page_section(app: &mut FigApp, ui: &mut Ui, doc: &Document) {
|
||||
new_color = Some((if carries_alpha { c } else { c.with_alpha(bg.a) }, None));
|
||||
}
|
||||
});
|
||||
if let Some(area) = hex_area {
|
||||
crate::variable_ui::bind_button(ui, area, &[page], "background", VariableType::Color);
|
||||
}
|
||||
app.picker_control(crate::colorpicker::PickerTarget::PageBackground, &sw);
|
||||
// The opacity: a field like every other opacity field, not a label (#1748).
|
||||
let alpha = |v: f64| bg.with_alpha((v / 100.0).clamp(0.0, 1.0) as f32);
|
||||
|
||||
@@ -2,7 +2,7 @@ use super::menu::{blend_menu, context_popup, menu_check, menu_item, menu_popup,
|
||||
use super::stroke::stroke_settings;
|
||||
use super::{
|
||||
Align2, BlendMode, CornerRadius, Document, FIELD_H, FieldEdit, FigApp, Icon, Id, Lead, ListDrag, MaskType, Node, NodeId, NodeKind, Paint,
|
||||
PaintKind, Rect, Sense, Stroke, StrokeAlign, StyleSlot, Tip, Tokens, Ui, Value, VariableType, common, icons, json, moved_index, pos2, regular,
|
||||
PaintKind, Rect, Sense, StrokeAlign, StyleSlot, Tip, Tokens, Ui, Value, VariableType, common, icons, json, moved_index, pos2, regular,
|
||||
removed_index, style_picker, tr, trf, vec2, widgets,
|
||||
};
|
||||
use crate::property_rows::PropertyKind;
|
||||
@@ -501,24 +501,7 @@ fn paint_row(app: &mut FigApp, ui: &mut Ui, ids: &[NodeId], i: usize, p: &Paint,
|
||||
match &p.kind {
|
||||
PaintKind::Solid { .. } if bound.is_some() => {
|
||||
let (key, name) = bound.clone().unwrap_or_default();
|
||||
let chip = Rect::from_min_max(pos2(text_r.min.x - 2.0, r.min.y + 3.0), pos2(text_r.max.x - 20.0, r.max.y - 3.0));
|
||||
child.painter().rect_filled(chip, CornerRadius::same(4), t.hover);
|
||||
child.painter().rect_stroke(chip, CornerRadius::same(4), Stroke::new(1.0, t.border), egui::StrokeKind::Inside);
|
||||
let short = name.rsplit('/').next().unwrap_or(&name).to_string();
|
||||
child.painter().with_clip_rect(chip.shrink2(vec2(5.0, 0.0))).text(
|
||||
pos2(chip.min.x + 5.0, r.center().y),
|
||||
Align2::LEFT_CENTER,
|
||||
short,
|
||||
regular(11.0),
|
||||
t.text,
|
||||
);
|
||||
let _ = child.interact(chip, Id::unique(("bound_paint", fills, i)), Sense::hover()).on_hover_text(&name);
|
||||
let dr = Rect::from_center_size(pos2(text_r.max.x - 9.0, r.center().y), vec2(18.0, 18.0));
|
||||
let dresp = child.interact(dr, Id::unique(("detach_paint", fills, i)), Sense::click()).tip(tr("Detach variable"));
|
||||
icons::paint(child.painter(), dr.shrink(3.0), Icon::Detach, t.icon_secondary);
|
||||
if dresp.clicked() {
|
||||
app.run("variable.bind", json!({"ids": ids, "field": key, "variable": null}));
|
||||
}
|
||||
crate::variable_ui::paint_chip(app, child, &ids, &key, &name, text_r, Id::unique(("bound_paint", fills, i)));
|
||||
}
|
||||
PaintKind::Solid { color } => {
|
||||
if let Some(h) = widgets::text_field_inline(
|
||||
|
||||
@@ -353,6 +353,31 @@ pub fn bindable(
|
||||
bind_button(ui, area, ids, field, kind);
|
||||
}
|
||||
|
||||
/// In a paint field's text area `text_r`: the chip of the colour variable `name` that `key` of
|
||||
/// `ids` is bound to (its last path part, the whole name on hover) and a button that detaches it.
|
||||
pub fn paint_chip(app: &mut FigApp, ui: &mut Ui, ids: &[NodeId], key: &str, name: &str, text_r: Rect, id: Id) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let r = ui.max_rect();
|
||||
let chip = Rect::from_min_max(pos2(text_r.min.x - 2.0, r.min.y + 3.0), pos2(text_r.max.x - 20.0, r.max.y - 3.0));
|
||||
ui.painter().rect_filled(chip, CornerRadius::same(4), t.hover);
|
||||
ui.painter().rect_stroke(chip, CornerRadius::same(4), Stroke::new(1.0, t.border), egui::StrokeKind::Inside);
|
||||
let short = name.rsplit('/').next().unwrap_or(name).to_string();
|
||||
ui.painter().with_clip_rect(chip.shrink2(vec2(5.0, 0.0))).text(
|
||||
pos2(chip.min.x + 5.0, r.center().y),
|
||||
Align2::LEFT_CENTER,
|
||||
short,
|
||||
regular(11.0),
|
||||
t.text,
|
||||
);
|
||||
let _ = ui.interact(chip, id, Sense::hover()).on_hover_text(name);
|
||||
let dr = Rect::from_center_size(pos2(text_r.max.x - 9.0, r.center().y), vec2(18.0, 18.0));
|
||||
let dresp = ui.interact(dr, id.with("detach"), Sense::click()).tip(tr("Detach variable"));
|
||||
icons::paint(ui.painter(), dr.shrink(3.0), Icon::Detach, t.icon_secondary);
|
||||
if dresp.clicked() {
|
||||
app.run("variable.bind", json!({"ids": ids, "field": key, "variable": null}));
|
||||
}
|
||||
}
|
||||
|
||||
/// A variable button at the right end of `rect` while the pointer is over it: opens the picker
|
||||
/// to bind `field` of `ids`.
|
||||
pub fn bind_button(ui: &mut Ui, rect: Rect, ids: &[NodeId], field: &str, kind: VariableType) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Components, variants, styles and variables parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-27 · **Change:** minor (Swap library re-points the styles and variables of the library copies that stay, so instances placed after a swap follow it too (#2568); the Local variables window reorders variables: Move up and Move down (Alt+↑ / Alt+↓) on a row, Sort A to Z and Z to A on a collection or group, numbers by value (#2633); `library.swap` lists the unused copies of the old library it removes in `dropped` (#2569); with several instances selected, the Design panel shows the properties they share, Mixed where their values differ, and sets a value on all of them; an enabled library's styles are offered in the style pickers without opening the Assets tab first, and the picker filters its list by source (All libraries, This file, one library); with a variable group shown in the Local variables window, Create variable makes the variable in that group, and renaming a variable in its row changes the part shown and keeps its group; a layer inside an instance bound to a variable its main layer doesn't bind keeps that binding as an override when instances are relinked after an import, a detach or a restore, and when its value is set back to the main's, so a library copy or an edit of the main no longer drops it; switching variants keeps the text typed into an instance when the other variant nests that text layer in other frames, matched by its name; a main component copied from a library file and pasted into another file is an instance of it from that library, instead of a new main; copied variants pasted with their own set, or a layer in it, selected join the set as new variants; the Scale tool keeps variable-bound lengths scaled: a scaled instance keeps its bindings and draws them at the variable's value times its scale factor, other scaled layers keep the scaled value and drop the binding (#2090); a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when another object is named like their id (follow-up to #1542); a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every Line truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-27 · **Change:** minor (a page's background can follow a colour variable in the page's own mode, set from the Page section's variable button or `page.setBackground {color: {$var}}` (#2343); Swap library re-points the styles and variables of the library copies that stay, so instances placed after a swap follow it too (#2568); the Local variables window reorders variables: Move up and Move down (Alt+↑ / Alt+↓) on a row, Sort A to Z and Z to A on a collection or group, numbers by value (#2633); `library.swap` lists the unused copies of the old library it removes in `dropped` (#2569); with several instances selected, the Design panel shows the properties they share, Mixed where their values differ, and sets a value on all of them; an enabled library's styles are offered in the style pickers without opening the Assets tab first, and the picker filters its list by source (All libraries, This file, one library); with a variable group shown in the Local variables window, Create variable makes the variable in that group, and renaming a variable in its row changes the part shown and keeps its group; a layer inside an instance bound to a variable its main layer doesn't bind keeps that binding as an override when instances are relinked after an import, a detach or a restore, and when its value is set back to the main's, so a library copy or an edit of the main no longer drops it; switching variants keeps the text typed into an instance when the other variant nests that text layer in other frames, matched by its name; a main component copied from a library file and pasted into another file is an instance of it from that library, instead of a new main; copied variants pasted with their own set, or a layer in it, selected join the set as new variants; the Scale tool keeps variable-bound lengths scaled: a scaled instance keeps its bindings and draws them at the variable's value times its scale factor, other scaled layers keep the scaled value and drop the binding (#2090); a style of one library that reaches a file through another library's component is, in a file linking both, the first library's own bound copy, so its modes colour it (#2414); with a variant selected, its property dropdowns show its own values and choosing one renames only that variant, instead of setting the set's default and moving the variants (#2349); library analytics count insertions and detachments of styles and variables; combining components gives every variant the properties any of them had; renaming a variable group to a path with `/` nests it under a parent group instead of turning the slash into a hyphen (#2353); a group's context menu in the Local variables window has Duplicate group, a copy named after it plus " 2" holding a copy of every variable, in one undo step (#2084); pages take a variable mode: with nothing selected the Design panel's Page section shows a Variable modes section, Auto or a mode of each collection that has more than one, as the help center says ("Apply variable mode" in the Page section of the right sidebar) (#2215); a text style binds a number variable to its weight (#2174); an instance lists only the properties its variant's layers use and long property names are cut to one line (#2022); with several layers selected the Design panel header's component button offers Create multiple components (#2088); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); text styles carry paragraph spacing and indent, the list style and the OpenType features, as the Supported in text styles table of Create and apply text styles says (#1829); a layer's effect binding takes only a field its effect has; Go to main component on an instance of a library component opens the library file in a tab and selects the main there; glass effects take variables; Delete on a layer inside an instance hides it as an override instead of being refused, as the help center says: "Figma will only toggle the layer's visibility instead of removing it"; library analytics list how many layers and files use each style and variable; SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; a typed or stored variable, collection or mode id names only the object with that id (#1613); colour variables can be calculated from other colours per mode — `{alpha}` replaces a colour's alpha, `{mix}` blends two — and follow them (#1280); stored variable and collection references keep their identity when anotLine truncated
|
||||
|
||||
Design systems are why teams adopt Figma. **Components: breadth ~96%, ready ~72%. Styles and
|
||||
variables: breadth ~95%, ready ~76% (estimated).** QA'd with a synthetic design system of ~300
|
||||
@@ -90,6 +90,7 @@ updates with overrides kept: `library_tests.rs`, `components_scale_tests.rs`.
|
||||
| 2026-11-19 | patch | M3: with a group selected in the Local variables window, + Create variable named the new variable without the group, so it went to the collection's top level and the table, showing the group, didn't show it; only All variables did. It's now made in the group shown (`space/Number`), as in Figma, where duplicating already kept the group. Renaming a variable in its row edited its whole name while the row shows the last part, so typing a name over a new grouped variable moved it out of the group; the field now edits the part shown and keeps the group (the Edit variable window still edits the whole name), and ignores a name of slashes alone. Creating a collection clears the group shown. Tests: `variables_group_create_tests` |
|
||||
| 2026-11-18 | patch | M3: enabled libraries were read only while the Assets panel showed, so after a file was opened the Design panel's style pickers offered none of their styles (a library's text styles read "No text styles yet") until the Assets tab had been opened. They are refreshed from the app's background tick now, a local library not read yet at once. The style picker has a source menu under its search field, as in Figma: All libraries (the default), This file, or one enabled library. Test: `style_picker::tests::a_reopened_files_text_styles_picker_lists_its_librarys_styles_without_the_assets_tab` |
|
||||
| 2026-11-23 | patch | M3, #2569: `library.swap {from, to}` removes `from`'s copies that nothing in the file uses before it starts (a component imported with `library.import` but not placed, a variable imported but not bound), as `library.remove` does, but its result didn't say so: `{"components": 0, "unmatched": [], "removed": true}` after an imported component had been deleted. The result now names them in `dropped` (`component auth-button`, `variable Theme/accent`, `collection Theme`), apart from copies that went because what used them moved to `to`. Test: `library_swap/tests.rs` (`swap_lists_the_unused_copies_it_removes`) |
|
||||
| 2026-11-27 | minor | M7, #2343: a page's background can follow a colour variable. The Page section in the Design panel offers the variable button on the background, as a fill does, and shows the bound variable's chip with a detach button; `page.setBackground` takes `{color: {$var: <id or name>}}` (and `variable.bind` the field `background` on a page), and a plain colour detaches it. The background resolves in the page's own variable mode, so switching a page to Dark turns its canvas dark along with what's on it, which makes page modes usable for checking a theme. Colour variables only; undo restores the binding. Tests: `page_background_variable_tests` |
|
||||
| 2026-11-27 | minor | M3, #2633: variables in the Local variables window stayed in creation order. A row's menu has Move up and Move down (Alt+↑ / Alt+↓ with one row selected), moving it past its neighbour in its group; a collection's and a group's menus have Sort A to Z and Sort Z to A, by name with each run of digits compared as a number, so `50, 100, 200 … 950` come in that order. The order is the stored one, so files, exports and the variable pickers follow it. New commands `variable.move {variables, before?}` and `variable.sort {collection, group?, descending?}`, one undo step each. Drag to reorder is not built. Tests: `variables_editor_tests::moving_variables_reorders_their_collection_only_and_undoes`, `variables_editor_tests::sorting_orders_numbers_by_value_within_the_group_asked`. Grade unchanged. |
|
||||
| 2026-11-27 | patch | M3, #2572: a test guards that dragging the Local variables window wider shows more mode columns, each still 200 points wide, while the columns that do not fit scroll sideways. The resizing itself came with #2354 (after v0.18.1). Test: `variables_window_resize_tests.rs`. |
|
||||
| 2026-11-23 | patch | M3, #2568: `library.swap {from, to}` re-pointed style links and variable bindings only on layers outside the read-only library copies. A copy the swap keeps (a component of `from` that `to` has no match for, or another library's component using `from`'s style) kept `from`'s style and variable, so instances placed after the swap showed the old colours while those placed before showed the new ones. The swap now re-points the copies' own layers too, with the same maps, and `from`'s style and variable copies that nothing links any more go. A layer's explicit mode for one of `from`'s collections stays next to `to`'s while a variable of that collection is left on `from` (no match), so that variable keeps its mode instead of falling back to the default. Tests: `library_swap/tests.rs` (`swap_repoints_the_styles_and_variables_of_component_copies_it_keeps`, `swap_keeps_the_mode_of_a_collection_that_still_has_a_variable_on_the_old_library`) |
|
||||
|
||||
Reference in new issue
Block a user