diff --git a/AGENTS.md b/AGENTS.md index 0bc4bd04..e823034a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,3 +36,4 @@ Learned from Skwir (another GPUI application) and binding for `Calix.Ui.Gpui`: - **An element is known by what it shows, never by where it stands** (`elements::clip::known_by`): a catalogue row or card takes its id from its package. GPUI keeps an element's tooltip, press and accessibility node under its id; an id by position hands them to whatever comes to stand there as the list scrolls or filters. - **Text cut to fit says itself whole while cut** (`elements::clip::clipped`): whether it was cut is read from the drawn layout when the tooltip is asked for, never in `render`. All tooltips share one look (`components::tooltip`). - **Empty is a state**: a list that shows nothing says why (the text typed, the filters, nothing to update) and the way out. +- **The workshop's look is in `docs/brand.md`** ("The interface: the workshop"): planes on the chassis (`bg_app` on `bg_sidebar`, edge + `shadow_sm`), the accent only for the cursor, focus, primary action and lamps (`accent_text` when it is text), sentence case, the three embedded voices of `fonts.rs`. Never name a font family but through `fonts::{UI, LABEL, CODE}`. diff --git a/Calix.Ui.Gpui/assets/fonts/InstrumentSans-Bold.ttf b/Calix.Ui.Gpui/assets/fonts/InstrumentSans-Bold.ttf new file mode 100644 index 00000000..3cca3ac9 Binary files /dev/null and b/Calix.Ui.Gpui/assets/fonts/InstrumentSans-Bold.ttf differ diff --git a/Calix.Ui.Gpui/assets/fonts/InstrumentSans-Medium.ttf b/Calix.Ui.Gpui/assets/fonts/InstrumentSans-Medium.ttf new file mode 100644 index 00000000..1630cd3a Binary files /dev/null and b/Calix.Ui.Gpui/assets/fonts/InstrumentSans-Medium.ttf differ diff --git a/Calix.Ui.Gpui/assets/fonts/InstrumentSans-Regular.ttf b/Calix.Ui.Gpui/assets/fonts/InstrumentSans-Regular.ttf new file mode 100644 index 00000000..bd43cf17 Binary files /dev/null and b/Calix.Ui.Gpui/assets/fonts/InstrumentSans-Regular.ttf differ diff --git a/Calix.Ui.Gpui/assets/fonts/InstrumentSans-SemiBold.ttf b/Calix.Ui.Gpui/assets/fonts/InstrumentSans-SemiBold.ttf new file mode 100644 index 00000000..46f0c3c3 Binary files /dev/null and b/Calix.Ui.Gpui/assets/fonts/InstrumentSans-SemiBold.ttf differ diff --git a/Calix.Ui.Gpui/assets/fonts/InstrumentSansSemiCondensed-Medium.ttf b/Calix.Ui.Gpui/assets/fonts/InstrumentSansSemiCondensed-Medium.ttf new file mode 100644 index 00000000..c4c7fe8a Binary files /dev/null and b/Calix.Ui.Gpui/assets/fonts/InstrumentSansSemiCondensed-Medium.ttf differ diff --git a/Calix.Ui.Gpui/assets/fonts/InstrumentSansSemiCondensed-SemiBold.ttf b/Calix.Ui.Gpui/assets/fonts/InstrumentSansSemiCondensed-SemiBold.ttf new file mode 100644 index 00000000..db51c1d7 Binary files /dev/null and b/Calix.Ui.Gpui/assets/fonts/InstrumentSansSemiCondensed-SemiBold.ttf differ diff --git a/Calix.Ui.Gpui/assets/fonts/JetBrainsMono-Medium.ttf b/Calix.Ui.Gpui/assets/fonts/JetBrainsMono-Medium.ttf new file mode 100644 index 00000000..dc2e5d08 Binary files /dev/null and b/Calix.Ui.Gpui/assets/fonts/JetBrainsMono-Medium.ttf differ diff --git a/Calix.Ui.Gpui/assets/fonts/JetBrainsMono-Regular.ttf b/Calix.Ui.Gpui/assets/fonts/JetBrainsMono-Regular.ttf new file mode 100644 index 00000000..711830ed Binary files /dev/null and b/Calix.Ui.Gpui/assets/fonts/JetBrainsMono-Regular.ttf differ diff --git a/Calix.Ui.Gpui/assets/fonts/OFL-InstrumentSans.txt b/Calix.Ui.Gpui/assets/fonts/OFL-InstrumentSans.txt new file mode 100644 index 00000000..26bd2f95 --- /dev/null +++ b/Calix.Ui.Gpui/assets/fonts/OFL-InstrumentSans.txt @@ -0,0 +1,93 @@ +Copyright 2022 The Instrument Sans Project Authors (https://github.com/Instrument/instrument-sans) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/Calix.Ui.Gpui/assets/fonts/OFL-JetBrainsMono.txt b/Calix.Ui.Gpui/assets/fonts/OFL-JetBrainsMono.txt new file mode 100644 index 00000000..5ceee002 --- /dev/null +++ b/Calix.Ui.Gpui/assets/fonts/OFL-JetBrainsMono.txt @@ -0,0 +1,93 @@ +Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://openfontlicense.org + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/Calix.Ui.Gpui/src/components/cheatsheet.rs b/Calix.Ui.Gpui/src/components/cheatsheet.rs index 86669e0c..e479f36f 100644 --- a/Calix.Ui.Gpui/src/components/cheatsheet.rs +++ b/Calix.Ui.Gpui/src/components/cheatsheet.rs @@ -70,7 +70,7 @@ impl Cheatsheet { .px_1p5() .py(px(1.0)) .text_xs() - .font_family("monospace") + .font_family(crate::fonts::UI) .text_color(theme.text_primary) .child(binding.label()) } @@ -116,7 +116,7 @@ impl Cheatsheet { .text_xs() .font_weight(FontWeight::BOLD) .text_color(theme.text_muted) - .child(group.to_uppercase()), + .child(group), ) .children(labels.into_iter().map(|label| Self::render_action(label, group, theme))) } @@ -174,13 +174,13 @@ impl Cheatsheet { .text_xs() .font_weight(FontWeight::BOLD) .text_color(theme.text_primary) - .child("KEYBOARD"), + .child("Keyboard shortcuts"), ) .child( div() .text_xs() .text_color(theme.text_muted) - .child("esc closes"), + .child("Esc closes"), ), ) .child( diff --git a/Calix.Ui.Gpui/src/components/context_header.rs b/Calix.Ui.Gpui/src/components/context_header.rs index 8011db9d..356c4e86 100644 --- a/Calix.Ui.Gpui/src/components/context_header.rs +++ b/Calix.Ui.Gpui/src/components/context_header.rs @@ -122,31 +122,8 @@ impl ContextHeader { } }; - // ── La couverture : les écosystèmes du périmètre ──────────────────── - let coverage = if is_packages { - // Les sources interrogeables, puis celles que le périmètre liste - // sans pouvoir les interroger : la ligne le dit, pour que la - // couverture ne mente pas sur ce qui se cherche. - let inventory_only = props.scope.inventory_only_sources(); - let searchable: Vec = props - .scope - .sources() - .iter() - .filter(|source| !inventory_only.contains(source)) - .map(|source| source.to_string()) - .collect(); - let listed: Vec = inventory_only - .iter() - .map(|source| source.to_string()) - .collect(); - let mut parts = vec![searchable.join(" · ")]; - if !listed.is_empty() { - parts.push(format!("{} (inventory only)", listed.join(" · "))); - } - parts.join(" + ") - } else { - String::new() - }; + // The coverage (which ecosystems the scope searches) is the source + // strip's to say, under the header: the header names the place. // Une source qui n'a pas répondu se dit, et se réessaie : la barre // d'état a laissé la place, la santé reste. @@ -205,7 +182,7 @@ impl ContextHeader { on_clear(window, cx); }) .text_xs() - .text_color(theme.accent) + .text_color(theme.accent_text) .hover(|s| s.bg(theme.bg_surface_hover).text_color(theme.accent_hover)) .child(summary.clone()) }); @@ -218,15 +195,6 @@ impl ContextHeader { .items_center() .gap(px(8.0)) .overflow_hidden(); - if !coverage.is_empty() { - second_line = second_line.child( - div() - .text_xs() - .text_color(theme.text_muted) - .truncate() - .child(coverage), - ); - } if let Some(age) = props.age.as_ref() { second_line = second_line.child( div().text_xs().text_color(theme.text_muted).child(age.clone()), @@ -273,12 +241,27 @@ impl ContextHeader { .flex_col() .gap(px(3.0)) .min_w(px(0.0)) + // The place's name is the one large thing in the chassis: the + // dial's label, set in the interface face at a display size. .child( div() - .text_sm() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_primary) - .child(title), + .flex() + .items_baseline() + .gap(px(10.0)) + .child( + div() + .text_xl() + .font_weight(FontWeight::SEMIBOLD) + .text_color(theme.text_primary) + .child(title), + ) + .child( + div() + .text_sm() + .font_features(crate::fonts::figures()) + .text_color(theme.text_muted) + .child(count), + ), ) .child(second_line), ); @@ -303,20 +286,12 @@ impl ContextHeader { .px(px(16.0)) .py(px(6.0)) .bg(theme.bg_sidebar) - .border_b_1() - .border_color(theme.border) .child(nameplate) .child( div() .flex() .items_center() .gap(px(10.0)) - .child( - div() - .text_xs() - .text_color(theme.text_secondary) - .child(count), - ) // Le disque de l'aide : la fiche des raccourcis n'est // jamais sur la surface, mais elle est découvrable. .when(props.on_toggle_help.is_some(), |element| { diff --git a/Calix.Ui.Gpui/src/components/facts.rs b/Calix.Ui.Gpui/src/components/facts.rs new file mode 100644 index 00000000..06caceaa --- /dev/null +++ b/Calix.Ui.Gpui/src/components/facts.rs @@ -0,0 +1,54 @@ +//! What a package is, said as a list of facts: a label in the narrow cut, its +//! value beside it, a hairline between two facts. +//! +//! The facts were a grid of boxed cards with capitalised captions, two per +//! row: a dashboard's kit, and a long URL broke out of its card. A list of +//! definitions reads down one edge, gives the value all the room the label +//! leaves, and wraps a long value instead of cutting into its neighbour. + +use crate::theme::Theme; +use gpui::*; + +/// The width of the labels' column: the longest label in the narrow cut +/// ("Download size") and its gap. +const LABEL_COLUMN: f32 = 112.0; + +/// A section's name: the narrow cut, sentence case, muted. +pub fn section_label(text: &'static str, theme: &Theme) -> Div { + div() + .font_family(crate::fonts::LABEL) + .text_xs() + .font_weight(FontWeight::MEDIUM) + .text_color(theme.text_muted) + .child(text) +} + +/// One fact: what it is, and its value. +pub fn fact(label: &'static str, value: impl IntoElement, theme: &Theme) -> Div { + div() + .flex() + .items_baseline() + .gap_3() + .py(px(7.0)) + .border_b_1() + .border_color(theme.border) + .child( + section_label(label, theme) + .flex_none() + .w(px(LABEL_COLUMN)), + ) + .child( + div() + .flex_1() + .min_w_0() + .text_sm() + .text_color(theme.text_primary) + .font_features(crate::fonts::figures()) + .child(value), + ) +} + +/// The facts, one under the other. +pub fn list(facts: impl IntoIterator) -> Div { + div().flex().flex_col().children(facts) +} diff --git a/Calix.Ui.Gpui/src/components/inspector_header.rs b/Calix.Ui.Gpui/src/components/inspector_header.rs index de6f47de..93e5f83b 100644 --- a/Calix.Ui.Gpui/src/components/inspector_header.rs +++ b/Calix.Ui.Gpui/src/components/inspector_header.rs @@ -62,7 +62,7 @@ pub struct InspectorHeaderProps<'a> { pub struct InspectorHeader; impl InspectorHeader { - /// Formate la ligne de métadonnées calme du bureau (Arch · extra · ● Installed) + /// Formate la ligne de métadonnées calme du bureau (Arch / extra ● Installed) pub fn format_metadata_line(pkg: &UnifiedPackage) -> (String, &'static str) { let source_name = match pkg.source_type.to_uppercase().as_str() { "ALPM" => "Arch", @@ -74,7 +74,8 @@ impl InspectorHeader { let mut meta = source_name.to_string(); if !pkg.repository_or_remote.is_empty() { - meta.push_str(" \u{00B7} "); + // The same words as the catalogue's Source column. + meta.push_str(" / "); meta.push_str(&pkg.repository_or_remote); } @@ -128,7 +129,7 @@ impl InspectorHeader { FontWeight::MEDIUM }) .text_color(if is_active { - theme.accent + theme.accent_text } else { theme.text_secondary }) @@ -146,7 +147,7 @@ impl InspectorHeader { .path(tab.icon().path()) .size_3_5() .text_color(if is_active { - theme.accent + theme.accent_text } else { theme.text_secondary }), @@ -178,7 +179,7 @@ impl InspectorHeader { let mut version_row = div().flex().items_center().gap_1().flex_shrink_0().child( div() .text_xs() - .font_family("monospace") + .font_family(crate::fonts::UI).font_features(crate::fonts::figures()) .text_color(theme.text_muted) .child(pkg.version.clone()), ); @@ -188,7 +189,7 @@ impl InspectorHeader { version_row = version_row.child( div() .text_xs() - .font_family("monospace") + .font_family(crate::fonts::UI).font_features(crate::fonts::figures()) .font_weight(FontWeight::BOLD) .text_color(theme.warning_text) .child(format!(" → {}", nv)), @@ -197,7 +198,7 @@ impl InspectorHeader { version_row = version_row.child( div() .text_xs() - .font_family("monospace") + .font_family(crate::fonts::UI).font_features(crate::fonts::figures()) .font_weight(FontWeight::BOLD) .text_color(theme.warning_text) .child(" (update)"), @@ -243,8 +244,9 @@ impl InspectorHeader { .gap_1p5() .text_xs() .text_color(theme.text_muted) - .child(div().child(meta_origin)) - .child(div().child("\u{00B7}")) + // Where it comes from, then its state behind its lamp: the + // lamp separates them, no dot between. + .child(div().mr_1().child(meta_origin)) .child( div() .size(px(6.0)) @@ -514,7 +516,7 @@ mod tests { }; let (meta, status) = InspectorHeader::format_metadata_line(&pkg_installed); - assert_eq!(meta, "Arch \u{00B7} extra"); + assert_eq!(meta, "Arch / extra"); assert_eq!(status, "Installed"); let pkg_update = UnifiedPackage { @@ -546,7 +548,7 @@ mod tests { }; let (meta3, status3) = InspectorHeader::format_metadata_line(&pkg_flatpak); - assert_eq!(meta3, "Flatpak \u{00B7} flathub"); + assert_eq!(meta3, "Flatpak / flathub"); assert_eq!(status3, "Available"); } } diff --git a/Calix.Ui.Gpui/src/components/log_drawer.rs b/Calix.Ui.Gpui/src/components/log_drawer.rs index 3ee6f2a9..b40093c5 100644 --- a/Calix.Ui.Gpui/src/components/log_drawer.rs +++ b/Calix.Ui.Gpui/src/components/log_drawer.rs @@ -248,34 +248,19 @@ impl LogDrawer { } } }) + .flex() + .items_center() + .gap(px(6.0)) .px_2() .py_1() - .rounded_sm() - .border_1() - .border_color(if auto_scroll { - theme.accent - } else { - theme.border - }) - .bg(if auto_scroll { - theme.bg_surface_active - } else { - theme.bg_surface - }) + .rounded_md() .text_xs() .font_weight(FontWeight::MEDIUM) - .text_color(if auto_scroll { - theme.accent - } else { - theme.text_muted - }) + .text_color(theme.text_secondary) .cursor_pointer() - .hover(move |s| s.bg(hover_bg).border_color(border_focus)) - .child(if auto_scroll { - "Auto-scroll: ON" - } else { - "Auto-scroll: PAUSE" - }); + .hover(move |s| s.bg(hover_bg)) + .child(lamp(auto_scroll, theme)) + .child("Follow output"); if let Some(handler) = on_toggle_autoscroll { btn = btn.on_mouse_down(MouseButton::Left, move |_e, w, cx| handler(w, cx)); @@ -302,30 +287,19 @@ impl LogDrawer { } } }) + .flex() + .items_center() + .gap(px(6.0)) .px_2() .py_1() - .rounded_sm() - .border_1() - .border_color(if show_raw { theme.accent } else { theme.border }) - .bg(if show_raw { - theme.bg_surface_active - } else { - theme.bg_surface - }) + .rounded_md() .text_xs() .font_weight(FontWeight::MEDIUM) - .text_color(if show_raw { - theme.accent - } else { - theme.text_secondary - }) + .text_color(theme.text_secondary) .cursor_pointer() - .hover(move |s| s.bg(hover_bg).border_color(border_focus)) - .child(if show_raw { - "Logs: Raw" - } else { - "Logs: Formatted" - }); + .hover(move |s| s.bg(hover_bg)) + .child(lamp(show_raw, theme)) + .child("Raw output"); if let Some(handler) = on_toggle_raw { btn = btn.on_mouse_down(MouseButton::Left, move |_e, w, cx| handler(w, cx)); @@ -360,7 +334,7 @@ impl LogDrawer { .text_xs() .font_weight(FontWeight::MEDIUM) .text_color(theme.text_secondary) - .hover(|s| s.text_color(theme.accent)) + .hover(|s| s.text_color(theme.accent_text)) .child( svg() .path(if is_open { @@ -389,9 +363,8 @@ impl LogDrawer { // Le bandeau du tiroir est une bande permanente : le budget // vertical le compte quand il répartit la fenêtre. .h(px(crate::ui_metrics::UiMetrics::DRAWER_HEADER_HEIGHT)) - .bg(theme.bg_surface) - .border_t_1() - .border_color(theme.border) + // The chassis' foot: it holds a state, on the aluminium. + .bg(theme.bg_sidebar) .child( div() .flex() @@ -399,10 +372,11 @@ impl LogDrawer { .gap_3() .child( div() - .text_xs() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_primary) - .child("CALIX OPERATION LOG"), + .font_family(crate::fonts::LABEL) + .text_sm() + .font_weight(FontWeight::SEMIBOLD) + .text_color(theme.text_secondary) + .child("Operation log"), ) // La commande du produit, puis ce que le moteur a // réellement lancé. Les deux ne sont jamais la même @@ -410,8 +384,8 @@ impl LogDrawer { .children(props.product_command.map(|command| { div() .text_xs() - .font_family("monospace") - .text_color(theme.accent) + .font_family(crate::fonts::CODE) + .text_color(theme.accent_text) .child(format!("$ {}", command)) })) .child(status_badge), @@ -561,7 +535,7 @@ impl LogDrawer { div() .id(idx) .py_0p5() - .font_family("monospace") + .font_family(crate::fonts::CODE) .text_color(color) .child(display_text.to_string()), ); @@ -602,3 +576,14 @@ pub fn sanitize_ansi(s: &str) -> String { } clean } + + +/// A toggle's lamp: lit in the accent while the toggle is on, a ring when it +/// is off — the same indicator as the source strip's. +fn lamp(on: bool, theme: &Theme) -> Div { + div() + .size(px(7.0)) + .rounded_full() + .when(on, |lamp| lamp.bg(theme.accent)) + .when(!on, |lamp| lamp.border_1().border_color(theme.text_muted)) +} diff --git a/Calix.Ui.Gpui/src/components/menu.rs b/Calix.Ui.Gpui/src/components/menu.rs index 79f04f12..4155bea6 100644 --- a/Calix.Ui.Gpui/src/components/menu.rs +++ b/Calix.Ui.Gpui/src/components/menu.rs @@ -183,7 +183,7 @@ impl MenuCheckmarkItem { gpui::rgba(0x00000000) }) .text_color(if is_selected { - theme.accent + theme.accent_text } else { theme.text_secondary }) @@ -203,7 +203,7 @@ impl MenuCheckmarkItem { svg() .path(AppIcon::Check.path()) .size(px(12.0)) - .text_color(theme.accent) + .text_color(theme.accent_text) .into_any_element() } else { div().size(px(12.0)).into_any_element() diff --git a/Calix.Ui.Gpui/src/components/mod.rs b/Calix.Ui.Gpui/src/components/mod.rs index 842a95b1..b949d764 100644 --- a/Calix.Ui.Gpui/src/components/mod.rs +++ b/Calix.Ui.Gpui/src/components/mod.rs @@ -1,5 +1,6 @@ pub mod cheatsheet; pub mod context_header; +pub mod facts; pub mod inspector_header; pub mod log_drawer; pub mod menu; diff --git a/Calix.Ui.Gpui/src/components/package_card.rs b/Calix.Ui.Gpui/src/components/package_card.rs index d787a68f..68be0d21 100644 --- a/Calix.Ui.Gpui/src/components/package_card.rs +++ b/Calix.Ui.Gpui/src/components/package_card.rs @@ -144,7 +144,7 @@ impl PackageCard { el.child( div() .text_xs() - .font_family("monospace") + .font_family(crate::fonts::UI).font_features(crate::fonts::figures()) .font_weight(FontWeight::BOLD) .text_color(theme.warning_text) .child(format!("→ {}", new_ver)), @@ -153,7 +153,7 @@ impl PackageCard { .child( div() .text_xs() - .font_family("monospace") + .font_family(crate::fonts::UI).font_features(crate::fonts::figures()) .font_weight(FontWeight::MEDIUM) .text_color(theme.text_muted) .child(pkg.version.clone()), @@ -162,7 +162,7 @@ impl PackageCard { el.child( div() .text_xs() - .font_family("monospace") + .font_family(crate::fonts::UI).font_features(crate::fonts::figures()) .font_weight(FontWeight::NORMAL) .text_color(theme.text_secondary) .child(display_size), @@ -170,7 +170,7 @@ impl PackageCard { }), ), ) - // Ligne 2 : Métadonnées desktop calmes sans pilules colorées ("Arch · extra · Installed") + // Ligne 2 : Métadonnées desktop calmes sans pilules colorées ("Arch / extra ● Installed") .child({ let mut meta = div().flex().items_center().gap_1p5().text_xs().child( div() @@ -180,16 +180,16 @@ impl PackageCard { ); if show_repo { - meta = meta - .child(div().text_color(theme.text_muted).child("·")) - .child( - div() - .text_color(theme.text_muted) - .child(pkg.repository_or_remote.clone()), - ); + // The same words as the table's Source column. + meta = meta.child( + div() + .text_color(theme.text_muted) + .child(format!("/ {}", pkg.repository_or_remote)), + ); } - meta = meta.child(div().text_color(theme.text_muted).child("·")); + // The state follows behind its lamp: no dot between. + meta = meta.child(div().w(px(4.0))); if pkg.has_update { meta = meta.child( diff --git a/Calix.Ui.Gpui/src/components/package_table.rs b/Calix.Ui.Gpui/src/components/package_table.rs index 88bc8f7f..a63220fc 100644 --- a/Calix.Ui.Gpui/src/components/package_table.rs +++ b/Calix.Ui.Gpui/src/components/package_table.rs @@ -39,7 +39,9 @@ impl PackageTable { _ => 0.0, }; let track = crate::ui_metrics::UiMetrics::SIZE_BAR_TRACK; - let bar = theme.accent; + // The figure is read, not signalled: the bar is graphite, and the + // accent stays for what the user acts on. + let bar = theme.text_secondary; div() .debug_selector(|| "package_row_bar_track".to_string()) .w(px(track)) @@ -154,8 +156,11 @@ impl PackageTable { .bg(gpui::rgba(0x00000000)) .border_b_1() .border_color(theme.border) + // A column's name is a label: the narrow face, in sentence case; + // its width, not capitals, sets it apart from the rows. + .font_family(crate::fonts::LABEL) .text_xs() - .font_weight(FontWeight::SEMIBOLD) + .font_weight(FontWeight::MEDIUM) .text_color(theme.text_muted) .child( div() @@ -163,21 +168,21 @@ impl PackageTable { .min_w_0() .overflow_hidden() .text_ellipsis() - .child("NAME"), + .child("Name"), ) .child( div() .w(px(105.0)) .overflow_hidden() .text_ellipsis() - .child("VERSION"), + .child("Version"), ) .child( div() .w(px(105.0)) .overflow_hidden() .text_ellipsis() - .child("SOURCE"), + .child("Source"), ) .child(Self::render_header_size_cell(theme, scale_max)) .child( @@ -185,7 +190,7 @@ impl PackageTable { .w(px(85.0)) .overflow_hidden() .text_ellipsis() - .child("STATUS"), + .child("Status"), ) } @@ -215,7 +220,7 @@ impl PackageTable { div() .overflow_hidden() .text_ellipsis() - .child("SIZE"), + .child("Size"), ) .child( div() @@ -223,7 +228,7 @@ impl PackageTable { .debug_selector(|| "package_header_size_caption".to_string()) .overflow_hidden() .text_size(px(8.0)) - .font_family("monospace") + .font_family(crate::fonts::UI).font_features(crate::fonts::figures()) .font_weight(FontWeight::NORMAL) .text_color(theme.text_muted) .child(caption), @@ -335,10 +340,12 @@ impl PackageTable { .debug_selector(|| "package_row_version".to_string()) .w(px(105.0)) .min_w(px(crate::ui_metrics::UiMetrics::ROW_VERSION_MIN_WIDTH)) + // A cut version keeps its distance from the source beside it. + .pr_2() .overflow_hidden() .text_ellipsis() .text_xs() - .font_family("monospace") + .font_family(crate::fonts::UI).font_features(crate::fonts::figures()) .font_weight(FontWeight::MEDIUM) .text_color(theme.text_muted); let mut version_cell = clip::clipped(version_cell, version_text); @@ -371,7 +378,7 @@ impl PackageTable { .overflow_hidden() .text_ellipsis() .text_xs() - .font_family("monospace") + .font_family(crate::fonts::UI).font_features(crate::fonts::figures()) .text_color(theme.text_secondary) .child(Self::display_size(pkg)); let measurement = Self::render_measurement(Self::size_bytes(pkg), scale_max, theme); diff --git a/Calix.Ui.Gpui/src/components/query_workbench.rs b/Calix.Ui.Gpui/src/components/query_workbench.rs index f7e5676c..1d529efe 100644 --- a/Calix.Ui.Gpui/src/components/query_workbench.rs +++ b/Calix.Ui.Gpui/src/components/query_workbench.rs @@ -272,7 +272,7 @@ impl QueryWorkbench { .text_xs() .text_color( if props.state_filter != PackageStateFilter::All || is_state_open { - theme.accent + theme.accent_text } else { theme.text_secondary }, @@ -457,7 +457,7 @@ impl QueryWorkbench { }) .text_xs() .text_color(if props.sort_mode != SortMode::Relevance || is_sort_open { - theme.accent + theme.accent_text } else { theme.text_secondary }) @@ -500,7 +500,7 @@ impl QueryWorkbench { .cursor_pointer() .text_xs() .font_weight(FontWeight::BOLD) - .text_color(theme.accent) + .text_color(theme.accent_text) .hover(|s| s.bg(theme.bg_surface_hover).text_color(theme.accent_hover)) .child(action.label) .on_mouse_down(MouseButton::Left, move |_ev, window, cx| { diff --git a/Calix.Ui.Gpui/src/components/scope_dial.rs b/Calix.Ui.Gpui/src/components/scope_dial.rs index 05371a53..b22b754d 100644 --- a/Calix.Ui.Gpui/src/components/scope_dial.rs +++ b/Calix.Ui.Gpui/src/components/scope_dial.rs @@ -162,6 +162,9 @@ impl Render for ScopeDialView { .bg(theme.bg_surface) .border_1() .border_color(theme.border) + // The knob stands proud of the aluminium: the one object of the + // chassis that casts a shadow of its own. + .shadow_md() .child( // The needle, thrown at the detent. The SVG is painted upside // down — the engine flips it — so the file's needle points @@ -176,7 +179,7 @@ impl Render for ScopeDialView { let needle = svg() .path(AppIcon::DialNeedle.path()) .size(px(g.face)) - .text_color(theme.accent); + .text_color(theme.accent_text); if still { needle .with_transformation(Transformation::rotate(gpui::radians( @@ -277,7 +280,7 @@ impl Render for ScopeDialView { .path(scope.icon().path()) .size(px(g.icon)) .text_color(if is_selected { - theme.accent + theme.accent_text } else { theme.text_muted }), diff --git a/Calix.Ui.Gpui/src/components/search_input.rs b/Calix.Ui.Gpui/src/components/search_input.rs index 629eba46..ac939e43 100644 --- a/Calix.Ui.Gpui/src/components/search_input.rs +++ b/Calix.Ui.Gpui/src/components/search_input.rs @@ -874,7 +874,7 @@ impl Render for SearchInputView { .size(px(16.0)) .flex_none() .text_color(if is_focused || is_searching { - theme.accent + theme.accent_text } else { theme.text_muted }), diff --git a/Calix.Ui.Gpui/src/components/sidebar.rs b/Calix.Ui.Gpui/src/components/sidebar.rs index 6091884b..b4c5397c 100644 --- a/Calix.Ui.Gpui/src/components/sidebar.rs +++ b/Calix.Ui.Gpui/src/components/sidebar.rs @@ -97,7 +97,7 @@ impl Sidebar { }; let icon_color = if is_active { - theme.accent + theme.accent_text } else { theme.text_secondary }; @@ -277,14 +277,14 @@ impl Sidebar { svg() .path(AppIcon::Calix.path()) .size_8() - .text_color(theme.accent), + .text_color(theme.accent_text), ) .child(if !is_collapsed { div() .text_lg() - .font_weight(FontWeight::BOLD) + .font_weight(FontWeight::SEMIBOLD) .text_color(theme.text_primary) - .child("CALIX") + .child("Calix") } else { div() }), diff --git a/Calix.Ui.Gpui/src/components/source_bank.rs b/Calix.Ui.Gpui/src/components/source_bank.rs index 6e1ba4e4..c2606891 100644 --- a/Calix.Ui.Gpui/src/components/source_bank.rs +++ b/Calix.Ui.Gpui/src/components/source_bank.rs @@ -103,10 +103,8 @@ impl SourceBank { fn render_aperture( entry: &SourceAxisEntry, health: Option<(&'static str, bool)>, - // The anchor: the channel that carries the most of this scope's - // work. It is wider than the others and it is the only one that - // says what it holds — seven equal slabs read as a form. - anchor: bool, + // The first segment has no rule before it. + first: bool, props: &SourceBankProps, on_toggle: SourceToggleHandler, step: Option<(WaterfallStep, Duration)>, @@ -114,23 +112,27 @@ impl SourceBank { let theme = props.theme; let on_retry = props.on_retry.clone(); let kind = entry.kind; - let border = if anchor { - theme.accent + // A source in the scope is a raised segment, in ink; one left out + // lies flat in the aluminium, muted. + let in_scope = entry.selected; + let failed = health.map(|(_, failed)| failed).unwrap_or(false); + let name_color = if in_scope { + theme.text_primary } else { - theme.border + theme.text_muted }; let count_color = if entry.count == 0 { theme.text_muted } else { - theme.text_primary + theme.text_secondary + }; + // What it holds is said when asked: a recipe and a binary are not the + // same thing, and the tooltip says so without a line of its own. + let says: SharedString = match (entry.inventory_only, health) { + (true, _) => format!("{} — listed, not queried", entry.holds).into(), + (false, Some((state, _))) => format!("{} — {}", entry.holds, state.to_lowercase()).into(), + (false, None) => entry.holds.into(), }; - - let health_line = health.map(|(label, failed)| { - div() - .text_xs() - .text_color(if failed { theme.danger } else { theme.text_muted }) - .child(label) - }); let aperture = div() .id(aperture_id(kind)) @@ -138,27 +140,18 @@ impl SourceBank { // the aperture under this name. A noop outside the tests. .debug_selector(move || aperture_selector(kind).to_string()) .flex() - .flex_col() - .gap(px(2.0)) - .min_w(px(96.0)) - // The aperture that carries the scope's work is wider than the - // others: the bank has a front, and the eye has a place to land. - .flex_basis(px(if anchor { 160.0 } else { 0.0 })) - .flex_grow(1.0) - .px_3() - .py_2() - .border_b_2() - .border_color(border) - .bg(if anchor { - theme.bg_surface_hover - } else { - theme.bg_surface - }) + .flex_none() + .items_center() + .gap(px(7.0)) + .h(px(28.0)) + .px(px(11.0)) + .when(!first, |el| el.border_l_1().border_color(theme.border)) .cursor_pointer() .hover(move |s| s.bg(theme.bg_surface_hover)) .focusable() .tab_stop(true) - .focus(move |s| s.border_b_2().border_color(theme.accent)) + .focus(move |s| s.bg(theme.bg_surface_hover)) + .tooltip(move |_, cx| crate::components::tooltip::tip(Some(says.clone()), cx)) .on_mouse_down(MouseButton::Left, { let on_toggle = on_toggle.clone(); move |_ev, window, cx| { @@ -173,34 +166,31 @@ impl SourceBank { } } }) - // The name of the source. + // The source's lamp: lit in the accent while the source is in + // the scope, a ring when it is left out — an instrument's + // indicator, read before the name. .child( div() - .text_xs() - .font_weight(FontWeight::BOLD) + .size(px(7.0)) + .rounded_full() + .when(in_scope, |lamp| lamp.bg(theme.accent)) + .when(!in_scope, |lamp| lamp.border_1().border_color(theme.text_muted)), + ) + .child( + div() + .text_sm() + .font_weight(FontWeight::MEDIUM) .whitespace_nowrap() - .overflow_hidden() - .text_color(if anchor { - theme.accent - } else { - theme.text_primary - }) - // L'ancre a la place de son nom entier ; les autres - // canaux sont étroits et portent leur nom court. Un nom - // coupé au milieu d'un mot se lirait comme un défaut. - .child(if anchor { - entry.label - } else { - entry.kind.short_label() - }), + .text_color(name_color) + .child(entry.kind.short_label()), ) // The count of the scope's rows in this source. A value that // changes re-reads and flashes once: it does not glide into place. .child({ let count = div() .id(count_id(kind)) - .text_sm() - .font_family("monospace") + .text_xs() + .font_features(crate::fonts::figures()) .text_color(count_color) .child(entry.count.to_string()); if props.reduce_motion { @@ -218,46 +208,25 @@ impl SourceBank { .into_any_element() } }) - // What it holds: the non-interchangeability, stated up front. - // Only the engaged aperture has the room to say it — the others - // are narrow enough that the line would be cut in the middle of - // a word, which reads as a defect, not as a caption. - .when(anchor, |element| { - element.child( - div() - .text_xs() - .text_color(theme.text_muted) - .child(entry.holds), - ) - }) - // The state of the source: a source that did not answer says so. - .children(health_line) - .when( - health.map(|(_, failed)| failed).unwrap_or(false), - |element| { - let retry = on_retry.clone(); - element.child( + // A source that did not answer: a red mark, and the way out. + .when(failed, |element| { + let retry = on_retry.clone(); + element + .child(div().size(px(6.0)).rounded_full().bg(theme.danger)) + .child( div() .id(retry_id(kind)) .text_xs() - .font_weight(FontWeight::BOLD) + .font_weight(FontWeight::MEDIUM) .text_color(theme.danger) .cursor_pointer() + .hover(|s| s.underline()) .child("Retry") - .on_mouse_down(MouseButton::Left, move |_ev, window, cx| { + .on_click(move |_ev, window, cx| { + cx.stop_propagation(); retry(kind, window, cx); }), ) - }, - ) - // The inventory ecosystems are listed, never queried. - .when(entry.inventory_only, |element| { - element.child( - div() - .text_xs() - .text_color(theme.text_muted) - .child("listed, not queried"), - ) }); // L'arrivée : la banque arrive par en dessous, dans une vague qui @@ -286,7 +255,6 @@ impl SourceBank { } pub fn render(props: SourceBankProps) -> impl IntoElement { - let theme = props.theme; let health_of = |kind| { props.source_health.get(&kind).and_then(|health| match health.status { SourceHealthStatus::Failed => Some(("Failed", true)), @@ -315,15 +283,12 @@ impl SourceBank { let steps = waterfall_entry(&weights); let total = waterfall_duration(&steps); - // L'ancre : le canal qui porte le plus de lignes du périmètre. - let anchor = crate::state::anchor_index(props.axis); - let mut apertures = Vec::with_capacity(props.axis.len()); for (index, entry) in props.axis.iter().enumerate() { apertures.push(Self::render_aperture( entry, health_of(entry.kind), - index == anchor, + index == 0, &props, props.on_toggle.clone(), steps.get(index).copied().map(|step| (step, total)), @@ -337,14 +302,24 @@ impl SourceBank { .debug_selector(|| "source_bank".to_string()) .flex() .flex_row() - .gap(px(6.0)) + .items_center() + .flex_none() .w_full() - .px_3() - .py_2() - .border_b_1() - .border_color(theme.border) - .bg(theme.bg_app) - .children(apertures) + .child( + // One control, its segments side by side: the sources are an + // axis, not a pile of chips. + div() + .flex() + .flex_row() + .items_center() + .rounded_md() + .border_1() + .border_color(props.theme.border) + .bg(props.theme.bg_surface) + .shadow_xs() + .overflow_hidden() + .children(apertures), + ) } } diff --git a/Calix.Ui.Gpui/src/components/toast_overlay.rs b/Calix.Ui.Gpui/src/components/toast_overlay.rs index 8d0b9d9a..691ded7a 100644 --- a/Calix.Ui.Gpui/src/components/toast_overlay.rs +++ b/Calix.Ui.Gpui/src/components/toast_overlay.rs @@ -145,7 +145,7 @@ impl ToastOverlay { .border_color(theme.border) .text_xs() .font_weight(FontWeight::MEDIUM) - .text_color(theme.accent) + .text_color(theme.accent_text) .cursor_pointer() .hover(move |s| s.bg(theme.bg_surface_hover)) .child("Open Logs") diff --git a/Calix.Ui.Gpui/src/components/unified_search.rs b/Calix.Ui.Gpui/src/components/unified_search.rs index 2ab1a85c..db04e66c 100644 --- a/Calix.Ui.Gpui/src/components/unified_search.rs +++ b/Calix.Ui.Gpui/src/components/unified_search.rs @@ -19,42 +19,26 @@ impl UnifiedSearch { svg() .path(AppIcon::Search.path()) .size_8() - .text_color(theme.accent) + .text_color(theme.accent_text) .mb_3(), ) .child( div() - .text_base() - .font_weight(FontWeight::BOLD) + .text_xl() + .font_weight(FontWeight::SEMIBOLD) .text_color(theme.text_primary) .mb_2() - .child("Unified Search in Calix"), + .child("Search every source at once"), ) .child( div() - .text_xs() + .text_sm() + .line_height(relative(1.5)) .text_color(theme.text_secondary) - .max_w(px(460.0)) - .mb_4() + .max_w(px(440.0)) .child( - "Type a package or application name to search across Arch repositories, the AUR, Flatpak, and AppImages.", + "The Arch repositories, the AUR, Flatpak and AppImages answer together. Type a name; the arrows walk the results, and Ctrl+K runs any command.", ), ) - .child( - div() - .flex() - .flex_col() - .gap_1() - .p_3() - .rounded_md() - .bg(theme.bg_surface) - .border_1() - .border_color(theme.border) - .text_xs() - .text_color(theme.text_muted) - .child("• No network requests are dispatched on empty input") - .child("• Filters menu refines results by distribution backend and state") - .child("• Use Up / Down arrows to navigate through the virtualized results"), - ) } } diff --git a/Calix.Ui.Gpui/src/components/view_mode_switcher.rs b/Calix.Ui.Gpui/src/components/view_mode_switcher.rs index 598cbada..a04e35ce 100644 --- a/Calix.Ui.Gpui/src/components/view_mode_switcher.rs +++ b/Calix.Ui.Gpui/src/components/view_mode_switcher.rs @@ -123,14 +123,14 @@ impl ViewModeSwitcher { .rounded_sm() .cursor_pointer() .text_color(if is_active { - theme.accent + theme.accent_text } else { theme.text_muted }) .hover(move |s| s.bg(hover_bg).text_color(theme.text_primary)) .child(svg().path(mode.icon().path()).size(px(14.0)).text_color( if is_active { - theme.accent + theme.accent_text } else { theme.text_muted }, diff --git a/Calix.Ui.Gpui/src/config.rs b/Calix.Ui.Gpui/src/config.rs index 0ea3e23d..23fc4411 100644 --- a/Calix.Ui.Gpui/src/config.rs +++ b/Calix.Ui.Gpui/src/config.rs @@ -129,8 +129,9 @@ pub const MIN_WINDOW_WIDTH: f32 = 620.0; /// demande, et non un chiffre posé à côté. pub const MIN_WINDOW_HEIGHT: f32 = 520.0; +/// Le look par défaut est l'atelier de jour ; la nuit est un choix. fn default_dark_theme() -> bool { - true + false } fn default_window_width() -> f32 { @@ -667,7 +668,7 @@ mod tests { let parsed: GpuiUiConfig = serde_json::from_str(empty_json) .expect("Empty JSON object should deserialize with default values for all fields"); - assert!(parsed.dark_theme); + assert!(!parsed.dark_theme, "the day workshop is the default look"); assert_eq!(parsed.window_width, 1280.0); assert_eq!(parsed.window_height, 840.0); assert!(!parsed.compact_view); diff --git a/Calix.Ui.Gpui/src/fonts.rs b/Calix.Ui.Gpui/src/fonts.rs new file mode 100644 index 00000000..48801a6c --- /dev/null +++ b/Calix.Ui.Gpui/src/fonts.rs @@ -0,0 +1,59 @@ +//! Les polices de Calix, embarquées : la fenêtre ne dépend pas de ce que le +//! système a installé, et ne paie jamais la résolution d'une pile par défaut +//! (Skwir mesure 35 à 50 ms par image quand elle échoue). +//! +//! - `UI` — Instrument Sans : la voix de l'interface, des titres aux chiffres. +//! - `LABEL` — Instrument Sans SemiCondensed : les petits libellés (en-têtes de +//! colonne, noms de section). La largeur porte la hiérarchie à la place des +//! capitales. +//! - `CODE` — JetBrains Mono : ce qui est vraiment du texte de machine, à +//! copier tel quel : le journal, un PKGBUILD, une commande. +//! +//! Toutes sous licence SIL OFL 1.1 (`assets/fonts/OFL-*.txt`). + +use std::borrow::Cow; + +pub const UI: &str = "Instrument Sans"; +pub const LABEL: &str = "Instrument Sans SemiCondensed"; +pub const CODE: &str = "JetBrains Mono"; + +const FILES: &[&[u8]] = &[ + include_bytes!("../assets/fonts/InstrumentSans-Regular.ttf"), + include_bytes!("../assets/fonts/InstrumentSans-Medium.ttf"), + include_bytes!("../assets/fonts/InstrumentSans-SemiBold.ttf"), + include_bytes!("../assets/fonts/InstrumentSans-Bold.ttf"), + include_bytes!("../assets/fonts/InstrumentSansSemiCondensed-Medium.ttf"), + include_bytes!("../assets/fonts/InstrumentSansSemiCondensed-SemiBold.ttf"), + include_bytes!("../assets/fonts/JetBrainsMono-Regular.ttf"), + include_bytes!("../assets/fonts/JetBrainsMono-Medium.ttf"), +]; + +/// Les chiffres d'une colonne : tabulaires, pour qu'une version ou une taille +/// se lise contre celle de la ligne d'au-dessus. +pub fn figures() -> gpui::FontFeatures { + gpui::FontFeatures(std::sync::Arc::new(vec![("tnum".into(), 1)])) +} + +/// Donne les polices au système de texte de GPUI, avant la première fenêtre. +pub fn install(cx: &mut gpui::App) { + let fonts = FILES.iter().map(|bytes| Cow::Borrowed(*bytes)).collect(); + if let Err(error) = cx.text_system().add_fonts(fonts) { + log::warn!("Les polices de Calix n'ont pas pu être chargées : {error}"); + } +} + +#[cfg(test)] +mod tests { + use super::*; + use core::prelude::v1::test; + + #[test] + fn every_embedded_face_is_a_truetype_font() { + // A file replaced by a pointer or a page of HTML would load as nothing + // and the window would fall back to the system's stack, silently. + for face in FILES { + assert_eq!(&face[..4], &[0, 1, 0, 0], "a TrueType outline font"); + assert!(face.len() > 50_000); + } + } +} diff --git a/Calix.Ui.Gpui/src/main.rs b/Calix.Ui.Gpui/src/main.rs index e0926df3..ef5407e9 100644 --- a/Calix.Ui.Gpui/src/main.rs +++ b/Calix.Ui.Gpui/src/main.rs @@ -9,6 +9,7 @@ mod components; mod config; mod control; mod elements; +mod fonts; pub mod brand; pub mod icons; pub mod render_lab; @@ -101,6 +102,7 @@ fn main() { Application::with_platform(gpui_linux::current_platform(false)) .with_assets(crate::icons::AppIcons::new()) .run(move |cx: &mut App| { + crate::fonts::install(cx); cx.bind_keys([ KeyBinding::new("backspace", Backspace, Some("SearchInput")), KeyBinding::new("delete", Delete, Some("SearchInput")), diff --git a/Calix.Ui.Gpui/src/theme.rs b/Calix.Ui.Gpui/src/theme.rs index f37086a7..f060384f 100644 --- a/Calix.Ui.Gpui/src/theme.rs +++ b/Calix.Ui.Gpui/src/theme.rs @@ -5,8 +5,9 @@ //! cascade. Un changement de thème est un `cx.set_global` ; chaque vue le lit //! au prochain rendu. //! -//! - surfaces : `bg_app` pour ce qui se lit, `bg_surface` pour le chrome, -//! `bg_sidebar` pour le rail. +//! - surfaces : `bg_sidebar` est le châssis (l'aluminium, le rail, l'en-tête), +//! `bg_app` les plans posés dessus où l'on lit, `bg_surface` les contrôles et +//! les champs. Voir « The interface: the workshop » dans `docs/brand.md`. //! - états : `bg_surface_hover` sous le pointeur, `selection_bg` / //! `selection_text` pour ce qui est choisi, `on_accent` pour le texte et les glyphes posés sur une couleur pleine //! (l'accent, un badge, un succès). Un état n'est jamais dérivé localement. @@ -14,8 +15,10 @@ //! `rounded_md` pour les contrôles et les rangées, `rounded_lg` pour les //! panneaux (menus, toasts, cartes, dialogues), `rounded_full` pour les //! pastilles. Rien d'autre. -//! - élévation : `shadow_md` pour les menus et popovers, `shadow_lg` pour les -//! toasts et dialogues ; rien d'autre ne porte d'ombre. +//! - élévation : `shadow_xs` sous un contrôle posé sur le châssis (la bande +//! des sources), `shadow_sm` sous un plan (catalogue, inspecteur), +//! `shadow_md` pour les menus, les popovers et le cadran, `shadow_lg` pour +//! les toasts et dialogues ; rien d'autre ne porte d'ombre. //! //! Les jetons d'état sont dérivés (`Theme::derive_states`) de la palette et de //! l'accent, puis leur contraste est garanti : un accent choisi par @@ -57,13 +60,16 @@ pub struct Theme { /// Le texte et les glyphes posés sur l'accent : blanc, ou sombre sur un /// accent clair — celui des deux qui se lit. pub on_accent: Rgba, + /// L'accent écrit en texte sur un plan : l'orange de la marque se lit mal + /// sur l'aluminium clair, il fonce vers l'encre jusqu'à 4,5:1. + pub accent_text: Rgba, } impl Global for Theme {} impl Default for Theme { fn default() -> Self { - Self::dark() + Self::light() } } @@ -119,9 +125,18 @@ fn guarded_fill(fill: Rgba, toward: Rgba, light: Rgba, dark: Rgba) -> (Rgba, Rgb (ground, readable_on(ground, light, dark)) } +/// Une couleur écrite en texte sur `ground` : elle va vers `toward` (l'encre) +/// jusqu'à se lire à 4,5:1. +fn guarded_text(color: Rgba, ground: Rgba, toward: Rgba) -> Rgba { + (0..=20) + .map(|step| lerp(color, toward, step as f32 / 20.0)) + .find(|candidate| contrast(*candidate, ground) >= TEXT_CONTRAST) + .unwrap_or(toward) +} + impl Theme { /// Le thème de la fenêtre. Hors d'une fenêtre qui l'a posé (un banc de - /// test), le thème sombre par défaut. + /// test), l'atelier de jour par défaut. pub fn of(cx: &App) -> Self { cx.try_global::().copied().unwrap_or_default() } @@ -153,7 +168,9 @@ impl Theme { let dark = self.is_dark(); // La sélection est l'accent, adouci vers le fond : elle se voit sans // crier, et son texte reste lisible. - let tint = lerp(self.bg_app, self.accent, if dark { 0.45 } else { 0.30 }); + // L'atelier : une sélection est un plan teinté, pas un aplat ; c'est la + // barre d'accent de la rangée qui la désigne. + let tint = lerp(self.bg_app, self.accent, if dark { 0.24 } else { 0.14 }); let toward = if dark { self.bg_app } else { white }; let (light_text, dark_text) = if dark { (self.text_primary, ink) @@ -162,80 +179,92 @@ impl Theme { }; let (selection_bg, selection_text) = guarded_fill(tint, toward, light_text, dark_text); let on_accent = self.on(self.accent); + let accent_text = guarded_text(self.accent, self.bg_app, self.text_primary); Self { selection_bg, selection_text, on_accent, + accent_text, ..self } } + /// L'atelier de nuit : la tuile anthracite de la marque (`#111418`) pour le + /// châssis, des plans d'aluminium anodisé foncé pour ce qui se lit. pub fn dark() -> Self { Self { - bg_app: rgb(0x0f0f14), // Ultra-deep charcoal base - bg_sidebar: rgb(0x0a0a0e), // Dark contrast header/nav - bg_surface: rgb(0x181822), // Layered elevated card surface - bg_surface_hover: rgb(0x232332), // Immediate reactive hover state - bg_surface_active: rgb(0x2c2d40), // Active item surface - border: rgb(0x262638), // Subtle 1px boundary frame - border_focus: rgb(0x38bdf8), // Electric cyan focus glow - text_primary: rgb(0xf1f5f9), // Crisp high-contrast slate-50 - text_secondary: rgb(0x94a3b8), // Balanced legible secondary text - text_muted: rgb(0x94a3b8), // Legible WCAG AA hints and captions (6.87:1) - accent: rgb(0x38bdf8), // Electric cyan - accent_hover: rgb(0x7dd3fc), // Luminous cyan highlight - success: rgb(0x10b981), // Vibrant emerald accent dot - success_text: rgb(0x34d399), // High-contrast emerald text label (9.16:1) - warning: rgb(0xf59e0b), // Bright amber accent dot - warning_text: rgb(0xfbbf24), // High-contrast amber text label (10.55:1) - danger: rgb(0xf43f5e), // Vivid ruby rose - danger_hover: rgb(0xfb7185), // Luminous ruby highlight - badge_alpm: rgb(0x38bdf8), // Electric Cyan (Official ALPM) - badge_aur: rgb(0xa855f7), // Vivid Violet (AUR) - badge_flatpak: rgb(0x06b6d4), // Cyan (Flatpak) - badge_appimage: rgb(0xf97316), // Warm Orange (AppImage) - badge_cargo: rgb(0xd97757), // Burnt Sienna (Cargo) - badge_npm: rgb(0xcb3837), // NPM Red - badge_release: rgb(0x10b981), // Emerald (Release) + bg_sidebar: rgb(0x111418), // Le châssis : la tuile anthracite + bg_app: rgb(0x171b21), // Les plans posés dessus + bg_surface: rgb(0x1e232b), // Les contrôles et les champs + bg_surface_hover: rgb(0x242a33), + bg_surface_active: rgb(0x2c333d), + border: rgb(0x2b313a), // L'arête d'un plan + border_focus: rgb(0xff6a00), + text_primary: rgb(0xeceef1), + text_secondary: rgb(0xb3b9c2), + text_muted: rgb(0x8f97a2), + accent: rgb(0xff6a00), + accent_hover: rgb(0xff8e40), + success: rgb(0x3fb971), + success_text: rgb(0x62cf90), + warning: rgb(0xe9a23b), + warning_text: rgb(0xf2b961), + danger: rgb(0xf05a63), + danger_hover: rgb(0xf57c83), + // Les badges disent un écosystème, pas la marque : chacun sa + // couleur, celle de son projet quand il en a une. + badge_alpm: rgb(0x1793d1), // Le bleu d'Arch + badge_aur: rgb(0xa182e6), + badge_flatpak: rgb(0x5c9de0), + badge_appimage: rgb(0x8fb3c9), + badge_cargo: rgb(0xe0763f), + badge_npm: rgb(0xe0565a), + badge_release: rgb(0x3fb971), // Dérivés plus bas (`derive_states`). selection_bg: rgb(0x000000), selection_text: rgb(0x000000), on_accent: rgb(0x000000), + accent_text: rgb(0x000000), } .derive_states() } + /// L'atelier de jour, le look par défaut : un instrument d'aluminium clair, + /// à l'encre anthracite. Le châssis est l'aluminium brossé (`bg_sidebar`), + /// les plans où l'on lit sont plus clairs et posés dessus, l'orange ne sert + /// qu'à signaler : le curseur, le focus, l'action. pub fn light() -> Self { Self { - bg_app: rgb(0xf8fafc), - bg_sidebar: rgb(0xf1f5f9), - bg_surface: rgb(0xffffff), - bg_surface_hover: rgb(0xe2e8f0), - bg_surface_active: rgb(0xcbd5e1), - border: rgb(0xe2e8f0), - border_focus: rgb(0x0284c7), - text_primary: rgb(0x0f172a), - text_secondary: rgb(0x475569), - text_muted: rgb(0x64748b), // WCAG AA compliant muted text (4.76:1) - accent: rgb(0x0284c7), - accent_hover: rgb(0x0369a1), - success: rgb(0x059669), // Emerald accent dot - success_text: rgb(0x047857), // WCAG AA compliant emerald text (5.48:1) - warning: rgb(0xd97706), // Amber accent dot - warning_text: rgb(0xb45309), // WCAG AA compliant amber text (5.02:1) - danger: rgb(0xe11d48), - danger_hover: rgb(0xbe123c), - badge_alpm: rgb(0x0284c7), - badge_aur: rgb(0x7c3aed), - badge_flatpak: rgb(0x0891b2), - badge_appimage: rgb(0xea580c), - badge_cargo: rgb(0xb45309), - badge_npm: rgb(0x9f1239), - badge_release: rgb(0x047857), + bg_sidebar: rgb(0xe7eaee), // Le châssis : aluminium brossé + bg_app: rgb(0xf7f8fa), // Les plans : ce qui se lit + bg_surface: rgb(0xffffff), // Les contrôles et les champs + bg_surface_hover: rgb(0xeef0f3), + bg_surface_active: rgb(0xe2e6eb), + border: rgb(0xd5dae0), // L'arête d'un plan + border_focus: rgb(0xff6a00), + text_primary: rgb(0x111418), // L'encre : l'anthracite de la marque + text_secondary: rgb(0x3d444f), + text_muted: rgb(0x5d6571), + accent: rgb(0xff6a00), + accent_hover: rgb(0xff8e40), + success: rgb(0x1f8a4c), + success_text: rgb(0x16703c), + warning: rgb(0xc26a00), + warning_text: rgb(0x8c4a00), + danger: rgb(0xc62839), + danger_hover: rgb(0xa91f30), + badge_alpm: rgb(0x1793d1), + badge_aur: rgb(0x7a4cc2), + badge_flatpak: rgb(0x3c78c3), + badge_appimage: rgb(0x52707f), + badge_cargo: rgb(0xb7410e), + badge_npm: rgb(0xcb3837), + badge_release: rgb(0x1f8a4c), // Dérivés plus bas (`derive_states`). selection_bg: rgb(0x000000), selection_text: rgb(0x000000), on_accent: rgb(0x000000), + accent_text: rgb(0x000000), } .derive_states() } @@ -321,10 +350,10 @@ mod tests { assert_ne!(dark.border, dark.border_focus); assert_ne!(light.border, light.border_focus); - // Ensure default is dark theme + // The default is the day workshop. let def = Theme::default(); - assert_eq!(def.bg_app, dark.bg_app); - assert_eq!(def.accent, dark.accent); + assert_eq!(def.bg_app, light.bg_app); + assert_eq!(def.accent, light.accent); } #[test] @@ -407,12 +436,26 @@ mod tests { } } + #[test] + fn the_accent_written_as_text_reads_on_the_planes() { + // Signal orange is 2.8:1 on the day workshop's planes: as text it + // darkens toward the ink until it reads, in every look and brand. + for brand in Brand::ALL { + for theme in [Theme::light().with_brand(*brand), Theme::dark().with_brand(*brand)] { + let ratio = Theme::contrast_ratio(theme.accent_text, theme.bg_app); + assert!(ratio >= 4.5, "{brand:?}: accent text at {ratio:.2}:1"); + } + } + // In the night workshop the brand's own colour already reads. + assert_eq!(Theme::dark().accent_text, Theme::dark().accent); + } + #[gpui::test] fn the_theme_is_read_from_the_global(cx: &mut gpui::TestAppContext) { cx.update(|cx| { - assert_eq!(Theme::of(cx).bg_app, Theme::dark().bg_app, "sombre par défaut"); - cx.set_global(Theme::light()); - assert_eq!(Theme::of(cx).bg_app, Theme::light().bg_app); + assert_eq!(Theme::of(cx).bg_app, Theme::light().bg_app, "l'atelier de jour par défaut"); + cx.set_global(Theme::dark()); + assert_eq!(Theme::of(cx).bg_app, Theme::dark().bg_app); }); } } diff --git a/Calix.Ui.Gpui/src/ui_metrics.rs b/Calix.Ui.Gpui/src/ui_metrics.rs index e1a8cf0d..ae326e51 100644 --- a/Calix.Ui.Gpui/src/ui_metrics.rs +++ b/Calix.Ui.Gpui/src/ui_metrics.rs @@ -24,7 +24,7 @@ impl UiMetrics { // 168 left the catalogue with less than a row and a half. The plate is a // context surface — it is the first to give way — and its floor is the // height at which it still shows its tabs. - pub const SPLITTER_THICKNESS: f32 = 5.0; + pub const SPLITTER_THICKNESS: f32 = 8.0; /// Le plancher de la plaque : l'identité seule. /// /// La plaque cède d'abord — elle rend sa place avant que le catalogue @@ -33,6 +33,25 @@ impl UiMetrics { /// sélectionné, et que sans elle la plaque ne dit plus rien. pub const NAMEPLATE_MIN_HEIGHT: f32 = 48.0; pub const NAMEPLATE_MAX_RATIO: f32 = 0.55; + /// What the plate asks for under the catalogue until the user drags it: + /// enough for its name, its actions, its tabs and a first paragraph. It + /// asked for its floor, and a plate at its floor says only a name. + pub const NAMEPLATE_REQUESTED_HEIGHT: f32 = 300.0; + + // ── The inspector beside the catalogue ────────────────────────────────── + // + // Where the window has the room for the catalogue's floor and a useful + // inspector side by side, the inspector stands to the right; otherwise + // it lies under the catalogue (the plate). + /// What the side inspector asks for until the user drags its edge. + pub const INSPECTOR_SIDE_WIDTH: f32 = 400.0; + /// Below this, a side inspector wraps its facts word by word: it goes + /// under the catalogue instead. + pub const INSPECTOR_SIDE_MIN_WIDTH: f32 = 340.0; + /// The share of the band the side inspector may take. + pub const INSPECTOR_SIDE_MAX_RATIO: f32 = 0.5; + /// The aluminium between two planes. + pub const PLANE_GAP: f32 = 8.0; // ── Workbench Dimensions ───────────────────────────────────────────────── pub const SEARCH_INPUT_HEIGHT: f32 = 40.0; @@ -55,7 +74,7 @@ impl UiMetrics { // The header's band: the place that says where we are. It is a band, not // a text that happens to be there — the budget divides the window with // it, so its height has to be a number everyone knows. - pub const CONTEXT_HEADER_HEIGHT: f32 = 88.0; + pub const CONTEXT_HEADER_HEIGHT: f32 = 84.0; /// The vertical space the primary workspace keeps, whatever else is open. /// /// The catalogue is the body; the plate and the log are context surfaces. diff --git a/Calix.Ui.Gpui/src/views/inspector/dependencies.rs b/Calix.Ui.Gpui/src/views/inspector/dependencies.rs index 265cc625..9e19b55d 100644 --- a/Calix.Ui.Gpui/src/views/inspector/dependencies.rs +++ b/Calix.Ui.Gpui/src/views/inspector/dependencies.rs @@ -48,7 +48,7 @@ impl DependenciesView { div() .font_weight(FontWeight::BOLD) .text_color(if is_nav { - theme.accent + theme.accent_text } else { theme.text_primary }) diff --git a/Calix.Ui.Gpui/src/views/inspector/files_build.rs b/Calix.Ui.Gpui/src/views/inspector/files_build.rs index 8ead52ab..c7976475 100644 --- a/Calix.Ui.Gpui/src/views/inspector/files_build.rs +++ b/Calix.Ui.Gpui/src/views/inspector/files_build.rs @@ -4,6 +4,7 @@ use crate::components::package_table::PackageTable; use crate::components::semantic_value::SemanticValue; use crate::icons::AppIcon; use crate::state::SemanticTarget; +use crate::components::facts; use crate::theme::Theme; use gpui::*; @@ -19,26 +20,8 @@ pub struct FilesBuildViewProps<'a> { pub struct FilesBuildView; impl FilesBuildView { - fn render_info_row( - label: &'static str, - value: impl IntoElement, - theme: &Theme, - ) -> impl IntoElement { - div() - .flex() - .items_center() - .justify_between() - .py_1p5() - .border_b_1() - .border_color(theme.border) - .child( - div() - .text_xs() - .font_weight(FontWeight::SEMIBOLD) - .text_color(theme.text_muted) - .child(label), - ) - .child(div().text_sm().text_color(theme.text_primary).child(value)) + fn render_info_row(label: &'static str, value: impl IntoElement, theme: &Theme) -> Div { + facts::fact(label, value, theme) } pub fn render(props: FilesBuildViewProps) -> impl IntoElement { @@ -71,7 +54,7 @@ impl FilesBuildView { .child( div() .text_xs() - .text_color(theme.accent) + .text_color(theme.accent_text) .child(format!("via calix search aur {} -p", pkg.name)), ), ) @@ -108,62 +91,23 @@ impl FilesBuildView { }), ); - let meta_summary = div() - .flex() - .gap_3() - .mb_4() - .child( - div() - .flex_1() - .p_2() - .rounded_md() - .bg(theme.bg_surface) - .border_1() - .border_color(theme.border) - .child( - div() - .text_xs() - .text_color(theme.text_muted) - .child("PACKAGE BASE"), - ) - .child( - div() - .text_sm() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_primary) - .child( - aur.package_base - .clone() - .unwrap_or_else(|| pkg.name.clone()), - ), - ), - ) - .child( - div() - .flex_1() - .p_2() - .rounded_md() - .bg(theme.bg_surface) - .border_1() - .border_color(theme.border) - .child( - div() - .text_xs() - .text_color(theme.text_muted) - .child("POPULARITY / VOTES"), - ) - .child( - div() - .text_sm() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_primary) - .child(format!( - "{:.2} ({} votes)", - aur.popularity.unwrap_or(0.0), - aur.num_votes.unwrap_or(0) - )), - ), - ); + let meta_summary = facts::list([ + facts::fact( + "Package base", + aur.package_base.clone().unwrap_or_else(|| pkg.name.clone()), + theme, + ), + facts::fact( + "Popularity", + format!( + "{:.2} · {} votes", + aur.popularity.unwrap_or(0.0), + aur.num_votes.unwrap_or(0) + ), + theme, + ), + ]) + .mb_4(); let viewer = if props.is_loading_pkgbuild { div() @@ -174,7 +118,7 @@ impl FilesBuildView { .child( div() .text_sm() - .text_color(theme.accent) + .text_color(theme.accent_text) .child("Loading PKGBUILD recipe..."), ) .into_any_element() @@ -253,16 +197,16 @@ impl FilesBuildView { .border_1() .border_color(theme.border) .gap_2() - .child(Self::render_info_row("LOCAL FILE PATH", path_elem, theme)) - .child(Self::render_info_row("SIZE ON DISK", size_str, theme)) - .child(Self::render_info_row("UPDATE URL", update_elem, theme)) + .child(Self::render_info_row("File", path_elem, theme)) + .child(Self::render_info_row("Size on disk", size_str, theme)) + .child(Self::render_info_row("Update URL", update_elem, theme)) .child(Self::render_info_row( - "DESKTOP ENTRY", + "Desktop entry", ai.desktop_name.clone().unwrap_or_else(|| "—".to_string()), theme, )) .child(Self::render_info_row( - "ICON NAME", + "Icon name", ai.icon_name.clone().unwrap_or_else(|| "—".to_string()), theme, )); @@ -273,11 +217,7 @@ impl FilesBuildView { .py_4() .gap_4() .child( - div() - .text_xs() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_muted) - .child("APPIMAGE BUNDLE METADATA"), + facts::section_label("AppImage bundle", theme), ) .child(info) } @@ -297,11 +237,11 @@ impl FilesBuildView { .border_1() .border_color(theme.border) .gap_2() - .child(Self::render_info_row("CRATE", pkg.name.clone(), theme)) - .child(Self::render_info_row("VERSION", crate_.version.clone(), theme)) - .child(Self::render_info_row("BINARIES", binaries, theme)) + .child(Self::render_info_row("Crate", pkg.name.clone(), theme)) + .child(Self::render_info_row("Version", crate_.version.clone(), theme)) + .child(Self::render_info_row("Binaries", binaries, theme)) .child(Self::render_info_row( - "REGISTRY", + "Registry", if crate_.source.is_empty() { "crates.io".to_string() } else { @@ -316,11 +256,7 @@ impl FilesBuildView { .py_4() .gap_4() .child( - div() - .text_xs() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_muted) - .child("CARGO ECOSYSTEM METADATA"), + facts::section_label("Cargo crate", theme), ) .child(info) } @@ -335,10 +271,10 @@ impl FilesBuildView { .border_1() .border_color(theme.border) .gap_2() - .child(Self::render_info_row("PACKAGE", pkg.name.clone(), theme)) - .child(Self::render_info_row("VERSION", package.version.clone(), theme)) + .child(Self::render_info_row("Package", pkg.name.clone(), theme)) + .child(Self::render_info_row("Version", package.version.clone(), theme)) .child(Self::render_info_row( - "OVERRIDDEN", + "Overridden", if package.overridden { "yes" } else { "no" }.to_string(), theme, )); @@ -349,11 +285,7 @@ impl FilesBuildView { .py_4() .gap_4() .child( - div() - .text_xs() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_muted) - .child("NPM ECOSYSTEM METADATA"), + facts::section_label("npm package", theme), ) .child(info) } @@ -368,24 +300,24 @@ impl FilesBuildView { .border_1() .border_color(theme.border) .gap_2() - .child(Self::render_info_row("PACKAGE", pkg.name.clone(), theme)) + .child(Self::render_info_row("Package", pkg.name.clone(), theme)) .child(Self::render_info_row( - "INSTALLED", + "Installed", release.installed_version.clone().unwrap_or_else(|| "—".into()), theme, )) .child(Self::render_info_row( - "LATEST", + "Latest", release.latest_version.clone().unwrap_or_else(|| "—".into()), theme, )) .child(Self::render_info_row( - "UPSTREAM", + "Upstream", release.repo.clone().unwrap_or_else(|| "—".into()), theme, )) .child(Self::render_info_row( - "CHANNEL", + "Channel", release.canal.clone().unwrap_or_else(|| "—".into()), theme, )); @@ -396,11 +328,7 @@ impl FilesBuildView { .py_4() .gap_4() .child( - div() - .text_xs() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_muted) - .child("RELEASE ECOSYSTEM METADATA"), + facts::section_label("Release", theme), ) .child(info) } @@ -425,11 +353,11 @@ impl FilesBuildView { .border_1() .border_color(theme.border) .gap_2() - .child(Self::render_info_row("PACKAGE BASE", pkg_base, theme)) - .child(Self::render_info_row("BUILD DATE", build_date, theme)) - .child(Self::render_info_row("INSTALL DATE", install_date, theme)) + .child(Self::render_info_row("Package base", pkg_base, theme)) + .child(Self::render_info_row("Build date", build_date, theme)) + .child(Self::render_info_row("Install date", install_date, theme)) .child(Self::render_info_row( - "REPOSITORY", + "Repository", if pkg.repository_or_remote.is_empty() { "—".to_string() } else { @@ -457,7 +385,7 @@ impl FilesBuildView { svg() .path(AppIcon::Info.path()) .size_3_5() - .text_color(theme.accent), + .text_color(theme.accent_text), ) .child("Detailed File Tree Listing"), ) @@ -474,13 +402,7 @@ impl FilesBuildView { .flex_col() .py_4() .gap_4() - .child( - div() - .text_xs() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_muted) - .child("BUILD & INSTALLATION METADATA"), - ) + .child(facts::section_label("Build and installation", theme)) .child(build_info) .child(notice) } @@ -506,9 +428,9 @@ impl FilesBuildView { .border_1() .border_color(theme.border) .gap_2() - .child(Self::render_info_row("APPLICATION ID", app_id, theme)) - .child(Self::render_info_row("REMOTE CATALOG", remote, theme)) - .child(Self::render_info_row("APPLICATION TYPE", app_type, theme)); + .child(Self::render_info_row("Application ID", app_id, theme)) + .child(Self::render_info_row("Remote catalog", remote, theme)) + .child(Self::render_info_row("Application type", app_type, theme)); let notice = div() .p_4() @@ -538,11 +460,7 @@ impl FilesBuildView { .py_4() .gap_4() .child( - div() - .text_xs() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_muted) - .child("FLATPAK PACKAGE DETAILS"), + facts::section_label("Flatpak application", theme), ) .child(info) .child(notice) diff --git a/Calix.Ui.Gpui/src/views/inspector/mod.rs b/Calix.Ui.Gpui/src/views/inspector/mod.rs index 3e23c0f3..e072610c 100644 --- a/Calix.Ui.Gpui/src/views/inspector/mod.rs +++ b/Calix.Ui.Gpui/src/views/inspector/mod.rs @@ -87,10 +87,7 @@ impl PackageInspectorView { .flex_col() .gap(px(5.0)) .child( - div() - .text_xs() - .text_color(theme.text_muted) - .child(quiet.heading), + crate::components::facts::section_label(quiet.heading, theme), ) .child( div() @@ -112,7 +109,7 @@ impl PackageInspectorView { div() .text_xs() .text_color(theme.text_muted) - .child("Select a row above and it opens here."), + .child("Select a package and it opens here."), ) .into_any_element(); }; @@ -431,7 +428,7 @@ mod tests { is_busy: false, copy_feedback: false, quiet: QuietPlate { - heading: "THE BANK", + heading: "No package selected", subject: "Official / ALPM".to_string(), detail: "official repositories — binaries · 1914 rows in this scope".to_string(), }, @@ -473,7 +470,7 @@ mod tests { // La plaque au repos n'est pas rendue quand un paquet est ouvert, // mais la charge est toujours fournie : une seule forme de props. quiet: QuietPlate { - heading: "THE BANK", + heading: "No package selected", subject: "Official / ALPM".to_string(), detail: String::new(), }, @@ -533,7 +530,7 @@ mod tests { is_busy: false, copy_feedback: false, quiet: QuietPlate { - heading: "THE BANK", + heading: "No package selected", subject: "Official / ALPM".to_string(), detail: String::new(), }, diff --git a/Calix.Ui.Gpui/src/views/inspector/overview.rs b/Calix.Ui.Gpui/src/views/inspector/overview.rs index 34c9bf9f..344e18b6 100644 --- a/Calix.Ui.Gpui/src/views/inspector/overview.rs +++ b/Calix.Ui.Gpui/src/views/inspector/overview.rs @@ -1,4 +1,5 @@ use crate::backend::models::{AlpmPackage, UnifiedPackage, UnifiedPackageSource}; +use crate::components::facts; use crate::components::package_table::PackageTable; use crate::components::semantic_value::{SemanticValue, StringActionHandler}; use crate::state::{AlsoIn, SemanticTarget}; @@ -17,30 +18,6 @@ pub struct OverviewViewProps<'a> { pub struct OverviewView; impl OverviewView { - fn render_meta_item( - label: &'static str, - value: impl IntoElement, - theme: &Theme, - ) -> impl IntoElement { - div() - .flex() - .flex_col() - .gap(px(2.0)) - .p_2() - .rounded_md() - .bg(theme.bg_surface) - .border_1() - .border_color(theme.border) - .child( - div() - .text_xs() - .font_weight(FontWeight::SEMIBOLD) - .text_color(theme.text_muted) - .child(label), - ) - .child(div().text_sm().text_color(theme.text_primary).child(value)) - } - pub fn render(props: OverviewViewProps) -> impl IntoElement { let theme = props.theme; let pkg = props.package; @@ -115,75 +92,20 @@ impl OverviewView { let install_reason = alpm.and_then(|d| d.install_reason.clone()); - // 1. Description + // 1. The description: the first paragraph, which needs no caption. let desc_section = div() - .flex() - .flex_col() - .gap(px(4.0)) - .mb_4() - .child( - div() - .text_xs() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_muted) - .child("DESCRIPTION"), - ) - .child( - div() - .text_sm() - .text_color(theme.text_primary) - .line_height(relative(1.4)) - .child(if pkg.description.is_empty() { - "No description available for this package.".to_string() - } else { - pkg.description.clone() - }), - ); - - // 2. Grille de métadonnées - let mut meta_grid = div().flex().flex_col().gap_3(); - - // Ligne 1 : Dépôt & Licence - let row1 = div() - .flex() - .gap_3() - .child(div().flex_1().child(Self::render_meta_item( - "REPOSITORY / REMOTE", - if pkg.repository_or_remote.is_empty() { - "—".to_string() - } else { - pkg.repository_or_remote.clone() - }, - theme, - ))) - .child(div().flex_1().child(Self::render_meta_item( - "LICENSE", - if licenses.is_empty() { - "—".to_string() - } else { - licenses - }, - theme, - ))); - meta_grid = meta_grid.child(row1); - - // Ligne 2 : Tailles (Installée & Téléchargement) - let row2 = div() - .flex() - .gap_3() - .child(div().flex_1().child(Self::render_meta_item( - "INSTALLED SIZE", - installed_size_str.unwrap_or_else(|| "—".to_string()), - theme, - ))) - .child(div().flex_1().child(Self::render_meta_item( - "DOWNLOAD SIZE", - download_size_str.unwrap_or_else(|| "—".to_string()), - theme, - ))); - meta_grid = meta_grid.child(row2); - - // Ligne 3 : URL amont & Mainteneur + .mb_3() + .text_base() + .text_color(theme.text_primary) + .line_height(relative(1.5)) + .child(if pkg.description.is_empty() { + "No description available for this package.".to_string() + } else { + pkg.description.clone() + }); + + // 2. The facts, one under the other. + let or_dash = |value: String| if value.is_empty() { "—".to_string() } else { value }; let on_nav = props.on_navigate_package.clone(); let url_element: AnyElement = if let Some(url) = upstream_url { let url_c = url.clone(); @@ -192,7 +114,13 @@ impl OverviewView { } else { div().child("—").into_any_element() }; - + // In the AUR a person keeps the recipe; in the repositories a package + // comes from a base: the label says which one is meant. + let maintainer_label = if matches!(pkg.inner, UnifiedPackageSource::Aur(_)) { + "Maintainer" + } else { + "Package base" + }; let maintainer_element: AnyElement = if let Some(m) = maintainer { let m_c = m.clone(); SemanticValue::render(m, SemanticTarget::CopyText(m_c), theme, None).into_any_element() @@ -200,24 +128,24 @@ impl OverviewView { div().child("—").into_any_element() }; - let row3 = div() - .flex() - .gap_3() - .child( - div() - .flex_1() - .child(Self::render_meta_item("UPSTREAM URL", url_element, theme)), - ) - .child(div().flex_1().child(Self::render_meta_item( - "MAINTAINER / BASE", - maintainer_element, + let mut meta_grid = facts::list([ + facts::fact("Repository", or_dash(pkg.repository_or_remote.clone()), theme), + facts::fact("License", or_dash(licenses), theme), + facts::fact( + "Installed size", + installed_size_str.unwrap_or_else(|| "—".to_string()), theme, - ))); - meta_grid = meta_grid.child(row3); - - // Ligne 4 : Raison d'installation (si installée) + ), + facts::fact( + "Download size", + download_size_str.unwrap_or_else(|| "—".to_string()), + theme, + ), + facts::fact("Upstream", url_element, theme), + facts::fact(maintainer_label, maintainer_element, theme), + ]); if let Some(reason) = install_reason { - meta_grid = meta_grid.child(Self::render_meta_item("INSTALL REASON", reason, theme)); + meta_grid = meta_grid.child(facts::fact("Install reason", reason, theme)); } // 3. Le même nom, ailleurs. @@ -233,13 +161,7 @@ impl OverviewView { .flex_col() .gap(px(4.0)) .mt_4() - .child( - div() - .text_xs() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_muted) - .child("ALSO IN"), - ) + .child(facts::section_label("Also in", theme)) .child( div() .flex() @@ -259,7 +181,7 @@ impl OverviewView { .child( div() .text_xs() - .font_family("monospace") + .font_family(crate::fonts::UI).font_features(crate::fonts::figures()) .text_color(theme.text_muted) .child(entry.version.clone()), ) diff --git a/Calix.Ui.Gpui/src/views/news.rs b/Calix.Ui.Gpui/src/views/news.rs index 2d11cdfd..77d96e81 100644 --- a/Calix.Ui.Gpui/src/views/news.rs +++ b/Calix.Ui.Gpui/src/views/news.rs @@ -172,7 +172,7 @@ impl NewsView { .child( div() .text_xs() - .text_color(theme.accent) + .text_color(theme.accent_text) .child(item.published_date.clone().unwrap_or_default()), ), ) @@ -200,13 +200,13 @@ impl NewsView { .items_center() .gap_1() .text_xs() - .text_color(theme.accent) + .text_color(theme.accent_text) .mt_2() .child( svg() .path(AppIcon::ExternalUrl.path()) .size_3() - .text_color(theme.accent), + .text_color(theme.accent_text), ) .child("Open in browser"), ); diff --git a/Calix.Ui.Gpui/src/views/package_workstation.rs b/Calix.Ui.Gpui/src/views/package_workstation.rs index 52cf86a5..84eac4dd 100644 --- a/Calix.Ui.Gpui/src/views/package_workstation.rs +++ b/Calix.Ui.Gpui/src/views/package_workstation.rs @@ -43,6 +43,44 @@ impl Render for NameplateEdge { } } +/// What the side inspector's edge carries while it is dragged. +pub struct InspectorEdge; + +impl Render for InspectorEdge { + fn render(&mut self, _window: &mut Window, _cx: &mut Context) -> impl IntoElement { + Empty + } +} + +/// The drag of the side inspector's edge. +#[derive(Debug, Clone, Copy, PartialEq)] +pub struct InspectorDragState { + pub start_width: f32, + pub start_pointer_x: f32, +} + +/// Whether the inspector stands beside the catalogue: the window has the +/// room for the rail, the catalogue's floor, the edge and a useful inspector. +/// A pure decision from the window's width, as Skwir decides its split. +pub fn inspector_beside(window_width: f32) -> bool { + window_width + >= UiMetrics::SIDEBAR_EXPANDED + + UiMetrics::CATALOGUE_MIN_WIDTH + + UiMetrics::SPLITTER_THICKNESS + + UiMetrics::INSPECTOR_SIDE_MIN_WIDTH + + 4.0 * UiMetrics::PLANE_GAP +} + +/// The side inspector's width after a drag of its edge: pulling left makes it +/// grow, never past its share of the band nor into the catalogue's floor. +pub fn inspector_width_after_drag(drag: InspectorDragState, pointer_x: f32, band_width: f32) -> f32 { + let requested = drag.start_width - (pointer_x - drag.start_pointer_x); + let max = (band_width - UiMetrics::CATALOGUE_MIN_WIDTH - UiMetrics::SPLITTER_THICKNESS) + .min(band_width * UiMetrics::INSPECTOR_SIDE_MAX_RATIO) + .max(UiMetrics::INSPECTOR_SIDE_MIN_WIDTH); + requested.clamp(UiMetrics::INSPECTOR_SIDE_MIN_WIDTH, max) +} + /// The drag of the nameplate's edge. #[derive(Debug, Clone, Copy, PartialEq)] pub struct NameplateDragState { @@ -152,6 +190,9 @@ pub struct PackageWorkstationView { /// The height of the nameplate: the caption of the readout, under it. pub nameplate_height: f32, pub nameplate_drag: Option, + /// The side inspector's width, as the user left it. + pub inspector_width: f32, + pub inspector_drag: Option, pub scroll_handle: UniformListScrollHandle, /// The inspector's body scroll: its bar reads it. pub inspector_scroll: ScrollHandle, @@ -272,8 +313,10 @@ impl PackageWorkstationView { toast_center, // The plate starts at its floor: it grows when the user pulls // it, and it never takes the catalogue's rows to do it. - nameplate_height: UiMetrics::NAMEPLATE_MIN_HEIGHT, + nameplate_height: UiMetrics::NAMEPLATE_REQUESTED_HEIGHT, nameplate_drag: None, + inspector_width: UiMetrics::INSPECTOR_SIDE_WIDTH, + inspector_drag: None, scroll_handle: UniformListScrollHandle::new(), inspector_scroll: ScrollHandle::new(), on_mutation: None, @@ -574,15 +617,26 @@ impl PackageWorkstationView { } pub fn on_pointer_up(&mut self, cx: &mut Context) { - if self.nameplate_drag.is_some() { + if self.nameplate_drag.is_some() || self.inspector_drag.is_some() { self.nameplate_drag = None; + self.inspector_drag = None; cx.notify(); } } + + pub fn on_side_edge_dragged(&mut self, pointer_x: f32, band_width: f32, cx: &mut Context) { + if let Some(drag) = self.inspector_drag { + let width = inspector_width_after_drag(drag, pointer_x, band_width); + if (width - self.inspector_width).abs() >= 1.0 { + self.inspector_width = width; + cx.notify(); + } + } + } } impl Render for PackageWorkstationView { - fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { + fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let theme = Theme::of(cx); let entity = cx.entity().clone(); let is_busy = self.console.read(cx).is_running(); @@ -1118,9 +1172,10 @@ impl Render for PackageWorkstationView { .size_full() .flex_1() .overflow_hidden() - .border_1() + // The table is the plane itself: a rule under the toolbar, no + // recess cut into the plane. + .border_t_1() .border_color(theme.border) - .bg(theme.bg_sidebar) .when(shows_a_table, |element| { element.child(PackageTable::render_header( &theme, @@ -1138,9 +1193,10 @@ impl Render for PackageWorkstationView { .size_full() .flex_1() .overflow_hidden() - .border_1() + // The table is the plane itself: a rule under the toolbar, no + // recess cut into the plane. + .border_t_1() .border_color(theme.border) - .bg(theme.bg_sidebar) .child(list_body) }; @@ -1193,6 +1249,12 @@ impl Render for PackageWorkstationView { // The readout: the band where the work happens, in full width. let readout = div() .id("workstation_readout") + // A plane resting on the aluminium. + .bg(theme.bg_app) + .border_1() + .border_color(theme.border) + .rounded_lg() + .shadow_sm() // The handle the audit measures: the harness reads the bounds of // the band under this name. A noop outside the tests. .debug_selector(|| "workstation_readout".to_string()) @@ -1212,21 +1274,35 @@ impl Render for PackageWorkstationView { // it rides on the sheet's top edge: the same gesture, but it lifts // the sheet instead of resizing it. let is_resizing = self.nameplate_drag.is_some(); + // The edge is the aluminium between the two planes: a groove that + // shows its line only under the pointer or while it is dragged. + let groove_line = |vertical: bool, active: bool| { + let line = div().rounded_full().bg(if active { + theme.accent + } else { + gpui::transparent_black().into() + }); + let line = if vertical { + line.w(px(2.0)).h(px(32.0)) + } else { + line.h(px(2.0)).w(px(32.0)) + }; + line.group_hover("workstation_edge", { + let accent = theme.accent; + move |s| s.bg(accent) + }) + }; let edge_style = |style: gpui::Div| { style .id("workstation_nameplate_edge") + .group("workstation_edge") .w_full() .h(px(UiMetrics::SPLITTER_THICKNESS)) - .bg(if is_resizing { - theme.accent - } else { - theme.border - }) + .flex() + .items_center() + .justify_center() + .child(groove_line(false, is_resizing)) .cursor_row_resize() - .hover({ - let h = theme.accent; - move |s| s.bg(h) - }) .on_drag(NameplateEdge, |_, _, _, cx| cx.new(|_| NameplateEdge)) .on_mouse_down(MouseButton::Left, move |event, _window, cx| { // The press gives where the drag starts; only the @@ -1242,6 +1318,30 @@ impl Render for PackageWorkstationView { }) }; let splitter = edge_style(div().flex_shrink_0()); + let is_side_resizing = self.inspector_drag.is_some(); + let entity_side = entity.clone(); + let side_edge = div() + .id("workstation_inspector_edge") + .group("workstation_edge") + .flex_shrink_0() + .h_full() + .w(px(UiMetrics::SPLITTER_THICKNESS)) + .flex() + .items_center() + .justify_center() + .child(groove_line(true, is_side_resizing)) + .cursor_col_resize() + .on_drag(InspectorEdge, |_, _, _, cx| cx.new(|_| InspectorEdge)) + .on_mouse_down(MouseButton::Left, move |event, _window, cx| { + let pointer_x = event.position.x.to_f64() as f32; + entity_side.update(cx, |view, cx| { + view.inspector_drag = Some(InspectorDragState { + start_width: view.inspector_width, + start_pointer_x: pointer_x, + }); + cx.notify(); + }); + }); // ── 4. Panneau d'inspection sémantique ────────────────────────────── let alpm_details = selected_key @@ -1295,7 +1395,7 @@ impl Render for PackageWorkstationView { // excuse. let anchor_entry = source_axis.get(crate::state::anchor_index(&source_axis)); let quiet = QuietPlate { - heading: "THE BANK", + heading: "No package selected", subject: anchor_entry .map(|entry| entry.label.to_string()) .unwrap_or_else(|| "All sources".to_string()), @@ -1429,26 +1529,79 @@ impl Render for PackageWorkstationView { .into_any_element() }; - // The nameplate: the caption of the readout, in full width, under it. - // - // It is a band under the catalogue, and it yields before the - // catalogue is reduced: one always knows which package is selected. - // The flex decides, where the room is real: the plate asks for the - // height the user gave it, shrinks first (the catalogue has a floor), - // never below its own floor and never above its share of the band. - let nameplate = div() + // The inspector's plane, beside the catalogue or under it: the window + // decides, from its width (`inspector_beside`). + let beside = inspector_beside(f32::from(window.viewport_size().width)); + let inspector_plane = div() .id("workstation_nameplate") // The handle the audit measures: the harness reads the bounds // of the band under this name. A noop outside the tests. .debug_selector(|| "workstation_nameplate".to_string()) - .w_full() - .h(px(self.nameplate_height)) - .flex_shrink(1.0) - .min_h(px(UiMetrics::NAMEPLATE_MIN_HEIGHT)) - .max_h(relative(UiMetrics::NAMEPLATE_MAX_RATIO)) + .relative() + .bg(theme.bg_app) + .border_1() + .border_color(theme.border) + .rounded_lg() + .shadow_sm() .overflow_hidden() - .child(inspector_element) - .into_any_element(); + .child(inspector_element); + + let band = if beside { + // Beside: the catalogue keeps its floor, the inspector the width + // the user left it, within its share. + div() + .id("workstation_band") + .flex() + .flex_row() + .flex_1() + .min_h(px(0.0)) + .w_full() + .on_drag_move::(move |event, _window, cx| { + let band_width: f32 = event.bounds.size.width.into(); + let pointer_x: f32 = event.event.position.x.into(); + entity_move.update(cx, |view, cx| { + view.on_side_edge_dragged(pointer_x, band_width, cx); + }); + }) + .child(readout.min_w(px(UiMetrics::CATALOGUE_MIN_WIDTH))) + .child(side_edge) + .child( + inspector_plane + .h_full() + .w(px(self.inspector_width)) + .flex_shrink(1.0) + .min_w(px(UiMetrics::INSPECTOR_SIDE_MIN_WIDTH)) + .max_w(relative(UiMetrics::INSPECTOR_SIDE_MAX_RATIO)), + ) + } else { + // Under: the plate is the caption of the readout. It asks for the + // height the user gave it, shrinks first (the catalogue has a + // floor), never below its own floor nor above its share. + div() + .id("workstation_band") + .flex() + .flex_col() + .flex_1() + .min_h(px(0.0)) + .w_full() + .on_drag_move::(move |event, _window, cx| { + let band_height: f32 = event.bounds.size.height.into(); + let pointer_y: f32 = event.event.position.y.into(); + entity_move.update(cx, |view, cx| { + view.on_edge_dragged(pointer_y, band_height, cx); + }); + }) + .child(readout) + .child(splitter) + .child( + inspector_plane + .w_full() + .h(px(self.nameplate_height)) + .flex_shrink(1.0) + .min_h(px(UiMetrics::NAMEPLATE_MIN_HEIGHT)) + .max_h(relative(UiMetrics::NAMEPLATE_MAX_RATIO)), + ) + }; // ── 5. Conteneur racine de la station de travail absorbant les moves ── div() @@ -1458,34 +1611,17 @@ impl Render for PackageWorkstationView { .size_full() .relative() .overflow_hidden() + // The aluminium around the planes. + .px(px(UiMetrics::PLANE_GAP)) + .pb(px(UiMetrics::PLANE_GAP)) + .gap(px(UiMetrics::PLANE_GAP)) .on_mouse_up(MouseButton::Left, move |_event, _window, cx| { entity_up.update(cx, |view, cx| { view.on_pointer_up(cx); }); }) .child(source_bank) - .child( - // The band the catalogue and the plate share. The edge's drag - // reads its bounds from here, where they are real. - div() - .id("workstation_band") - .flex() - .flex_col() - .flex_1() - .min_h(px(0.0)) - .w_full() - .overflow_hidden() - .on_drag_move::(move |event, _window, cx| { - let band_height: f32 = event.bounds.size.height.into(); - let pointer_y: f32 = event.event.position.y.into(); - entity_move.update(cx, |view, cx| { - view.on_edge_dragged(pointer_y, band_height, cx); - }); - }) - .child(readout) - .child(splitter) - .child(nameplate), - ) + .child(band) } } @@ -1867,7 +2003,10 @@ mod tests { ); }; - // ── The whole window: the composition at the window's floor. + // ── A window too narrow for the inspector beside the catalogue: the + // plate lies under it, as the window decides (`inspector_beside`). + assert!(!inspector_beside(f32::from(window.0))); + cx.simulate_resize(size(window.0, window.1)); draw(cx); let bank = cx.debug_bounds("source_bank").expect("the bank is drawn"); let readout = cx @@ -1876,72 +2015,91 @@ mod tests { let nameplate = cx .debug_bounds("workstation_nameplate") .expect("the nameplate is drawn"); + let gap = UiMetrics::PLANE_GAP; - // The three bands fill the window: nothing is lost between them. - assert!( - (bank.size.height + readout.size.height + nameplate.size.height).floor() - <= window.1.floor(), - "the bands fit in the window: {} + {} + {} <= {}", - bank.size.height, - readout.size.height, - nameplate.size.height, - window.1 + // The bands fill the window, with the aluminium between them: the + // bank, a gap, the catalogue, the edge, the plate, a gap. + assert_eq!( + (f32::from(bank.size.height) + + gap + + f32::from(readout.size.height) + + UiMetrics::SPLITTER_THICKNESS + + f32::from(nameplate.size.height) + + gap) + .round(), + f32::from(window.1).round(), + "the bands and the aluminium fill the window" ); - assert!( - readout.size.height > px(0.0), - "the catalogue has room when the window is whole: {}", - readout.size.height + // With the room, the plate has the height it asks for: a name, its + // actions, its tabs and a first paragraph, not a name alone. + assert_eq!( + nameplate.size.height, + px(UiMetrics::NAMEPLATE_REQUESTED_HEIGHT), + "the plate has the height it asks for" ); + assert!(readout.size.height >= px(UiMetrics::CATALOGUE_MIN_HEIGHT)); // ── The station in the band the log drawer leaves it. // - // 372 px: the band cannot hold the bank, the edge, the catalogue's - // six rows *and* the plate's chrome. The plate yields first — it - // keeps its identity (48 px) and the catalogue keeps the rest. + // 372 px cannot hold the bank, the catalogue's six rows and the + // plate's request: the plate yields first, down to its floor, and the + // catalogue keeps its floor. let band_height = 372.0; fixture.update(cx, |fixture, _cx| fixture.band = Some(band_height)); draw(cx); let squeezed_readout = cx .debug_bounds("workstation_readout") .expect("the readout is drawn"); - // The bank takes what its content needs: read, never assumed. - let squeezed_bank = cx.debug_bounds("source_bank").expect("the bank is drawn"); - - // The plate stays in the flow — it yields, it does not leave: one - // always knows which package is selected. - assert!( - cx.debug_bounds("workstation_nameplate").is_some(), - "la plaque reste une bande du flux" - ); - - // And the catalogue takes the band below the bank, less the plate's - // floor: the plate yields, it does not leave, and the catalogue - // keeps its floor. + let squeezed_plate = cx + .debug_bounds("workstation_nameplate") + .expect("la plaque reste une bande du flux"); assert_eq!( squeezed_readout.size.height, - px(band_height - - f32::from(squeezed_bank.size.height) - - UiMetrics::SPLITTER_THICKNESS - - UiMetrics::NAMEPLATE_MIN_HEIGHT), - "le catalogue garde son plancher, la plaque son identité : {}", - squeezed_readout.size.height + px(UiMetrics::CATALOGUE_MIN_HEIGHT), + "le catalogue garde son plancher de six lignes" ); assert!( - squeezed_readout.size.height >= px(UiMetrics::CATALOGUE_MIN_HEIGHT) - px(0.5), - "et il garde son plancher de six lignes : {}", - squeezed_readout.size.height + squeezed_plate.size.height >= px(UiMetrics::NAMEPLATE_MIN_HEIGHT) + && squeezed_plate.size.height < px(UiMetrics::NAMEPLATE_REQUESTED_HEIGHT), + "la plaque cède d'abord, jusqu'à son identité : {}", + squeezed_plate.size.height ); - // In the flow, the plate takes its chrome from the band, and the - // catalogue keeps the rest. + // ── A wide window: the inspector stands beside the catalogue, as tall + // as it, at the width it asks for. + fixture.update(cx, |fixture, _cx| fixture.band = None); + let wide = (px(1400.0), px(800.0)); + assert!(inspector_beside(f32::from(wide.0))); + cx.simulate_resize(size(wide.0, wide.1)); + cx.draw(point(px(0.0), px(0.0)), size(wide.0, wide.1), |_window, _cx| { + fixture.clone().into_element() + }); + let readout = cx.debug_bounds("workstation_readout").unwrap(); + let inspector = cx.debug_bounds("workstation_nameplate").unwrap(); + assert_eq!(readout.origin.y, inspector.origin.y, "side by side"); + assert_eq!(readout.size.height, inspector.size.height, "as tall as the catalogue"); + assert_eq!(inspector.size.width, px(UiMetrics::INSPECTOR_SIDE_WIDTH)); + assert!(readout.size.width >= px(UiMetrics::CATALOGUE_MIN_WIDTH)); + } + + #[test] + fn the_side_inspector_is_dragged_within_its_bounds() { + let drag = InspectorDragState { + start_width: 400.0, + start_pointer_x: 1000.0, + }; + // Pulled left, it grows. + assert_eq!(inspector_width_after_drag(drag, 950.0, 1200.0), 450.0); + // Never past its share of the band, nor into the catalogue's floor. + assert_eq!(inspector_width_after_drag(drag, 0.0, 1200.0), 600.0); assert_eq!( - readout.size.height, - px(window.1 / px(1.0) - - f32::from(bank.size.height) - - UiMetrics::SPLITTER_THICKNESS - - UiMetrics::NAMEPLATE_MIN_HEIGHT), - "dans le flux, la plaque prend son chrome et le catalogue le reste : {}", - readout.size.height + inspector_width_after_drag(drag, 0.0, 1000.0), + 1000.0 - UiMetrics::CATALOGUE_MIN_WIDTH - UiMetrics::SPLITTER_THICKNESS + ); + // Pushed right, never below its floor. + assert_eq!( + inspector_width_after_drag(drag, 2000.0, 1200.0), + UiMetrics::INSPECTOR_SIDE_MIN_WIDTH ); } diff --git a/Calix.Ui.Gpui/src/views/settings.rs b/Calix.Ui.Gpui/src/views/settings.rs index e7c76f42..2312d8df 100644 --- a/Calix.Ui.Gpui/src/views/settings.rs +++ b/Calix.Ui.Gpui/src/views/settings.rs @@ -228,8 +228,10 @@ impl SettingsView { .flex() .flex_col() .size_full() - .bg(theme.bg_app) - .p_6() + // The sections are planes on the aluminium, like the catalogue. + .bg(theme.bg_sidebar) + .px(px(crate::ui_metrics::UiMetrics::PLANE_GAP)) + .pb_6() .overflow_y_scroll() .track_scroll(props.scroll); @@ -238,18 +240,19 @@ impl SettingsView { div() .flex() .flex_col() - .mb_6() + .mb_3() + .mt_1() .child( div() .flex() .items_center() .gap_3() + // The header names the place; this line says what it holds. .child( div() - .text_2xl() - .font_weight(FontWeight::BOLD) - .text_color(theme.text_primary) - .child("Calix Settings"), + .text_sm() + .text_color(theme.text_secondary) + .child("Package sources, desktop preferences and motion."), ) .child(if is_dirty { div() @@ -260,7 +263,7 @@ impl SettingsView { .text_xs() .font_weight(FontWeight::BOLD) .text_color(theme.on(theme.warning)) - .child("Unsaved Changes") + .child("Unsaved changes") } else { div() .px_2p5() @@ -272,12 +275,10 @@ impl SettingsView { .text_xs() .font_weight(FontWeight::MEDIUM) .text_color(theme.text_muted) - .child("Up to Date") + .child("Saved") }), ) - .child(div().text_xs().text_color(theme.text_muted).child( - "Configuration of package sources, desktop preferences, and motion policy.", - )), + ); // Section 1: PACKAGE SOURCES @@ -285,18 +286,19 @@ impl SettingsView { .flex() .flex_col() .p_4() - .mb_6() - .rounded_md() + .mb_3() + .rounded_lg() .bg(theme.bg_surface) .border_1() .border_color(theme.border) .child( div() - .text_sm() - .font_weight(FontWeight::BOLD) - .text_color(theme.accent) + .font_family(crate::fonts::LABEL) + .text_base() + .font_weight(FontWeight::SEMIBOLD) + .text_color(theme.text_primary) .mb_3() - .child("PACKAGE SOURCES"), + .child("Package sources"), ) .child(Self::toggle_row( "setting_aur", @@ -330,18 +332,19 @@ impl SettingsView { .flex() .flex_col() .p_4() - .mb_6() - .rounded_md() + .mb_3() + .rounded_lg() .bg(theme.bg_surface) .border_1() .border_color(theme.border) .child( div() - .text_sm() - .font_weight(FontWeight::BOLD) - .text_color(theme.accent) + .font_family(crate::fonts::LABEL) + .text_base() + .font_weight(FontWeight::SEMIBOLD) + .text_color(theme.text_primary) .mb_3() - .child("PACKAGE MANAGEMENT"), + .child("Package management"), ) .child(Self::toggle_row( "setting_cascade_delete", @@ -367,18 +370,19 @@ impl SettingsView { .flex() .flex_col() .p_4() - .mb_6() - .rounded_md() + .mb_3() + .rounded_lg() .bg(theme.bg_surface) .border_1() .border_color(theme.border) .child( div() - .text_sm() - .font_weight(FontWeight::BOLD) - .text_color(theme.accent) + .font_family(crate::fonts::LABEL) + .text_base() + .font_weight(FontWeight::SEMIBOLD) + .text_color(theme.text_primary) .mb_3() - .child("APPEARANCE & DENSITY"), + .child("Appearance and density"), ) .child(Self::toggle_row( "setting_dark_theme", @@ -431,18 +435,19 @@ impl SettingsView { .flex() .flex_col() .p_4() - .mb_6() - .rounded_md() + .mb_3() + .rounded_lg() .bg(theme.bg_surface) .border_1() .border_color(theme.border) .child( div() - .text_sm() - .font_weight(FontWeight::BOLD) - .text_color(theme.accent) + .font_family(crate::fonts::LABEL) + .text_base() + .font_weight(FontWeight::SEMIBOLD) + .text_color(theme.text_primary) .mb_3() - .child("MOTION & FEEDBACK"), + .child("Motion and feedback"), ) .child(Self::toggle_row( "setting_reduce_motion", @@ -460,18 +465,19 @@ impl SettingsView { .flex() .flex_col() .p_4() - .mb_6() - .rounded_md() + .mb_3() + .rounded_lg() .bg(theme.bg_surface) .border_1() .border_color(theme.border) .child( div() - .text_sm() - .font_weight(FontWeight::BOLD) - .text_color(theme.accent) + .font_family(crate::fonts::LABEL) + .text_base() + .font_weight(FontWeight::SEMIBOLD) + .text_color(theme.text_primary) .mb_3() - .child("LOGS & OPERATIONS"), + .child("Logs and operations"), ) .child(Self::toggle_row( "setting_log_drawer_auto_open", @@ -493,8 +499,8 @@ impl SettingsView { .flex() .flex_col() .p_4() - .mb_6() - .rounded_md() + .mb_3() + .rounded_lg() .bg(theme.bg_surface) .border_1() .border_color(theme.border) @@ -518,10 +524,11 @@ impl SettingsView { }) .child( div() - .text_sm() - .font_weight(FontWeight::BOLD) - .text_color(theme.accent) - .child("ADVANCED SETTINGS"), + .font_family(crate::fonts::LABEL) + .text_base() + .font_weight(FontWeight::SEMIBOLD) + .text_color(theme.text_primary) + .child("Advanced"), ) .child( div() @@ -560,7 +567,7 @@ impl SettingsView { svg() .path(AppIcon::RenderLab.path()) .size(px(16.0)) - .text_color(theme.accent), + .text_color(theme.accent_text), ) .child( div() @@ -1033,7 +1040,7 @@ mod tests { assert!(!settings.draft_calix.package_management_remove_configs); settings.toggle_dark_theme(); - assert!(!settings.draft_gpui.dark_theme); + assert!(settings.draft_gpui.dark_theme); settings.toggle_compact_view(); assert!(settings.draft_gpui.compact_view); diff --git a/Calix.Ui.Gpui/src/views/workspace.rs b/Calix.Ui.Gpui/src/views/workspace.rs index d2dd6767..b2b55498 100644 --- a/Calix.Ui.Gpui/src/views/workspace.rs +++ b/Calix.Ui.Gpui/src/views/workspace.rs @@ -2581,13 +2581,22 @@ impl Render for WorkspaceView { NavScope::Installed => &store.installed_packages, NavScope::Updates => &store.updates_packages, }; + // The count is the list's: in Installed and Updates the text + // typed narrows the rows, as the station narrows them, so the + // header never says "3 packages" over an empty list. + let query = self.session.read(cx).search_query.clone(); + let query_narrows = header_scope != NavScope::Results && !query.trim().is_empty(); crate::state::query::visible_packages( rows, &source_scope, state_filter, SortMode::Relevance, ) - .len() + .iter() + .filter(|package| { + !query_narrows || crate::state::query::matches_query(package, &query) + }) + .count() } Place::News => self.news.len(), Place::Settings => 0, @@ -2683,7 +2692,8 @@ impl Render for WorkspaceView { .relative() .flex() .flex_row() - .bg(theme.bg_app) + .bg(theme.bg_sidebar) + .font_family(crate::fonts::UI) .text_color(theme.text_primary) .track_focus(&self.search_focus) .key_context(keys::WORKSPACE_CONTEXT) diff --git a/docs/brand.md b/docs/brand.md index d72026da..1148b7b7 100644 --- a/docs/brand.md +++ b/docs/brand.md @@ -66,6 +66,39 @@ From the logo pack, and they are the rules the application follows: - Clear space: at least 10% of the mark's height on every side. - Scale uniformly only. Never skew, never re-typeset. +## The interface: the workshop + +The window is an instrument made of the mark's own materials: the brushed +aluminium of the stem and the anthracite of the tile. Calix opens in the +**day workshop** (light); the **night workshop** is a choice in the settings. + +| Token | Day | Night | What it is | +|---|---|---|---| +| `bg_sidebar` | `#E7EAEE` | `#111418` | The chassis: aluminium by day, the brand's anthracite tile by night | +| `bg_app` | `#F7F8FA` | `#171B21` | The planes where one reads: the catalogue, the inspector, the settings' sections | +| `bg_surface` | `#FFFFFF` | `#1E232B` | Controls and fields | +| `border` | `#D5DAE0` | `#2B313A` | A plane's edge, a hairline between two facts | +| `text_primary` | `#111418` | `#ECEEF1` | The ink: the brand's anthracite by day | +| `accent_text` | derived | derived | The accent written as text, darkened toward the ink until it reads at 4.5:1 | + +Rules the interface keeps: + +- **The accent signals, it does not decorate.** It is the cursor (the + selection's bar), the focus, the primary action, and the lamps of what is + on. A figure (a size bar) is graphite. +- **Two kinds of surface.** Planes rest on the chassis with an edge and a fine + shadow, separated by a groove of aluminium that is also their resize handle. + The dial is the one object of the chassis with a shadow of its own. +- **Lamps for what is on.** A source in the scope, a toggle that is on: a dot + lit in the accent; off, a ring. +- **Three voices** (`src/fonts.rs`, embedded, OFL): Instrument Sans for the + interface, its SemiCondensed cut for labels, JetBrains Mono only for what is + machine text (the log, a PKGBUILD, a command). Figures in columns are + tabular. +- **Sentence case.** A label is set apart by its narrow cut and its colour, + never by capitals; meta is joined by its own words ("Arch / extra"), not by + middle dots. + ## Provenance The pack is a deterministic build: `src/build_calix_logo.py` regenerates the whole