drafftink_widgets/
lib.rs

1//! Reusable egui widget components with Tailwind-inspired styling.
2//!
3//! This crate provides a collection of styled UI components for egui applications:
4//!
5//! - **Buttons**: Icon buttons, toggle buttons, multi-state toggles
6//! - **Colors**: Tailwind color palette, color swatches, color picker grids
7//! - **Menu**: Menu items, separators, panel frames
8//! - **Layout**: Section labels, separators, spacing helpers
9
10pub mod buttons;
11pub mod colors;
12pub mod layout;
13pub mod menu;
14
15pub use buttons::{
16    FontSizeButton, IconButton, IconButtonStyle, MultiToggle, MultiToggleState, StrokeWidthButton,
17    TextButton, ToggleButton,
18};
19pub use colors::{
20    colors_match, hue_to_rgb, parse_css_color, ColorGrid, ColorGridPosition, ColorSwatch,
21    ColorSwatchStyle, ColorSwatchWithWheel, NoColorSwatch, SelectionStyle, TailwindColor,
22    TailwindPalette, SHADE_LABELS, TAILWIND_COLORS,
23};
24pub use layout::{section_label, separator, vertical_separator};
25pub use menu::{menu_item, menu_item_enabled, menu_separator, panel_frame, toolbar_frame};
26
27/// Standard sizing constants used across widgets.
28pub mod sizing {
29    /// Small button size (icons, color swatches)
30    pub const SMALL: f32 = 20.0;
31    /// Medium button size (toolbar buttons)
32    pub const MEDIUM: f32 = 28.0;
33    /// Large button size
34    pub const LARGE: f32 = 36.0;
35    /// Standard corner radius
36    pub const CORNER_RADIUS: u8 = 4;
37    /// Panel corner radius
38    pub const PANEL_RADIUS: u8 = 8;
39}
40
41/// Standard colors used across widgets.
42pub mod theme {
43    use egui::Color32;
44
45    /// Text color (dark gray)
46    pub const TEXT: Color32 = Color32::from_rgb(60, 60, 60);
47    /// Muted text color
48    pub const TEXT_MUTED: Color32 = Color32::from_rgb(120, 120, 120);
49    /// Border color
50    pub const BORDER: Color32 = Color32::from_rgb(220, 220, 220);
51    /// Selection/active color (blue)
52    pub const ACCENT: Color32 = Color32::from_rgb(59, 130, 246);
53    /// Hover background
54    pub const HOVER_BG: Color32 = Color32::from_rgb(245, 245, 245);
55    /// Selected background
56    pub const SELECTED_BG: Color32 = Color32::from_rgb(235, 245, 255);
57    /// Panel background
58    pub const PANEL_BG: Color32 = Color32::from_rgba_premultiplied(250, 250, 252, 250);
59}