diff --git a/Cargo.lock b/Cargo.lock index 337d40f9..ad77b9f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1151,8 +1151,6 @@ dependencies = [ "criterion", "eframe", "eggshell-ui", - "eggshell-ui-extras", - "eggshell-ui-shadcn", "egui", "egui-wgpu", "egui_extras", @@ -1162,33 +1160,16 @@ dependencies = [ "nohash-hasher", "pollster", "proptest", + "pulldown-cmark", "taffy", "trybuild", + "unicode-normalization", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", "web-time", ] -[[package]] -name = "eggshell-ui-extras" -version = "0.1.0" -dependencies = [ - "eggshell-ui", - "egui", - "pulldown-cmark", - "unicode-normalization", -] - -[[package]] -name = "eggshell-ui-shadcn" -version = "0.1.0" -dependencies = [ - "eggshell-ui", - "eggshell-ui-extras", - "egui", -] - [[package]] name = "egui" version = "0.37.0" diff --git a/Cargo.toml b/Cargo.toml index 763dd987..faec5cb0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,9 +16,22 @@ nohash-hasher = "0.2" web-time = "1.1" log = "0.4" egui_kittest = { version = "0.37", optional = true } +pulldown-cmark = { version = "0.13.6", default-features = false, optional = true } +unicode-normalization = { version = "0.1.25", optional = true } [features] -default = ["clipboard"] +default = [ + "clipboard", + "fonts", + # keep sorted + "accordion", + "badge", + "dialog", + "disclosure", + "skeleton", + "spinner", + "tabs", +] # The system clipboard, read on demand through `Shell::read_clipboard`. # Without it, or on wasm, a read answers `ClipboardError::Unavailable`. clipboard = ["dep:arboard"] @@ -33,6 +46,20 @@ screenshots = ["dep:egui_kittest", "egui_kittest/wgpu", "dep:egui-wgpu", "dep:po # Golden-image tests: kittest renders them on the screenshot path, so they need # Mesa lavapipe. `cargo xtask snapshots` selects it. snapshots = ["screenshots", "egui_kittest/snapshot"] +# The widgets beyond core's controls, each its own feature. +# keep sorted +accordion = ["disclosure"] +badge = [] +command = ["dep:unicode-normalization"] +dialog = [] +disclosure = [] +form = [] +hover-card = [] +markdown = ["dep:pulldown-cmark"] +notify = [] +skeleton = [] +spinner = [] +tabs = [] # The version egui-winit asks for, so the tree has the one arboard. [target.'cfg(not(any(target_arch = "wasm32", target_os = "android", target_os = "ios")))'.dependencies] @@ -57,9 +84,8 @@ eframe = "0.37" egui_kittest = "0.37" trybuild = "1" # eggshell's own tests drive views through `testing::Driver`. -eggshell-ui = { path = ".", features = ["driver"] } -eggshell-ui-shadcn = { path = "crates/eggshell-ui-shadcn", features = ["extras"] } -eggshell-ui-extras = { path = "crates/eggshell-ui-extras", features = [ +eggshell-ui = { path = ".", features = [ + "driver", # keep sorted "accordion", "badge", @@ -89,7 +115,7 @@ harness = false wasm-bindgen-futures = "0.4" [workspace] -members = ["crates/eggshell-ui-shadcn", "crates/eggshell-ui-extras", "xtask"] +members = ["xtask"] # clippy.toml's disallowed macros and methods are denied in library code by # each library's crate attributes; tests, examples and benches may use them. @@ -114,3 +140,7 @@ debug = "line-tables-only" inherits = "dev" debug-assertions = false overflow-checks = false + +[[example]] +name = "preset_dump" +required-features = ["badge", "command", "dialog", "disclosure", "form", "hover-card", "markdown", "notify", "skeleton"] diff --git a/README.md b/README.md index 0b45499e..c11d4e2b 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,27 @@ so lavapipe is needed there too. - `--filter NAME` runs only the goldens whose test name starts with `NAME` (they live in the `snapshots` module of the `it` test binary, so `NAME` is matched after `snapshots::`). - `--clean` deletes the stray `.new.png` and `.diff.png` files. +## Fonts + +With the default `fonts` feature the preset bundles **Geist**, shadcn's +default sans-serif, as one variable font, `src/fonts/Geist-Variable.ttf` +(`Geist[wght].ttf` from [vercel/geist-font](https://github.com/vercel/geist-font) +v1.9.2, 165 KiB). `Shadcn::apply` registers it at 400, 500, 600 and 700, so +`font_medium()`, `font_semibold()` and `font_bold()` draw real faces, and the +preset's buttons, labels and menu headings take shadcn's weights. + +Geist is licensed under the SIL Open Font License 1.1; the licence is shipped +beside the font in [`src/fonts/OFL.txt`](src/fonts/OFL.txt) and applies to the font +file only. The crate's code is MIT. + +- Swap the font with `Shadcn::with_fonts(Some(FontSet::variable(..)))` or + `FontSet::faces(..)` for static files, or keep egui's fonts with + `with_fonts(None)`. +- Leave it out with `default-features = false`: nothing is embedded, and + weights are drawn in the regular face with a debug warning. +- egui's own `default_fonts` feature embeds Ubuntu-Light, which Geist makes a + fallback only. Depend on egui with `default-features = false` to drop it. + ## License MIT diff --git a/crates/eggshell-ui-extras/Cargo.toml b/crates/eggshell-ui-extras/Cargo.toml deleted file mode 100644 index 3a4e09f9..00000000 --- a/crates/eggshell-ui-extras/Cargo.toml +++ /dev/null @@ -1,36 +0,0 @@ -[package] -name = "eggshell-ui-extras" -version = "0.1.0" -edition = "2024" -rust-version = "1.96" -license = "MIT" -description = "Reusable composites and third-party adapters for eggshell" -repository = "https://github.com/samitbasu/eggshell" - -[features] -# Each widget is opt-in. -# keep sorted -accordion = ["disclosure"] -badge = [] -command = ["dep:unicode-normalization"] -dialog = [] -disclosure = [] -form = [] -hover-card = [] -markdown = ["dep:pulldown-cmark"] -notify = [] -skeleton = [] -spinner = [] -tabs = [] - -[dependencies] -eggshell-ui = { path = "../..", version = "0.1.0" } -egui = "0.37" -pulldown-cmark = { version = "0.13.6", default-features = false, optional = true } -unicode-normalization = { version = "0.1.25", optional = true } - -[package.metadata.docs.rs] -all-features = true - -[lints] -workspace = true diff --git a/crates/eggshell-ui-extras/src/lib.rs b/crates/eggshell-ui-extras/src/lib.rs deleted file mode 100644 index 99a806e3..00000000 --- a/crates/eggshell-ui-extras/src/lib.rs +++ /dev/null @@ -1,60 +0,0 @@ -#![cfg_attr( - not(test), - deny( - clippy::panic, - clippy::unwrap_used, - clippy::expect_used, - clippy::unreachable, - clippy::todo, - clippy::unimplemented, - clippy::panic_in_result_fn, - clippy::unwrap_in_result, - clippy::get_unwrap, - clippy::string_slice, - clippy::indexing_slicing, - clippy::unchecked_time_subtraction, - clippy::disallowed_macros, - clippy::disallowed_methods, - clippy::fn_params_excessive_bools - ) -)] -//! TODO(prose) - -// keep sorted -#[cfg(feature = "accordion")] -pub mod accordion; -#[cfg(feature = "badge")] -pub mod badge; -#[cfg(feature = "command")] -pub mod command; -#[cfg(feature = "dialog")] -pub mod dialog; -#[cfg(feature = "disclosure")] -pub mod disclosure; -#[cfg(feature = "form")] -pub mod form; -#[cfg(feature = "hover-card")] -pub mod hover_card; -#[cfg(feature = "markdown")] -pub mod markdown; -#[cfg(feature = "notify")] -pub mod notify; -#[cfg(feature = "skeleton")] -pub mod skeleton; -#[cfg(feature = "spinner")] -pub mod spinner; -// keep sorted -#[cfg(any( - feature = "badge", - feature = "command", - feature = "disclosure", - feature = "form", - feature = "markdown", - feature = "notify", - feature = "skeleton", - feature = "spinner", - feature = "tabs" -))] -mod styles; -#[cfg(feature = "tabs")] -pub mod tabs; diff --git a/crates/eggshell-ui-shadcn/Cargo.toml b/crates/eggshell-ui-shadcn/Cargo.toml deleted file mode 100644 index 7f9c18a7..00000000 --- a/crates/eggshell-ui-shadcn/Cargo.toml +++ /dev/null @@ -1,40 +0,0 @@ -[package] -name = "eggshell-ui-shadcn" -version = "0.1.0" -edition = "2024" -rust-version = "1.96" -license = "MIT" -description = "The shadcn/ui design system as a eggshell style" -repository = "https://github.com/samitbasu/eggshell" - -[features] -default = ["fonts"] -# Bundles Geist (SIL OFL 1.1, fonts/OFL.txt), 165 KiB, as the preset's font. -fonts = ["eggshell-ui/fonts"] -# Fills the looks of eggshell-ui-extras' widgets from the preset's tokens. -extras = [ - "dep:eggshell-ui-extras", - # keep sorted - "eggshell-ui-extras/accordion", - "eggshell-ui-extras/badge", - "eggshell-ui-extras/command", - "eggshell-ui-extras/dialog", - "eggshell-ui-extras/disclosure", - "eggshell-ui-extras/form", - "eggshell-ui-extras/hover-card", - "eggshell-ui-extras/markdown", - "eggshell-ui-extras/notify", - "eggshell-ui-extras/skeleton", -] - -[dependencies] -eggshell-ui = { path = "../..", version = "0.1.0" } -egui = "0.37" -eggshell-ui-extras = { path = "../eggshell-ui-extras", version = "0.1.0", optional = true } - -[lints] -workspace = true - -[[example]] -name = "preset_dump" -required-features = ["extras"] diff --git a/crates/eggshell-ui-shadcn/README.md b/crates/eggshell-ui-shadcn/README.md deleted file mode 100644 index e3268505..00000000 --- a/crates/eggshell-ui-shadcn/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# eggshell-ui-shadcn - -The shadcn/ui design system as an eggshell style. Nothing here runs until the -application calls `Shadcn::apply` (or `Shadcn::apply_both`). - -## Fonts - -With the default `fonts` feature the preset bundles **Geist**, shadcn's -default sans-serif, as one variable font, `src/fonts/Geist-Variable.ttf` -(`Geist[wght].ttf` from [vercel/geist-font](https://github.com/vercel/geist-font) -v1.9.2, 165 KiB). `Shadcn::apply` registers it at 400, 500, 600 and 700, so -`font_medium()`, `font_semibold()` and `font_bold()` draw real faces, and the -preset's buttons, labels and menu headings take shadcn's weights. - -Geist is licensed under the SIL Open Font License 1.1; the licence is shipped -beside the font in [`src/fonts/OFL.txt`](../../src/fonts/OFL.txt) and applies to the font -file only. The crate's code is MIT. - -- Swap the font with `Shadcn::with_fonts(Some(FontSet::variable(..)))` or - `FontSet::faces(..)` for static files, or keep egui's fonts with - `with_fonts(None)`. -- Leave it out with `default-features = false`: nothing is embedded, and - weights are drawn in the regular face with a debug warning. -- egui's own `default_fonts` feature embeds Ubuntu-Light, which Geist makes a - fallback only. Depend on egui with `default-features = false` to drop it. diff --git a/crates/eggshell-ui-shadcn/src/lib.rs b/crates/eggshell-ui-shadcn/src/lib.rs deleted file mode 100644 index 9f95ec33..00000000 --- a/crates/eggshell-ui-shadcn/src/lib.rs +++ /dev/null @@ -1,136 +0,0 @@ -#![deny(missing_docs)] -#![cfg_attr( - not(test), - deny( - clippy::panic, - clippy::unwrap_used, - clippy::expect_used, - clippy::unreachable, - clippy::todo, - clippy::unimplemented, - clippy::panic_in_result_fn, - clippy::unwrap_in_result, - clippy::get_unwrap, - clippy::string_slice, - clippy::indexing_slicing, - clippy::unchecked_time_subtraction, - clippy::disallowed_macros, - clippy::disallowed_methods, - clippy::fn_params_excessive_bools - ) -)] -//! The shadcn/ui design system as a [`eggshell_ui::Style`]. -//! -//! [`Shadcn`] is a preset: a [`ShadcnStyle`] (which of shadcn's styles, such as -//! [`Vega`](ShadcnStyle::Vega) or [`Lyra`](ShadcnStyle::Lyra)), a -//! [`Palette`] (shadcn's base and theme colours) and an egui theme (light or dark), -//! chosen independently. Nothing here runs unless the application calls -//! [`Shadcn::apply`]: the library never changes egui's style on its own. -//! -//! The crate only fills the contract. `eggshell` defines what its widgets -//! need and has no shadcn names or values; a style is data, so changing -//! [`ShadcnStyle`] at run time changes sizes, radii, text size and ring width -//! with no code change in the application. -//! -//! Applying a preset does three things. It fills the [`eggshell_ui::Style`] -//! contract with the tokens ([`Shadcn::style`]) and installs it for the -//! preset's theme, which the owned widgets and the text edit of `eggshell` -//! draw from. It maps the [`Tokens`] onto the egui [`Style`](egui::Style) of -//! the preset's theme (widget fills, strokes, radii, selection, spacing) for -//! the egui widgets an application draws outside eggshell. It also remembers -//! the tokens in the context, for [`tokens`] and [`Shadcn::of`]. -//! -//! ``` -//! use eggshell_ui_shadcn::{Palette, Shadcn, ShadcnStyle, ThemeColor}; -//! -//! let ctx = egui::Context::default(); -//! // Once at startup: shadcn's default preset, light and dark. -//! Shadcn::apply_both(&ctx); -//! // Or every frame, to switch style or colour at run time; a no-op while -//! // nothing changes. -//! Shadcn::apply_both_with(&ctx, ShadcnStyle::Lyra, Palette::new().theme(ThemeColor::Blue)); -//! // The tokens, for the application's own colours. -//! let background = Shadcn::of(&ctx).tokens.background; -//! # let _ = background; -//! ``` -//! -//! What eggshell cannot draw exactly and the preset therefore approximates is -//! documented on [`eggshell_ui::contract::InputStyle`] for the wrapped text edit; -//! the owned widgets are exact except for the negative spread of `shadow-md`. -//! -//! # Fonts -//! -//! With the default `fonts` feature the preset bundles Geist, shadcn's -//! `--font-sans`, as one variable font (165 KiB, SIL Open Font License 1.1, -//! `fonts/OFL.txt`) and [`Shadcn::apply`] registers it at every [`Weight`]: -//! Normal as the first font of [`FontFamily::Proportional`], the others as -//! named families its [`Faces`] declare. [`Shadcn::with_fonts`] swaps in -//! another [`FontSet`], or `None` for egui's fonts as the application set -//! them. Without the feature nothing is embedded and the preset starts with -//! no font, so its medium controls are drawn in the regular face, with a -//! debug warning. -//! -//! The application's own text picks a weight with eggshell's classes -//! (`tw().font_medium()`, `font_semibold`, `font_bold`). A [`FontSet`] of -//! static faces that leaves a weight out draws it in the nearest lighter -//! face it has. eggshell's symbol face (⌘, ⇧, ⌥) sits last in every weight's -//! family, behind Geist, so key chips and menu shortcuts draw in any weight. -//! -//! egui's `default_fonts` feature embeds its own Ubuntu-Light, which Geist -//! makes a fallback only. An application that does not need it can depend on -//! egui with `default-features = false` (and the features it does use) to -//! drop it from the binary. -//! -//! [`Weight`]: eggshell_ui::Weight -//! [`Faces`]: eggshell_ui::Faces -//! [`FontFamily::Proportional`]: egui::FontFamily::Proportional -//! -//! # Hovered and selected -//! -//! shadcn's components pair the two as follows, and the helpers on -//! [`Tokens`] name the pairs: -//! -//! | Component | Hovered | Selected | -//! |---|---|---| -//! | List or menu row on the page | `accent/50` ([`Tokens::accent_50`]) | `accent` with `accent-foreground` | -//! | Table row | `muted/50` ([`Tokens::muted_50`]) | `muted` | -//! | Ghost and outline button | `accent` with `accent-foreground` (dark: `accent/50`, `input/50`) | | -//! | Secondary, primary, destructive button | `secondary/80`, `primary/90`, `destructive/90` | | -//! -//! In the neutral palette `muted`, `accent` and `secondary` are one colour, -//! so a hover on a `muted` surface needs the half-strength variant of the -//! selected colour, not a different token. - -mod drag_chip; -mod preset; -#[rustfmt::skip] -mod sheets; - -pub use drag_chip::{DragChip, drag_chip}; -pub use eggshell_ui::theme::size; -pub use eggshell_ui::theme::{ - BaseColor, ContrastPair, ContrastRatio, Elevation, FontSet, HoverSurface, Palette, - REGISTRY_MISSES, RegistryMiss, ShadcnStyle, ThemeColor, Tokens, -}; -pub use preset::{Shadcn, tokens}; - -/// The names of shadcn's button variants, as the preset's sheet names them -/// for [`ButtonPart`](eggshell_ui::owned::ButtonPart). shadcn's `default` is -/// [`PRIMARY`](variant::PRIMARY); a button that names no variant is -/// [`SECONDARY`](variant::SECONDARY). -pub mod variant { - use eggshell_ui::contract::Variant; - - /// `default`. - pub const PRIMARY: Variant = Variant("primary"); - /// `secondary`: the variant of a button that names none. - pub const SECONDARY: Variant = Variant("secondary"); - /// `destructive`. - pub const DESTRUCTIVE: Variant = Variant("destructive"); - /// `outline`. - pub const OUTLINE: Variant = Variant("outline"); - /// `ghost`. - pub const GHOST: Variant = Variant("ghost"); - /// TODO(prose): `link`: primary-coloured text, underlined under the pointer. - pub const LINK: Variant = Variant("link"); -} diff --git a/crates/eggshell-ui-shadcn/src/sheets/mod.rs b/crates/eggshell-ui-shadcn/src/sheets/mod.rs deleted file mode 100644 index 5b4bfc56..00000000 --- a/crates/eggshell-ui-shadcn/src/sheets/mod.rs +++ /dev/null @@ -1,83 +0,0 @@ -//! The widgets' rules in each shadcn style, generated from the pinned shadcn -//! source by `cargo xtask shadcn-import --write`; CI fails if they drift -//! (`--check`). Each rule's classes carry the shadcn class they came from. -//! -//! This file is generated too. Do not edit. - -use eggshell_ui::sheet::Sheet; -use egui::Theme; - -use crate::ShadcnStyle; - -/// One half of a widget's rules: its light or its dark theme. -type Half = fn(&mut Sheet); - -#[cfg(feature = "extras")] mod vega_combobox; -#[cfg(feature = "extras")] mod vega_command; -#[cfg(feature = "extras")] mod vega_hover_card; -#[cfg(feature = "extras")] mod vega_dialog; -#[cfg(feature = "extras")] mod vega_alert_dialog; -#[cfg(feature = "extras")] mod vega_sheet; -#[cfg(feature = "extras")] mod vega_popover; -#[cfg(feature = "extras")] mod vega_badge; -#[cfg(feature = "extras")] mod vega_card; -#[cfg(feature = "extras")] mod vega_accordion; -#[cfg(feature = "extras")] mod vega_sonner; -#[cfg(feature = "extras")] mod vega_skeleton; -#[cfg(feature = "extras")] mod vega_spinner; -#[cfg(feature = "extras")] mod lyra_combobox; -#[cfg(feature = "extras")] mod lyra_command; -#[cfg(feature = "extras")] mod lyra_hover_card; -#[cfg(feature = "extras")] mod lyra_dialog; -#[cfg(feature = "extras")] mod lyra_alert_dialog; -#[cfg(feature = "extras")] mod lyra_sheet; -#[cfg(feature = "extras")] mod lyra_popover; -#[cfg(feature = "extras")] mod lyra_badge; -#[cfg(feature = "extras")] mod lyra_card; -#[cfg(feature = "extras")] mod lyra_accordion; -#[cfg(feature = "extras")] mod lyra_sonner; -#[cfg(feature = "extras")] mod lyra_skeleton; -#[cfg(feature = "extras")] mod lyra_spinner; - -/// Writes the rules of `style` for `theme` into `sheet`. Their colours are -/// the style's core tokens, which the sheet is resolved with. -pub(crate) fn write(sheet: &mut Sheet, style: ShadcnStyle, theme: Theme) { - let halves: &[(Half, Half)] = match style { - ShadcnStyle::Vega => &[ - #[cfg(feature = "extras")] (vega_combobox::light, vega_combobox::dark), - #[cfg(feature = "extras")] (vega_command::light, vega_command::dark), - #[cfg(feature = "extras")] (vega_hover_card::light, vega_hover_card::dark), - #[cfg(feature = "extras")] (vega_dialog::light, vega_dialog::dark), - #[cfg(feature = "extras")] (vega_alert_dialog::light, vega_alert_dialog::dark), - #[cfg(feature = "extras")] (vega_sheet::light, vega_sheet::dark), - #[cfg(feature = "extras")] (vega_popover::light, vega_popover::dark), - #[cfg(feature = "extras")] (vega_badge::light, vega_badge::dark), - #[cfg(feature = "extras")] (vega_card::light, vega_card::dark), - #[cfg(feature = "extras")] (vega_accordion::light, vega_accordion::dark), - #[cfg(feature = "extras")] (vega_sonner::light, vega_sonner::dark), - #[cfg(feature = "extras")] (vega_skeleton::light, vega_skeleton::dark), - #[cfg(feature = "extras")] (vega_spinner::light, vega_spinner::dark), - ], - ShadcnStyle::Lyra => &[ - #[cfg(feature = "extras")] (lyra_combobox::light, lyra_combobox::dark), - #[cfg(feature = "extras")] (lyra_command::light, lyra_command::dark), - #[cfg(feature = "extras")] (lyra_hover_card::light, lyra_hover_card::dark), - #[cfg(feature = "extras")] (lyra_dialog::light, lyra_dialog::dark), - #[cfg(feature = "extras")] (lyra_alert_dialog::light, lyra_alert_dialog::dark), - #[cfg(feature = "extras")] (lyra_sheet::light, lyra_sheet::dark), - #[cfg(feature = "extras")] (lyra_popover::light, lyra_popover::dark), - #[cfg(feature = "extras")] (lyra_badge::light, lyra_badge::dark), - #[cfg(feature = "extras")] (lyra_card::light, lyra_card::dark), - #[cfg(feature = "extras")] (lyra_accordion::light, lyra_accordion::dark), - #[cfg(feature = "extras")] (lyra_sonner::light, lyra_sonner::dark), - #[cfg(feature = "extras")] (lyra_skeleton::light, lyra_skeleton::dark), - #[cfg(feature = "extras")] (lyra_spinner::light, lyra_spinner::dark), - ], - }; - for (light, dark) in halves { - match theme { - Theme::Light => light(sheet), - Theme::Dark => dark(sheet), - } - } -} diff --git a/examples/accordion.rs b/examples/accordion.rs index 9cbe3479..c5a5f2d5 100644 --- a/examples/accordion.rs +++ b/examples/accordion.rs @@ -12,8 +12,8 @@ #[path = "common/mod.rs"] mod common; +use eggshell_ui::owned::accordion::{AccordionExt, Single}; use eggshell_ui::{Builder, tw}; -use eggshell_ui_extras::accordion::{AccordionExt, Single}; #[derive(Clone, Copy, Debug, Hash)] pub enum Part { diff --git a/examples/button.rs b/examples/button.rs index ce0f40be..a4a57cf7 100644 --- a/examples/button.rs +++ b/examples/button.rs @@ -10,8 +10,8 @@ #[path = "common/mod.rs"] mod common; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Tw, tw}; -use eggshell_ui_shadcn::Tokens; use egui::Color32; type B<'b, 'f, A> = Builder<'b, 'f, A>; diff --git a/examples/button_children.rs b/examples/button_children.rs index e83a6a45..832a2bc9 100644 --- a/examples/button_children.rs +++ b/examples/button_children.rs @@ -5,8 +5,8 @@ mod common; use common::glyphs::{self, Glyph}; +use eggshell_ui::theme::size; use eggshell_ui::{Builder, tw}; -use eggshell_ui_shadcn::size; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum Tool { diff --git a/examples/chat.rs b/examples/chat.rs index 22f92d8d..014f41e6 100644 --- a/examples/chat.rs +++ b/examples/chat.rs @@ -116,7 +116,7 @@ impl Default for State { /// My bubbles are on the right and the others' on the left, with the corner /// nearest the speaker square. -fn bubble(t: &eggshell_ui_shadcn::Tokens, mine: bool) -> Tw { +fn bubble(t: &eggshell_ui::theme::Tokens, mine: bool) -> Tw { let bubble = tw() .flex() .flex_col() diff --git a/examples/chat_shell/details.rs b/examples/chat_shell/details.rs index 88d81f73..44f7e7c1 100644 --- a/examples/chat_shell/details.rs +++ b/examples/chat_shell/details.rs @@ -1,8 +1,8 @@ //! The right pane: environment, context, changes and background tasks. use eggshell_ui::overlay::Shown; +use eggshell_ui::owned::disclosure::SectionExt; use eggshell_ui::{Builder, Scope, Tw, tw}; -use eggshell_ui_extras::disclosure::SectionExt; use egui::Color32; use super::state::{App, MODELS, Pane}; diff --git a/examples/chat_shell/state.rs b/examples/chat_shell/state.rs index 5628b872..588635fb 100644 --- a/examples/chat_shell/state.rs +++ b/examples/chat_shell/state.rs @@ -4,7 +4,7 @@ use std::ops::RangeInclusive; use eggshell_ui::Progress; use eggshell_ui::owned::PaneSize; -use eggshell_ui_shadcn::ThemeColor; +use eggshell_ui::theme::ThemeColor; use egui::Vec2; /// A pane whose width the user drags. diff --git a/examples/chat_shell/theme.rs b/examples/chat_shell/theme.rs index 2f8f4b68..ced87a0b 100644 --- a/examples/chat_shell/theme.rs +++ b/examples/chat_shell/theme.rs @@ -5,8 +5,8 @@ use core::ops::Index; +use eggshell_ui::theme::Shadcn; use eggshell_ui::{TextSpec, TextStyle, Weight}; -use eggshell_ui_shadcn::Shadcn; use egui::{Color32, Context, FontFamily}; /// A colour by what it is for. diff --git a/examples/clipboard.rs b/examples/clipboard.rs index e29e92bc..18c80fe5 100644 --- a/examples/clipboard.rs +++ b/examples/clipboard.rs @@ -106,10 +106,10 @@ pub fn layout<'f>(b: &mut Builder<'_, 'f, State>, state: &'f State) { b.div_id(Part::Page, tw().flex().flex_col().gap(3.0).p(4.0), |s| { s.div(tw().flex().gap(2.0).items_center(), |s| { s.dropdown_menu(Part::Menu, "Edit") - .variant(eggshell_ui_shadcn::variant::OUTLINE) + .variant(eggshell_ui::theme::variant::OUTLINE) .items(|m| m.command(Cmd::Paste).add()); s.button(Part::Button, "Paste") - .variant(eggshell_ui_shadcn::variant::OUTLINE) + .variant(eggshell_ui::theme::variant::OUTLINE) .command(Cmd::Paste); }); match &state.arrived { diff --git a/examples/command_palette.rs b/examples/command_palette.rs index 460a084b..5c90e550 100644 --- a/examples/command_palette.rs +++ b/examples/command_palette.rs @@ -6,8 +6,8 @@ mod common; use eggshell_ui::owned::Mark; +use eggshell_ui::owned::command::{CommandExt, Open}; use eggshell_ui::{Builder, Chord, Command, Commands, tw}; -use eggshell_ui_extras::command::{CommandExt, Open}; use egui::{Key, Modifiers}; #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] diff --git a/examples/common/mod.rs b/examples/common/mod.rs index 7e3728c0..21da12b8 100644 --- a/examples/common/mod.rs +++ b/examples/common/mod.rs @@ -19,8 +19,8 @@ use eggshell_ui::contract::{Themed, Variant}; use eggshell_ui::owned::{Cell, MenuPart}; use eggshell_ui::prim::text_field::Field; use eggshell_ui::sheet::Key as SheetKey; +use eggshell_ui::theme::{Palette, Shadcn, ShadcnStyle, ThemeColor, Tokens}; use eggshell_ui::{Aria, Builder, LayoutState, Match, TextSpec, TextStyle, Tw, Weight, tw}; -use eggshell_ui_shadcn::{Palette, Shadcn, ShadcnStyle, ThemeColor, Tokens}; use egui::{Color32, Context, FontFamily, Key, Role, Theme, ThemePreference, WidgetInfo}; pub mod dnd; diff --git a/examples/control_sizes.rs b/examples/control_sizes.rs index 338954e1..04b83c2f 100644 --- a/examples/control_sizes.rs +++ b/examples/control_sizes.rs @@ -4,8 +4,8 @@ #[path = "common/mod.rs"] mod common; +use eggshell_ui::theme::size; use eggshell_ui::{Builder, tw}; -use eggshell_ui_shadcn::size; /// ```html ///
@@ -32,7 +32,7 @@ pub fn layout(b: &mut Builder<'_, '_, ()>, _: &()) { |s| { s.span("title", tw().font_semibold(), name); s.button("button", "Button") - .variant(eggshell_ui_shadcn::variant::OUTLINE) + .variant(eggshell_ui::theme::variant::OUTLINE) .on_click(|_| {}); s.checkbox("checkbox", "Checkbox", true) .on_change(|_, _| {}); diff --git a/examples/controls_gallery.rs b/examples/controls_gallery.rs index 6150f41f..fc7482ec 100644 --- a/examples/controls_gallery.rs +++ b/examples/controls_gallery.rs @@ -22,13 +22,13 @@ use std::collections::BTreeMap; use common::glyphs::{self, Glyph}; use eggshell_ui::contract::{Colors, Paint, States, Style, Variant}; use eggshell_ui::owned; +use eggshell_ui::owned::badge::BadgeExt; +use eggshell_ui::owned::skeleton::SkeletonExt; +use eggshell_ui::owned::spinner::SpinnerExt; use eggshell_ui::prim::text_field::{self, Field}; +use eggshell_ui::theme::{BaseColor, Palette, ThemeColor, size, variant}; use eggshell_ui::widget::{Lines, TextEdit}; use eggshell_ui::{Builder, Icon, Progress, Scope, TextStyle, Tw, icons, tw}; -use eggshell_ui_extras::badge::BadgeExt; -use eggshell_ui_extras::skeleton::SkeletonExt; -use eggshell_ui_extras::spinner::SpinnerExt; -use eggshell_ui_shadcn::{BaseColor, Palette, ThemeColor, size, variant}; use egui::{Color32, Context, Rect, Response, Stroke, StrokeKind, Ui, UiBuilder, vec2}; type B<'b, 'f> = Builder<'b, 'f, State>; @@ -331,7 +331,7 @@ pub fn prepare(ctx: &Context, state: &State) { const ARMED: Variant = Variant("armed"); /// `style` with the armed toggle variant, in the colours of `tokens`. -fn add_armed_variant(style: &mut Style, tokens: &eggshell_ui_shadcn::Tokens) { +fn add_armed_variant(style: &mut Style, tokens: &eggshell_ui::theme::Tokens) { let off = *style.toggle.off.get(Variant::DEFAULT); let on = Paint::new(States::still( Colors { diff --git a/examples/crate_ui.rs b/examples/crate_ui.rs index 76d03c5c..77692ee1 100644 --- a/examples/crate_ui.rs +++ b/examples/crate_ui.rs @@ -13,8 +13,8 @@ #[path = "common/mod.rs"] mod common; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Tw, tw}; -use eggshell_ui_shadcn::Tokens; type B<'b, 'f> = Builder<'b, 'f, State>; diff --git a/examples/dialog.rs b/examples/dialog.rs index 869d708d..a6755ab6 100644 --- a/examples/dialog.rs +++ b/examples/dialog.rs @@ -16,11 +16,11 @@ mod common; use eggshell_ui::overlay::{Modal, Nav, Shown, Side, Wrap}; +use eggshell_ui::owned::dialog::{Dialog, DialogExt}; use eggshell_ui::prim::text_field::Field; use eggshell_ui::scroll::Axis; +use eggshell_ui::theme::variant; use eggshell_ui::{Builder, Scope, tw}; -use eggshell_ui_extras::dialog::{Dialog, DialogExt}; -use eggshell_ui_shadcn::variant; use egui::Role; #[derive(Clone, Copy, Debug, Hash)] diff --git a/examples/dnd_gallery.rs b/examples/dnd_gallery.rs index b967ee80..30f61819 100644 --- a/examples/dnd_gallery.rs +++ b/examples/dnd_gallery.rs @@ -16,9 +16,9 @@ mod common; use core::time::Duration; use common::glyphs::{self, Glyph}; +use eggshell_ui::owned::DragChip as _; use eggshell_ui::testing::PlacedFrame; use eggshell_ui::{File, Files, LayoutState, Opacity, tw}; -use eggshell_ui_shadcn::DragChip as _; use egui::{Context, Key, Ui, vec2}; type B<'b, 'f, A> = eggshell_ui::Builder<'b, 'f, A>; diff --git a/examples/dnd_reorder.rs b/examples/dnd_reorder.rs index 6f291bb0..abb9cbff 100644 --- a/examples/dnd_reorder.rs +++ b/examples/dnd_reorder.rs @@ -11,9 +11,9 @@ mod common; use core::time::Duration; +use eggshell_ui::owned::DragChip as _; use eggshell_ui::testing::PlacedFrame; use eggshell_ui::{LayoutState, Opacity, tw}; -use eggshell_ui_shadcn::DragChip as _; use egui::{Context, Key, Modifiers, Response, Ui}; type B<'b, 'f, A> = eggshell_ui::Builder<'b, 'f, A>; diff --git a/examples/dnd_zones.rs b/examples/dnd_zones.rs index 7ab4ba5e..b5d3d651 100644 --- a/examples/dnd_zones.rs +++ b/examples/dnd_zones.rs @@ -12,9 +12,9 @@ mod common; use std::any::Any; +use eggshell_ui::owned::DragChip as _; use eggshell_ui::testing::PlacedFrame; use eggshell_ui::{File, Files, LayoutState, tw}; -use eggshell_ui_shadcn::DragChip as _; use egui::{Ui, Vec2}; type B<'b, 'f, A> = eggshell_ui::Builder<'b, 'f, A>; diff --git a/examples/docs_embed.rs b/examples/docs_embed.rs index 77d79fdf..5fb0b668 100644 --- a/examples/docs_embed.rs +++ b/examples/docs_embed.rs @@ -9,10 +9,10 @@ mod common; use eggshell_ui::owned::Mark; +use eggshell_ui::owned::markdown::{Directive, Directives, MarkdownExt, Typeset}; use eggshell_ui::prim::text_field::Field; +use eggshell_ui::theme::ThemeColor; use eggshell_ui::{Builder, Chord, Command, Commands, Scope, tw}; -use eggshell_ui_extras::markdown::{Directive, Directives, MarkdownExt, Typeset}; -use eggshell_ui_shadcn::ThemeColor; use egui::{Key, Modifiers}; const LOREM: &str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod \ diff --git a/examples/field_focus.rs b/examples/field_focus.rs index 94688cb6..87dba9d5 100644 --- a/examples/field_focus.rs +++ b/examples/field_focus.rs @@ -71,7 +71,7 @@ pub fn layout<'f>(b: &mut Builder<'_, 'f, State>, state: &'f State) { .classes(tw().w_px(160.0)) .on_change(|state, text| state.name = text); s.button(Part::Rename, "Rename") - .variant(eggshell_ui_shadcn::variant::OUTLINE) + .variant(eggshell_ui::theme::variant::OUTLINE) .on_click(|state: &mut State| state.focus_name += 1); }); }); diff --git a/examples/field_icons.rs b/examples/field_icons.rs index 539de531..055c4309 100644 --- a/examples/field_icons.rs +++ b/examples/field_icons.rs @@ -4,8 +4,8 @@ #[path = "common/mod.rs"] mod common; +use eggshell_ui::theme::size; use eggshell_ui::{Builder, Icon, icons, tw}; -use eggshell_ui_shadcn::size; #[derive(Default)] pub struct State { diff --git a/examples/form.rs b/examples/form.rs index b2d3a855..20eaa72e 100644 --- a/examples/form.rs +++ b/examples/form.rs @@ -14,8 +14,8 @@ mod common; use eggshell_ui::owned::Enablement; use eggshell_ui::prim::text_field::Field; +use eggshell_ui::theme::variant; use eggshell_ui::{Builder, Key, NodeUi as _, Scope, Tw, tw}; -use eggshell_ui_shadcn::variant; use egui::{Color32, Role, WidgetInfo}; type B<'b, 'f> = Builder<'b, 'f, State>; diff --git a/examples/form_sections.rs b/examples/form_sections.rs index 5be92072..8d525cfb 100644 --- a/examples/form_sections.rs +++ b/examples/form_sections.rs @@ -5,8 +5,8 @@ #[path = "common/mod.rs"] mod common; +use eggshell_ui::owned::form::{FormExt, FormStyle}; use eggshell_ui::{Builder, Progress, tw}; -use eggshell_ui_extras::form::{FormExt, FormStyle}; pub struct Settings { pub gain: f64, diff --git a/examples/hover_card.rs b/examples/hover_card.rs index 071b8a24..76ab0712 100644 --- a/examples/hover_card.rs +++ b/examples/hover_card.rs @@ -11,9 +11,9 @@ mod common; use core::time::Duration; use eggshell_ui::overlay::{Anchor, Placement, Side}; +use eggshell_ui::owned::hover_card::HoverCardExt as _; +use eggshell_ui::theme::variant; use eggshell_ui::{Builder, Distance, Icon, tw}; -use eggshell_ui_extras::hover_card::HoverCardExt as _; -use eggshell_ui_shadcn::variant; #[derive(Default)] struct State { diff --git a/examples/icons.rs b/examples/icons.rs index 67486439..b0141a58 100644 --- a/examples/icons.rs +++ b/examples/icons.rs @@ -46,7 +46,7 @@ pub fn layout(b: &mut Builder<'_, '_, ()>, _: &()) { s.div_id("context", tw().flex().gap(3.0).items_center(), |s| { s.button("button", "Settings") .icon(Icon::new(icons::GEAR)) - .variant(eggshell_ui_shadcn::variant::OUTLINE) + .variant(eggshell_ui::theme::variant::OUTLINE) .on_click(|_| {}); s.segmented( "segmented", @@ -59,7 +59,7 @@ pub fn layout(b: &mut Builder<'_, '_, ()>, _: &()) { .on_change(|_, _| {}); s.dropdown_menu("menu", "Menu") .icon(Icon::new(icons::CHEVRON_DOWN)) - .variant(eggshell_ui_shadcn::variant::OUTLINE) + .variant(eggshell_ui::theme::variant::OUTLINE) .items(|m| { m.item("settings", "Settings") .icon(Icon::new(icons::GEAR)) diff --git a/examples/kaolin/layouts.rs b/examples/kaolin/layouts.rs index 6c2d12d2..76dd22f1 100644 --- a/examples/kaolin/layouts.rs +++ b/examples/kaolin/layouts.rs @@ -9,8 +9,8 @@ reason = "each crate that includes this file uses a subset of it" )] +use eggshell_ui::theme::{Shadcn, Tokens}; use eggshell_ui::{Builder, TextSpec, Tw, Weight, tw}; -use eggshell_ui_shadcn::{Shadcn, Tokens}; use egui::{Color32, FontFamily, ImageSource}; type B<'b, 'f, A> = Builder<'b, 'f, A>; diff --git a/examples/known_gaps.rs b/examples/known_gaps.rs index bdbfc301..bf458fbf 100644 --- a/examples/known_gaps.rs +++ b/examples/known_gaps.rs @@ -20,8 +20,8 @@ #[path = "common/mod.rs"] mod common; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, LayoutState, TextSpec, TextStyle, Tw, Weight, tw}; -use eggshell_ui_shadcn::Tokens; use egui::epaint::RectShape; use egui::{Color32, CornerRadius, FontFamily, Rect, Shadow, Theme}; diff --git a/examples/long_list.rs b/examples/long_list.rs index 0bcf998f..635427f3 100644 --- a/examples/long_list.rs +++ b/examples/long_list.rs @@ -11,8 +11,8 @@ #[path = "common/mod.rs"] mod common; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Tw, tw}; -use eggshell_ui_shadcn::Tokens; use egui::Align; type B<'b, 'f> = Builder<'b, 'f, State>; diff --git a/examples/markdown.rs b/examples/markdown.rs index 5c157082..71f18307 100644 --- a/examples/markdown.rs +++ b/examples/markdown.rs @@ -6,8 +6,8 @@ mod common; use std::sync::Arc; +use eggshell_ui::owned::markdown::{Directive, Directives, MarkdownExt, Typeset, heading_id}; use eggshell_ui::{Builder, Scope, Shell, Span, tw}; -use eggshell_ui_extras::markdown::{Directive, Directives, MarkdownExt, Typeset, heading_id}; use egui::load::{ImageLoadResult, ImageLoader, ImagePoll, LoadError, SizeHint}; use egui::{Align, Color32, ColorImage, Context, Id, Rect}; diff --git a/examples/menu.rs b/examples/menu.rs index e362ac67..f068250d 100644 --- a/examples/menu.rs +++ b/examples/menu.rs @@ -158,7 +158,7 @@ fn commands() -> Commands { fn actions(b: &mut Builder<'_, '_, State>, state: &State) { let (snap, size) = (state.snap, state.size); b.dropdown_menu(Part::PopoverButton, "Actions") - .variant(eggshell_ui_shadcn::variant::OUTLINE) + .variant(eggshell_ui::theme::variant::OUTLINE) .chevron() .items(|m| { m.command(Part::Item(Item::Copy)).add(); @@ -206,7 +206,7 @@ fn accent(b: &mut Builder<'_, '_, State>, state: &State) { .get(chosen) .map_or(Color32::GRAY, |(_, color)| *color); b.dropdown_menu(Part::Accent, Face::Empty("Accent".into())) - .variant(eggshell_ui_shadcn::variant::OUTLINE) + .variant(eggshell_ui::theme::variant::OUTLINE) .children(move |s| { s.div_id( Part::Swatch, diff --git a/examples/notify.rs b/examples/notify.rs index 992f6465..17b6ff45 100644 --- a/examples/notify.rs +++ b/examples/notify.rs @@ -11,9 +11,9 @@ mod common; use core::time::Duration; +use eggshell_ui::owned::notify::{Lifetime, Notice, NoticeId, NotifyExt, ScreenAnchor}; +use eggshell_ui::theme::variant; use eggshell_ui::{Builder, tw}; -use eggshell_ui_extras::notify::{Lifetime, Notice, NoticeId, NotifyExt, ScreenAnchor}; -use eggshell_ui_shadcn::variant; #[derive(Clone, Copy)] enum Act { diff --git a/crates/eggshell-ui-shadcn/examples/preset_dump.rs b/examples/preset_dump.rs similarity index 98% rename from crates/eggshell-ui-shadcn/examples/preset_dump.rs rename to examples/preset_dump.rs index 9251b7c6..bd744e0b 100644 --- a/crates/eggshell-ui-shadcn/examples/preset_dump.rs +++ b/examples/preset_dump.rs @@ -7,7 +7,7 @@ use eggshell_ui::contract::{Colors, Look, Variant}; use eggshell_ui::owned::{InputPart, MenuPart}; use eggshell_ui::sheet::Key; -use eggshell_ui_shadcn::{Shadcn, ShadcnStyle}; +use eggshell_ui::theme::{Shadcn, ShadcnStyle}; use egui::Theme; fn colors(prefix: &str, state: &str, c: &Colors) { diff --git a/examples/responsive.rs b/examples/responsive.rs index e43865b4..d17cdf5c 100644 --- a/examples/responsive.rs +++ b/examples/responsive.rs @@ -13,8 +13,8 @@ mod common; use common::glyphs::{self, Glyph}; use eggshell_ui::owned::Face; use eggshell_ui::scroll::Axis; +use eggshell_ui::theme::{size, variant}; use eggshell_ui::{Builder, Width, tw}; -use eggshell_ui_shadcn::{size, variant}; use egui::Vec2; type B<'b, 'f, A> = Builder<'b, 'f, A>; diff --git a/examples/scroll.rs b/examples/scroll.rs index cd1bd2d1..7feefe1e 100644 --- a/examples/scroll.rs +++ b/examples/scroll.rs @@ -14,8 +14,8 @@ mod common; use eggshell_ui::scroll::{Axis, EdgeFade}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Opacity, Tw, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Align, Rect, vec2}; type B<'b, 'f> = Builder<'b, 'f, State>; diff --git a/examples/signup_form.rs b/examples/signup_form.rs index 966bffb3..9a8ecb32 100644 --- a/examples/signup_form.rs +++ b/examples/signup_form.rs @@ -14,8 +14,8 @@ mod common; use eggshell_ui::prim::text_field::Field; +use eggshell_ui::theme::variant; use eggshell_ui::{Builder, Scope, Tw, tw}; -use eggshell_ui_shadcn::variant; use egui::Role; type B<'b, 'f> = Builder<'b, 'f, State>; diff --git a/examples/slider_header.rs b/examples/slider_header.rs index 49b76424..4a748dc0 100644 --- a/examples/slider_header.rs +++ b/examples/slider_header.rs @@ -7,8 +7,8 @@ mod common; use eggshell_ui::owned::Step; +use eggshell_ui::theme::size; use eggshell_ui::{Builder, tw}; -use eggshell_ui_shadcn::size; pub struct Levels { pub volume: f64, diff --git a/examples/swatch_picker.rs b/examples/swatch_picker.rs index 19fd3ee3..28772435 100644 --- a/examples/swatch_picker.rs +++ b/examples/swatch_picker.rs @@ -103,7 +103,7 @@ pub fn layout<'f>(b: &mut Builder<'_, 'f, State>, state: &'f State) { tw().flex().items_center().gap(3.0).p(4.0), |s| { s.button(Part::Trigger, "Colour") - .variant(eggshell_ui_shadcn::variant::OUTLINE) + .variant(eggshell_ui::theme::variant::OUTLINE) .on_click(|state: &mut State| state.open = !state.open); s.text(tw(), state.choice.name()); if state.open { diff --git a/examples/table.rs b/examples/table.rs index 90eb56e1..4f7aab00 100644 --- a/examples/table.rs +++ b/examples/table.rs @@ -11,8 +11,8 @@ mod common; use common::glyphs::{self, Glyph}; use eggshell_ui::owned::{Align, Column, Stripes}; +use eggshell_ui::theme::variant; use eggshell_ui::{Builder, Track, tw}; -use eggshell_ui_shadcn::variant; #[derive(Clone, Copy, PartialEq)] pub enum Status { diff --git a/examples/tabs.rs b/examples/tabs.rs index 53988511..ed180f3c 100644 --- a/examples/tabs.rs +++ b/examples/tabs.rs @@ -1,4 +1,4 @@ -//! Tabs (`eggshell_ui_extras::tabs`): shadcn/ui's account and password demo, +//! Tabs (`eggshell_ui::owned::tabs`): shadcn/ui's account and password demo, //! a code switcher, tabs with icons and a disabled one, and tabs that select //! on Enter rather than as the arrow keys move. //! @@ -9,9 +9,9 @@ mod common; use common::glyphs::{self, Glyph}; +use eggshell_ui::owned::tabs::TabsExt; use eggshell_ui::owned::{Choice, Enablement}; use eggshell_ui::{Builder, tw}; -use eggshell_ui_extras::tabs::TabsExt; type B<'b, 'f> = Builder<'b, 'f, State>; diff --git a/examples/todo.rs b/examples/todo.rs index e15e709a..0a52301b 100644 --- a/examples/todo.rs +++ b/examples/todo.rs @@ -12,8 +12,8 @@ mod common; use core::time::Duration; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Opacity, Tw, tw}; -use eggshell_ui_shadcn::Tokens; type B<'b, 'f, A> = Builder<'b, 'f, A>; diff --git a/examples/toggle_group.rs b/examples/toggle_group.rs index ce139744..c45a65e7 100644 --- a/examples/toggle_group.rs +++ b/examples/toggle_group.rs @@ -8,8 +8,8 @@ mod common; use common::glyphs::{self, Glyph}; use eggshell_ui::contract::Size; use eggshell_ui::owned::{ButtonOptions, Face, ToggleGroup}; +use eggshell_ui::theme::{size, variant}; use eggshell_ui::{Builder, Scope, tw}; -use eggshell_ui_shadcn::{size, variant}; #[derive(Clone, Copy, Debug, Hash)] pub enum Part { diff --git a/examples/typeset/main.rs b/examples/typeset/main.rs index 8fcad789..b0165b88 100644 --- a/examples/typeset/main.rs +++ b/examples/typeset/main.rs @@ -9,8 +9,8 @@ #[path = "../common/mod.rs"] mod common; +use eggshell_ui::owned::markdown::{MarkdownExt, Typeset}; use eggshell_ui::{Builder, tw}; -use eggshell_ui_extras::markdown::{MarkdownExt, Typeset}; /// The parts the layout names. #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] diff --git a/src/builder.rs b/src/builder.rs index 1bd22ed3..b3b329b9 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -425,12 +425,11 @@ impl<'b, 'f, A> Builder<'b, 'f, A> { self.scope_with(&path, body); } - /// Not a stable API: it exists for `eggshell-ui-extras`. Builds `body` - /// with its nodes keyed under the node `parent` instead of this scope, so - /// that their ids can be found from `parent` alone, wherever they sit in - /// the tree. - #[doc(hidden)] - pub fn keyed_under(&mut self, parent: Id, body: impl FnOnce(&mut Scope<'_, 'f, A>)) { + /// Builds `body` with its nodes keyed under the node `parent` instead of + /// this scope, so that their ids can be found from `parent` alone, + /// wherever they sit in the tree. + #[cfg(feature = "markdown")] + pub(crate) fn keyed_under(&mut self, parent: Id, body: impl FnOnce(&mut Scope<'_, 'f, A>)) { body(&mut Scope(Builder::new( self.st, self.frame, diff --git a/src/contract.rs b/src/contract.rs index 955924bd..2c27ae83 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -1797,6 +1797,11 @@ impl Style { crate::sheets::write(&mut self.sheet, self.tokens.style, self.tokens.theme); crate::owned::write_field_sizes(&mut self.sheet, &self.tokens); self.write_exceptions(); + #[cfg(feature = "disclosure")] + { + let disclosure = self.extension::(); + crate::owned::disclosure::write_exceptions(&mut self.sheet, &disclosure); + } } /// Writes the [`InputStyle`] and the selection colours into `egui`, the diff --git a/src/lib.rs b/src/lib.rs index ec9b59b8..52d0ee43 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -437,7 +437,8 @@ pub use overlay::{Boundary, Distance, InsetBoundary}; pub use overlay_input::Blur; pub use pipeline::{Built, LayoutState, NodeKind, Placed, PlacedNode}; pub use prim::Icon; -pub use report::{Problem, Report, report}; +pub(crate) use report::report; +pub use report::{Problem, Report}; pub use roots::OverlayRef; pub use shell::{Shell, ShellExt}; pub use sizing::Width; diff --git a/crates/eggshell-ui-extras/src/accordion.rs b/src/owned/accordion.rs similarity index 93% rename from crates/eggshell-ui-extras/src/accordion.rs rename to src/owned/accordion.rs index 564c50d5..7f180b39 100644 --- a/crates/eggshell-ui-extras/src/accordion.rs +++ b/src/owned/accordion.rs @@ -3,7 +3,7 @@ //! //! ``` //! use eggshell_ui::{Builder, tw}; -//! use eggshell_ui_extras::accordion::{AccordionExt, Single}; +//! use eggshell_ui::owned::accordion::{AccordionExt, Single}; //! //! #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] //! enum Faq { Access, Motion } @@ -25,13 +25,13 @@ use std::marker::PhantomData; use std::rc::Rc; -use eggshell_ui::overlay::{Nav, Shown, Wrap}; -use eggshell_ui::owned::{Enablement, Face}; -use eggshell_ui::{Builder, Key, Scope, Tw, tw}; +use crate::overlay::{Nav, Shown, Wrap}; +use crate::owned::{Enablement, Face}; +use crate::{Builder, Key, Scope, Tw, tw}; -use eggshell_ui::sheet::Defaults; +use crate::sheet::Defaults; -use crate::disclosure::{DisclosureStyle, SectionExt}; +use crate::owned::disclosure::{DisclosureStyle, SectionExt}; /// What an accordion runs with what a header asked for. type OnItems = Rc; @@ -132,7 +132,7 @@ impl Shown> Mode for Multiple { /// TODO(prose): adds [`accordion`](Self::accordion) to the builder. pub trait AccordionExt<'b, 'f, A> { /// TODO(prose): an accordion whose items are open as `mode` says. It is - /// built by [`items`](AccordionChain::items) once it has an + /// built by [`items`](BoundAccordion::items) once it has an /// [`on_change`](AccordionChain::on_change). fn accordion<'s, K: Key, M>( &'s mut self, @@ -226,7 +226,7 @@ impl<'f, A: 'static, K: Key, M: Mode, T: Value, C: 'static> None => column, }; let column = b.part_over( - crate::disclosure::AccordionPart::Root, + crate::owned::disclosure::AccordionPart::Root, &[], Defaults(tw()), column.merge(classes), @@ -283,10 +283,17 @@ impl<'i, 'b, 'f, A: 'static, M: Mode, T: Value, C: Clone + 'stati } /// TODO(prose): an accordion item: the options of a -/// [`section`](crate::disclosure::SectionExt::section). +/// [`section`](crate::owned::disclosure::SectionExt::section). #[must_use = "an item is built by `.children(..)`"] pub struct ItemChain<'s, 'b, 'f, A, T> { - section: crate::disclosure::SectionChain<'s, 'b, 'f, A, T, crate::disclosure::OnChange>, + section: crate::owned::disclosure::SectionChain< + 's, + 'b, + 'f, + A, + T, + crate::owned::disclosure::OnChange, + >, } impl<'f, A: 'static, T: Value> ItemChain<'_, '_, 'f, A, T> { diff --git a/crates/eggshell-ui-extras/src/badge/chip.rs b/src/owned/badge/chip.rs similarity index 96% rename from crates/eggshell-ui-extras/src/badge/chip.rs rename to src/owned/badge/chip.rs index d964d111..c03fcef8 100644 --- a/crates/eggshell-ui-extras/src/badge/chip.rs +++ b/src/owned/badge/chip.rs @@ -2,9 +2,9 @@ use std::rc::Rc; -use eggshell_ui::contract::{Look, Variant}; -use eggshell_ui::owned::Enablement; -use eggshell_ui::{Builder, Icon, Key, NodeUi as _, Style, Tw, icons, tw}; +use crate::contract::{Look, Variant}; +use crate::owned::Enablement; +use crate::{Builder, Icon, Key, NodeUi as _, Style, Tw, icons, tw}; use egui::{Modifiers, Role}; use super::{BadgeStyle, End, Face, Options}; @@ -51,7 +51,7 @@ enum Stop { /// both, and finish it with [`add`](Self::add). /// /// A clickable chip is a button and a Tab stop; a removable one ends in a ×, -/// a button named "Remove Directives { /// /// ``` /// # use eggshell_ui::{Builder, Shell}; -/// # use eggshell_ui_extras::markdown::{MarkdownExt, heading_id}; +/// # use eggshell_ui::owned::markdown::{MarkdownExt, heading_id}; /// fn page(b: &mut Builder<'_, '_, ()>, land_on: Option<&str>) { /// let shell: Shell = b.shell(); /// if let Some(anchor) = land_on { @@ -218,7 +218,7 @@ fn parsed(ctx: &egui::Context, source: &str) -> Arc { #[cfg(test)] mod tests { - use eggshell_ui::testing::{assert_no_reports, assert_reported}; + use crate::testing::{assert_no_reports, assert_reported}; use super::*; @@ -232,7 +232,7 @@ mod tests { parse::Malformed::CellOutsideTable, ]; report_malformed(&ctx, doc, &malformed); - let reports = eggshell_ui::testing::reports(&ctx); + let reports = crate::testing::reports(&ctx); assert_eq!(reports.len(), 2, "{reports:#?}"); assert!( reports diff --git a/crates/eggshell-ui-extras/src/markdown/parse.rs b/src/owned/markdown/parse.rs similarity index 99% rename from crates/eggshell-ui-extras/src/markdown/parse.rs rename to src/owned/markdown/parse.rs index 9d4516a5..3aef7808 100644 --- a/crates/eggshell-ui-extras/src/markdown/parse.rs +++ b/src/owned/markdown/parse.rs @@ -3,8 +3,8 @@ use std::collections::{HashMap, HashSet}; use std::ops::Range; -use eggshell_ui::owned::Align; -use eggshell_ui::{FontStyle, Span, Spans, Weight}; +use crate::owned::Align; +use crate::{FontStyle, Span, Spans, Weight}; use pulldown_cmark::{Alignment, CodeBlockKind, Event, HeadingLevel, Options, Parser, Tag, TagEnd}; /// A document's blocks, and what of its events did not nest as Markdown diff --git a/crates/eggshell-ui-extras/src/markdown/style.rs b/src/owned/markdown/style.rs similarity index 94% rename from crates/eggshell-ui-extras/src/markdown/style.rs rename to src/owned/markdown/style.rs index 24d1d680..f3a215d0 100644 --- a/crates/eggshell-ui-extras/src/markdown/style.rs +++ b/src/owned/markdown/style.rs @@ -1,17 +1,17 @@ //! How the Markdown widget looks. -use eggshell_ui::contract::Em; -use eggshell_ui::owned::TablePart; -use eggshell_ui::sheet::Sheet; -use eggshell_ui::theme::Tokens; -use eggshell_ui::{Style, TextSpec, Tracking, Tw, Weight}; +use crate::contract::Em; +use crate::owned::TablePart; +use crate::sheet::Sheet; +use crate::theme::Tokens; +use crate::{Style, TextSpec, Tracking, Tw, Weight}; use egui::{Color32, FontFamily}; use super::parse::Level; /// TODO(prose) /// -/// Lengths are in Tailwind spacing units (a unit is 4 points), as [`Tw`](eggshell_ui::Tw)'s +/// Lengths are in Tailwind spacing units (a unit is 4 points), as [`Tw`](crate::Tw)'s /// spacing classes take them. #[derive(Clone, Debug, PartialEq)] #[non_exhaustive] @@ -42,11 +42,11 @@ pub struct MarkdownStyle { /// What a construct the widget does not show looks like. pub unsupported: UnsupportedStyle, /// TODO(prose): the document's tables, over the page's - /// [`TableStyle`](eggshell_ui::contract::TableStyle); `None` keeps the + /// [`TableStyle`](crate::contract::TableStyle); `None` keeps the /// page's. pub table: Option, /// TODO(prose): the document's links and inline code, over the page's - /// [`RichTextStyle`](eggshell_ui::contract::RichTextStyle); `None` keeps + /// [`RichTextStyle`](crate::contract::RichTextStyle); `None` keeps /// the page's. pub rich: Option, } @@ -124,7 +124,7 @@ impl TableLook { } } -impl eggshell_ui::contract::Extension for MarkdownStyle { +impl crate::contract::Extension for MarkdownStyle { fn derive(style: &Style) -> Self { Self::from_style(style) } @@ -228,7 +228,7 @@ pub struct QuoteStyle { /// TODO(prose) pub text: Color32, /// TODO(prose) - pub font_style: eggshell_ui::FontStyle, + pub font_style: crate::FontStyle, } /// TODO(prose) @@ -268,7 +268,7 @@ pub struct UnsupportedStyle { impl MarkdownStyle { /// TODO(prose) pub fn from_style(style: &Style) -> Self { - let border = crate::styles::input_border(style); + let border = crate::owned::styles::input_border(style); let muted = style.input.hint.unwrap_or(style.label.disabled.text); let body = &style.text; let mono = |scale: f32| TextSpec { @@ -324,7 +324,7 @@ impl MarkdownStyle { border_width: 2.0, padding: 6.0, text: style.label.rest.text, - font_style: eggshell_ui::FontStyle::Italic, + font_style: crate::FontStyle::Italic, }, code: CodeBlockStyle { fill: style.rich.code.fill, diff --git a/crates/eggshell-ui-extras/src/markdown/typeset.rs b/src/owned/markdown/typeset.rs similarity index 98% rename from crates/eggshell-ui-extras/src/markdown/typeset.rs rename to src/owned/markdown/typeset.rs index 4971074c..de0ec537 100644 --- a/crates/eggshell-ui-extras/src/markdown/typeset.rs +++ b/src/owned/markdown/typeset.rs @@ -6,8 +6,8 @@ //! divides some margins by the element's size ratio; each length here is //! that `em` resolved to points. -use eggshell_ui::contract::Em; -use eggshell_ui::{TextSpec, Tracking, Weight}; +use crate::contract::Em; +use crate::{TextSpec, Tracking, Weight}; use egui::{Color32, FontFamily}; use super::style::{ @@ -19,7 +19,7 @@ use super::style::{ /// document's look is derived. The defaults are shadcn's. /// /// ``` -/// use eggshell_ui_extras::markdown::{Measure, Typeset}; +/// use eggshell_ui::owned::markdown::{Measure, Typeset}; /// /// let reading = Typeset { /// size: 18.0, @@ -249,7 +249,7 @@ impl Typeset { border_width: 2.0, padding: em(1.0), text: ink.foreground, - font_style: eggshell_ui::FontStyle::Normal, + font_style: crate::FontStyle::Normal, }, code: CodeBlockStyle { fill: ink.code_fill, @@ -300,7 +300,7 @@ impl Typeset { #[cfg(test)] mod tests { use super::*; - use crate::markdown::Level; + use crate::owned::markdown::Level; fn ink() -> TypesetInk { TypesetInk { diff --git a/src/owned/mod.rs b/src/owned/mod.rs index 2a410fea..085f5202 100644 --- a/src/owned/mod.rs +++ b/src/owned/mod.rs @@ -39,6 +39,48 @@ //! When the colour follows only whether the control is chosen, carry it in //! the style variant's on and off looks instead. +// keep sorted +#[cfg(feature = "accordion")] +pub mod accordion; +#[cfg(feature = "badge")] +pub mod badge; +#[cfg(feature = "command")] +pub mod command; +#[cfg(feature = "dialog")] +pub mod dialog; +#[cfg(feature = "disclosure")] +pub mod disclosure; +#[cfg(feature = "form")] +pub mod form; +#[cfg(feature = "hover-card")] +pub mod hover_card; +#[cfg(feature = "markdown")] +pub mod markdown; +#[cfg(feature = "notify")] +pub mod notify; +#[cfg(feature = "skeleton")] +pub mod skeleton; +#[cfg(feature = "spinner")] +pub mod spinner; +// keep sorted +#[cfg(any( + feature = "badge", + feature = "command", + feature = "disclosure", + feature = "form", + feature = "markdown", + feature = "notify", + feature = "skeleton", + feature = "spinner", + feature = "tabs" +))] +mod styles; +#[cfg(feature = "tabs")] +pub mod tabs; + +mod drag_chip; +pub use drag_chip::{DragChip, drag_chip}; + mod button; mod checkbox; mod choice; diff --git a/crates/eggshell-ui-extras/src/notify/dwell.rs b/src/owned/notify/dwell.rs similarity index 100% rename from crates/eggshell-ui-extras/src/notify/dwell.rs rename to src/owned/notify/dwell.rs diff --git a/crates/eggshell-ui-extras/src/notify/look.rs b/src/owned/notify/look.rs similarity index 98% rename from crates/eggshell-ui-extras/src/notify/look.rs rename to src/owned/notify/look.rs index f7d4f918..114d9139 100644 --- a/crates/eggshell-ui-extras/src/notify/look.rs +++ b/src/owned/notify/look.rs @@ -3,7 +3,7 @@ use std::sync::Arc; -use eggshell_ui::{Tw, tw}; +use crate::{Tw, tw}; use super::NotifyStyle; diff --git a/crates/eggshell-ui-extras/src/notify/mod.rs b/src/owned/notify/mod.rs similarity index 97% rename from crates/eggshell-ui-extras/src/notify/mod.rs rename to src/owned/notify/mod.rs index c9971154..0273d6f4 100644 --- a/crates/eggshell-ui-extras/src/notify/mod.rs +++ b/src/owned/notify/mod.rs @@ -3,7 +3,7 @@ //! ``` //! use core::time::Duration; //! use eggshell_ui::{Builder, Distance}; -//! use eggshell_ui_extras::notify::{Lifetime, Notice, NoticeId, NotifyExt, ScreenAnchor}; +//! use eggshell_ui::owned::notify::{Lifetime, Notice, NoticeId, NotifyExt, ScreenAnchor}; //! //! #[derive(Clone, Copy)] //! enum Act { @@ -42,8 +42,8 @@ use core::time::Duration; use std::collections::HashMap; use std::rc::Rc; -use eggshell_ui::overlay::{Align, Anchor, Band, DismissOn, Focus, Outside, Placement, Side}; -use eggshell_ui::{Boundary, Builder, Distance, Icon, Key, NodeUi as _, Scope, Sides, icons, tw}; +use crate::overlay::{Align, Anchor, Band, DismissOn, Focus, Outside, Placement, Side}; +use crate::{Boundary, Builder, Distance, Icon, Key, NodeUi as _, Scope, Sides, icons, tw}; use egui::accesskit::Live; use egui::{Context, Id, Modifiers, Role}; @@ -60,7 +60,7 @@ pub enum NotifyPart { Toast, } -impl eggshell_ui::sheet::Part for NotifyPart { +impl crate::sheet::Part for NotifyPart { const SOURCE: &'static str = "sonner.tsx"; fn slot(self) -> &'static str { @@ -444,7 +444,7 @@ fn card( let classes = s.part_over( NotifyPart::Toast, &[], - eggshell_ui::sheet::Defaults(look.card()), + crate::sheet::Defaults(look.card()), tw(), ); let card = s.div_id(id, classes, |s| { diff --git a/crates/eggshell-ui-extras/src/notify/style.rs b/src/owned/notify/style.rs similarity index 96% rename from crates/eggshell-ui-extras/src/notify/style.rs rename to src/owned/notify/style.rs index 49e6bbe6..ebc9272a 100644 --- a/crates/eggshell-ui-extras/src/notify/style.rs +++ b/src/owned/notify/style.rs @@ -1,6 +1,6 @@ //! How notifications look: the card, the stack and the buttons in it. -use eggshell_ui::{Distance, Style, TextSpec, Weight}; +use crate::{Distance, Style, TextSpec, Weight}; use egui::Color32; use egui::epaint::Shadow; @@ -83,7 +83,7 @@ pub struct CloseStyle { pub hover_border: Color32, } -impl eggshell_ui::contract::Extension for NotifyStyle { +impl crate::contract::Extension for NotifyStyle { fn derive(style: &Style) -> Self { Self::from_style(style) } @@ -94,7 +94,7 @@ impl NotifyStyle { /// wide, 16 points of padding, 6 between a card's parts, 14 between /// cards, 3 on show and 24 points from the window's edges. pub fn from_style(style: &Style) -> Self { - let popup = crate::styles::Popover::of(style); + let popup = crate::owned::styles::Popover::of(style); let colors = popup.colors; Self { fill: colors.fill, diff --git a/crates/eggshell-ui-extras/src/skeleton.rs b/src/owned/skeleton.rs similarity index 91% rename from crates/eggshell-ui-extras/src/skeleton.rs rename to src/owned/skeleton.rs index 2402d3c1..9e059bfe 100644 --- a/crates/eggshell-ui-extras/src/skeleton.rs +++ b/src/owned/skeleton.rs @@ -3,7 +3,7 @@ //! //! ``` //! use eggshell_ui::{Builder, tw}; -//! use eggshell_ui_extras::skeleton::SkeletonExt; +//! use eggshell_ui::owned::skeleton::SkeletonExt; //! //! fn view(b: &mut Builder<'_, '_, ()>) { //! b.skeleton(tw().h_px(16.0).w_px(250.0)); @@ -13,7 +13,7 @@ use std::time::Duration; -use eggshell_ui::{Builder, Easing, Opacity, Progress, Style, Tw, cycle, tw}; +use crate::{Builder, Easing, Opacity, Progress, Style, Tw, cycle, tw}; use egui::Color32; /// TODO(prose): how skeletons look: their fill, corners and pulse. @@ -31,7 +31,7 @@ pub struct SkeletonStyle { pub low: Opacity, } -impl eggshell_ui::contract::Extension for SkeletonStyle { +impl crate::contract::Extension for SkeletonStyle { fn derive(style: &Style) -> Self { Self::from_style(style) } @@ -44,7 +44,7 @@ impl SkeletonStyle { pub fn from_style(style: &Style) -> Self { Self { fill: Color32::from_gray(128).gamma_multiply(0.2), - radius: crate::styles::Popover::of(style).radius, + radius: crate::owned::styles::Popover::of(style).radius, period: Duration::from_secs(2), low: Opacity::new(0.5), } @@ -59,7 +59,7 @@ pub enum SkeletonPart { Root, } -impl eggshell_ui::sheet::Part for SkeletonPart { +impl crate::sheet::Part for SkeletonPart { const SOURCE: &'static str = "skeleton.tsx"; fn slot(self) -> &'static str { @@ -84,7 +84,7 @@ impl SkeletonExt for Builder<'_, '_, A> { let styled = self.part_over( SkeletonPart::Root, &[], - eggshell_ui::sheet::Defaults(look), + crate::sheet::Defaults(look), tw().shrink_0().opacity(opacity).merge(classes), ); self.div(styled, |_| {}); diff --git a/crates/eggshell-ui-extras/src/spinner/LUCIDE-LICENSE b/src/owned/spinner/LUCIDE-LICENSE similarity index 100% rename from crates/eggshell-ui-extras/src/spinner/LUCIDE-LICENSE rename to src/owned/spinner/LUCIDE-LICENSE diff --git a/crates/eggshell-ui-extras/src/spinner/loader-circle.svg b/src/owned/spinner/loader-circle.svg similarity index 100% rename from crates/eggshell-ui-extras/src/spinner/loader-circle.svg rename to src/owned/spinner/loader-circle.svg diff --git a/crates/eggshell-ui-extras/src/spinner/mod.rs b/src/owned/spinner/mod.rs similarity index 92% rename from crates/eggshell-ui-extras/src/spinner/mod.rs rename to src/owned/spinner/mod.rs index eb3e6639..a2b777ba 100644 --- a/crates/eggshell-ui-extras/src/spinner/mod.rs +++ b/src/owned/spinner/mod.rs @@ -3,7 +3,7 @@ //! //! ``` //! use eggshell_ui::Builder; -//! use eggshell_ui_extras::spinner::SpinnerExt; +//! use eggshell_ui::owned::spinner::SpinnerExt; //! //! fn view(b: &mut Builder<'_, '_, ()>) { //! b.spinner("loading").add(); @@ -13,8 +13,8 @@ use std::time::Duration; -use eggshell_ui::contract::{Keyed, Size}; -use eggshell_ui::{Angle, Builder, Icon, Key, NodeUi as _, Style, Tw, cycle, tw}; +use crate::contract::{Keyed, Size}; +use crate::{Angle, Builder, Icon, Key, NodeUi as _, Style, Tw, cycle, tw}; use egui::{Context, ImageSource, Role, WidgetInfo, include_image}; /// Lucide's `loader-circle` (ISC, `LUCIDE-LICENSE` beside it), the icon of @@ -25,7 +25,7 @@ const LOADER: ImageSource<'static> = include_image!("loader-circle.svg"); /// /// ``` /// use std::time::Duration; -/// use eggshell_ui_extras::spinner::SpinnerStyle; +/// use eggshell_ui::owned::spinner::SpinnerStyle; /// /// let mut style = eggshell_ui::Style::default(); /// let mut look = (*style.extension::()).clone(); @@ -50,7 +50,7 @@ pub enum SpinnerPart { Root, } -impl eggshell_ui::sheet::Part for SpinnerPart { +impl crate::sheet::Part for SpinnerPart { const SOURCE: &'static str = "spinner.tsx"; fn slot(self) -> &'static str { @@ -58,7 +58,7 @@ impl eggshell_ui::sheet::Part for SpinnerPart { } } -impl eggshell_ui::contract::Extension for SpinnerStyle { +impl crate::contract::Extension for SpinnerStyle { fn derive(style: &Style) -> Self { Self::from_style(style) } @@ -153,14 +153,14 @@ impl SpinnerChain<'_, '_, '_, A, K> { let ctx = b.ctx().clone(); let style = b.style().extension::(); let size = size.unwrap_or_else(|| b.control_size()); - let side = *crate::styles::entry(&ctx, &style.sizes, size); + let side = *crate::owned::styles::entry(&ctx, &style.sizes, size); let name = name.unwrap_or_else(|| "Loading".to_owned()); // The size is the widget's, from its size's entry (#348), over the // sheet's `size-4`. let classes = b.part_over( SpinnerPart::Root, &[], - eggshell_ui::sheet::Defaults(tw()), + crate::sheet::Defaults(tw()), tw().size_px(side) .shrink_0() .sense_hover() diff --git a/crates/eggshell-ui-extras/src/styles.rs b/src/owned/styles.rs similarity index 72% rename from crates/eggshell-ui-extras/src/styles.rs rename to src/owned/styles.rs index ed7be964..20d65394 100644 --- a/crates/eggshell-ui-extras/src/styles.rs +++ b/src/owned/styles.rs @@ -8,13 +8,13 @@ use egui::{Context, Id}; #[track_caller] pub(crate) fn entry<'k, K: Ord + Copy + std::fmt::Debug, T>( ctx: &Context, - keyed: &'k eggshell_ui::contract::Keyed, + keyed: &'k crate::contract::Keyed, key: K, ) -> &'k T { if !keyed.keys().any(|defined| defined == key) { - eggshell_ui::report( + crate::report( ctx, - eggshell_ui::Problem::MissingStyleEntry, + crate::Problem::MissingStyleEntry, Some(Id::NULL.with(("style-entry", format!("{key:?}")))), || format!("the style defines no {key:?}; drawing its default entry"), ); @@ -24,10 +24,10 @@ pub(crate) fn entry<'k, K: Ord + Copy + std::fmt::Debug, T>( #[cfg(any(feature = "command", feature = "markdown"))] /// The border colour `style`'s sheet gives a text field at rest. -pub(crate) fn input_border(style: &eggshell_ui::Style) -> egui::Color32 { +pub(crate) fn input_border(style: &crate::Style) -> egui::Color32 { style .sheet - .resolve(eggshell_ui::owned::InputPart::Root, &[], &style.tokens) + .resolve(crate::owned::InputPart::Root, &[], &style.tokens) .paint_classes() .border_colors .top @@ -44,7 +44,7 @@ pub(crate) fn input_border(style: &eggshell_ui::Style) -> egui::Color32 { ))] /// TODO(prose): the box a widget draws as `style`'s menus draw theirs: the popover's colours and shadow from the tokens, a 1 pt border, and the radius of the sheet's menu box. pub(crate) struct Popover { - pub colors: eggshell_ui::contract::Colors, + pub colors: crate::contract::Colors, pub border_width: f32, pub radius: u8, pub shadow: egui::Shadow, @@ -59,16 +59,16 @@ pub(crate) struct Popover { feature = "skeleton" ))] impl Popover { - pub(crate) fn of(style: &eggshell_ui::Style) -> Self { + pub(crate) fn of(style: &crate::Style) -> Self { let k = &style.tokens; Self { - colors: eggshell_ui::contract::Colors { + colors: crate::contract::Colors { fill: k.popover, border: k.border, text: k.popover_foreground, }, border_width: 1.0, - radius: menu_part(style, eggshell_ui::owned::MenuPart::Content, &[]) + radius: menu_part(style, crate::owned::MenuPart::Content, &[]) .paint_classes() .radius .nw, @@ -76,11 +76,11 @@ impl Popover { } } - /// The box as a [`Look`](eggshell_ui::contract::Look), the same in every + /// The box as a [`Look`](crate::contract::Look), the same in every /// state. #[cfg(feature = "hover-card")] - pub(crate) fn look(&self) -> eggshell_ui::contract::Look { - eggshell_ui::contract::Look::new(eggshell_ui::contract::States::still( + pub(crate) fn look(&self) -> crate::contract::Look { + crate::contract::Look::new(crate::contract::States::still( self.colors, self.colors.fill, )) @@ -99,9 +99,9 @@ impl Popover { ))] /// The classes `style`'s sheet gives the menu's `part` under `keys`. pub(crate) fn menu_part( - style: &eggshell_ui::Style, - part: eggshell_ui::owned::MenuPart, - keys: &[eggshell_ui::sheet::Key], -) -> eggshell_ui::Tw { + style: &crate::Style, + part: crate::owned::MenuPart, + keys: &[crate::sheet::Key], +) -> crate::Tw { style.sheet.resolve(part, keys, &style.tokens) } diff --git a/crates/eggshell-ui-extras/src/tabs/mod.rs b/src/owned/tabs/mod.rs similarity index 97% rename from crates/eggshell-ui-extras/src/tabs/mod.rs rename to src/owned/tabs/mod.rs index 91307f6e..b8faadf4 100644 --- a/crates/eggshell-ui-extras/src/tabs/mod.rs +++ b/src/owned/tabs/mod.rs @@ -3,7 +3,7 @@ //! //! ``` //! use eggshell_ui::Builder; -//! use eggshell_ui_extras::tabs::TabsExt; +//! use eggshell_ui::owned::tabs::TabsExt; //! //! #[derive(Clone, Copy, PartialEq)] //! enum Lang { Rust, Html } @@ -23,10 +23,10 @@ use std::rc::Rc; -use eggshell_ui::contract::Size; -use eggshell_ui::overlay::{Nav, Wrap}; -use eggshell_ui::owned::{Cell, Choice, Enablement, IntoChoice, Mark, SegmentedRows, TabsPart}; -use eggshell_ui::{Builder, Key, Tw, tw}; +use crate::contract::Size; +use crate::overlay::{Nav, Wrap}; +use crate::owned::{Cell, Choice, Enablement, IntoChoice, Mark, SegmentedRows, TabsPart}; +use crate::{Builder, Key, Tw, tw}; use egui::Role; /// TODO(prose): adds [`tabs`](Self::tabs) to the builder. diff --git a/src/report.rs b/src/report.rs index 454fdde6..57a838d1 100644 --- a/src/report.rs +++ b/src/report.rs @@ -181,13 +181,11 @@ fn with_store(ctx: &Context, f: impl FnOnce(&mut Store) -> R) -> R { ctx.data_mut(|data| f(data.get_temp_mut_or_default::(store_id()))) } -/// Not a stable API: it exists for `eggshell-ui-extras`. Reports `problem` -/// at the caller, about `subject` if it concerns one identified thing. -/// Repeats of a (problem, caller, subject) are counted, and only the first -/// runs `message` and is logged. -#[doc(hidden)] +/// Reports `problem` at the caller, about `subject` if it concerns one +/// identified thing. Repeats of a (problem, caller, subject) are counted, and +/// only the first runs `message` and is logged. #[track_caller] -pub fn report( +pub(crate) fn report( ctx: &Context, problem: Problem, subject: Option, diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_accordion.rs b/src/sheets/lyra_accordion.rs similarity index 98% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_accordion.rs rename to src/sheets/lyra_accordion.rs index cd4dc4f5..5707d98a 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_accordion.rs +++ b/src/sheets/lyra_accordion.rs @@ -4,9 +4,9 @@ use std::time::Duration; use egui::Color32; -use eggshell_ui_extras::disclosure::AccordionPart; -use eggshell_ui::sheet::{Sheet, When}; -use eggshell_ui::{Aria, Match, Opacity}; +use crate::owned::disclosure::AccordionPart; +use crate::sheet::{Sheet, When}; +use crate::{Aria, Match, Opacity}; const ACCORDION: &str = "registry/bases/radix/ui/accordion.tsx"; const LYRA: &str = "registry/styles/style-lyra.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_alert_dialog.rs b/src/sheets/lyra_alert_dialog.rs similarity index 99% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_alert_dialog.rs rename to src/sheets/lyra_alert_dialog.rs index 4e6769f2..d91aaf79 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_alert_dialog.rs +++ b/src/sheets/lyra_alert_dialog.rs @@ -1,9 +1,9 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `alert-dialog` //! (`registry/bases/radix/ui/alert-dialog.tsx`, `registry/styles/style-lyra.css`). Do not edit. -use eggshell_ui_extras::dialog::AlertDialogPart; -use eggshell_ui::sheet::Sheet; -use eggshell_ui::{Match}; +use crate::owned::dialog::AlertDialogPart; +use crate::sheet::Sheet; +use crate::{Match}; const ALERT_DIALOG: &str = "registry/bases/radix/ui/alert-dialog.tsx"; const LYRA: &str = "registry/styles/style-lyra.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_badge.rs b/src/sheets/lyra_badge.rs similarity index 98% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_badge.rs rename to src/sheets/lyra_badge.rs index 830af220..991f9665 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_badge.rs +++ b/src/sheets/lyra_badge.rs @@ -4,10 +4,10 @@ use std::time::Duration; use egui::Color32; -use eggshell_ui::contract::{Variant}; -use eggshell_ui_extras::badge::BadgePart; -use eggshell_ui::sheet::{Sheet, When}; -use eggshell_ui::{Aria, Match}; +use crate::contract::{Variant}; +use crate::owned::badge::BadgePart; +use crate::sheet::{Sheet, When}; +use crate::{Aria, Match}; const BADGE: &str = "registry/bases/radix/ui/badge.tsx"; const LYRA: &str = "registry/styles/style-lyra.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_card.rs b/src/sheets/lyra_card.rs similarity index 96% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_card.rs rename to src/sheets/lyra_card.rs index d3bde7c5..49ce0e8d 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_card.rs +++ b/src/sheets/lyra_card.rs @@ -1,10 +1,10 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `card` //! (`registry/bases/radix/ui/card.tsx`, `registry/styles/style-lyra.css`). Do not edit. -use eggshell_ui::contract::{Size}; -use eggshell_ui_extras::form::CardPart; -use eggshell_ui::sheet::{Sheet, When}; -use eggshell_ui::{Match}; +use crate::contract::{Size}; +use crate::owned::form::CardPart; +use crate::sheet::{Sheet, When}; +use crate::{Match}; const CARD: &str = "registry/bases/radix/ui/card.tsx"; const LYRA: &str = "registry/styles/style-lyra.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_combobox.rs b/src/sheets/lyra_combobox.rs similarity index 99% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_combobox.rs rename to src/sheets/lyra_combobox.rs index 6bf73bcc..3c896000 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_combobox.rs +++ b/src/sheets/lyra_combobox.rs @@ -4,9 +4,9 @@ use std::time::Duration; use egui::Shadow; -use eggshell_ui_extras::command::ComboboxPart; -use eggshell_ui::sheet::{Sheet, When}; -use eggshell_ui::{Aria, Match, Opacity}; +use crate::owned::command::ComboboxPart; +use crate::sheet::{Sheet, When}; +use crate::{Aria, Match, Opacity}; const COMBOBOX: &str = "registry/bases/radix/ui/combobox.tsx"; const INPUT_GROUP: &str = "registry/bases/radix/ui/input-group.tsx"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_command.rs b/src/sheets/lyra_command.rs similarity index 99% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_command.rs rename to src/sheets/lyra_command.rs index bbf51a70..893999a7 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_command.rs +++ b/src/sheets/lyra_command.rs @@ -4,9 +4,9 @@ use std::time::Duration; use egui::Shadow; -use eggshell_ui_extras::command::CommandPart; -use eggshell_ui::sheet::{Sheet, When}; -use eggshell_ui::{Aria, Match, Opacity, Tracking}; +use crate::owned::command::CommandPart; +use crate::sheet::{Sheet, When}; +use crate::{Aria, Match, Opacity, Tracking}; const COMMAND: &str = "registry/bases/radix/ui/command.tsx"; const INPUT_GROUP: &str = "registry/bases/radix/ui/input-group.tsx"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_dialog.rs b/src/sheets/lyra_dialog.rs similarity index 99% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_dialog.rs rename to src/sheets/lyra_dialog.rs index b2c0f9dd..40ca3a42 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_dialog.rs +++ b/src/sheets/lyra_dialog.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `dialog` //! (`registry/bases/radix/ui/dialog.tsx`, `registry/styles/style-lyra.css`). Do not edit. -use eggshell_ui_extras::dialog::DialogPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::dialog::DialogPart; +use crate::sheet::Sheet; const DIALOG: &str = "registry/bases/radix/ui/dialog.tsx"; const LYRA: &str = "registry/styles/style-lyra.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_hover_card.rs b/src/sheets/lyra_hover_card.rs similarity index 98% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_hover_card.rs rename to src/sheets/lyra_hover_card.rs index 253228ed..0b6acbdf 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_hover_card.rs +++ b/src/sheets/lyra_hover_card.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `hover-card` //! (`registry/bases/radix/ui/hover-card.tsx`, `registry/styles/style-lyra.css`). Do not edit. -use eggshell_ui_extras::hover_card::HoverCardPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::hover_card::HoverCardPart; +use crate::sheet::Sheet; const HOVER_CARD: &str = "registry/bases/radix/ui/hover-card.tsx"; const LYRA: &str = "registry/styles/style-lyra.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_popover.rs b/src/sheets/lyra_popover.rs similarity index 98% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_popover.rs rename to src/sheets/lyra_popover.rs index b1cc05ee..137ea188 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_popover.rs +++ b/src/sheets/lyra_popover.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `popover` //! (`registry/bases/radix/ui/popover.tsx`, `registry/styles/style-lyra.css`). Do not edit. -use eggshell_ui_extras::dialog::PopoverPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::dialog::PopoverPart; +use crate::sheet::Sheet; const LYRA: &str = "registry/styles/style-lyra.css"; const POPOVER: &str = "registry/bases/radix/ui/popover.tsx"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_sheet.rs b/src/sheets/lyra_sheet.rs similarity index 99% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_sheet.rs rename to src/sheets/lyra_sheet.rs index 70ef41c1..05a29fd6 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_sheet.rs +++ b/src/sheets/lyra_sheet.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `sheet` //! (`registry/bases/radix/ui/sheet.tsx`, `registry/styles/style-lyra.css`). Do not edit. -use eggshell_ui_extras::dialog::SheetPart; -use eggshell_ui::sheet::{Sheet, When}; +use crate::owned::dialog::SheetPart; +use crate::sheet::{Sheet, When}; const LYRA: &str = "registry/styles/style-lyra.css"; const REGISTRY: &str = "registry/bases/radix/registry.ts"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_skeleton.rs b/src/sheets/lyra_skeleton.rs similarity index 93% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_skeleton.rs rename to src/sheets/lyra_skeleton.rs index 2d9db885..c286a642 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_skeleton.rs +++ b/src/sheets/lyra_skeleton.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `skeleton` //! (`registry/bases/radix/ui/skeleton.tsx`, `registry/styles/style-lyra.css`). Do not edit. -use eggshell_ui_extras::skeleton::SkeletonPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::skeleton::SkeletonPart; +use crate::sheet::Sheet; const LYRA: &str = "registry/styles/style-lyra.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_sonner.rs b/src/sheets/lyra_sonner.rs similarity index 90% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_sonner.rs rename to src/sheets/lyra_sonner.rs index cb5dec27..d6b525d0 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_sonner.rs +++ b/src/sheets/lyra_sonner.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `sonner` //! (`registry/bases/radix/ui/sonner.tsx`, `registry/styles/style-lyra.css`). Do not edit. -use eggshell_ui_extras::notify::NotifyPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::notify::NotifyPart; +use crate::sheet::Sheet; const LYRA: &str = "registry/styles/style-lyra.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/lyra_spinner.rs b/src/sheets/lyra_spinner.rs similarity index 92% rename from crates/eggshell-ui-shadcn/src/sheets/lyra_spinner.rs rename to src/sheets/lyra_spinner.rs index 2fd2cf25..e562bec5 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/lyra_spinner.rs +++ b/src/sheets/lyra_spinner.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `spinner` //! (`registry/bases/radix/ui/spinner.tsx`, `registry/styles/style-lyra.css`). Do not edit. -use eggshell_ui_extras::spinner::SpinnerPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::spinner::SpinnerPart; +use crate::sheet::Sheet; const SPINNER: &str = "registry/bases/radix/ui/spinner.tsx"; diff --git a/src/sheets/mod.rs b/src/sheets/mod.rs index 1ad5df3b..7150cedf 100644 --- a/src/sheets/mod.rs +++ b/src/sheets/mod.rs @@ -16,6 +16,8 @@ mod vega_button; mod vega_input; mod vega_input_group; mod vega_select; +#[cfg(feature = "command")] mod vega_combobox; +#[cfg(feature = "command")] mod vega_command; mod vega_dropdown_menu; mod vega_tooltip; mod vega_checkbox; @@ -23,13 +25,26 @@ mod vega_radio_group; mod vega_switch; mod vega_field; mod vega_table; +#[cfg(feature = "hover-card")] mod vega_hover_card; +#[cfg(feature = "dialog")] mod vega_dialog; +#[cfg(feature = "dialog")] mod vega_alert_dialog; +#[cfg(feature = "dialog")] mod vega_sheet; +#[cfg(feature = "dialog")] mod vega_popover; +#[cfg(feature = "badge")] mod vega_badge; +#[cfg(feature = "form")] mod vega_card; mod vega_slider; +#[cfg(feature = "disclosure")] mod vega_accordion; +#[cfg(feature = "notify")] mod vega_sonner; +#[cfg(feature = "skeleton")] mod vega_skeleton; +#[cfg(feature = "spinner")] mod vega_spinner; mod vega_progress; mod vega_tabs; mod lyra_button; mod lyra_input; mod lyra_input_group; mod lyra_select; +#[cfg(feature = "command")] mod lyra_combobox; +#[cfg(feature = "command")] mod lyra_command; mod lyra_dropdown_menu; mod lyra_tooltip; mod lyra_checkbox; @@ -37,7 +52,18 @@ mod lyra_radio_group; mod lyra_switch; mod lyra_field; mod lyra_table; +#[cfg(feature = "hover-card")] mod lyra_hover_card; +#[cfg(feature = "dialog")] mod lyra_dialog; +#[cfg(feature = "dialog")] mod lyra_alert_dialog; +#[cfg(feature = "dialog")] mod lyra_sheet; +#[cfg(feature = "dialog")] mod lyra_popover; +#[cfg(feature = "badge")] mod lyra_badge; +#[cfg(feature = "form")] mod lyra_card; mod lyra_slider; +#[cfg(feature = "disclosure")] mod lyra_accordion; +#[cfg(feature = "notify")] mod lyra_sonner; +#[cfg(feature = "skeleton")] mod lyra_skeleton; +#[cfg(feature = "spinner")] mod lyra_spinner; mod lyra_progress; mod lyra_tabs; @@ -50,6 +76,8 @@ pub(crate) fn write(sheet: &mut Sheet, style: ShadcnStyle, theme: Theme) { (vega_input::light, vega_input::dark), (vega_input_group::light, vega_input_group::dark), (vega_select::light, vega_select::dark), + #[cfg(feature = "command")] (vega_combobox::light, vega_combobox::dark), + #[cfg(feature = "command")] (vega_command::light, vega_command::dark), (vega_dropdown_menu::light, vega_dropdown_menu::dark), (vega_tooltip::light, vega_tooltip::dark), (vega_checkbox::light, vega_checkbox::dark), @@ -57,7 +85,18 @@ pub(crate) fn write(sheet: &mut Sheet, style: ShadcnStyle, theme: Theme) { (vega_switch::light, vega_switch::dark), (vega_field::light, vega_field::dark), (vega_table::light, vega_table::dark), + #[cfg(feature = "hover-card")] (vega_hover_card::light, vega_hover_card::dark), + #[cfg(feature = "dialog")] (vega_dialog::light, vega_dialog::dark), + #[cfg(feature = "dialog")] (vega_alert_dialog::light, vega_alert_dialog::dark), + #[cfg(feature = "dialog")] (vega_sheet::light, vega_sheet::dark), + #[cfg(feature = "dialog")] (vega_popover::light, vega_popover::dark), + #[cfg(feature = "badge")] (vega_badge::light, vega_badge::dark), + #[cfg(feature = "form")] (vega_card::light, vega_card::dark), (vega_slider::light, vega_slider::dark), + #[cfg(feature = "disclosure")] (vega_accordion::light, vega_accordion::dark), + #[cfg(feature = "notify")] (vega_sonner::light, vega_sonner::dark), + #[cfg(feature = "skeleton")] (vega_skeleton::light, vega_skeleton::dark), + #[cfg(feature = "spinner")] (vega_spinner::light, vega_spinner::dark), (vega_progress::light, vega_progress::dark), (vega_tabs::light, vega_tabs::dark), ], @@ -66,6 +105,8 @@ pub(crate) fn write(sheet: &mut Sheet, style: ShadcnStyle, theme: Theme) { (lyra_input::light, lyra_input::dark), (lyra_input_group::light, lyra_input_group::dark), (lyra_select::light, lyra_select::dark), + #[cfg(feature = "command")] (lyra_combobox::light, lyra_combobox::dark), + #[cfg(feature = "command")] (lyra_command::light, lyra_command::dark), (lyra_dropdown_menu::light, lyra_dropdown_menu::dark), (lyra_tooltip::light, lyra_tooltip::dark), (lyra_checkbox::light, lyra_checkbox::dark), @@ -73,7 +114,18 @@ pub(crate) fn write(sheet: &mut Sheet, style: ShadcnStyle, theme: Theme) { (lyra_switch::light, lyra_switch::dark), (lyra_field::light, lyra_field::dark), (lyra_table::light, lyra_table::dark), + #[cfg(feature = "hover-card")] (lyra_hover_card::light, lyra_hover_card::dark), + #[cfg(feature = "dialog")] (lyra_dialog::light, lyra_dialog::dark), + #[cfg(feature = "dialog")] (lyra_alert_dialog::light, lyra_alert_dialog::dark), + #[cfg(feature = "dialog")] (lyra_sheet::light, lyra_sheet::dark), + #[cfg(feature = "dialog")] (lyra_popover::light, lyra_popover::dark), + #[cfg(feature = "badge")] (lyra_badge::light, lyra_badge::dark), + #[cfg(feature = "form")] (lyra_card::light, lyra_card::dark), (lyra_slider::light, lyra_slider::dark), + #[cfg(feature = "disclosure")] (lyra_accordion::light, lyra_accordion::dark), + #[cfg(feature = "notify")] (lyra_sonner::light, lyra_sonner::dark), + #[cfg(feature = "skeleton")] (lyra_skeleton::light, lyra_skeleton::dark), + #[cfg(feature = "spinner")] (lyra_spinner::light, lyra_spinner::dark), (lyra_progress::light, lyra_progress::dark), (lyra_tabs::light, lyra_tabs::dark), ], diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_accordion.rs b/src/sheets/vega_accordion.rs similarity index 98% rename from crates/eggshell-ui-shadcn/src/sheets/vega_accordion.rs rename to src/sheets/vega_accordion.rs index 0bc54049..9eaaaa18 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_accordion.rs +++ b/src/sheets/vega_accordion.rs @@ -4,9 +4,9 @@ use std::time::Duration; use egui::Color32; -use eggshell_ui_extras::disclosure::AccordionPart; -use eggshell_ui::sheet::{Sheet, When}; -use eggshell_ui::{Aria, Match, Opacity}; +use crate::owned::disclosure::AccordionPart; +use crate::sheet::{Sheet, When}; +use crate::{Aria, Match, Opacity}; const ACCORDION: &str = "registry/bases/radix/ui/accordion.tsx"; const REGISTRY: &str = "registry/bases/radix/registry.ts"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_alert_dialog.rs b/src/sheets/vega_alert_dialog.rs similarity index 99% rename from crates/eggshell-ui-shadcn/src/sheets/vega_alert_dialog.rs rename to src/sheets/vega_alert_dialog.rs index fe4fca5e..a984e27c 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_alert_dialog.rs +++ b/src/sheets/vega_alert_dialog.rs @@ -1,9 +1,9 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `alert-dialog` //! (`registry/bases/radix/ui/alert-dialog.tsx`, `registry/styles/style-vega.css`). Do not edit. -use eggshell_ui_extras::dialog::AlertDialogPart; -use eggshell_ui::sheet::Sheet; -use eggshell_ui::{Match}; +use crate::owned::dialog::AlertDialogPart; +use crate::sheet::Sheet; +use crate::{Match}; const ALERT_DIALOG: &str = "registry/bases/radix/ui/alert-dialog.tsx"; const VEGA: &str = "registry/styles/style-vega.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_badge.rs b/src/sheets/vega_badge.rs similarity index 98% rename from crates/eggshell-ui-shadcn/src/sheets/vega_badge.rs rename to src/sheets/vega_badge.rs index 8234cb0f..51e2520a 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_badge.rs +++ b/src/sheets/vega_badge.rs @@ -4,10 +4,10 @@ use std::time::Duration; use egui::Color32; -use eggshell_ui::contract::{Variant}; -use eggshell_ui_extras::badge::BadgePart; -use eggshell_ui::sheet::{Sheet, When}; -use eggshell_ui::{Aria, Match}; +use crate::contract::{Variant}; +use crate::owned::badge::BadgePart; +use crate::sheet::{Sheet, When}; +use crate::{Aria, Match}; const BADGE: &str = "registry/bases/radix/ui/badge.tsx"; const REGISTRY: &str = "registry/bases/radix/registry.ts"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_card.rs b/src/sheets/vega_card.rs similarity index 98% rename from crates/eggshell-ui-shadcn/src/sheets/vega_card.rs rename to src/sheets/vega_card.rs index 2c0c1e56..d0ce30b5 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_card.rs +++ b/src/sheets/vega_card.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `card` //! (`registry/bases/radix/ui/card.tsx`, `registry/styles/style-vega.css`). Do not edit. -use eggshell_ui_extras::form::CardPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::form::CardPart; +use crate::sheet::Sheet; const CARD: &str = "registry/bases/radix/ui/card.tsx"; const VEGA: &str = "registry/styles/style-vega.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_combobox.rs b/src/sheets/vega_combobox.rs similarity index 99% rename from crates/eggshell-ui-shadcn/src/sheets/vega_combobox.rs rename to src/sheets/vega_combobox.rs index 7e9b5506..28b975d8 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_combobox.rs +++ b/src/sheets/vega_combobox.rs @@ -2,9 +2,9 @@ //! (`registry/bases/radix/ui/combobox.tsx`, `registry/styles/style-vega.css`). Do not edit. use egui::Shadow; -use eggshell_ui_extras::command::ComboboxPart; -use eggshell_ui::sheet::{Sheet, When}; -use eggshell_ui::{Aria, Match, Opacity}; +use crate::owned::command::ComboboxPart; +use crate::sheet::{Sheet, When}; +use crate::{Aria, Match, Opacity}; const COMBOBOX: &str = "registry/bases/radix/ui/combobox.tsx"; const INPUT_GROUP: &str = "registry/bases/radix/ui/input-group.tsx"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_command.rs b/src/sheets/vega_command.rs similarity index 99% rename from crates/eggshell-ui-shadcn/src/sheets/vega_command.rs rename to src/sheets/vega_command.rs index 28bc0408..b640b0a6 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_command.rs +++ b/src/sheets/vega_command.rs @@ -2,9 +2,9 @@ //! (`registry/bases/radix/ui/command.tsx`, `registry/styles/style-vega.css`). Do not edit. use egui::Shadow; -use eggshell_ui_extras::command::CommandPart; -use eggshell_ui::sheet::{Sheet, When}; -use eggshell_ui::{Aria, Match, Opacity, Tracking}; +use crate::owned::command::CommandPart; +use crate::sheet::{Sheet, When}; +use crate::{Aria, Match, Opacity, Tracking}; const COMMAND: &str = "registry/bases/radix/ui/command.tsx"; const INPUT_GROUP: &str = "registry/bases/radix/ui/input-group.tsx"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_dialog.rs b/src/sheets/vega_dialog.rs similarity index 99% rename from crates/eggshell-ui-shadcn/src/sheets/vega_dialog.rs rename to src/sheets/vega_dialog.rs index 4cab16ce..31f44340 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_dialog.rs +++ b/src/sheets/vega_dialog.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `dialog` //! (`registry/bases/radix/ui/dialog.tsx`, `registry/styles/style-vega.css`). Do not edit. -use eggshell_ui_extras::dialog::DialogPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::dialog::DialogPart; +use crate::sheet::Sheet; const DIALOG: &str = "registry/bases/radix/ui/dialog.tsx"; const VEGA: &str = "registry/styles/style-vega.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_hover_card.rs b/src/sheets/vega_hover_card.rs similarity index 98% rename from crates/eggshell-ui-shadcn/src/sheets/vega_hover_card.rs rename to src/sheets/vega_hover_card.rs index 613dfa9b..899270a9 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_hover_card.rs +++ b/src/sheets/vega_hover_card.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `hover-card` //! (`registry/bases/radix/ui/hover-card.tsx`, `registry/styles/style-vega.css`). Do not edit. -use eggshell_ui_extras::hover_card::HoverCardPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::hover_card::HoverCardPart; +use crate::sheet::Sheet; const HOVER_CARD: &str = "registry/bases/radix/ui/hover-card.tsx"; const VEGA: &str = "registry/styles/style-vega.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_popover.rs b/src/sheets/vega_popover.rs similarity index 98% rename from crates/eggshell-ui-shadcn/src/sheets/vega_popover.rs rename to src/sheets/vega_popover.rs index 5c12667c..fcd81c1e 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_popover.rs +++ b/src/sheets/vega_popover.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `popover` //! (`registry/bases/radix/ui/popover.tsx`, `registry/styles/style-vega.css`). Do not edit. -use eggshell_ui_extras::dialog::PopoverPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::dialog::PopoverPart; +use crate::sheet::Sheet; const POPOVER: &str = "registry/bases/radix/ui/popover.tsx"; const VEGA: &str = "registry/styles/style-vega.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_sheet.rs b/src/sheets/vega_sheet.rs similarity index 99% rename from crates/eggshell-ui-shadcn/src/sheets/vega_sheet.rs rename to src/sheets/vega_sheet.rs index 915aec85..8de8a955 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_sheet.rs +++ b/src/sheets/vega_sheet.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `sheet` //! (`registry/bases/radix/ui/sheet.tsx`, `registry/styles/style-vega.css`). Do not edit. -use eggshell_ui_extras::dialog::SheetPart; -use eggshell_ui::sheet::{Sheet, When}; +use crate::owned::dialog::SheetPart; +use crate::sheet::{Sheet, When}; const REGISTRY: &str = "registry/bases/radix/registry.ts"; const SHEET: &str = "registry/bases/radix/ui/sheet.tsx"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_skeleton.rs b/src/sheets/vega_skeleton.rs similarity index 93% rename from crates/eggshell-ui-shadcn/src/sheets/vega_skeleton.rs rename to src/sheets/vega_skeleton.rs index c6da4595..a756e4ec 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_skeleton.rs +++ b/src/sheets/vega_skeleton.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `skeleton` //! (`registry/bases/radix/ui/skeleton.tsx`, `registry/styles/style-vega.css`). Do not edit. -use eggshell_ui_extras::skeleton::SkeletonPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::skeleton::SkeletonPart; +use crate::sheet::Sheet; const VEGA: &str = "registry/styles/style-vega.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_sonner.rs b/src/sheets/vega_sonner.rs similarity index 90% rename from crates/eggshell-ui-shadcn/src/sheets/vega_sonner.rs rename to src/sheets/vega_sonner.rs index 98fdb77c..8f0d0da6 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_sonner.rs +++ b/src/sheets/vega_sonner.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `sonner` //! (`registry/bases/radix/ui/sonner.tsx`, `registry/styles/style-vega.css`). Do not edit. -use eggshell_ui_extras::notify::NotifyPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::notify::NotifyPart; +use crate::sheet::Sheet; const VEGA: &str = "registry/styles/style-vega.css"; diff --git a/crates/eggshell-ui-shadcn/src/sheets/vega_spinner.rs b/src/sheets/vega_spinner.rs similarity index 92% rename from crates/eggshell-ui-shadcn/src/sheets/vega_spinner.rs rename to src/sheets/vega_spinner.rs index b3ee02b5..7948719e 100644 --- a/crates/eggshell-ui-shadcn/src/sheets/vega_spinner.rs +++ b/src/sheets/vega_spinner.rs @@ -1,8 +1,8 @@ //! Generated by `cargo xtask shadcn-import --write` from shadcn's `spinner` //! (`registry/bases/radix/ui/spinner.tsx`, `registry/styles/style-vega.css`). Do not edit. -use eggshell_ui_extras::spinner::SpinnerPart; -use eggshell_ui::sheet::Sheet; +use crate::owned::spinner::SpinnerPart; +use crate::sheet::Sheet; const SPINNER: &str = "registry/bases/radix/ui/spinner.tsx"; diff --git a/src/theme/contrast.rs b/src/theme/contrast.rs index d7b42c1c..0f5726a3 100644 --- a/src/theme/contrast.rs +++ b/src/theme/contrast.rs @@ -242,7 +242,7 @@ impl RegistryMiss { /// Reports, in a debug build, each pair of `tokens` under AA that is neither /// accepted nor a registry miss, once per pair and theme. The colours are not /// changed. -pub fn warn_low_contrast(ctx: &Context, tokens: &Tokens) { +pub(crate) fn warn_low_contrast(ctx: &Context, tokens: &Tokens) { let theme = tokens.theme; if !cfg!(debug_assertions) { return; diff --git a/src/theme/fonts.rs b/src/theme/fonts.rs index 59722072..5ec1bfdf 100644 --- a/src/theme/fonts.rs +++ b/src/theme/fonts.rs @@ -82,7 +82,7 @@ impl FontSet { } /// The named family of each weight but Normal, for the style contract. - pub fn declared(&self) -> Faces { + pub(crate) fn declared(&self) -> Faces { self.weighted().fold(Faces::default(), |faces, weight| { faces.with(FontFamily::Proportional, weight, self.family(weight)) }) @@ -91,7 +91,7 @@ impl FontSet { /// Adds the faces to `ctx`'s fonts. The Normal face also backs every /// named family, for the glyphs a weighted face lacks. Adding a face egui /// has under its name already does nothing. - pub fn install(&self, ctx: &Context) { + pub(crate) fn install(&self, ctx: &Context) { for font in self.inserts() { ctx.add_font(font); } @@ -99,7 +99,7 @@ impl FontSet { /// The faces as egui font insertions: each weight's face first in its /// own family, and the Normal face last in every weighted family. - pub fn inserts(&self) -> Vec { + pub(crate) fn inserts(&self) -> Vec { let first = |family| InsertFontFamily { family, priority: FontPriority::Highest, diff --git a/src/theme/mod.rs b/src/theme/mod.rs index d5e7a582..ea5801ea 100644 --- a/src/theme/mod.rs +++ b/src/theme/mod.rs @@ -1,17 +1,102 @@ //! TODO(prose): shadcn's tokens, the values every look is drawn from: the //! palette, light and dark, the shadcn style's sizes, the density tokens, //! the font and the contrast check. +//! +//! The shadcn/ui design system as a [`Style`](crate::Style). +//! +//! [`Shadcn`] is a preset: a [`ShadcnStyle`] (which of shadcn's styles, such as +//! [`Vega`](ShadcnStyle::Vega) or [`Lyra`](ShadcnStyle::Lyra)), a +//! [`Palette`] (shadcn's base and theme colours) and an egui theme (light or dark), +//! chosen independently. Nothing here runs unless the application calls +//! [`Shadcn::apply`]: the library never changes egui's style on its own. +//! +//! The crate only fills the contract. `eggshell` defines what its widgets +//! need and has no shadcn names or values; a style is data, so changing +//! [`ShadcnStyle`] at run time changes sizes, radii, text size and ring width +//! with no code change in the application. +//! +//! Applying a preset does three things. It fills the [`Style`](crate::Style) +//! contract with the tokens ([`Shadcn::style`]) and installs it for the +//! preset's theme, which the owned widgets and the text edit of `eggshell` +//! draw from. It maps the [`Tokens`] onto the egui [`Style`](egui::Style) of +//! the preset's theme (widget fills, strokes, radii, selection, spacing) for +//! the egui widgets an application draws outside eggshell. It also remembers +//! the tokens in the context, for [`tokens`] and [`Shadcn::of`]. +//! +//! ``` +//! use eggshell_ui::theme::{Palette, Shadcn, ShadcnStyle, ThemeColor}; +//! +//! let ctx = egui::Context::default(); +//! // Once at startup: shadcn's default preset, light and dark. +//! Shadcn::apply_both(&ctx); +//! // Or every frame, to switch style or colour at run time; a no-op while +//! // nothing changes. +//! Shadcn::apply_both_with(&ctx, ShadcnStyle::Lyra, Palette::new().theme(ThemeColor::Blue)); +//! // The tokens, for the application's own colours. +//! let background = Shadcn::of(&ctx).tokens.background; +//! # let _ = background; +//! ``` +//! +//! What eggshell cannot draw exactly and the preset therefore approximates is +//! documented on [`InputStyle`](crate::contract::InputStyle) for the wrapped text edit; +//! the owned widgets are exact except for the negative spread of `shadow-md`. +//! +//! # Fonts +//! +//! With the default `fonts` feature the preset bundles Geist, shadcn's +//! `--font-sans`, as one variable font (165 KiB, SIL Open Font License 1.1, +//! `fonts/OFL.txt`) and [`Shadcn::apply`] registers it at every [`Weight`]: +//! Normal as the first font of [`FontFamily::Proportional`], the others as +//! named families its [`Faces`] declare. [`Shadcn::with_fonts`] swaps in +//! another [`FontSet`], or `None` for egui's fonts as the application set +//! them. Without the feature nothing is embedded and the preset starts with +//! no font, so its medium controls are drawn in the regular face, with a +//! debug warning. +//! +//! The application's own text picks a weight with eggshell's classes +//! (`tw().font_medium()`, `font_semibold`, `font_bold`). A [`FontSet`] of +//! static faces that leaves a weight out draws it in the nearest lighter +//! face it has. eggshell's symbol face (⌘, ⇧, ⌥) sits last in every weight's +//! family, behind Geist, so key chips and menu shortcuts draw in any weight. +//! +//! egui's `default_fonts` feature embeds its own Ubuntu-Light, which Geist +//! makes a fallback only. An application that does not need it can depend on +//! egui with `default-features = false` (and the features it does use) to +//! drop it from the binary. +//! +//! [`Weight`]: crate::Weight +//! [`Faces`]: crate::Faces +//! [`FontFamily::Proportional`]: egui::FontFamily::Proportional +//! +//! # Hovered and selected +//! +//! shadcn's components pair the two as follows, and the helpers on +//! [`Tokens`] name the pairs: +//! +//! | Component | Hovered | Selected | +//! |---|---|---| +//! | List or menu row on the page | `accent/50` ([`Tokens::accent_50`]) | `accent` with `accent-foreground` | +//! | Table row | `muted/50` ([`Tokens::muted_50`]) | `muted` | +//! | Ghost and outline button | `accent` with `accent-foreground` (dark: `accent/50`, `input/50`) | | +//! | Secondary, primary, destructive button | `secondary/80`, `primary/90`, `destructive/90` | | +//! +//! In the neutral palette `muted`, `accent` and `secondary` are one colour, +//! so a hover on a `muted` surface needs the half-strength variant of the +//! selected colour, not a different token. mod contrast; mod fonts; mod palette; +mod preset; mod styles; mod theme_color; mod tokens; -pub use contrast::{ContrastPair, ContrastRatio, REGISTRY_MISSES, RegistryMiss, warn_low_contrast}; +pub(crate) use contrast::warn_low_contrast; +pub use contrast::{ContrastPair, ContrastRatio, REGISTRY_MISSES, RegistryMiss}; pub use fonts::FontSet; pub use palette::{BaseColor, Palette}; +pub use preset::{Shadcn, tokens}; pub use styles::{Elevation, HoverSurface, ShadcnStyle}; pub use theme_color::ThemeColor; pub use tokens::Tokens; @@ -42,3 +127,24 @@ pub mod size { /// TODO(prose): `icon-lg`: [`ICON`] at [`LG`]. pub const ICON_LG: Size = Size("icon-lg"); } + +/// The names of shadcn's button variants, as the preset's sheet names them +/// for [`ButtonPart`](crate::owned::ButtonPart). shadcn's `default` is +/// [`PRIMARY`](variant::PRIMARY); a button that names no variant is +/// [`SECONDARY`](variant::SECONDARY). +pub mod variant { + use crate::contract::Variant; + + /// `default`. + pub const PRIMARY: Variant = Variant("primary"); + /// `secondary`: the variant of a button that names none. + pub const SECONDARY: Variant = Variant("secondary"); + /// `destructive`. + pub const DESTRUCTIVE: Variant = Variant("destructive"); + /// `outline`. + pub const OUTLINE: Variant = Variant("outline"); + /// `ghost`. + pub const GHOST: Variant = Variant("ghost"); + /// TODO(prose): `link`: primary-coloured text, underlined under the pointer. + pub const LINK: Variant = Variant("link"); +} diff --git a/crates/eggshell-ui-shadcn/src/preset.rs b/src/theme/preset.rs similarity index 79% rename from crates/eggshell-ui-shadcn/src/preset.rs rename to src/theme/preset.rs index 6ed4e367..0f1b09e6 100644 --- a/crates/eggshell-ui-shadcn/src/preset.rs +++ b/src/theme/preset.rs @@ -1,17 +1,37 @@ -use eggshell_ui::contract; +use crate::contract; use egui::{Context, Id, Theme}; -#[cfg(feature = "extras")] +#[cfg(any( + feature = "badge", + feature = "command", + feature = "dialog", + feature = "disclosure", + feature = "form", + feature = "hover-card", + feature = "markdown", + feature = "notify", + feature = "skeleton" +))] use { - eggshell_ui::contract::{Colors, Focus, Keyed, Look as BoxLook, States}, - eggshell_ui::{Opacity, TextSpec, Weight}, - egui::{Color32, Shadow}, + crate::contract::{Colors, Focus, Keyed, Look as BoxLook, States}, + crate::{Opacity, TextSpec, Weight}, + egui::Color32, std::time::Duration, }; -use crate::ShadcnStyle; -use crate::{ContrastPair, FontSet, Palette, Tokens}; -#[cfg(feature = "extras")] -use crate::{size, variant}; +use crate::theme::ShadcnStyle; +use crate::theme::{ContrastPair, FontSet, Palette, Tokens}; +#[cfg(any( + feature = "badge", + feature = "command", + feature = "dialog", + feature = "disclosure", + feature = "form", + feature = "hover-card", + feature = "markdown", + feature = "notify", + feature = "skeleton" +))] +use crate::theme::{size, variant}; /// The shadcn/ui preset: [`Tokens`] for one egui theme. #[derive(Clone, Debug, PartialEq)] @@ -104,7 +124,7 @@ impl Shadcn { /// /// ``` /// use eggshell_ui::LayoutState; - /// use eggshell_ui_shadcn::{Palette, Shadcn, ShadcnStyle}; + /// use eggshell_ui::theme::{Palette, Shadcn, ShadcnStyle}; /// /// let style = Shadcn::themed(ShadcnStyle::Vega, Palette::new()); /// let _layout = LayoutState::new().with_style(style); @@ -112,7 +132,7 @@ impl Shadcn { pub fn themed( style: ShadcnStyle, palette: Palette, - ) -> eggshell_ui::contract::Themed> { + ) -> crate::contract::Themed> { let half = |preset: Self| { std::sync::Arc::new( preset @@ -121,7 +141,7 @@ impl Shadcn { .layout_style(), ) }; - eggshell_ui::contract::Themed { + crate::contract::Themed { light: half(Self::light()), dark: half(Self::dark()), } @@ -132,7 +152,7 @@ impl Shadcn { /// ``` /// use eggshell_ui::LayoutState; /// use eggshell_ui::contract::Themed; - /// use eggshell_ui_shadcn::Shadcn; + /// use eggshell_ui::theme::Shadcn; /// use std::sync::Arc; /// /// let style = Themed { @@ -142,48 +162,65 @@ impl Shadcn { /// let _layout = LayoutState::new().with_style(style); /// ``` pub fn layout_style(&self) -> contract::Style { - #[cfg(not(feature = "extras"))] - return self.style(); - #[cfg(feature = "extras")] - { - let mut core = self.style(); - // keep sorted - let badge = self.badge(&core); - let command = self.command(&core); - let dialog = self.dialog(&core); - let disclosure = self.disclosure(&core); - let form = self.form(&core); - let notify = self.notify(&core); - let skeleton = self.skeleton(&core); - core.set_extension(badge); - core.set_extension(command); - core.set_extension(dialog); - core.set_extension(disclosure); - core.set_extension(form); - core.set_extension(self.hover_card()); - core.set_extension(self.markdown()); - core.set_extension(notify); - core.set_extension(skeleton); - core - } + #[cfg_attr( + not(any( + feature = "badge", + feature = "command", + feature = "dialog", + feature = "disclosure", + feature = "form", + feature = "hover-card", + feature = "markdown", + feature = "notify", + feature = "skeleton" + )), + allow(unused_mut) + )] + let mut core = self.style(); + // keep sorted + #[cfg(feature = "badge")] + let badge = self.badge(&core); + #[cfg(feature = "command")] + let command = self.command(&core); + #[cfg(feature = "dialog")] + let dialog = self.dialog(&core); + #[cfg(feature = "disclosure")] + let disclosure = self.disclosure(&core); + #[cfg(feature = "form")] + let form = self.form(&core); + #[cfg(feature = "notify")] + let notify = self.notify(&core); + #[cfg(feature = "skeleton")] + let skeleton = self.skeleton(&core); + #[cfg(feature = "badge")] + core.set_extension(badge); + #[cfg(feature = "command")] + core.set_extension(command); + #[cfg(feature = "dialog")] + core.set_extension(dialog); + #[cfg(feature = "disclosure")] + core.set_extension(disclosure); + #[cfg(feature = "form")] + core.set_extension(form); + #[cfg(feature = "hover-card")] + core.set_extension(self.hover_card()); + #[cfg(feature = "markdown")] + core.set_extension(self.markdown()); + #[cfg(feature = "notify")] + core.set_extension(notify); + #[cfg(feature = "skeleton")] + core.set_extension(skeleton); + core } - /// This preset as the [`eggshell_ui::Style`] contract. + /// This preset as the [`Style`](crate::Style) contract. pub fn style(&self) -> contract::Style { - let t = &self.tokens; - let mut style = contract::Style::new(t); - crate::sheets::write(&mut style.sheet, t.style, t.theme); - #[cfg(feature = "extras")] - { - let disclosure = style.extension::(); - eggshell_ui_extras::disclosure::write_exceptions(&mut style.sheet, &disclosure); - } - style + contract::Style::new(&self.tokens) } /// A box's colours at rest and under the pointer, with the focused /// border, `focus-visible:border-ring`, over the page. - #[cfg(feature = "extras")] + #[cfg(feature = "badge")] fn states(&self, rest: Colors, hover: Colors) -> States { States { focused: Colors { @@ -213,11 +250,11 @@ impl Shadcn { /// a weight is drawn in the nearest lighter registered face. /// /// TODO(prose): in a debug build it reports each [`ContrastPair`] under - /// AA contrast as [`Problem::LowContrast`](eggshell_ui::Problem::LowContrast), + /// AA contrast as [`Problem::LowContrast`](crate::Problem::LowContrast), /// unless the tokens accept it or it is shadcn's own colour; it never /// changes a colour. pub fn apply(&self, ctx: &Context) { - eggshell_ui::theme::warn_low_contrast(ctx, &self.tokens); + crate::theme::warn_low_contrast(ctx, &self.tokens); if let Some(font) = &self.tokens.font { font.install(ctx); } @@ -251,10 +288,10 @@ impl Shadcn { /// and in `--normal-text` over `--normal-border`, with `hsl(0 0% 12%)` /// and `hsl(0 0% 25%)` under the pointer, in the dark (styles.css 520- /// 536). - #[cfg(feature = "extras")] - pub fn notify(&self, style: &contract::Style) -> eggshell_ui_extras::notify::NotifyStyle { + #[cfg(feature = "notify")] + pub fn notify(&self, style: &contract::Style) -> crate::owned::notify::NotifyStyle { let t = &self.tokens; - let mut notify = eggshell_ui_extras::notify::NotifyStyle::from_style(style); + let mut notify = crate::owned::notify::NotifyStyle::from_style(style); notify.fill = t.popover; notify.border = t.border; notify.text = t.popover_foreground; @@ -263,7 +300,7 @@ impl Shadcn { ShadcnStyle::Vega => contract::corner(t.radius.lg() * 1.8), ShadcnStyle::Lyra => 0, }; - notify.shadow = Some(Shadow { + notify.shadow = Some(egui::Shadow { offset: [0, 4], blur: 12, spread: 0, @@ -300,9 +337,9 @@ impl Shadcn { /// TODO(prose): the skeleton's look: shadcn's `Skeleton`, `bg-muted /// rounded-md animate-pulse`: the muted fill, the radius of its style /// (square in Lyra) and Tailwind's two-second pulse down to half. - #[cfg(feature = "extras")] - pub fn skeleton(&self, style: &contract::Style) -> eggshell_ui_extras::skeleton::SkeletonStyle { - let mut skeleton = eggshell_ui_extras::skeleton::SkeletonStyle::from_style(style); + #[cfg(feature = "skeleton")] + pub fn skeleton(&self, style: &contract::Style) -> crate::owned::skeleton::SkeletonStyle { + let mut skeleton = crate::owned::skeleton::SkeletonStyle::from_style(style); skeleton.fill = self.tokens.muted; skeleton.radius = self.tokens.radius_md(); skeleton @@ -319,15 +356,15 @@ impl Shadcn { /// TODO(prose) /// /// ``` - /// use eggshell_ui_shadcn::{Shadcn, variant}; + /// use eggshell_ui::theme::{Shadcn, variant}; /// /// let shadcn = Shadcn::light(); /// let badge = shadcn.badge(&shadcn.style()); /// assert_eq!(badge.variants.default_key(), variant::PRIMARY); /// assert_eq!(badge.height, 20.0); /// ``` - #[cfg(feature = "extras")] - pub fn badge(&self, style: &contract::Style) -> eggshell_ui_extras::badge::BadgeStyle { + #[cfg(feature = "badge")] + pub fn badge(&self, style: &contract::Style) -> crate::owned::badge::BadgeStyle { let t = &self.tokens; let dark = self.theme() == Theme::Dark; let clear = Color32::TRANSPARENT; @@ -354,7 +391,7 @@ impl Shadcn { border: t.border, text: t.foreground, }; - let mut badge = eggshell_ui_extras::badge::BadgeStyle::from_style(style); + let mut badge = crate::owned::badge::BadgeStyle::from_style(style); badge.variants = Keyed::new( variant::PRIMARY, look( @@ -417,9 +454,9 @@ impl Shadcn { /// TODO(prose): the look of a command list's rows: shadcn's /// `CommandItem`, `data-selected:bg-muted data-selected:text-foreground`, /// and its list `max-h-72`. - #[cfg(feature = "extras")] - pub fn command(&self, style: &contract::Style) -> eggshell_ui_extras::command::CommandStyle { - let mut command = eggshell_ui_extras::command::CommandStyle::from_style(style); + #[cfg(feature = "command")] + pub fn command(&self, style: &contract::Style) -> crate::owned::command::CommandStyle { + let mut command = crate::owned::command::CommandStyle::from_style(style); command.selected_fill = self.tokens.muted; command.selected_text = self.tokens.foreground; command @@ -450,20 +487,17 @@ impl Shadcn { /// TODO(prose) /// /// ``` - /// use eggshell_ui_shadcn::Shadcn; + /// use eggshell_ui::theme::Shadcn; /// /// let shadcn = Shadcn::light(); /// let disclosure = shadcn.disclosure(&shadcn.style()); /// assert_eq!(disclosure.header.padding_y, 16.0); /// ``` - #[cfg(feature = "extras")] - pub fn disclosure( - &self, - style: &contract::Style, - ) -> eggshell_ui_extras::disclosure::DisclosureStyle { + #[cfg(feature = "disclosure")] + pub fn disclosure(&self, style: &contract::Style) -> crate::owned::disclosure::DisclosureStyle { let t = &self.tokens; let lyra = t.style == ShadcnStyle::Lyra; - let mut disclosure = eggshell_ui_extras::disclosure::DisclosureStyle::from_style(style); + let mut disclosure = crate::owned::disclosure::DisclosureStyle::from_style(style); disclosure.section.size = 16.0; disclosure.tree.size = 16.0; disclosure.tone = Some(t.muted_foreground); @@ -503,18 +537,18 @@ impl Shadcn { /// and a row `px-4 py-2`, as chosen. /// /// ``` - /// use eggshell_ui_shadcn::Shadcn; + /// use eggshell_ui::theme::Shadcn; /// /// let shadcn = Shadcn::light(); /// let form = shadcn.form(&shadcn.style()); /// assert_eq!(form.fill, shadcn.tokens.card); /// assert_eq!(form.radius, 14); /// ``` - #[cfg(feature = "extras")] - pub fn form(&self, style: &contract::Style) -> eggshell_ui_extras::form::FormStyle { + #[cfg(feature = "form")] + pub fn form(&self, style: &contract::Style) -> crate::owned::form::FormStyle { let t = &self.tokens; let vega = t.style == ShadcnStyle::Vega; - let mut form = eggshell_ui_extras::form::FormStyle::from_style(style); + let mut form = crate::owned::form::FormStyle::from_style(style); form.fill = t.card; form.border = t.border; form.border_width = 1.0; @@ -546,9 +580,9 @@ impl Shadcn { /// TODO(prose): the hover card's look: shadcn's `HoverCardContent` /// (`w-64 rounded-lg bg-popover p-4 shadow-md duration-100`, 4 pt below, /// centred) in this preset's colours, with Radix's 700/300 ms delays. - #[cfg(feature = "extras")] - pub fn hover_card(&self) -> eggshell_ui_extras::hover_card::HoverCardStyle { - let mut card = eggshell_ui_extras::hover_card::HoverCardStyle::from_style(&self.style()); + #[cfg(feature = "hover-card")] + pub fn hover_card(&self) -> crate::owned::hover_card::HoverCardStyle { + let mut card = crate::owned::hover_card::HoverCardStyle::from_style(&self.style()); card.radius = self.tokens.radius_lg(); card.transition = Duration::from_millis(100); card @@ -556,17 +590,17 @@ impl Shadcn { /// TODO(prose): the Markdown widget's look: shadcn/typeset at its /// defaults, in this preset's colours. - #[cfg(feature = "extras")] - pub fn markdown(&self) -> eggshell_ui_extras::markdown::MarkdownStyle { - eggshell_ui_extras::markdown::Typeset::default().markdown_style(&self.typeset_ink()) + #[cfg(feature = "markdown")] + pub fn markdown(&self) -> crate::owned::markdown::MarkdownStyle { + crate::owned::markdown::Typeset::default().markdown_style(&self.typeset_ink()) } /// TODO(prose): the look of the dialog surface, the sheet and the /// popover: shadcn's `DialogContent`, `SheetContent` and /// `PopoverContent`. Placeholder values until the render round. - #[cfg(feature = "extras")] - pub fn dialog(&self, style: &contract::Style) -> eggshell_ui_extras::dialog::DialogStyle { - use eggshell_ui_extras::dialog::{DialogStyle, Surface, shadow_lg}; + #[cfg(feature = "dialog")] + pub fn dialog(&self, style: &contract::Style) -> crate::owned::dialog::DialogStyle { + use crate::owned::dialog::{DialogStyle, Surface, shadow_lg}; let t = &self.tokens; let mut dialog = DialogStyle::from_style(style); dialog.surface = Surface::new(t.background, t.foreground, t.border) @@ -584,11 +618,11 @@ impl Shadcn { /// TODO(prose): the theme colours a [`Typeset`] takes, from this preset's /// tokens, for a typeset of other parameters. /// - /// [`Typeset`]: eggshell_ui_extras::markdown::Typeset - #[cfg(feature = "extras")] - pub fn typeset_ink(&self) -> eggshell_ui_extras::markdown::TypesetInk { + /// [`Typeset`]: crate::owned::markdown::Typeset + #[cfg(feature = "markdown")] + pub fn typeset_ink(&self) -> crate::owned::markdown::TypesetInk { let t = &self.tokens; - eggshell_ui_extras::markdown::TypesetInk { + crate::owned::markdown::TypesetInk { foreground: t.foreground, muted: t.muted_foreground, rule: t.border, diff --git a/src/theme/styles.rs b/src/theme/styles.rs index 719cc529..d2e76f91 100644 --- a/src/theme/styles.rs +++ b/src/theme/styles.rs @@ -103,7 +103,7 @@ pub enum Elevation { impl Elevation { /// TODO(prose): `shadow` on a raised control, or none on a flat one. - pub fn shadow(self, shadow: egui::Shadow) -> Option { + pub(crate) fn shadow(self, shadow: egui::Shadow) -> Option { match self { Self::Raised => Some(shadow), Self::Flat => None, diff --git a/tests/it/accordion.rs b/tests/it/accordion.rs index 7f6e1c10..0a5789d3 100644 --- a/tests/it/accordion.rs +++ b/tests/it/accordion.rs @@ -5,8 +5,8 @@ use std::collections::BTreeSet; use eggshell_ui::overlay::Shown; use eggshell_ui::owned::Enablement; +use eggshell_ui::owned::accordion::{AccordionExt, Items, Mode, Multiple, Single}; use eggshell_ui::{Builder, tw}; -use eggshell_ui_extras::accordion::{AccordionExt, Items, Mode, Multiple, Single}; use egui::accesskit::Role as AccessRole; use egui::vec2; use egui_kittest::Harness; diff --git a/tests/it/badge.rs b/tests/it/badge.rs index f3eff28d..f78501d6 100644 --- a/tests/it/badge.rs +++ b/tests/it/badge.rs @@ -2,11 +2,11 @@ //! shadcn preset the rig applies. use eggshell_ui::contract::Variant; +use eggshell_ui::owned::badge::{BadgeExt, BadgeStyle}; +use eggshell_ui::owned::spinner::SpinnerExt; use eggshell_ui::testing::{Animation, Driver, Target}; +use eggshell_ui::theme::{Tokens, size, variant}; use eggshell_ui::{Builder, Problem, TextStyle, tw}; -use eggshell_ui_extras::badge::{BadgeExt, BadgeStyle}; -use eggshell_ui_extras::spinner::SpinnerExt; -use eggshell_ui_shadcn::{Tokens, size, variant}; use egui::{Key, Role, Theme, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; @@ -293,7 +293,7 @@ fn an_app_rule_restyles_a_badge() { style .sheet .as_app() - .rule(eggshell_ui_extras::badge::BadgePart::Root, |t, _| { + .rule(eggshell_ui::owned::badge::BadgePart::Root, |t, _| { t.bg(egui::Color32::RED) }); })) @@ -339,7 +339,7 @@ fn an_app_rule_restyles_a_spinner() { style .sheet .as_app() - .rule(eggshell_ui_extras::spinner::SpinnerPart::Root, |t, _| { + .rule(eggshell_ui::owned::spinner::SpinnerPart::Root, |t, _| { t.bg(egui::Color32::RED).size(10.0) }); })) diff --git a/tests/it/button_options.rs b/tests/it/button_options.rs index 26463a61..74a58c55 100644 --- a/tests/it/button_options.rs +++ b/tests/it/button_options.rs @@ -3,8 +3,8 @@ use eggshell_ui::contract::Size; use eggshell_ui::owned::{ButtonChain, ButtonOptions}; +use eggshell_ui::theme::{Shadcn, size, variant}; use eggshell_ui::{Builder, LayoutState, Scope, tw}; -use eggshell_ui_shadcn::{Shadcn, size, variant}; use egui::epaint::ClippedShape; use egui::{RawInput, Rect, pos2}; diff --git a/tests/it/chat_shell_demo.rs b/tests/it/chat_shell_demo.rs index a0260dcf..26459b1b 100644 --- a/tests/it/chat_shell_demo.rs +++ b/tests/it/chat_shell_demo.rs @@ -772,7 +772,7 @@ mod appearance { mod accents { use super::*; - use eggshell_ui_shadcn::ThemeColor; + use eggshell_ui::theme::ThemeColor; use egui::epaint::Shape; fn text_colors(d: &Driver, text: &str) -> Vec { @@ -800,9 +800,9 @@ mod accents { assert_eq!(text_colors(&d, "Running"), [k[Tok::Accent]]); assert_ne!(k[Tok::Success], k[Tok::Danger], "precondition"); assert_eq!( - eggshell_ui_shadcn::Shadcn::of(d.ctx()).tokens.primary, - eggshell_ui_shadcn::Shadcn::for_theme(theme) - .with_palette(eggshell_ui_shadcn::Palette::new().theme(ThemeColor::Blue)) + eggshell_ui::theme::Shadcn::of(d.ctx()).tokens.primary, + eggshell_ui::theme::Shadcn::for_theme(theme) + .with_palette(eggshell_ui::theme::Palette::new().theme(ThemeColor::Blue)) .tokens .primary, "the example's accent is blue" diff --git a/tests/it/children.rs b/tests/it/children.rs index fcf2ab15..10393e31 100644 --- a/tests/it/children.rs +++ b/tests/it/children.rs @@ -7,8 +7,8 @@ use eggshell_ui::contract::{Disabled, Size, Themed, Variant}; use eggshell_ui::owned::{ButtonPart, Enablement, Face}; use eggshell_ui::sheet::{Key, When}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::{Shadcn, Tokens}; use eggshell_ui::{Aria, Builder, Opacity, TextStyle, tw}; -use eggshell_ui_shadcn::{Shadcn, Tokens}; use egui::{Color32, Rect, Theme, pos2, vec2}; use crate::support::{self, box_at, shapes, text_color}; diff --git a/tests/it/choice_cards.rs b/tests/it/choice_cards.rs index 2441ac08..437cda39 100644 --- a/tests/it/choice_cards.rs +++ b/tests/it/choice_cards.rs @@ -3,8 +3,8 @@ use eggshell_ui::owned::{Choice, Enablement}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::{Shadcn, Tokens}; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::{Shadcn, Tokens}; use egui::{Key, Rect, Role, Theme, pos2, vec2}; use egui_kittest::kittest::Queryable as _; diff --git a/tests/it/choices.rs b/tests/it/choices.rs index 06da6b41..22b0660e 100644 --- a/tests/it/choices.rs +++ b/tests/it/choices.rs @@ -6,8 +6,8 @@ use std::fmt; use eggshell_ui::owned::{Choice, Enablement}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Icon, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Key, Role, Theme, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/tests/it/combobox_sheet.rs b/tests/it/combobox_sheet.rs index 95fc8eb5..2a71b62a 100644 --- a/tests/it/combobox_sheet.rs +++ b/tests/it/combobox_sheet.rs @@ -4,10 +4,10 @@ use eggshell_ui::Style; use eggshell_ui::contract::Themed; +use eggshell_ui::owned::command::{ComboboxPart, CommandExt}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, TextSpec, TextStyle, Weight, tw}; -use eggshell_ui_extras::command::{ComboboxPart, CommandExt}; -use eggshell_ui_shadcn::Tokens; use egui::epaint::Shape; use egui::{Color32, FontFamily, Rect, vec2}; @@ -61,25 +61,6 @@ fn content(d: &Driver) -> Rect { .expect("the list's box") } -#[test] -fn the_presets_look_replaces_the_combobox_defaults() { - // The widget's own box is the menu's, bordered; shadcn's is ringed. - let bare = opened(Some(Style::default())); - let boxed = content(&bare); - assert_eq!( - support::box_at(&bare, boxed).stroke.width, - 1.0, - "the defaults' border" - ); - let preset = opened(None); - let boxed = content(&preset); - assert_eq!( - support::box_at(&preset, boxed).stroke.width, - 0.0, - "shadcn's content has no border: the defaults are cut" - ); -} - /// The fills of `d`'s open list drawn in `fill`. fn drawn_in(d: &Driver, fill: Color32) -> usize { let list = content(d); @@ -103,23 +84,6 @@ fn without_a_preset_the_highlighted_option_takes_the_accent_token() { assert_eq!(drawn_in(&d, accent), 1, "one highlighted option"); } -#[test] -fn without_a_preset_the_box_takes_the_menus_radius_from_the_sheet() { - let mut style = Style::default(); - style - .sheet - .as_app() - .rule(eggshell_ui::owned::MenuPart::Content, |t, _| { - t.rounded_px(11.0) - }); - let d = opened(Some(style)); - let boxed = content(&d); - assert_eq!( - support::box_at(&d, boxed).corner_radius, - egui::CornerRadius::same(11) - ); -} - #[test] fn the_highlighted_option_takes_shadcns_accent() { let d = opened(None); @@ -141,7 +105,7 @@ fn the_highlighted_option_takes_shadcns_accent() { #[test] fn an_app_rule_restyles_an_option() { - let mut style = eggshell_ui_shadcn::Shadcn::light().style(); + let mut style = eggshell_ui::theme::Shadcn::light().style(); style .sheet .as_app() diff --git a/tests/it/command_palette.rs b/tests/it/command_palette.rs index 1d808929..78e09459 100644 --- a/tests/it/command_palette.rs +++ b/tests/it/command_palette.rs @@ -566,7 +566,7 @@ fn the_palettes_current_command_is_muted() { .harness() .get_by_role_and_label(Role::ListBoxOption, &label) .rect(); - let tokens = eggshell_ui_shadcn::Tokens::for_theme(egui::Theme::Light); + let tokens = eggshell_ui::theme::Tokens::for_theme(egui::Theme::Light); assert_eq!(support::box_at(&d, row).fill, tokens.muted, "bg-muted"); } @@ -577,7 +577,7 @@ fn an_app_rule_restyles_the_palette() { style .sheet .as_app() - .rule(eggshell_ui_extras::command::CommandPart::Root, |t, _| { + .rule(eggshell_ui::owned::command::CommandPart::Root, |t, _| { t.bg(Color32::RED) }); }); diff --git a/tests/it/contract.rs b/tests/it/contract.rs index 855457e1..60d7e1ac 100644 --- a/tests/it/contract.rs +++ b/tests/it/contract.rs @@ -5,8 +5,8 @@ use std::sync::Arc; use eggshell_ui::contract::{Keyed, Size, Variant}; use eggshell_ui::testing::{Headless, assert_no_reports, assert_reported}; +use eggshell_ui::theme::Shadcn; use eggshell_ui::{Builder, LayoutState, Problem, Style, Weight}; -use eggshell_ui_shadcn::Shadcn; use egui::{Color32, Context, Theme, vec2}; #[test] diff --git a/tests/it/contract_gaps.rs b/tests/it/contract_gaps.rs index 184496ce..1b8766e7 100644 --- a/tests/it/contract_gaps.rs +++ b/tests/it/contract_gaps.rs @@ -8,8 +8,8 @@ use std::sync::Arc; use eggshell_ui::contract::{Disabled, Paint, Size, Themed, Variant}; use eggshell_ui::owned::{Cell, Choice, Enablement, Face, SegmentedRows, TabsPart}; use eggshell_ui::sheet::When; +use eggshell_ui::theme::{Shadcn, ShadcnStyle, Tokens, size}; use eggshell_ui::{Aria, Builder, Icon, Opacity, Style, TextSpec, TextStyle, Weight, tw}; -use eggshell_ui_shadcn::{Shadcn, ShadcnStyle, Tokens, size}; use egui::TextureId; use egui::epaint::Shape; use egui::{Color32, FontFamily, Rect, Role, Theme, vec2}; @@ -688,7 +688,7 @@ fn disabled_row(b: &mut Builder<'_, '_, App>, _: &App) { b.div(tw().flex().flex_col().items_start().gap(2.0), |b| { for enablement in [Enablement::Enabled, Enablement::Disabled] { b.button(("button", enablement), "Save") - .variant(eggshell_ui_shadcn::variant::PRIMARY) + .variant(eggshell_ui::theme::variant::PRIMARY) .enablement(enablement) .on_click(|app: &mut App| app.clicks += 1); b.checkbox(("check", enablement), "Agree", true) @@ -715,7 +715,7 @@ fn a_faded_disabled_control_is_node_opacity_over_its_rest_colours() { }, disabled_row, ); - let rest = support::button::look(theme, eggshell_ui_shadcn::variant::PRIMARY); + let rest = support::button::look(theme, eggshell_ui::theme::variant::PRIMARY); let enabled = d.rect(Target::suffix("/(\"button\", Enabled)")); let disabled = d.rect(Target::suffix("/(\"button\", Disabled)")); assert_eq!(box_at(&d, enabled).fill, rest.fill, "precondition"); @@ -758,7 +758,7 @@ fn a_faded_control_on_a_translucent_surface_lets_the_surface_through() { |style| { style.sheet.as_app().rule_when( eggshell_ui::owned::ButtonPart::Root, - eggshell_ui::sheet::When::always().variant(eggshell_ui_shadcn::variant::PRIMARY), + eggshell_ui::sheet::When::always().variant(eggshell_ui::theme::variant::PRIMARY), move |t, _| t.bg(translucent), ); style.sheet.as_app().rule_when( @@ -785,7 +785,7 @@ fn icon_buttons(b: &mut Builder<'_, '_, App>, app: &App) { b.div(tw().flex().gap(2.0).items_center(), |b| { b.button("icon", (app.icon(), "Search")) .size(size::ICON) - .variant(eggshell_ui_shadcn::variant::GHOST) + .variant(eggshell_ui::theme::variant::GHOST) .on_click(|app: &mut App| app.clicks += 1); b.button("labelled", "Add") .icon(app.icon()) @@ -811,7 +811,7 @@ fn an_icon_button_is_a_glyph_in_the_size_and_named_for_assistive_technology() { let (tint, glyph) = icon_in(&d, button); assert_eq!(glyph.size(), vec2(16.0, 16.0), "[&_svg]:size-4"); assert!(glyph.center().distance(button.center()) <= 0.75, "centred"); - let ghost = support::button::look(theme, eggshell_ui_shadcn::variant::GHOST); + let ghost = support::button::look(theme, eggshell_ui::theme::variant::GHOST); assert_eq!(tint, ghost.text); d.hover(Target::suffix("/\"icon\"")); diff --git a/crates/eggshell-ui-shadcn/tests/contrast.rs b/tests/it/contrast.rs similarity index 99% rename from crates/eggshell-ui-shadcn/tests/contrast.rs rename to tests/it/contrast.rs index 64f29850..e68d3958 100644 --- a/crates/eggshell-ui-shadcn/tests/contrast.rs +++ b/tests/it/contrast.rs @@ -6,7 +6,7 @@ use eggshell_ui::Problem; use eggshell_ui::testing::{assert_no_reports, assert_reported, reports}; -use eggshell_ui_shadcn::{ +use eggshell_ui::theme::{ BaseColor, ContrastPair, ContrastRatio, Palette, REGISTRY_MISSES, Shadcn, ThemeColor, Tokens, }; use egui::{Color32, Context, Theme}; diff --git a/tests/it/control_size.rs b/tests/it/control_size.rs index 427bc7d3..147f7754 100644 --- a/tests/it/control_size.rs +++ b/tests/it/control_size.rs @@ -231,7 +231,7 @@ fn stepper_and_field(b: &mut Builder<'_, '_, Size>, size: &Size) { } fn themed_at(size: Size, theme: egui::Theme) -> Driver { - let tokens = eggshell_ui_shadcn::Tokens::for_theme(theme); + let tokens = eggshell_ui::theme::Tokens::for_theme(theme); let mut d = support::driver( vec2(300.0, 300.0), TextStyle::new(tokens.text_role(), tokens.foreground), @@ -247,7 +247,7 @@ fn themed_at(size: Size, theme: egui::Theme) -> Driver { #[test] fn a_steppers_value_and_chevrons_keep_its_own_metrics_and_colour_at_every_size() { for theme in [egui::Theme::Light, egui::Theme::Dark] { - let style = eggshell_ui_shadcn::Shadcn::for_theme(theme).style(); + let style = eggshell_ui::theme::Shadcn::for_theme(theme).style(); let stepper = &style.stepper; for size in [Size::DEFAULT, SM, XS] { let d = themed_at(size, theme); diff --git a/tests/it/density.rs b/tests/it/density.rs index d8d93204..95144b84 100644 --- a/tests/it/density.rs +++ b/tests/it/density.rs @@ -5,8 +5,8 @@ use std::sync::Arc; use eggshell_ui::contract::{Radius, Spacing, TextSize, Themed}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::{Shadcn, ShadcnStyle, Tokens, size}; use eggshell_ui::{Builder, Icon, Match, TextStyle, icons, tw}; -use eggshell_ui_shadcn::{Shadcn, ShadcnStyle, Tokens, size}; use egui::epaint::Shape; use egui::{Rect, vec2}; diff --git a/tests/it/dialog_surface.rs b/tests/it/dialog_surface.rs index 02b7e478..ff74eb9f 100644 --- a/tests/it/dialog_surface.rs +++ b/tests/it/dialog_surface.rs @@ -3,9 +3,9 @@ //! and what assistive technology reads. use eggshell_ui::overlay::{Anchor, Modal, Shown, Side}; +use eggshell_ui::owned::dialog::{Dialog, DialogContent, DialogExt, PopoverExt}; use eggshell_ui::prim::text_field::Field; use eggshell_ui::{Builder, tw}; -use eggshell_ui_extras::dialog::{Dialog, DialogContent, DialogExt, PopoverExt}; use egui::{Key, Pos2, Role, vec2}; use egui_kittest::Harness; use egui_kittest::kittest::{NodeT as _, Queryable as _}; @@ -121,7 +121,7 @@ fn content<'c, 'f>(app: &'c App) -> impl FnOnce(&mut DialogContent<'c, 'f, App>) } fn prepare(ctx: &egui::Context, _: &App) { - eggshell_ui_shadcn::Shadcn::apply_both(ctx); + eggshell_ui::theme::Shadcn::apply_both(ctx); } fn harness(app: App) -> Harness<'static, Rig> { diff --git a/tests/it/disclosure.rs b/tests/it/disclosure.rs index ba21ee28..93ccf89e 100644 --- a/tests/it/disclosure.rs +++ b/tests/it/disclosure.rs @@ -3,8 +3,8 @@ use eggshell_ui::overlay::Shown; use eggshell_ui::owned::Enablement; +use eggshell_ui::owned::disclosure::{DisclosureExt, SectionExt}; use eggshell_ui::{Builder, Problem, tw}; -use eggshell_ui_extras::disclosure::{DisclosureExt, SectionExt}; use egui::accesskit::Role as AccessRole; use egui::{Key, vec2}; use egui_kittest::Harness; @@ -351,7 +351,7 @@ fn an_unnamed_disclosure_button_is_reported() { #[test] fn the_disclosure_button_is_a_square_with_an_accent_tint_under_the_pointer() { - use eggshell_ui_shadcn::Shadcn; + use eggshell_ui::theme::Shadcn; use egui::epaint::Shape; let mut harness = harness(); let rect = rect_of(&harness, r#"/"fold""#); @@ -406,7 +406,7 @@ fn a_sections_header_is_shadcns_accordion_trigger() { fn an_app_rule_restyles_a_sections_header() { let d = driver_with(|style| { style.sheet.as_app().rule( - eggshell_ui_extras::disclosure::AccordionPart::Trigger, + eggshell_ui::owned::disclosure::AccordionPart::Trigger, |t, _| t.bg(egui::Color32::RED), ); }); @@ -428,9 +428,9 @@ fn title_and_chevron(d: &eggshell_ui::testing::Driver) -> (egui::Rect, egui #[test] fn a_sections_header_keeps_its_gap_and_its_chevrons_nudge() { let d = driver_with(|_| {}); - let style = eggshell_ui_shadcn::Shadcn::for_theme(egui::Theme::Light) + let style = eggshell_ui::theme::Shadcn::for_theme(egui::Theme::Light) .style() - .extension::(); + .extension::(); let header = d.rect(Target::suffix(HEADER)); let (title, chevron) = title_and_chevron(&d); assert_eq!(chevron.left() - title.right(), style.header.gap, "the gap"); diff --git a/tests/it/dnd_gallery.rs b/tests/it/dnd_gallery.rs index 2b4ef064..7f40da7e 100644 --- a/tests/it/dnd_gallery.rs +++ b/tests/it/dnd_gallery.rs @@ -893,8 +893,8 @@ fn the_drag_chip_wears_the_tooltip_look_in_both_themes() { fills[0] ); let (primary_in_light, primary_in_dark) = ( - eggshell_ui_shadcn::Shadcn::light().tokens.primary, - eggshell_ui_shadcn::Shadcn::dark().tokens.primary, + eggshell_ui::theme::Shadcn::light().tokens.primary, + eggshell_ui::theme::Shadcn::dark().tokens.primary, ); assert_ne!( primary_in_light, primary_in_dark, diff --git a/tests/it/edits.rs b/tests/it/edits.rs index 66cc9988..37f50fc9 100644 --- a/tests/it/edits.rs +++ b/tests/it/edits.rs @@ -3,8 +3,8 @@ use eggshell_ui::owned::Edit; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Event, Key, Theme, pos2, vec2}; use egui_kittest::kittest::Queryable as _; diff --git a/tests/it/egui_look.rs b/tests/it/egui_look.rs index 3903cbab..91e8a488 100644 --- a/tests/it/egui_look.rs +++ b/tests/it/egui_look.rs @@ -3,8 +3,8 @@ //! preset's `apply` does, so raw egui widgets look as they always have. use eggshell_ui::contract::Themed; +use eggshell_ui::theme::{Palette, Shadcn, ShadcnStyle}; use eggshell_ui::{Builder, LayoutState, tw}; -use eggshell_ui_shadcn::{Palette, Shadcn, ShadcnStyle}; use egui::{Context, Theme, vec2}; use egui_kittest::Harness; diff --git a/tests/it/expanded.rs b/tests/it/expanded.rs index d0420f4f..b9990dfe 100644 --- a/tests/it/expanded.rs +++ b/tests/it/expanded.rs @@ -2,10 +2,10 @@ //! shadcn's open look, and a container's `has-aria-expanded` rule sees it. use eggshell_ui::contract::Variant; +use eggshell_ui::owned::command::CommandExt as _; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Aria, Builder, Match, TextStyle, tw}; -use eggshell_ui_extras::command::CommandExt as _; -use eggshell_ui_shadcn::Tokens; use egui::{Color32, Theme, vec2}; use crate::support::{self, box_at}; diff --git a/tests/it/field_box.rs b/tests/it/field_box.rs index abebb3ab..b0558b8f 100644 --- a/tests/it/field_box.rs +++ b/tests/it/field_box.rs @@ -2,8 +2,8 @@ use eggshell_ui::contract::Size; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::{Shadcn, size}; use eggshell_ui::{Builder, Icon, TextSpec, TextStyle, Weight, icons, tw}; -use eggshell_ui_shadcn::{Shadcn, size}; use egui::{Color32, FontFamily, Theme, vec2}; use crate::support::{self, box_at, ring_at}; @@ -53,7 +53,7 @@ fn view(b: &mut Builder<'_, '_, App>, app: &App) { .bare() .on_change(|_: &mut App, _| {}); s.button("addon", "Go") - .variant(eggshell_ui_shadcn::variant::GHOST) + .variant(eggshell_ui::theme::variant::GHOST) .size(size::SM) .on_click(|_: &mut App| {}); }); diff --git a/tests/it/focus_on_appear.rs b/tests/it/focus_on_appear.rs index 67892f1b..5eabdf2f 100644 --- a/tests/it/focus_on_appear.rs +++ b/tests/it/focus_on_appear.rs @@ -2,8 +2,8 @@ //! once, and not again while it stays. use eggshell_ui::testing::Driver; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Theme, vec2}; use egui_kittest::kittest::Queryable as _; diff --git a/tests/it/focus_options.rs b/tests/it/focus_options.rs index 3fa1b55c..16f744be 100644 --- a/tests/it/focus_options.rs +++ b/tests/it/focus_options.rs @@ -7,8 +7,8 @@ use eggshell_ui::overlay::Anchor; use eggshell_ui::owned::{PaneSize, ToggleGroup}; use eggshell_ui::prim::text_field::Select; use eggshell_ui::testing::{assert_no_reports, assert_reported}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Event, Theme, vec2}; use egui_kittest::Harness; use egui_kittest::kittest::Queryable as _; diff --git a/tests/it/font_weights.rs b/tests/it/font_weights.rs index 3eb8ef57..61f8d3c7 100644 --- a/tests/it/font_weights.rs +++ b/tests/it/font_weights.rs @@ -5,8 +5,8 @@ use std::sync::Arc; use eggshell_ui::contract::Themed; use eggshell_ui::testing::Driver; +use eggshell_ui::theme::{FontSet, Shadcn}; use eggshell_ui::{Builder, Problem, TextSpec, Weight, tw}; -use eggshell_ui_shadcn::{FontSet, Shadcn}; use egui::epaint::Shape; use egui::{FontFamily, Theme, Vec2}; diff --git a/tests/it/form.rs b/tests/it/form.rs index 28d9afec..083f56b6 100644 --- a/tests/it/form.rs +++ b/tests/it/form.rs @@ -4,12 +4,12 @@ //! on the page. use eggshell_ui::contract::Size; +use eggshell_ui::owned::form::{FormExt, FormStyle}; use eggshell_ui::owned::{Enablement, Mark, ProgressPart, SliderPart, SwitchPart}; -use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_extras::form::{FormExt, FormStyle}; -use eggshell_ui_shadcn::{ +use eggshell_ui::theme::{ BaseColor, ContrastRatio, Palette, Shadcn, ShadcnStyle, ThemeColor, Tokens, }; +use eggshell_ui::{Builder, TextStyle, tw}; use egui::{Color32, Role, Theme, vec2}; use egui_kittest::Harness; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/tests/it/fuzz/overlays.rs b/tests/it/fuzz/overlays.rs index d57a3c43..a0b37ea2 100644 --- a/tests/it/fuzz/overlays.rs +++ b/tests/it/fuzz/overlays.rs @@ -13,11 +13,11 @@ use eggshell_ui::overlay::{ Anchor, Anchored, Band, Distance, Focus, Modal, Outside, Placement, Shown, }; +use eggshell_ui::owned::dialog::{Dialog, DialogExt, PopoverExt}; use eggshell_ui::owned::{Enablement, Mark}; use eggshell_ui::scroll::Axis; use eggshell_ui::testing::{Points, leaves_bounds}; use eggshell_ui::{Builder, LayoutState, Placed, Scope, TextStyle, tw}; -use eggshell_ui_extras::dialog::{Dialog, DialogExt, PopoverExt}; use egui::{Color32, Event, Id, Key, LayerId, Modifiers, PointerButton, Pos2, Rect, Role, vec2}; use egui_kittest::Harness; use proptest::prelude::*; @@ -348,7 +348,7 @@ struct Rig { } fn rig_harness() -> Harness<'static, Rig> { - let tokens = eggshell_ui_shadcn::Tokens::for_theme(egui::Theme::Light); + let tokens = eggshell_ui::theme::Tokens::for_theme(egui::Theme::Light); let base = TextStyle::new(tokens.text_role(), tokens.foreground); let rig = Rig { app: App::default(), @@ -371,10 +371,10 @@ fn rig_harness() -> Harness<'static, Rig> { seen, focus_after_bar, } = rig; - if eggshell_ui_shadcn::tokens(ui.ctx()).is_none() { - eggshell_ui_shadcn::Shadcn::apply_both(ui.ctx()); + if eggshell_ui::theme::tokens(ui.ctx()).is_none() { + eggshell_ui::theme::Shadcn::apply_both(ui.ctx()); } - let background = eggshell_ui_shadcn::Shadcn::of(ui.ctx()).tokens.background; + let background = eggshell_ui::theme::Shadcn::of(ui.ctx()).tokens.background; ui.painter() .rect_filled(ui.ctx().content_rect(), 0.0, background); bar.show(ui); diff --git a/tests/it/gallery.rs b/tests/it/gallery.rs index e6ebc6e7..fda4bd8e 100644 --- a/tests/it/gallery.rs +++ b/tests/it/gallery.rs @@ -250,7 +250,7 @@ fn name_cells(d: &Driver) -> Vec { fn every_row_name_fits_on_one_line() { use controls_gallery::Section; let line = controls_gallery::base_text().spec.line_height; - for style in eggshell_ui_shadcn::ShadcnStyle::ALL { + for style in eggshell_ui::theme::ShadcnStyle::ALL { for section in [Section::Buttons, Section::Choices, Section::Values] { let mut d = driver(State { section, diff --git a/tests/it/handlers.rs b/tests/it/handlers.rs index bfcfce21..ec210365 100644 --- a/tests/it/handlers.rs +++ b/tests/it/handlers.rs @@ -2,8 +2,8 @@ //! what generated enums and row ids need of the owned controls. That this //! file compiles is half of each test. +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Role, Theme, vec2}; use egui_kittest::kittest::Queryable as _; diff --git a/tests/it/headless.rs b/tests/it/headless.rs index 3b431822..efd230f7 100644 --- a/tests/it/headless.rs +++ b/tests/it/headless.rs @@ -4,8 +4,8 @@ use std::sync::Arc; use eggshell_ui::contract::Themed; use eggshell_ui::testing::{Headless, PixelsPerPoint}; +use eggshell_ui::theme::Shadcn; use eggshell_ui::{Builder, Placed, Style, TextSpec, TextStyle, Weight, tw}; -use eggshell_ui_shadcn::Shadcn; use egui::{Color32, FontFamily, TextStyle as EguiTextStyle, Theme, vec2}; use crate::support::{self, rect_of}; @@ -309,7 +309,7 @@ fn themed_width(theme: Theme) -> f32 { Theme::Dark => 60.0, }; assert!( - eggshell_ui_shadcn::tokens(b.ctx()).is_some(), + eggshell_ui::theme::tokens(b.ctx()).is_some(), "prepare ran before the build" ); b.div_id("t", tw().w_px(width), |_| {}); @@ -446,7 +446,7 @@ const CARD_BODY: &str = "Every sample the probes recorded since the last sweep, written as one file per channel with the calibration it was taken under."; fn shadcn_body() -> TextStyle { - let tokens = eggshell_ui_shadcn::Tokens::for_theme(Theme::Light); + let tokens = eggshell_ui::theme::Tokens::for_theme(Theme::Light); TextStyle::new(tokens.text_role(), tokens.foreground) } diff --git a/tests/it/hover_anchored.rs b/tests/it/hover_anchored.rs index 96bfa69c..a7a77fe6 100644 --- a/tests/it/hover_anchored.rs +++ b/tests/it/hover_anchored.rs @@ -6,8 +6,8 @@ use core::time::Duration; use eggshell_ui::overlay::{Distance, HoverIntent, Placement}; use eggshell_ui::testing::{Animation, Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Problem, Style, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Event, Key, Pos2, Rect, Theme, pos2, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/tests/it/hover_card.rs b/tests/it/hover_card.rs index 1c8f037a..7a84ff7b 100644 --- a/tests/it/hover_card.rs +++ b/tests/it/hover_card.rs @@ -3,10 +3,10 @@ use core::time::Duration; +use eggshell_ui::owned::hover_card::{HoverCardExt as _, HoverCardStyle}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::{Shadcn, Tokens}; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_extras::hover_card::{HoverCardExt as _, HoverCardStyle}; -use eggshell_ui_shadcn::{Shadcn, Tokens}; use egui::{Theme, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; @@ -157,7 +157,7 @@ fn hovering_a_trigger_with_nothing_focusable_in_it_opens_the_card() { /// bordered; an App rule on its part restyles it. #[test] fn the_cards_box_is_shadcns_from_the_sheet_and_an_app_rule_restyles_it() { - use eggshell_ui_extras::hover_card::HoverCardPart; + use eggshell_ui::owned::hover_card::HoverCardPart; let open = |d: &mut Driver| { d.hover(Target::suffix(HANDLE)) .advance(Duration::from_millis(800)); diff --git a/tests/it/inert_look.rs b/tests/it/inert_look.rs index e8fa998f..b091670c 100644 --- a/tests/it/inert_look.rs +++ b/tests/it/inert_look.rs @@ -3,8 +3,8 @@ use eggshell_ui::owned::Enablement; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Theme, vec2}; use crate::support::{self, shapes}; diff --git a/tests/it/invalid.rs b/tests/it/invalid.rs index 5778697c..d42ce6e9 100644 --- a/tests/it/invalid.rs +++ b/tests/it/invalid.rs @@ -4,10 +4,10 @@ //! invalid either way. use eggshell_ui::owned::Enablement; +use eggshell_ui::owned::command::CommandExt; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Icon, TextStyle, icons, tw}; -use eggshell_ui_extras::command::CommandExt; -use eggshell_ui_shadcn::Tokens; use egui::accesskit::Invalid; use egui::{Theme, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/tests/it/layout.rs b/tests/it/layout.rs index e18fc637..f90cbd4a 100644 --- a/tests/it/layout.rs +++ b/tests/it/layout.rs @@ -159,7 +159,7 @@ fn kaolin_hello_world() { let div_node = placed.nodes().find(|n| n.kind() == NodeKind::Div).unwrap(); assert_eq!( div_node.paint().background, - Some(eggshell_ui_shadcn::Shadcn::of(ctx()).tokens.background) + Some(eggshell_ui::theme::Shadcn::of(ctx()).tokens.background) ); } diff --git a/tests/it/long_list_example.rs b/tests/it/long_list_example.rs index aea6ea1b..d59d32ff 100644 --- a/tests/it/long_list_example.rs +++ b/tests/it/long_list_example.rs @@ -3,7 +3,7 @@ use eggshell_ui::TextStyle; use eggshell_ui::testing::{Driver, Target}; -use eggshell_ui_shadcn::Tokens; +use eggshell_ui::theme::Tokens; use egui::{Theme, vec2}; use crate::support; diff --git a/tests/it/main.rs b/tests/it/main.rs index f0d37c36..1928c6b7 100644 --- a/tests/it/main.rs +++ b/tests/it/main.rs @@ -37,6 +37,7 @@ mod compile_fail; mod continuity; mod contract; mod contract_gaps; +mod contrast; mod control_size; mod controls; mod debug; @@ -117,12 +118,14 @@ mod pop_out; mod popup_style; mod ports; mod presence; +mod preset_styles; mod press_bubble; mod prims; mod progress; mod reduced_motion; mod refused; mod regions; +mod registry; mod release; mod reserve; mod responsive_example; @@ -165,6 +168,7 @@ mod theme_toggle; mod todo_demo; mod toggle_group; mod tone; +mod tones; mod tooltips; mod touch_scroll; mod typed_range; diff --git a/tests/it/markdown.rs b/tests/it/markdown.rs index 769528f9..4397791b 100644 --- a/tests/it/markdown.rs +++ b/tests/it/markdown.rs @@ -1,9 +1,9 @@ //! The Markdown widget (#254) through the real path: its test page, built, //! laid out and drawn by the rig, clicked as a user would. +use eggshell_ui::owned::markdown::{Level, MarkdownExt, MarkdownStyle, heading_id, headings}; use eggshell_ui::testing::Headless; use eggshell_ui::testing::{Driver, Target}; -use eggshell_ui_extras::markdown::{Level, MarkdownExt, MarkdownStyle, heading_id, headings}; use egui::epaint::Shape; use egui::{Rect, Theme, vec2}; @@ -271,7 +271,7 @@ fn a_registered_directive_mounts_a_live_example() { fn the_shadcn_preset_fills_the_markdown_style() { let d = driver(); let tokens = common::tokens(d.ctx()); - let preset = eggshell_ui_shadcn::Shadcn::of(d.ctx()); + let preset = eggshell_ui::theme::Shadcn::of(d.ctx()); let installed = style(&d); assert_eq!(*installed, preset.markdown()); assert_eq!(installed.rule, tokens.border); diff --git a/tests/it/menu.rs b/tests/it/menu.rs index cc120057..c1743fa0 100644 --- a/tests/it/menu.rs +++ b/tests/it/menu.rs @@ -865,8 +865,8 @@ mod open_query { let mut bar = support::Bar::new(base_text()); let mut d = Driver::whole_frame(app, move |ui, app, layout| { let area = ui.max_rect(); - if eggshell_ui_shadcn::tokens(ui.ctx()).is_none() { - eggshell_ui_shadcn::Shadcn::apply_both(ui.ctx()); + if eggshell_ui::theme::tokens(ui.ctx()).is_none() { + eggshell_ui::theme::Shadcn::apply_both(ui.ctx()); } bar.show(ui); let placed = layout.build(ui.ctx(), |b| view(b, &*app)).layout(area); @@ -973,7 +973,7 @@ mod open_query { mod look { //! shadcn's dropdown-menu, as the preset draws it (`style-vega.css`). use super::*; - use eggshell_ui_shadcn::Tokens; + use eggshell_ui::theme::Tokens; fn tokens(d: &Driver) -> Tokens { Tokens::for_theme(d.ctx().theme()) diff --git a/tests/it/modal.rs b/tests/it/modal.rs index a46b3690..95ceb680 100644 --- a/tests/it/modal.rs +++ b/tests/it/modal.rs @@ -549,7 +549,7 @@ mod example { fn a_modal_reports_how_it_presents() { use eggshell_ui::testing::Headless; let placed = Headless::new(SCREEN) - .prepare(eggshell_ui_shadcn::Shadcn::apply_both) + .prepare(eggshell_ui::theme::Shadcn::apply_both) .style(crate::support::shadcn()) .layout(&State::default(), |b, _| { let open = State { diff --git a/tests/it/notify.rs b/tests/it/notify.rs index 8c459a5e..036048aa 100644 --- a/tests/it/notify.rs +++ b/tests/it/notify.rs @@ -4,10 +4,10 @@ use core::time::Duration; use eggshell_ui::overlay::Modal; +use eggshell_ui::owned::notify::{Dismissed, Lifetime, Notice, NoticeId, NotifyExt, ScreenAnchor}; use eggshell_ui::testing::{Driver, Target, WindowFocus}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Distance, TextStyle, tw}; -use eggshell_ui_extras::notify::{Dismissed, Lifetime, Notice, NoticeId, NotifyExt, ScreenAnchor}; -use eggshell_ui_shadcn::Tokens; use egui::accesskit::{Live, Role}; use egui::{Color32, Key, Theme, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; @@ -368,7 +368,7 @@ fn a_notice_floats_above_an_open_dialog_and_takes_the_pointer() { #[test] fn the_preset_gives_sonners_notification_look() { use eggshell_ui::Weight; - use eggshell_ui_shadcn::{Shadcn, ShadcnStyle}; + use eggshell_ui::theme::{Shadcn, ShadcnStyle}; let vega = Shadcn::light(); let notify = vega.notify(&vega.style()); assert_eq!(notify.fill, vega.tokens.popover, "--normal-bg"); @@ -465,7 +465,7 @@ fn a_notice_card_draws_from_the_sheet() { style .sheet .as_app() - .rule(eggshell_ui_extras::notify::NotifyPart::Toast, |t, _| { + .rule(eggshell_ui::owned::notify::NotifyPart::Toast, |t, _| { t.bg(egui::Color32::RED) }); })) diff --git a/tests/it/numbers.rs b/tests/it/numbers.rs index 10cb1098..34ae74a6 100644 --- a/tests/it/numbers.rs +++ b/tests/it/numbers.rs @@ -5,9 +5,9 @@ use std::time::Duration; use eggshell_ui::testing::{Driver, Headless, Target, assert_reported}; +use eggshell_ui::theme::Tokens; use eggshell_ui::widget::Stock; use eggshell_ui::{Builder, Problem, TextStyle, Width, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Color32, Context, Key, Role, Theme, Vec2, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/tests/it/owned.rs b/tests/it/owned.rs index c01c1b58..a814dd12 100644 --- a/tests/it/owned.rs +++ b/tests/it/owned.rs @@ -10,8 +10,8 @@ use eggshell_ui::owned::ButtonPart; use eggshell_ui::owned::Enablement; use eggshell_ui::sheet::{Key as Keyed, When}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::{Shadcn, Tokens, variant}; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::{Shadcn, Tokens, variant}; use egui::epaint::Shape; use egui::{Color32, Key, Role, Theme, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/tests/it/owned_choice.rs b/tests/it/owned_choice.rs index e2a8404c..fc4ee235 100644 --- a/tests/it/owned_choice.rs +++ b/tests/it/owned_choice.rs @@ -7,8 +7,8 @@ use std::sync::Arc; use eggshell_ui::contract::{Size, Themed}; use eggshell_ui::owned::{Cell, Enablement, Mark, SegmentedRows, SwitchPart, TabsPart}; +use eggshell_ui::theme::{Shadcn, Tokens}; use eggshell_ui::{Builder, Style, TextStyle, tw}; -use eggshell_ui_shadcn::{Shadcn, Tokens}; use egui::epaint::{CircleShape, Shape}; use egui::{Key, KeyboardShortcut, Rect, Role, Theme, vec2}; diff --git a/tests/it/owned_number.rs b/tests/it/owned_number.rs index 3ad2c4d8..d76d5c92 100644 --- a/tests/it/owned_number.rs +++ b/tests/it/owned_number.rs @@ -4,8 +4,8 @@ use eggshell_ui::contract::Size; use eggshell_ui::owned::{Enablement, SliderPart, Step}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::{Shadcn, ShadcnStyle, Tokens}; use eggshell_ui::{Builder, Style, TextStyle, tw}; -use eggshell_ui_shadcn::{Shadcn, ShadcnStyle, Tokens}; use egui::epaint::Shape; use egui::{Key, KeyboardShortcut, Modifiers, Rect, Role, Theme, pos2, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/tests/it/pop_out.rs b/tests/it/pop_out.rs index 959029a0..b1f99fc6 100644 --- a/tests/it/pop_out.rs +++ b/tests/it/pop_out.rs @@ -883,7 +883,7 @@ mod example_cards { #[test] fn a_cards_button_pops_it_out_and_back_in() { - let tokens = eggshell_ui_shadcn::Tokens::for_theme(egui::Theme::Light); + let tokens = eggshell_ui::theme::Tokens::for_theme(egui::Theme::Light); let mut h = support::driver( vec2(800.0, 700.0), TextStyle::new(tokens.text_role(), tokens.foreground), @@ -918,7 +918,7 @@ mod example_cards { #[test] fn a_card_with_a_scroll_body_opens_at_its_inline_size() { const CARD: &str = "/Grid/Card(0)"; - let tokens = eggshell_ui_shadcn::Tokens::for_theme(egui::Theme::Light); + let tokens = eggshell_ui::theme::Tokens::for_theme(egui::Theme::Light); let mut h = support::driver( vec2(800.0, 700.0), TextStyle::new(tokens.text_role(), tokens.foreground), diff --git a/tests/it/popup_style.rs b/tests/it/popup_style.rs index 06f5db3e..60d418d9 100644 --- a/tests/it/popup_style.rs +++ b/tests/it/popup_style.rs @@ -3,8 +3,8 @@ //! context's global style. The owned select therefore paints its list from //! `style.select` alone, which the second test pins. +use eggshell_ui::theme::{Palette, Shadcn, ShadcnStyle}; use eggshell_ui::{LayoutState, NodeUi as _, TextSpec, TextStyle, Weight, tw}; -use eggshell_ui_shadcn::{Palette, Shadcn, ShadcnStyle}; use egui::{Color32, FontFamily, Popup, SetOpenCommand, Vec2, vec2}; use egui_kittest::Harness; use egui_kittest::kittest::Queryable as _; diff --git a/crates/eggshell-ui-shadcn/tests/styles.rs b/tests/it/preset_styles.rs similarity index 98% rename from crates/eggshell-ui-shadcn/tests/styles.rs rename to tests/it/preset_styles.rs index 98495abf..dee06470 100644 --- a/crates/eggshell-ui-shadcn/tests/styles.rs +++ b/tests/it/preset_styles.rs @@ -5,7 +5,7 @@ use eggshell_ui::Tw; use eggshell_ui::contract::{Fonts, Size, Style, TextScale, TextSize, TextStep, Variant}; use eggshell_ui::owned::{ButtonPart, Enablement, InputPart, SegmentedRows, SliderPart, TabsPart}; use eggshell_ui::sheet::Key; -use eggshell_ui_shadcn::{Palette, Shadcn, ShadcnStyle, ThemeColor, Tokens, variant}; +use eggshell_ui::theme::{Palette, Shadcn, ShadcnStyle, ThemeColor, Tokens, variant}; use egui::{Theme, vec2}; fn style_of(theme: Theme, style: ShadcnStyle) -> Style { @@ -128,7 +128,7 @@ fn every_style_names_the_same_variants_and_sizes() { assert_eq!(keys(&vega), keys(&lyra)); assert!(keys(&vega).contains(&Key::Variant(variant::LINK)), "link"); assert!( - keys(&vega).contains(&Key::Size(eggshell_ui_shadcn::size::ICON_LG)), + keys(&vega).contains(&Key::Size(eggshell_ui::theme::size::ICON_LG)), "icon-lg" ); } diff --git a/tests/it/prims.rs b/tests/it/prims.rs index 5528ed93..977737b9 100644 --- a/tests/it/prims.rs +++ b/tests/it/prims.rs @@ -8,9 +8,9 @@ use eggshell_ui::owned::Cell; use eggshell_ui::prim::text_field::Field; use eggshell_ui::testing::Headless; use eggshell_ui::testing::{Driver, PixelsPerPoint, Target}; +use eggshell_ui::theme::{Shadcn, Tokens}; use eggshell_ui::widget::{Stock, TextEdit}; use eggshell_ui::{Builder, TextSpec, TextStyle, Weight, Width, tw}; -use eggshell_ui_shadcn::{Shadcn, Tokens}; use egui::epaint::Shape; use egui::{Color32, FontFamily, Id, Key, Theme, vec2}; use egui_kittest::kittest::Queryable as _; diff --git a/tests/it/progress.rs b/tests/it/progress.rs index ad19b5c3..655f7f26 100644 --- a/tests/it/progress.rs +++ b/tests/it/progress.rs @@ -2,8 +2,8 @@ //! progress indicator. use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::{Shadcn, Tokens}; use eggshell_ui::{Builder, Progress, Style, TextStyle, tw}; -use eggshell_ui_shadcn::{Shadcn, Tokens}; use egui::epaint::Shape; use egui::{Rect, Role, Theme, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; @@ -46,7 +46,7 @@ fn the_bar_is_the_styles_track_and_range_filled_to_the_fraction() { let d = harness(Progress::new(0.4)); let progress = style().progress; let bar = d.rect(Target::suffix("/\"upload\"")); - let tokens = eggshell_ui_shadcn::Tokens::for_theme(Theme::Light); + let tokens = eggshell_ui::theme::Tokens::for_theme(Theme::Light); assert_eq!(progress.range.fill, tokens.primary, "bg-primary"); assert_eq!(bar.width(), 200.0); assert_eq!(bar.height(), 6.0, "vega h-1.5"); diff --git a/tests/it/refused.rs b/tests/it/refused.rs index b338b79b..01dee4d5 100644 --- a/tests/it/refused.rs +++ b/tests/it/refused.rs @@ -6,8 +6,8 @@ use core::time::Duration; use eggshell_ui::owned::{Choice, Enablement}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Command, Commands, Style, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Role, Shape, Theme, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/crates/eggshell-ui-shadcn/tests/registry.rs b/tests/it/registry.rs similarity index 99% rename from crates/eggshell-ui-shadcn/tests/registry.rs rename to tests/it/registry.rs index a5b59dbe..531547ea 100644 --- a/crates/eggshell-ui-shadcn/tests/registry.rs +++ b/tests/it/registry.rs @@ -2,7 +2,7 @@ //! (`registry/themes.ts`, a copy of the registry's file), converted from //! oklch to sRGB, under the preset's documented departures. -use eggshell_ui_shadcn::{BaseColor, Palette, ThemeColor, Tokens}; +use eggshell_ui::theme::{BaseColor, Palette, ThemeColor, Tokens}; use egui::{Color32, Theme}; use std::collections::BTreeMap; diff --git a/crates/eggshell-ui-shadcn/tests/registry/themes.ts b/tests/it/registry/themes.ts similarity index 100% rename from crates/eggshell-ui-shadcn/tests/registry/themes.ts rename to tests/it/registry/themes.ts diff --git a/tests/it/responsive_example.rs b/tests/it/responsive_example.rs index 10de6f0a..f09a53d3 100644 --- a/tests/it/responsive_example.rs +++ b/tests/it/responsive_example.rs @@ -4,8 +4,8 @@ use std::collections::BTreeSet; use eggshell_ui::testing::Headless; +use eggshell_ui::theme::Shadcn; use eggshell_ui::{NodeKind, Placed, TextSpec, TextStyle, Weight}; -use eggshell_ui_shadcn::Shadcn; use egui::{Color32, FontFamily, vec2}; #[allow(dead_code, reason = "the example's main is not run here")] diff --git a/tests/it/roving.rs b/tests/it/roving.rs index ffa7990f..5fdddea1 100644 --- a/tests/it/roving.rs +++ b/tests/it/roving.rs @@ -6,8 +6,8 @@ use eggshell_ui::overlay::{Nav, Wrap}; use eggshell_ui::owned::Mark; use eggshell_ui::testing::Driver; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Problem, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Key, KeyboardShortcut, Modifiers, Role, Theme, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/tests/it/scroll.rs b/tests/it/scroll.rs index 3a167055..716b0bd0 100644 --- a/tests/it/scroll.rs +++ b/tests/it/scroll.rs @@ -1154,7 +1154,7 @@ mod bars { } fn thumb(d: &H) -> Color32 { - eggshell_ui_shadcn::Shadcn::of(d.ctx()).tokens.border + eggshell_ui::theme::Shadcn::of(d.ctx()).tokens.border } #[test] @@ -1347,8 +1347,8 @@ mod bars { for theme in [egui::Theme::Light, egui::Theme::Dark] { let d = harness(10); d.ctx().set_theme(theme); - let style = eggshell_ui_shadcn::Shadcn::of(d.ctx()).style().scroll; - let tokens = eggshell_ui_shadcn::Tokens::for_theme(theme); + let style = eggshell_ui::theme::Shadcn::of(d.ctx()).style().scroll; + let tokens = eggshell_ui::theme::Tokens::for_theme(theme); assert_eq!(style.thumb, tokens.border, "{theme:?}"); assert_eq!(style.width, 10.0); assert_eq!(style.track, Color32::TRANSPARENT); diff --git a/tests/it/scroll_keys.rs b/tests/it/scroll_keys.rs index 70a5aa2a..01dfdd31 100644 --- a/tests/it/scroll_keys.rs +++ b/tests/it/scroll_keys.rs @@ -858,7 +858,7 @@ fn a_default_container_paints_no_fade_and_an_opted_in_one_does() { fn neither_the_default_style_nor_the_shadcn_preset_fades() { assert_eq!(eggshell_ui::Style::default().scroll.fade, EdgeFade::OFF); for theme in [egui::Theme::Light, egui::Theme::Dark] { - let style = eggshell_ui_shadcn::Shadcn::for_theme(theme).style(); + let style = eggshell_ui::theme::Shadcn::for_theme(theme).style(); assert_eq!(style.scroll.fade, EdgeFade::OFF, "{theme:?}"); } } diff --git a/tests/it/segmented_classes.rs b/tests/it/segmented_classes.rs index 5a553565..71295229 100644 --- a/tests/it/segmented_classes.rs +++ b/tests/it/segmented_classes.rs @@ -5,8 +5,8 @@ use eggshell_ui::contract::{Disabled, Size, Style}; use eggshell_ui::owned::{Cell, SegmentedRows, TabsPart}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Icon, Opacity, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Theme, vec2}; use egui_kittest::Harness; diff --git a/tests/it/select.rs b/tests/it/select.rs index 8bf5130e..892baa3c 100644 --- a/tests/it/select.rs +++ b/tests/it/select.rs @@ -485,8 +485,8 @@ mod beside_another_frame { .with_base_text(base_text()) .with_style(support::shadcn()); let mut d = Driver::whole_frame(App::default(), move |ui, app, page| { - if eggshell_ui_shadcn::tokens(ui.ctx()).is_none() { - eggshell_ui_shadcn::Shadcn::apply_both(ui.ctx()); + if eggshell_ui::theme::tokens(ui.ctx()).is_none() { + eggshell_ui::theme::Shadcn::apply_both(ui.ctx()); } let area = ui.max_rect(); bar.build(ui.ctx(), |b| b.div(tw().h_px(10.0), |_| {})) diff --git a/tests/it/selection.rs b/tests/it/selection.rs index 9b068c6e..a831714e 100644 --- a/tests/it/selection.rs +++ b/tests/it/selection.rs @@ -50,7 +50,7 @@ fn view(b: &mut Builder<'_, '_, App>, app: &App) { } fn base() -> TextStyle { - let tokens = eggshell_ui_shadcn::Tokens::light(); + let tokens = eggshell_ui::theme::Tokens::light(); TextStyle::new(tokens.text_role(), tokens.foreground) } diff --git a/tests/it/sheet.rs b/tests/it/sheet.rs index 43d2a6f5..642a81a5 100644 --- a/tests/it/sheet.rs +++ b/tests/it/sheet.rs @@ -250,7 +250,7 @@ fn a_negated_key_applies_while_the_node_lacks_the_state() { #[test] fn a_preset_hands_out_the_sheet_of_each_theme_at_the_base_layer() { - use eggshell_ui_shadcn::{Palette, Shadcn, ShadcnStyle}; + use eggshell_ui::theme::{Palette, Shadcn, ShadcnStyle}; let themed = Shadcn::themed(ShadcnStyle::Vega, Palette::new()); assert_eq!(themed.light.sheet.layer(), eggshell_ui::sheet::Layer::Base); assert_eq!(themed.dark.sheet.layer(), eggshell_ui::sheet::Layer::Base); @@ -298,7 +298,7 @@ fn a_rule_body_is_given_the_tokens_of_the_style_it_is_resolved_in() { #[test] fn the_preset_fills_the_shadow_scale() { - use eggshell_ui_shadcn::{Palette, Shadcn, ShadcnStyle}; + use eggshell_ui::theme::{Palette, Shadcn, ShadcnStyle}; let themed = Shadcn::themed(ShadcnStyle::Vega, Palette::new()); let tokens = &themed.light.tokens; assert_ne!(tokens.shadow_xs, egui::Shadow::NONE); diff --git a/tests/it/sizing.rs b/tests/it/sizing.rs index 2bfa1bbb..924d2be4 100644 --- a/tests/it/sizing.rs +++ b/tests/it/sizing.rs @@ -3,9 +3,9 @@ //! widget. Each case varies the text, the font size and the style, and a //! width that makes text wrap. +use eggshell_ui::theme::{Shadcn, ShadcnStyle}; use eggshell_ui::widget::{Lines, Stock, TextEdit}; use eggshell_ui::{TextSpec, TextStyle, Weight, Width}; -use eggshell_ui_shadcn::{Shadcn, ShadcnStyle}; use egui::{ Color32, Context, FontFamily, Rect, Response, Style, Theme, Ui, UiBuilder, Vec2, pos2, vec2, }; diff --git a/tests/it/skeleton.rs b/tests/it/skeleton.rs index fdc0e1f9..3030a302 100644 --- a/tests/it/skeleton.rs +++ b/tests/it/skeleton.rs @@ -3,10 +3,10 @@ use std::time::Duration; +use eggshell_ui::owned::skeleton::{SkeletonExt as _, SkeletonStyle}; use eggshell_ui::testing::{Animation, Driver, Target}; +use eggshell_ui::theme::{Shadcn, ShadcnStyle, Tokens}; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_extras::skeleton::{SkeletonExt as _, SkeletonStyle}; -use eggshell_ui_shadcn::{Shadcn, ShadcnStyle, Tokens}; use egui::epaint::Shape; use egui::{Color32, Theme, vec2}; @@ -139,7 +139,7 @@ fn an_app_rule_restyles_a_skeleton() { style .sheet .as_app() - .rule(eggshell_ui_extras::skeleton::SkeletonPart::Root, |t, _| { + .rule(eggshell_ui::owned::skeleton::SkeletonPart::Root, |t, _| { t.bg(Color32::RED) }); })) diff --git a/tests/it/slider_header.rs b/tests/it/slider_header.rs index dd65197a..58c8f350 100644 --- a/tests/it/slider_header.rs +++ b/tests/it/slider_header.rs @@ -4,8 +4,8 @@ use eggshell_ui::contract::Size; use eggshell_ui::owned::Step; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::{Shadcn, Tokens, size}; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::{Shadcn, Tokens, size}; use egui::{Key, Theme, vec2}; use std::time::Duration; diff --git a/tests/it/snapshots.rs b/tests/it/snapshots.rs index edf082ba..db22c685 100644 --- a/tests/it/snapshots.rs +++ b/tests/it/snapshots.rs @@ -5,8 +5,8 @@ use std::sync::Once; +use eggshell_ui::theme::{ShadcnStyle, Tokens}; use eggshell_ui::{Builder, LayoutState, TextStyle, tw}; -use eggshell_ui_shadcn::{ShadcnStyle, Tokens}; use egui::{Color32, ImageSource, TextureHandle, TextureOptions, Vec2, load::SizedTexture}; use egui_kittest::Harness; @@ -2900,9 +2900,9 @@ fn palette_open_dark() { /// the rule drew. The inventory is in PHASE2-AUDIT.md. mod child_rules { use super::*; + use eggshell_ui::owned::badge::BadgeExt as _; + use eggshell_ui::owned::command::CommandExt as _; use eggshell_ui::{Icon, icons}; - use eggshell_ui_extras::badge::BadgeExt as _; - use eggshell_ui_extras::command::CommandExt as _; fn suffix(theme: egui::Theme) -> &'static str { match theme { diff --git a/tests/it/splitter.rs b/tests/it/splitter.rs index 8b5ddb86..5c83a59a 100644 --- a/tests/it/splitter.rs +++ b/tests/it/splitter.rs @@ -5,8 +5,8 @@ use std::time::Duration; use eggshell_ui::owned::PaneSize; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::{Shadcn, Tokens}; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::{Shadcn, Tokens}; use egui::epaint::Shape; use egui::{Color32, CursorIcon, Key, Modifiers, Pos2, Role, Theme, Vec2, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/tests/it/state_stable.rs b/tests/it/state_stable.rs index 579ffe8e..b8fd2875 100644 --- a/tests/it/state_stable.rs +++ b/tests/it/state_stable.rs @@ -3,8 +3,8 @@ //! themes. use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Rect, Theme, vec2}; use crate::support; diff --git a/tests/it/style.rs b/tests/it/style.rs index a1248cdf..bcb63859 100644 --- a/tests/it/style.rs +++ b/tests/it/style.rs @@ -1,9 +1,9 @@ //! The shadcn preset: what `apply` sets in egui, the text edit under it, and //! the library's primitives drawn with its proportions. +use eggshell_ui::theme::{BaseColor, Palette, Shadcn, ThemeColor, Tokens, tokens}; use eggshell_ui::widget::{Stock, TextEdit}; use eggshell_ui::{Builder, LayoutState, TextSpec, TextStyle, Weight, Width, tw}; -use eggshell_ui_shadcn::{BaseColor, Palette, Shadcn, ThemeColor, Tokens, tokens}; use egui::epaint::Shape; use egui::{Color32, Context, FontFamily, Rect, Theme, vec2}; diff --git a/tests/it/style_switch.rs b/tests/it/style_switch.rs index 45135298..cd2a4b4c 100644 --- a/tests/it/style_switch.rs +++ b/tests/it/style_switch.rs @@ -3,9 +3,9 @@ //! every example still fits under both. use eggshell_ui::contract::{Size, Style}; +use eggshell_ui::theme::{Palette, Shadcn, ShadcnStyle, ThemeColor, Tokens}; use eggshell_ui::widget::TextEdit; use eggshell_ui::{Builder, LayoutState, Placed, tw}; -use eggshell_ui_shadcn::{Palette, Shadcn, ShadcnStyle, ThemeColor, Tokens}; use egui::{Context, Rect, Theme, pos2}; #[path = "../../examples/common/mod.rs"] @@ -169,7 +169,7 @@ fn style_and_theme_colour_are_chosen_independently() { .style() }; let primary = |style: &Style| { - *crate::support::button::classes(style, eggshell_ui_shadcn::variant::PRIMARY, Size::DEFAULT) + *crate::support::button::classes(style, eggshell_ui::theme::variant::PRIMARY, Size::DEFAULT) .paint_classes() }; for style in ShadcnStyle::ALL { diff --git a/tests/it/styled.rs b/tests/it/styled.rs index ec791ae7..a6fd8f60 100644 --- a/tests/it/styled.rs +++ b/tests/it/styled.rs @@ -4,8 +4,8 @@ use eggshell_ui::owned::{Column, TablePart}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, NodeUi as _, Span, Spans, TextStyle, Track, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Color32, Theme, Vec2, vec2}; use crate::support::{self, rest_for_tooltip}; diff --git a/tests/it/support/button.rs b/tests/it/support/button.rs index cf73209e..51ed8802 100644 --- a/tests/it/support/button.rs +++ b/tests/it/support/button.rs @@ -4,7 +4,7 @@ //! apart from the generator so a mapping error cannot agree with itself. use eggshell_ui::contract::Variant; -use eggshell_ui_shadcn::{Tokens, variant}; +use eggshell_ui::theme::{Tokens, variant}; use egui::{Color32, Theme}; /// A variant's colours at rest and under the pointer. Text a variant does diff --git a/tests/it/support/mod.rs b/tests/it/support/mod.rs index d973f3cd..d6abf4be 100644 --- a/tests/it/support/mod.rs +++ b/tests/it/support/mod.rs @@ -229,9 +229,9 @@ const BAR_HEIGHT: f32 = 44.0; /// The style a rig's layout builds with unless it `prepare`s its own: shadcn's /// default, light and dark. pub fn shadcn() -> Themed> { - eggshell_ui_shadcn::Shadcn::themed( - eggshell_ui_shadcn::ShadcnStyle::default(), - eggshell_ui_shadcn::Palette::new(), + eggshell_ui::theme::Shadcn::themed( + eggshell_ui::theme::ShadcnStyle::default(), + eggshell_ui::theme::Palette::new(), ) } @@ -393,15 +393,15 @@ fn harness_timed( ids, } = rig; full_motion(ui.ctx()); - if eggshell_ui_shadcn::tokens(ui.ctx()).is_none() { - eggshell_ui_shadcn::Shadcn::apply_both(ui.ctx()); + if eggshell_ui::theme::tokens(ui.ctx()).is_none() { + eggshell_ui::theme::Shadcn::apply_both(ui.ctx()); } if let Some(prepare) = prepare { prepare(ui.ctx(), &*app); layout.set_style(common::style(ui.ctx())); } if *page == Page::Themed { - let background = eggshell_ui_shadcn::Shadcn::of(ui.ctx()).tokens.background; + let background = eggshell_ui::theme::Shadcn::of(ui.ctx()).tokens.background; ui.painter() .rect_filled(ui.ctx().content_rect(), 0.0, background); } @@ -767,10 +767,10 @@ pub fn frame_harness_scaled( .build_ui_state( move |ui, rig: &mut FrameRig| { full_motion(ui.ctx()); - if eggshell_ui_shadcn::tokens(ui.ctx()).is_none() { - eggshell_ui_shadcn::Shadcn::apply_both(ui.ctx()); + if eggshell_ui::theme::tokens(ui.ctx()).is_none() { + eggshell_ui::theme::Shadcn::apply_both(ui.ctx()); } - let background = eggshell_ui_shadcn::Shadcn::of(ui.ctx()).tokens.background; + let background = eggshell_ui::theme::Shadcn::of(ui.ctx()).tokens.background; ui.painter() .rect_filled(ui.ctx().content_rect(), 0.0, background); rig.bar.show(ui); @@ -911,15 +911,15 @@ fn rig_driver( Driver::whole_frame(app, move |ui, app, layout| { let area = ui.max_rect(); let Surround { page, companion } = surround(ui.ctx()); - if eggshell_ui_shadcn::tokens(ui.ctx()).is_none() { - eggshell_ui_shadcn::Shadcn::apply_both(ui.ctx()); + if eggshell_ui::theme::tokens(ui.ctx()).is_none() { + eggshell_ui::theme::Shadcn::apply_both(ui.ctx()); } if let Some(prepare) = prepare { prepare(ui.ctx(), &*app); layout.set_style(common::style(ui.ctx())); } if page == Page::Themed { - let background = eggshell_ui_shadcn::Shadcn::of(ui.ctx()).tokens.background; + let background = eggshell_ui::theme::Shadcn::of(ui.ctx()).tokens.background; ui.painter() .rect_filled(ui.ctx().content_rect(), 0.0, background); } @@ -950,10 +950,10 @@ pub fn frame_driver( let mut bar = Bar::new(base_text.clone()); let step = Duration::from_nanos(1_000_000_000 / 60); Driver::whole_frame(app, move |ui, app, layout| { - if eggshell_ui_shadcn::tokens(ui.ctx()).is_none() { - eggshell_ui_shadcn::Shadcn::apply_both(ui.ctx()); + if eggshell_ui::theme::tokens(ui.ctx()).is_none() { + eggshell_ui::theme::Shadcn::apply_both(ui.ctx()); } - let background = eggshell_ui_shadcn::Shadcn::of(ui.ctx()).tokens.background; + let background = eggshell_ui::theme::Shadcn::of(ui.ctx()).tokens.background; ui.painter() .rect_filled(ui.ctx().content_rect(), 0.0, background); bar.show(ui); diff --git a/tests/it/swatch_picker.rs b/tests/it/swatch_picker.rs index d5aa2c77..6625db3e 100644 --- a/tests/it/swatch_picker.rs +++ b/tests/it/swatch_picker.rs @@ -5,8 +5,8 @@ use eggshell_ui::Problem; use eggshell_ui::overlay::{Anchor, Nav}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Key, Role, Theme, vec2}; use egui_kittest::kittest::Queryable as _; diff --git a/tests/it/table.rs b/tests/it/table.rs index 71d49a5f..e1684b6c 100644 --- a/tests/it/table.rs +++ b/tests/it/table.rs @@ -4,8 +4,8 @@ use eggshell_ui::owned::{Align, Column, Stripes, TablePart}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::{Shadcn, Tokens}; use eggshell_ui::{Builder, Style, TextStyle, Track, tw}; -use eggshell_ui_shadcn::{Shadcn, Tokens}; use egui::accesskit::Action; use egui::epaint::Shape; use egui::{Color32, Key, Modifiers, Rect, Role, Theme, Vec2, vec2}; diff --git a/tests/it/table_columns.rs b/tests/it/table_columns.rs index 95d04b02..be205d93 100644 --- a/tests/it/table_columns.rs +++ b/tests/it/table_columns.rs @@ -5,8 +5,8 @@ use eggshell_ui::owned::Column; use eggshell_ui::testing::assert_reported; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Problem, TextStyle, Track, tw}; -use eggshell_ui_shadcn::Tokens; use egui::epaint::Shape; use egui::{Rect, Role, Theme, vec2}; use egui_kittest::Harness; diff --git a/tests/it/tabs.rs b/tests/it/tabs.rs index 31cbbd1a..3953ee8e 100644 --- a/tests/it/tabs.rs +++ b/tests/it/tabs.rs @@ -4,11 +4,11 @@ use std::cell::RefCell; +use eggshell_ui::owned::tabs::TabsExt; use eggshell_ui::owned::{Choice, Enablement, TabsPart}; use eggshell_ui::sheet::When; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Aria, Builder, TextStyle, tw}; -use eggshell_ui_extras::tabs::TabsExt; -use eggshell_ui_shadcn::Tokens; use egui::{Event, Key, Modifiers, MouseWheelUnit, Role, Theme, Vec2, vec2}; use egui_kittest::Harness; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/tests/it/tabular_nums.rs b/tests/it/tabular_nums.rs index fc1a9a6c..f6ad3183 100644 --- a/tests/it/tabular_nums.rs +++ b/tests/it/tabular_nums.rs @@ -219,7 +219,7 @@ fn view(b: &mut Builder<'_, '_, ()>, _: &()) { } fn selectable() -> Driver<()> { - let tokens = eggshell_ui_shadcn::Tokens::light(); + let tokens = eggshell_ui::theme::Tokens::light(); let mut d = support::driver( vec2(300.0, 100.0), eggshell_ui::TextStyle::new(tokens.text_role(), tokens.foreground), diff --git a/tests/it/text_field_ring.rs b/tests/it/text_field_ring.rs index b6d7982e..4cec6562 100644 --- a/tests/it/text_field_ring.rs +++ b/tests/it/text_field_ring.rs @@ -2,8 +2,8 @@ //! around the box, as the owned controls do. use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Shadcn; use eggshell_ui::{Builder, TextSpec, TextStyle, Weight, tw}; -use eggshell_ui_shadcn::Shadcn; use egui::epaint::Shape; use egui::{Color32, FontFamily, Theme, vec2}; diff --git a/tests/it/theme_toggle.rs b/tests/it/theme_toggle.rs index 6eee56ed..2b1897f7 100644 --- a/tests/it/theme_toggle.rs +++ b/tests/it/theme_toggle.rs @@ -90,6 +90,10 @@ fn every_example_shows_the_toggle_and_none_pins_a_theme() { examples.len() ); for (file, text) in examples { + // It prints the preset's facts for the importer and draws nothing. + if file.ends_with("preset_dump.rs") { + continue; + } let shared_runner = text.contains("common::run(") || text.contains("common::run_app(") || text.contains("common::run_app_styled(") diff --git a/tests/it/themed_examples.rs b/tests/it/themed_examples.rs index a7e7f29a..8fbcabd0 100644 --- a/tests/it/themed_examples.rs +++ b/tests/it/themed_examples.rs @@ -2,7 +2,7 @@ //! their main surfaces carry that theme's tokens. Shapes only, no GPU. use eggshell_ui::{Builder, LayoutState, NodeKind, Placed, PlacedNode}; -use eggshell_ui_shadcn::{Palette, Shadcn, ThemeColor, Tokens}; +use eggshell_ui::theme::{Palette, Shadcn, ThemeColor, Tokens}; use egui::{Color32, Context, ImageSource, Rect, Theme, pos2}; #[path = "../../examples/common/mod.rs"] @@ -233,13 +233,13 @@ fn controls_gallery_applies_the_chosen_base_and_theme_colour() { for theme in THEMES { let ctx = ctx_in(theme); let state = controls_gallery::State { - base: eggshell_ui_shadcn::BaseColor::Zinc, + base: eggshell_ui::theme::BaseColor::Zinc, theme_color: ThemeColor::Green, ..Default::default() }; controls_gallery::prepare(&ctx, &state); let palette = Palette::new() - .base(eggshell_ui_shadcn::BaseColor::Zinc) + .base(eggshell_ui::theme::BaseColor::Zinc) .theme(ThemeColor::Green); let tokens = Shadcn::of(&ctx).tokens; assert_eq!( diff --git a/tests/it/toggle_group.rs b/tests/it/toggle_group.rs index 55142fc0..c97e12d8 100644 --- a/tests/it/toggle_group.rs +++ b/tests/it/toggle_group.rs @@ -6,8 +6,8 @@ use std::sync::Arc; use eggshell_ui::contract::{Keyed, Metrics, Size, Themed}; use eggshell_ui::owned::{ButtonOptions, Face, ToggleGroup}; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::{Shadcn, Tokens, size}; use eggshell_ui::{Builder, Problem, Style, TextStyle, tw}; -use eggshell_ui_shadcn::{Shadcn, Tokens, size}; use egui::{Rect, Role, Theme, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/crates/eggshell-ui-shadcn/tests/tones.rs b/tests/it/tones.rs similarity index 96% rename from crates/eggshell-ui-shadcn/tests/tones.rs rename to tests/it/tones.rs index 7b9698ae..e62eccf7 100644 --- a/crates/eggshell-ui-shadcn/tests/tones.rs +++ b/tests/it/tones.rs @@ -2,7 +2,7 @@ use eggshell_ui::Tone; use eggshell_ui::contract::ToneColors; -use eggshell_ui_shadcn::{Shadcn, Tokens}; +use eggshell_ui::theme::{Shadcn, Tokens}; use egui::Theme; fn expected(t: &Tokens, tone: Tone) -> ToneColors { diff --git a/tests/it/tooltips.rs b/tests/it/tooltips.rs index 4fa9c5b7..80270ac8 100644 --- a/tests/it/tooltips.rs +++ b/tests/it/tooltips.rs @@ -6,8 +6,8 @@ use core::time::Duration; use eggshell_ui::owned::{Choice, Enablement, Face, TooltipPart}; use eggshell_ui::testing::{Driver, Target, Timeline, record}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, Style, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Key, KeyboardShortcut, Rect, RichText, Shape, Theme, pos2, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; @@ -433,7 +433,7 @@ fn a_tooltip_opening_swapping_and_closing_never_teleports() { #[test] fn the_shadcn_tooltip_is_inverted_with_an_arrow() { for theme in [Theme::Light, Theme::Dark] { - let preset = eggshell_ui_shadcn::Shadcn::for_theme(theme); + let preset = eggshell_ui::theme::Shadcn::for_theme(theme); let style = preset.style(); let content = support::part(&style, TooltipPart::Content); assert_eq!( diff --git a/tests/it/typed_range.rs b/tests/it/typed_range.rs index 577b987a..44a86340 100644 --- a/tests/it/typed_range.rs +++ b/tests/it/typed_range.rs @@ -3,8 +3,8 @@ //! from where the value is, and the step's lattice stays the track's. use eggshell_ui::owned::{Step, ValueRange}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Event, Key, Theme, vec2}; use egui_kittest::Harness; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/tests/it/typeset.rs b/tests/it/typeset.rs index 98554815..541a367f 100644 --- a/tests/it/typeset.rs +++ b/tests/it/typeset.rs @@ -2,9 +2,9 @@ //! style, measured on the page as drawn. Every expected length is derived //! from typeset.css at shadcn's defaults: 15 pt, leading 1.75, flow 1.25em. +use eggshell_ui::owned::markdown::{Directives, MarkdownExt, MarkdownStyle, Typeset, TypesetInk}; use eggshell_ui::testing::{Driver, Target}; use eggshell_ui::{Builder, Style, TextSpec, TextStyle, Weight, tw}; -use eggshell_ui_extras::markdown::{Directives, MarkdownExt, MarkdownStyle, Typeset, TypesetInk}; use egui::{Color32, FontFamily, Rect, vec2}; use crate::support; diff --git a/tests/it/value_widgets.rs b/tests/it/value_widgets.rs index 5232438d..84a4c419 100644 --- a/tests/it/value_widgets.rs +++ b/tests/it/value_widgets.rs @@ -2,8 +2,8 @@ //! through kittest's real pointer and key events. use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Key, Theme, vec2}; use crate::support; diff --git a/tests/it/vlist.rs b/tests/it/vlist.rs index 5ab3c802..44a77cff 100644 --- a/tests/it/vlist.rs +++ b/tests/it/vlist.rs @@ -6,8 +6,8 @@ use std::cell::Cell; use std::collections::HashMap; use eggshell_ui::overlay::{Anchor, Shown}; +use eggshell_ui::theme::Tokens; use eggshell_ui::{Builder, TextStyle, scroll, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Align, Id, Key, Rect, Theme, vec2}; use eggshell_ui::testing::{Driver, Target}; diff --git a/tests/it/vlist_nav.rs b/tests/it/vlist_nav.rs index ad663546..fb6a08a7 100644 --- a/tests/it/vlist_nav.rs +++ b/tests/it/vlist_nav.rs @@ -6,9 +6,9 @@ use std::cell::RefCell; use std::collections::BTreeSet; use eggshell_ui::testing::{Driver, Target}; +use eggshell_ui::theme::Tokens; use eggshell_ui::vlist::ListNav; use eggshell_ui::{Builder, TextStyle, tw}; -use eggshell_ui_shadcn::Tokens; use egui::{Color32, Key, Pos2, Rect, Theme, vec2}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; diff --git a/tests/it/vlist_ports.rs b/tests/it/vlist_ports.rs index a6c47780..fe036f60 100644 --- a/tests/it/vlist_ports.rs +++ b/tests/it/vlist_ports.rs @@ -4,8 +4,8 @@ //! rows it shows are the ones its data puts there. use eggshell_ui::testing::Driver; +use eggshell_ui::theme::Tokens; use eggshell_ui::{TextStyle, scroll}; -use eggshell_ui_shadcn::Tokens; use egui::{Align, Rect, Theme, vec2}; use crate::support::{self, View}; diff --git a/xtask/src/clock.rs b/xtask/src/clock.rs index 868073fe..456027fc 100644 --- a/xtask/src/clock.rs +++ b/xtask/src/clock.rs @@ -95,7 +95,7 @@ pub fn check(dir: &Path) -> Result<()> { } /// The library crates of the workspace, relative to its root. -pub const LIBRARY_SOURCES: [&str; 2] = ["src", "crates/eggshell-ui-shadcn/src"]; +pub const LIBRARY_SOURCES: [&str; 1] = ["src"]; pub fn check_library() -> Result<()> { let root = process::workspace_root(); diff --git a/xtask/src/shadcn_import/emit.rs b/xtask/src/shadcn_import/emit.rs index c78a0e41..8ee7f204 100644 --- a/xtask/src/shadcn_import/emit.rs +++ b/xtask/src/shadcn_import/emit.rs @@ -789,53 +789,32 @@ pub struct Widget { pub absent: &'static [(&'static str, &'static str)], } -/// Where core's sheets are checked in, from the workspace root. -pub const CORE_SHEETS: &str = "src/sheets"; - -/// Where the extensions' sheets are checked in: the preset's crate, which -/// may name their part enums. -pub const EXTENSION_SHEETS: &str = "crates/eggshell-ui-shadcn/src/sheets"; - -/// Where a widget's part enum lives: core's `owned`, or an extension -/// crate's module, whose rules the preset writes only with its `extras` -/// feature. +/// Where a widget's part enum lives: core's `owned`, or an opt-in widget's +/// module under it, whose rules are written only with its feature. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum Home { Core, - Extension(&'static str), + /// An opt-in widget's module under `owned`, behind the feature of its + /// name. + Feature(&'static str), } impl Home { /// The module that names the part enum. - fn module(self) -> &'static str { + fn module(self) -> String { match self { - Self::Core => "crate::owned", - Self::Extension(module) => module, + Self::Core => "crate::owned".to_owned(), + Self::Feature(module) => format!("crate::owned::{module}"), } } - /// The crate a sheet of this home names core by. - fn krate(self) -> &'static str { + /// The attribute a sheet of this home takes in the index. + pub fn cfg(self) -> String { match self { - Self::Core => "crate", - Self::Extension(_) => "eggshell_ui", - } - } - - /// Where the sheets of this home are checked in, from the workspace root: - /// core's parts in core, the extensions' in the preset's crate. - pub fn sheets(self) -> &'static str { - match self { - Self::Core => CORE_SHEETS, - Self::Extension(_) => EXTENSION_SHEETS, - } - } - - /// The attribute an item of the preset's crate takes for it. - pub fn cfg(self) -> &'static str { - match self { - Self::Core => "", - Self::Extension(_) => "#[cfg(feature = \"extras\")] ", + Self::Core => String::new(), + Self::Feature(module) => { + format!("#[cfg(feature = \"{}\")] ", module.replace('_', "-")) + } } } } @@ -1356,12 +1335,7 @@ pub fn emit( } } if !contract.is_empty() { - let _ = writeln!( - rust, - "use {}::contract::{{{}}};", - widget.home.krate(), - contract.join(", ") - ); + let _ = writeln!(rust, "use crate::contract::{{{}}};", contract.join(", ")); } let _ = writeln!( rust, @@ -1373,10 +1347,9 @@ pub fn emit( true => "{Sheet, When}", false => "Sheet", }; - let krate = widget.home.krate(); - let _ = writeln!(rust, "use {krate}::sheet::{sheet};"); + let _ = writeln!(rust, "use crate::sheet::{sheet};"); if !core.is_empty() { - let _ = writeln!(rust, "use {krate}::{{{}}};", core.join(", ")); + let _ = writeln!(rust, "use crate::{{{}}};", core.join(", ")); } let _ = writeln!(rust); for (constant, path) in &constants { diff --git a/xtask/src/shadcn_import/mod.rs b/xtask/src/shadcn_import/mod.rs index 5454a2b1..8e28a3ec 100644 --- a/xtask/src/shadcn_import/mod.rs +++ b/xtask/src/shadcn_import/mod.rs @@ -148,7 +148,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "combobox", - home: Home::Extension("eggshell_ui_extras::command"), + home: Home::Feature("command"), checked_in: true, variants: &[], sizes: &[], @@ -167,7 +167,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "command", - home: Home::Extension("eggshell_ui_extras::command"), + home: Home::Feature("command"), checked_in: true, variants: &[], sizes: &[], @@ -342,7 +342,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "hover-card", - home: Home::Extension("eggshell_ui_extras::hover_card"), + home: Home::Feature("hover_card"), checked_in: true, variants: &[], sizes: &[], @@ -358,7 +358,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "dialog", - home: Home::Extension("eggshell_ui_extras::dialog"), + home: Home::Feature("dialog"), checked_in: true, variants: &[], sizes: &[], @@ -374,7 +374,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "alert-dialog", - home: Home::Extension("eggshell_ui_extras::dialog"), + home: Home::Feature("dialog"), checked_in: true, variants: &[], sizes: &[], @@ -390,7 +390,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "sheet", - home: Home::Extension("eggshell_ui_extras::dialog"), + home: Home::Feature("dialog"), checked_in: true, variants: &[], sizes: &[], @@ -406,7 +406,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "popover", - home: Home::Extension("eggshell_ui_extras::dialog"), + home: Home::Feature("dialog"), checked_in: true, variants: &[], sizes: &[], @@ -422,7 +422,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "badge", - home: Home::Extension("eggshell_ui_extras::badge"), + home: Home::Feature("badge"), checked_in: true, variants: &[("default", &["primary"])], sizes: &[], @@ -439,7 +439,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "card", - home: Home::Extension("eggshell_ui_extras::form"), + home: Home::Feature("form"), checked_in: true, variants: &[], sizes: &[], @@ -471,7 +471,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "accordion", - home: Home::Extension("eggshell_ui_extras::disclosure"), + home: Home::Feature("disclosure"), checked_in: true, variants: &[], sizes: &[], @@ -487,7 +487,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "sonner", - home: Home::Extension("eggshell_ui_extras::notify"), + home: Home::Feature("notify"), checked_in: true, variants: &[], sizes: &[], @@ -503,7 +503,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "skeleton", - home: Home::Extension("eggshell_ui_extras::skeleton"), + home: Home::Feature("skeleton"), checked_in: true, variants: &[], sizes: &[], @@ -519,7 +519,7 @@ const WIDGETS: [emit::Widget; 27] = [ }, emit::Widget { component: "spinner", - home: Home::Extension("eggshell_ui_extras::spinner"), + home: Home::Feature("spinner"), checked_in: true, variants: &[], sizes: &[], @@ -838,19 +838,21 @@ const TABS: [emit::Assumed; 7] = { ] }; -/// A `sheets` module: a module per migrated `component` and style, and +/// The `sheets` module: a module per migrated `component` and style, and /// `write`, which writes them all for a style and theme, in the order of -/// `components`. `uses` names `Sheet` and `ShadcnStyle` where the module is. -fn index(components: &[(&str, Home)], uses: &str) -> String { +/// `components`. +fn index(components: &[(&str, Home)]) -> String { let module = |style: &str, component: &str| format!("{style}_{}", component.replace('-', "_")); let mut out = String::from( "//! The widgets' rules in each shadcn style, generated from the pinned shadcn\n\ //! source by `cargo xtask shadcn-import --write`; CI fails if they drift\n\ //! (`--check`). Each rule's classes carry the shadcn class they came from.\n\ //!\n\ - //! This file is generated too. Do not edit.\n\n", + //! This file is generated too. Do not edit.\n\n\ + use crate::sheet::Sheet;\n\ + use egui::Theme;\n\n\ + use crate::theme::ShadcnStyle;\n", ); - out.push_str(uses); out.push_str( "\n/// One half of a widget's rules: its light or its dark theme.\n\ type Half = fn(&mut Sheet);\n", @@ -889,20 +891,13 @@ fn index(components: &[(&str, Home)], uses: &str) -> String { } /// Where a widget's checked-in rules for `style` live. -fn checked_in(root: &Path, style: &str, component: &str, home: Home) -> PathBuf { - root.join(home.sheets()) +fn checked_in(root: &Path, style: &str, component: &str) -> PathBuf { + root.join(SHEETS) .join(format!("{style}_{}.rs", component.replace('-', "_"))) } -/// What a `sheets` index of core names `Sheet` and `ShadcnStyle` by. -const CORE_USES: &str = "use crate::sheet::Sheet;\n\ - use egui::Theme;\n\n\ - use crate::theme::ShadcnStyle;\n"; - -/// What the preset crate's `sheets` index names them by. -const EXTENSION_USES: &str = "use eggshell_ui::sheet::Sheet;\n\ - use egui::Theme;\n\n\ - use crate::ShadcnStyle;\n"; +/// Where the generated sheets are checked in, from the workspace root. +const SHEETS: &str = "src/sheets"; /// What the run does besides the report. #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -951,28 +946,13 @@ fn sheets(root: &Path, registry: &Path, classifier: &Classifier<'_>, mode: Mode) .filter(|w| w.checked_in) .map(|w| (w.component, w.home)) .collect(); - let (core, extensions): (Vec<_>, Vec<_>) = migrated - .into_iter() - .partition(|(_, home)| matches!(home, Home::Core)); - let mut files = vec![ - ( - root.join(emit::CORE_SHEETS).join("mod.rs"), - index(&core, CORE_USES), - ), - ( - root.join(emit::EXTENSION_SHEETS).join("mod.rs"), - index(&extensions, EXTENSION_USES), - ), - ]; + let mut files = vec![(root.join(SHEETS).join("mod.rs"), index(&migrated))]; for style in STYLES { let mut scratch = Sources::default(); let (rows, _) = extract(registry, style, classifier, &mut scratch)?; for widget in WIDGETS.iter().filter(|w| w.checked_in) { let emitted = emit::emit(classifier, &rows, &scratch, widget, style); - files.push(( - checked_in(root, style, widget.component, widget.home), - emitted.rust, - )); + files.push((checked_in(root, style, widget.component), emitted.rust)); } } let mut stale = Vec::new(); @@ -1298,10 +1278,8 @@ fn preset_dump(root: &Path) -> Result { "cargo", "run", "-q", - "-p", - "eggshell-ui-shadcn", "--features", - "extras", + "badge,command,dialog,disclosure,form,hover-card,markdown,notify,skeleton", "--example", "preset_dump" ) @@ -1431,21 +1409,15 @@ mod tests { #[test] fn the_sheets_index_declares_and_writes_every_migrated_widget_in_each_style() { - let index = index( - &[ - ("button", Home::Core), - ("input-group", Home::Core), - ("combobox", Home::Extension("eggshell_ui_extras::command")), - ], - EXTENSION_USES, - ); - assert!(index.contains(EXTENSION_USES)); - assert!(index.contains("\n#[cfg(feature = \"extras\")] mod vega_combobox;")); - assert!( - index.contains( - "#[cfg(feature = \"extras\")] (vega_combobox::light, vega_combobox::dark)," - ) - ); + let index = index(&[ + ("button", Home::Core), + ("input-group", Home::Core), + ("combobox", Home::Feature("command")), + ]); + assert!(index.contains("\n#[cfg(feature = \"command\")] mod vega_combobox;")); + assert!(index.contains( + "#[cfg(feature = \"command\")] (vega_combobox::light, vega_combobox::dark)," + )); for module in [ "vega_button", "vega_input_group", diff --git a/xtask/src/steps.rs b/xtask/src/steps.rs index 3e3c474d..f82e4b94 100644 --- a/xtask/src/steps.rs +++ b/xtask/src/steps.rs @@ -225,17 +225,15 @@ pub fn screenshots() -> Step { }) } -/// The crates with optional features, built with none of them: what is -/// gated on a feature must build, and lint, without it. +/// The library built with none of its optional features: what is gated on +/// a feature must build, and lint, without it. pub fn features() -> Step { Step::cargo( "features", &[ "clippy", "-p", - "eggshell-ui-shadcn", - "-p", - "eggshell-ui-extras", + "eggshell-ui", "--no-default-features", "--", "-D", @@ -367,7 +365,7 @@ mod tests { "built-in clock check", "built-in spacing-units check", "cargo clippy --workspace --all-targets --features eggshell-ui/snapshots -- -D warnings", - "cargo clippy -p eggshell-ui-shadcn -p eggshell-ui-extras --no-default-features -- -D warnings", + "cargo clippy -p eggshell-ui --no-default-features -- -D warnings", "built-in shadcn-sheets check", "built-in test check", "cargo test --workspace --doc", diff --git a/xtask/src/units.rs b/xtask/src/units.rs index 6e375490..5fd2b9d3 100644 --- a/xtask/src/units.rs +++ b/xtask/src/units.rs @@ -10,7 +10,7 @@ use anyhow::{Result, bail}; use crate::process; -const SOURCES: [&str; 4] = ["src", "crates", "examples", "tests"]; +const SOURCES: [&str; 3] = ["src", "examples", "tests"]; /// What turns points into spacing units at Tailwind's 4 points a unit. const QUARTERS: [&str; 3] = ["/ 4.0", "/4.0", "* 0.25"];