Files
Marcos Paulo 30dba88e1c feat: variable collections, shared libraries, assets and offline CLI
Variables move to a project-level design.json: collections with their
own modes, slash groups, color/number/string/boolean types and aliases.
Pages keep a derived cache, every writer goes through one path, and a
change reaches every page in one undo step per page. Strokes, text
color, size, gap, padding, radius, font size, line height, opacity and
visibility can bind to variables. Projects migrate to version 2.

Components work across pages, and any file can publish itself as a
library that other files enable, update after review, or disable.

New Variables and Libraries modals, an Assets view grouped by name
prefix, variable pickers in the inspector, and a slimmer Design tab.

papercraft-cli runs tools in-process when the app is closed, with a
`shell` command for interactive sessions and scripts.

Also centres the sidebar footer and title bar text on their icons.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 17:47:23 -03:00

49 lines
1.8 KiB
Rust

//! The Variables modal draws without panicking for a design with two collections, at both
//! window sizes, with a variable selected, an alias, a library collection and a confirm open.
use egui::{Pos2, Rect, Vec2};
use papercraft::editor::Editor;
use papercraft::ui::{self, UiState};
use papercraft::variables::{Kind, Value};
fn frame(ctx: &egui::Context, size: Vec2, st: &mut UiState, ed: &mut Editor) {
let input = egui::RawInput {
screen_rect: Some(Rect::from_min_size(Pos2::ZERO, size)),
..Default::default()
};
let mut out = ctx.run_ui(input, |ui| {
ui::draw(ui, ed, st);
});
out.textures_delta.clear();
}
#[test]
fn variables_modal_renders_two_collections() {
let ctx = egui::Context::default();
ui::setup_style(&ctx);
let mut ed = Editor::default();
ed.edit_design("seed", |ds| {
let colors = ds.add_collection("Colors");
let dark = ds.add_mode(&colors, "Dark")?;
let primary = ds.add_variable(&colors, "color/brand/primary", Kind::Color)?;
let accent = ds.add_variable(&colors, "color/brand/accent", Kind::Color)?;
let mode = ds.collection(&colors).unwrap().default_mode.clone();
ds.set_value(&accent, &mode, Value::Alias(primary))?;
ds.set_value(&accent, &dark, Value::Color(papercraft::model::Color::rgb(1, 2, 3)))?;
let tokens = ds.add_collection("Tokens");
ds.add_variable(&tokens, "space/md", Kind::Number)?;
ds.add_variable(&tokens, "flag/compact", Kind::Boolean)?;
ds.add_variable(&tokens, "font/family", Kind::String)?;
Ok(())
})
.unwrap();
let mut st = UiState::default();
st.variables.open = true;
for size in [Vec2::new(2560.0, 1440.0), Vec2::new(1280.0, 800.0)] {
for _ in 0..3 {
frame(&ctx, size, &mut st, &mut ed);
}
}
assert!(st.variables.open);
}