cronixui 1.0.6 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -5
- package/package.json +20 -5
- package/packages/flutter/lib/cronixui.dart +41 -0
- package/packages/flutter/lib/src/tokens/colors.dart +34 -0
- package/packages/flutter/lib/src/tokens/spacing.dart +54 -0
- package/packages/flutter/lib/src/tokens/theme.dart +174 -0
- package/packages/flutter/lib/src/widgets/cn_accordion.dart +254 -0
- package/packages/flutter/lib/src/widgets/cn_alert.dart +137 -0
- package/packages/flutter/lib/src/widgets/cn_avatar.dart +98 -0
- package/packages/flutter/lib/src/widgets/cn_badge.dart +80 -0
- package/packages/flutter/lib/src/widgets/cn_breadcrumb.dart +88 -0
- package/packages/flutter/lib/src/widgets/cn_button.dart +137 -0
- package/packages/flutter/lib/src/widgets/cn_card.dart +99 -0
- package/packages/flutter/lib/src/widgets/cn_checkbox.dart +77 -0
- package/packages/flutter/lib/src/widgets/cn_command_palette.dart +299 -0
- package/packages/flutter/lib/src/widgets/cn_container.dart +131 -0
- package/packages/flutter/lib/src/widgets/cn_dropdown.dart +149 -0
- package/packages/flutter/lib/src/widgets/cn_file_input.dart +113 -0
- package/packages/flutter/lib/src/widgets/cn_footer.dart +108 -0
- package/packages/flutter/lib/src/widgets/cn_header.dart +173 -0
- package/packages/flutter/lib/src/widgets/cn_input.dart +142 -0
- package/packages/flutter/lib/src/widgets/cn_list.dart +150 -0
- package/packages/flutter/lib/src/widgets/cn_modal.dart +213 -0
- package/packages/flutter/lib/src/widgets/cn_nav.dart +157 -0
- package/packages/flutter/lib/src/widgets/cn_pagination.dart +193 -0
- package/packages/flutter/lib/src/widgets/cn_progress.dart +146 -0
- package/packages/flutter/lib/src/widgets/cn_radio.dart +133 -0
- package/packages/flutter/lib/src/widgets/cn_search.dart +183 -0
- package/packages/flutter/lib/src/widgets/cn_select.dart +244 -0
- package/packages/flutter/lib/src/widgets/cn_sidebar.dart +207 -0
- package/packages/flutter/lib/src/widgets/cn_skeleton.dart +136 -0
- package/packages/flutter/lib/src/widgets/cn_slider.dart +141 -0
- package/packages/flutter/lib/src/widgets/cn_spinner.dart +85 -0
- package/packages/flutter/lib/src/widgets/cn_stat.dart +135 -0
- package/packages/flutter/lib/src/widgets/cn_table.dart +136 -0
- package/packages/flutter/lib/src/widgets/cn_tabs.dart +229 -0
- package/packages/flutter/lib/src/widgets/cn_tag.dart +185 -0
- package/packages/flutter/lib/src/widgets/cn_textarea.dart +143 -0
- package/packages/flutter/lib/src/widgets/cn_toast.dart +121 -0
- package/packages/flutter/lib/src/widgets/cn_toggle.dart +78 -0
- package/packages/flutter/lib/src/widgets/cn_tooltip.dart +118 -0
- package/packages/flutter/pubspec.yaml +20 -0
- package/packages/go/cronixui/cronixui.go +784 -237
- package/packages/go/cronixui/go.mod +32 -0
- package/packages/go/cronixui/go.sum +666 -0
- package/packages/python/cronixui/__init__.py +59 -3
- package/packages/python/cronixui/alert.py +61 -0
- package/packages/python/cronixui/avatar.py +50 -0
- package/packages/python/cronixui/badge.py +46 -0
- package/packages/python/cronixui/button.py +64 -0
- package/packages/python/cronixui/card.py +62 -0
- package/packages/python/cronixui/form.py +255 -0
- package/packages/python/cronixui/layout.py +143 -0
- package/packages/python/cronixui/list.py +51 -0
- package/packages/python/cronixui/loading.py +36 -0
- package/packages/python/cronixui/progress.py +90 -0
- package/packages/python/cronixui/table.py +48 -0
- package/packages/python/cronixui/tooltip.py +28 -0
- package/packages/react/src/components/Accordion.tsx +82 -0
- package/packages/react/src/components/Alert.tsx +80 -0
- package/packages/react/src/components/Avatar.tsx +54 -0
- package/packages/react/src/components/Badge.tsx +32 -0
- package/packages/react/src/components/Breadcrumb.tsx +50 -0
- package/packages/react/src/components/Button.tsx +47 -0
- package/packages/react/src/components/Card.tsx +69 -0
- package/packages/react/src/components/Checkbox.tsx +30 -0
- package/packages/react/src/components/CommandPalette.tsx +131 -0
- package/packages/react/src/components/Container.tsx +26 -0
- package/packages/react/src/components/Dropdown.tsx +88 -0
- package/packages/react/src/components/FileInput.tsx +86 -0
- package/packages/react/src/components/Footer.tsx +36 -0
- package/packages/react/src/components/FormGroup.tsx +36 -0
- package/packages/react/src/components/Header.tsx +29 -0
- package/packages/react/src/components/Input.tsx +54 -0
- package/packages/react/src/components/List.tsx +55 -0
- package/packages/react/src/components/Modal.tsx +89 -0
- package/packages/react/src/components/Nav.tsx +63 -0
- package/packages/react/src/components/Pagination.tsx +107 -0
- package/packages/react/src/components/Progress.tsx +49 -0
- package/packages/react/src/components/Radio.tsx +64 -0
- package/packages/react/src/components/Search.tsx +95 -0
- package/packages/react/src/components/Select.tsx +41 -0
- package/packages/react/src/components/Sidebar.tsx +64 -0
- package/packages/react/src/components/Skeleton.tsx +39 -0
- package/packages/react/src/components/Slider.tsx +32 -0
- package/packages/react/src/components/Spinner.tsx +24 -0
- package/packages/react/src/components/Stack.tsx +69 -0
- package/packages/react/src/components/Stat.tsx +35 -0
- package/packages/react/src/components/Table.tsx +90 -0
- package/packages/react/src/components/Tabs.tsx +85 -0
- package/packages/react/src/components/Tag.tsx +30 -0
- package/packages/react/src/components/Textarea.tsx +21 -0
- package/packages/react/src/components/Toast.tsx +134 -0
- package/packages/react/src/components/Toggle.tsx +58 -0
- package/packages/react/src/components/Tooltip.tsx +31 -0
- package/packages/react/src/components/Typography.tsx +66 -0
- package/packages/react/src/index.ts +40 -0
- package/packages/react/src/styles.css +2039 -0
- package/packages/react/src/tokens/index.ts +94 -0
- package/packages/rust/cronixui/src/colors.rs +135 -0
- package/packages/rust/cronixui/src/components/accordion.rs +47 -0
- package/packages/rust/cronixui/src/components/alert.rs +95 -0
- package/packages/rust/cronixui/src/components/avatar.rs +85 -0
- package/packages/rust/cronixui/src/components/badge.rs +35 -0
- package/packages/rust/cronixui/src/components/breadcrumb.rs +58 -0
- package/packages/rust/cronixui/src/components/button.rs +70 -0
- package/packages/rust/cronixui/src/components/card.rs +259 -0
- package/packages/rust/cronixui/src/components/command_palette.rs +254 -0
- package/packages/rust/cronixui/src/components/dropdown.rs +179 -0
- package/packages/rust/cronixui/src/components/file_input.rs +74 -0
- package/packages/rust/cronixui/src/components/input.rs +21 -0
- package/packages/rust/cronixui/src/components/list.rs +38 -0
- package/packages/rust/cronixui/src/components/mod.rs +51 -0
- package/packages/rust/cronixui/src/{modal.rs → components/modal.rs} +15 -1
- package/packages/rust/cronixui/src/components/nav.rs +19 -0
- package/packages/rust/cronixui/src/{pagination.rs → components/pagination.rs} +14 -13
- package/packages/rust/cronixui/src/components/progress.rs +50 -0
- package/packages/rust/cronixui/src/components/search.rs +185 -0
- package/packages/rust/cronixui/src/components/skeleton.rs +63 -0
- package/packages/rust/cronixui/src/components/spinner.rs +21 -0
- package/packages/rust/cronixui/src/components/table.rs +56 -0
- package/packages/rust/cronixui/src/components/tabs.rs +43 -0
- package/packages/rust/cronixui/src/components/toast.rs +69 -0
- package/packages/rust/cronixui/src/{toggle.rs → components/toggle.rs} +7 -5
- package/packages/rust/cronixui/src/components/tooltip.rs +11 -0
- package/packages/rust/cronixui/src/lib.rs +111 -64
- package/packages/rust/cronixui/src/tokens.rs +97 -127
- package/packages/web/src/variables.css +81 -81
- package/packages/go/cronixui/tokens.go +0 -129
- package/packages/python/cronixui/pyproject.toml +0 -11
- package/packages/react/src/components/Accordion.jsx +0 -50
- package/packages/react/src/components/Alert.jsx +0 -62
- package/packages/react/src/components/Avatar.jsx +0 -34
- package/packages/react/src/components/Badge.jsx +0 -15
- package/packages/react/src/components/Breadcrumb.jsx +0 -27
- package/packages/react/src/components/Button.jsx +0 -21
- package/packages/react/src/components/Card.jsx +0 -23
- package/packages/react/src/components/Checkbox.jsx +0 -27
- package/packages/react/src/components/CommandPalette.jsx +0 -93
- package/packages/react/src/components/Dropdown.jsx +0 -48
- package/packages/react/src/components/FileInput.jsx +0 -44
- package/packages/react/src/components/Input.jsx +0 -22
- package/packages/react/src/components/List.jsx +0 -29
- package/packages/react/src/components/Modal.jsx +0 -65
- package/packages/react/src/components/Nav.jsx +0 -50
- package/packages/react/src/components/Pagination.jsx +0 -81
- package/packages/react/src/components/Progress.jsx +0 -23
- package/packages/react/src/components/Radio.jsx +0 -50
- package/packages/react/src/components/Search.jsx +0 -70
- package/packages/react/src/components/Select.jsx +0 -33
- package/packages/react/src/components/Skeleton.jsx +0 -15
- package/packages/react/src/components/Slider.jsx +0 -29
- package/packages/react/src/components/Spinner.jsx +0 -5
- package/packages/react/src/components/Stat.jsx +0 -19
- package/packages/react/src/components/Table.jsx +0 -48
- package/packages/react/src/components/Tabs.jsx +0 -65
- package/packages/react/src/components/Tag.jsx +0 -19
- package/packages/react/src/components/Textarea.jsx +0 -17
- package/packages/react/src/components/Toast.jsx +0 -78
- package/packages/react/src/components/Toggle.jsx +0 -34
- package/packages/react/src/components/Tooltip.jsx +0 -12
- package/packages/react/src/index.d.ts +0 -103
- package/packages/react/src/index.js +0 -33
- package/packages/rust/cronixui/src/accordion.rs +0 -49
- package/packages/rust/cronixui/src/command_palette.rs +0 -62
- package/packages/rust/cronixui/src/dropdown.rs +0 -31
- package/packages/rust/cronixui/src/search.rs +0 -49
- package/packages/rust/cronixui/src/tabs.rs +0 -23
- package/packages/rust/cronixui/src/toast.rs +0 -70
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//! Toast notifications
|
|
2
|
+
|
|
3
|
+
use crate::colors::*;
|
|
4
|
+
use egui::Color32;
|
|
5
|
+
|
|
6
|
+
pub enum ToastType {
|
|
7
|
+
Success,
|
|
8
|
+
Error,
|
|
9
|
+
Warning,
|
|
10
|
+
Info,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
pub struct Toast {
|
|
14
|
+
pub message: String,
|
|
15
|
+
pub toast_type: ToastType,
|
|
16
|
+
pub duration: f32,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
impl Toast {
|
|
20
|
+
pub fn success(message: impl Into<String>) -> Self {
|
|
21
|
+
Self {
|
|
22
|
+
message: message.into(),
|
|
23
|
+
toast_type: ToastType::Success,
|
|
24
|
+
duration: 3.0,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
pub fn error(message: impl Into<String>) -> Self {
|
|
29
|
+
Self {
|
|
30
|
+
message: message.into(),
|
|
31
|
+
toast_type: ToastType::Error,
|
|
32
|
+
duration: 3.0,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
pub fn warning(message: impl Into<String>) -> Self {
|
|
37
|
+
Self {
|
|
38
|
+
message: message.into(),
|
|
39
|
+
toast_type: ToastType::Warning,
|
|
40
|
+
duration: 3.0,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
pub fn info(message: impl Into<String>) -> Self {
|
|
45
|
+
Self {
|
|
46
|
+
message: message.into(),
|
|
47
|
+
toast_type: ToastType::Info,
|
|
48
|
+
duration: 3.0,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
pub fn color(&self) -> Color32 {
|
|
53
|
+
match self.toast_type {
|
|
54
|
+
ToastType::Success => SUCCESS,
|
|
55
|
+
ToastType::Error => ERROR,
|
|
56
|
+
ToastType::Warning => WARNING,
|
|
57
|
+
ToastType::Info => INFO,
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
pub fn prefix(&self) -> &'static str {
|
|
62
|
+
match self.toast_type {
|
|
63
|
+
ToastType::Success => "✓ ",
|
|
64
|
+
ToastType::Error => "✕ ",
|
|
65
|
+
ToastType::Warning => "⚠ ",
|
|
66
|
+
ToastType::Info => "ℹ ",
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
//! Toggle component
|
|
2
|
+
|
|
1
3
|
pub struct Toggle {
|
|
2
|
-
on: bool,
|
|
4
|
+
pub on: bool,
|
|
3
5
|
}
|
|
4
6
|
|
|
5
7
|
impl Toggle {
|
|
@@ -11,12 +13,12 @@ impl Toggle {
|
|
|
11
13
|
self.on = !self.on;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
pub fn
|
|
15
|
-
self.on
|
|
16
|
+
pub fn set(&mut self, value: bool) {
|
|
17
|
+
self.on = value;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
pub fn
|
|
19
|
-
self.on
|
|
20
|
+
pub fn is_on(&self) -> bool {
|
|
21
|
+
self.on
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
|
|
@@ -1,81 +1,128 @@
|
|
|
1
|
-
//! CronixUI - A dark-themed UI toolkit
|
|
1
|
+
//! CronixUI - A dark-themed UI toolkit for egui
|
|
2
2
|
//!
|
|
3
3
|
//! ## Example
|
|
4
4
|
//!
|
|
5
5
|
//! ```rust
|
|
6
|
-
//! use cronixui::{
|
|
6
|
+
//! use cronixui::{CronixUI, Colors, components::*};
|
|
7
7
|
//!
|
|
8
|
-
//! //
|
|
9
|
-
//!
|
|
10
|
-
//!
|
|
11
|
-
//!
|
|
12
|
-
//!
|
|
13
|
-
//!
|
|
14
|
-
//!
|
|
8
|
+
//! // In your egui app
|
|
9
|
+
//! fn update(&mut self, ctx: &egui::Context) {
|
|
10
|
+
//! CronixUI::apply_theme(ctx);
|
|
11
|
+
//!
|
|
12
|
+
//! egui::CentralPanel::default().show(ctx, |ui| {
|
|
13
|
+
//! // Use components
|
|
14
|
+
//! if ui.button_primary("Click me").clicked() {
|
|
15
|
+
//! // handle click
|
|
16
|
+
//! }
|
|
17
|
+
//! });
|
|
18
|
+
//! }
|
|
15
19
|
//! ```
|
|
16
20
|
|
|
17
|
-
pub
|
|
18
|
-
|
|
19
|
-
mod
|
|
20
|
-
mod toggle;
|
|
21
|
-
mod modal;
|
|
22
|
-
mod dropdown;
|
|
23
|
-
mod tabs;
|
|
24
|
-
mod accordion;
|
|
25
|
-
mod pagination;
|
|
26
|
-
mod command_palette;
|
|
27
|
-
mod search;
|
|
28
|
-
mod tokens;
|
|
21
|
+
pub mod colors;
|
|
22
|
+
pub mod tokens;
|
|
23
|
+
pub mod components;
|
|
29
24
|
|
|
30
|
-
pub use
|
|
31
|
-
pub use toggle::Toggle;
|
|
32
|
-
pub use modal::Modal;
|
|
33
|
-
pub use dropdown::Dropdown;
|
|
34
|
-
pub use tabs::Tabs;
|
|
35
|
-
pub use accordion::Accordion;
|
|
36
|
-
pub use pagination::Pagination;
|
|
37
|
-
pub use command_palette::{CommandPalette, CommandPaletteItem};
|
|
38
|
-
pub use search::{Search, SearchItem};
|
|
25
|
+
pub use colors::*;
|
|
39
26
|
pub use tokens::*;
|
|
27
|
+
pub use components::*;
|
|
28
|
+
|
|
29
|
+
use egui::{Color32, Vec2, Rounding};
|
|
40
30
|
|
|
41
|
-
///
|
|
42
|
-
pub
|
|
43
|
-
|
|
31
|
+
/// Current version
|
|
32
|
+
pub const VERSION: &str = "1.0.6";
|
|
33
|
+
|
|
34
|
+
/// Apply CronixUI theme to egui context
|
|
35
|
+
pub fn apply_theme(ctx: &egui::Context) {
|
|
36
|
+
let colors = Colors::default();
|
|
37
|
+
|
|
38
|
+
let mut style = (*ctx.style()).clone();
|
|
39
|
+
|
|
40
|
+
// Visuals
|
|
41
|
+
style.visuals.window_fill = colors.bg;
|
|
42
|
+
style.visuals.panel_fill = colors.bg;
|
|
43
|
+
style.visuals.extreme_bg_color = colors.surface;
|
|
44
|
+
style.visuals.faint_bg_color = colors.surface_2;
|
|
45
|
+
style.visuals.code_bg_color = colors.surface_3;
|
|
46
|
+
|
|
47
|
+
// Text colors
|
|
48
|
+
style.visuals.strong_text_color = colors.text;
|
|
49
|
+
style.visuals.weak_text_color = colors.text_muted;
|
|
50
|
+
style.visuals.text_color = colors.text;
|
|
51
|
+
|
|
52
|
+
// Widget colors
|
|
53
|
+
style.visuals.widgets.noninteractive.bg_fill = colors.surface;
|
|
54
|
+
style.visuals.widgets.noninteractive.bg_stroke.color = colors.border;
|
|
55
|
+
style.visuals.widgets.noninteractive.fg_stroke.color = colors.text;
|
|
56
|
+
|
|
57
|
+
style.visuals.widgets.inactive.bg_fill = colors.surface_2;
|
|
58
|
+
style.visuals.widgets.inactive.bg_stroke.color = colors.border;
|
|
59
|
+
style.visuals.widgets.inactive.fg_stroke.color = colors.text;
|
|
60
|
+
|
|
61
|
+
style.visuals.widgets.hovered.bg_fill = colors.surface_3;
|
|
62
|
+
style.visuals.widgets.hovered.bg_stroke.color = colors.border_hover;
|
|
63
|
+
style.visuals.widgets.hovered.fg_stroke.color = colors.text;
|
|
64
|
+
|
|
65
|
+
style.visuals.widgets.active.bg_fill = colors.accent;
|
|
66
|
+
style.visuals.widgets.active.bg_stroke.color = colors.accent;
|
|
67
|
+
style.visuals.widgets.active.fg_stroke.color = colors.text;
|
|
68
|
+
|
|
69
|
+
style.visuals.widgets.open.bg_fill = colors.surface_3;
|
|
70
|
+
style.visuals.widgets.open.bg_stroke.color = colors.accent;
|
|
71
|
+
|
|
72
|
+
// Selection
|
|
73
|
+
style.visuals.selection.bg_fill = colors.accent;
|
|
74
|
+
style.visuals.selection.stroke.color = colors.accent_text;
|
|
75
|
+
|
|
76
|
+
// Hyperlink
|
|
77
|
+
style.visuals.hyperlink_color = colors.accent_text;
|
|
78
|
+
|
|
79
|
+
// Button rounding
|
|
80
|
+
style.visuals.button_rounding = Rounding::same(tokens::RADIUS);
|
|
81
|
+
|
|
82
|
+
// Window rounding
|
|
83
|
+
style.visuals.window_rounding = Rounding::same(tokens::RADIUS_LG);
|
|
84
|
+
|
|
85
|
+
// Spacing
|
|
86
|
+
style.spacing.button_padding = Vec2::new(tokens::SPACE_4, tokens::SPACE_2);
|
|
87
|
+
style.spacing.item_spacing = Vec2::new(tokens::SPACE_2, tokens::SPACE_2);
|
|
88
|
+
style.spacing.indent = tokens::SPACE_4;
|
|
89
|
+
|
|
90
|
+
ctx.set_style(style);
|
|
44
91
|
}
|
|
45
92
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
93
|
+
/// Helper trait for CronixUI button variants
|
|
94
|
+
pub trait CronixButton {
|
|
95
|
+
fn button_primary(&mut self, text: &str) -> egui::Response;
|
|
96
|
+
fn button_danger(&mut self, text: &str) -> egui::Response;
|
|
97
|
+
fn button_success(&mut self, text: &str) -> egui::Response;
|
|
98
|
+
fn button_ghost(&mut self, text: &str) -> egui::Response;
|
|
99
|
+
fn button_outline(&mut self, text: &str) -> egui::Response;
|
|
100
|
+
}
|
|
49
101
|
|
|
50
|
-
|
|
51
|
-
fn
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
toggle.toggle();
|
|
55
|
-
assert!(toggle.is_on());
|
|
56
|
-
toggle.set_on(false);
|
|
57
|
-
assert!(!toggle.is_on());
|
|
102
|
+
impl CronixButton for egui::Ui {
|
|
103
|
+
fn button_primary(&mut self, text: &str) -> egui::Response {
|
|
104
|
+
let colors = Colors::default();
|
|
105
|
+
self.add(egui::Button::new(text).fill(colors.accent))
|
|
58
106
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
assert_eq!(pagination.current(), 1);
|
|
64
|
-
pagination.next();
|
|
65
|
-
assert_eq!(pagination.current(), 2);
|
|
66
|
-
pagination.go_to(5);
|
|
67
|
-
assert_eq!(pagination.current(), 5);
|
|
107
|
+
|
|
108
|
+
fn button_danger(&mut self, text: &str) -> egui::Response {
|
|
109
|
+
let colors = Colors::default();
|
|
110
|
+
self.add(egui::Button::new(text).fill(colors.error))
|
|
68
111
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
112
|
+
|
|
113
|
+
fn button_success(&mut self, text: &str) -> egui::Response {
|
|
114
|
+
let colors = Colors::default();
|
|
115
|
+
self.add(egui::Button::new(text).fill(colors.success))
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
fn button_ghost(&mut self, text: &str) -> egui::Response {
|
|
119
|
+
self.add(egui::Button::new(text).fill(Color32::TRANSPARENT))
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
fn button_outline(&mut self, text: &str) -> egui::Response {
|
|
123
|
+
let colors = Colors::default();
|
|
124
|
+
self.add(egui::Button::new(text)
|
|
125
|
+
.fill(Color32::TRANSPARENT)
|
|
126
|
+
.stroke(egui::Stroke::new(1.0, colors.border)))
|
|
80
127
|
}
|
|
81
128
|
}
|
|
@@ -1,137 +1,107 @@
|
|
|
1
1
|
//! Design tokens for CronixUI
|
|
2
2
|
|
|
3
|
-
use
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
use egui::{vec2, Rounding};
|
|
4
|
+
|
|
5
|
+
// =============================================================================
|
|
6
|
+
// TYPOGRAPHY TOKENS
|
|
7
|
+
// =============================================================================
|
|
8
|
+
|
|
9
|
+
pub const FONT_FAMILY: &str = "Outfit";
|
|
10
|
+
pub const FONT_MONO: &str = "JetBrains Mono";
|
|
11
|
+
|
|
12
|
+
pub const FONT_SIZE_XS: f32 = 11.0;
|
|
13
|
+
pub const FONT_SIZE_SM: f32 = 12.0;
|
|
14
|
+
pub const FONT_SIZE_BASE: f32 = 13.0;
|
|
15
|
+
pub const FONT_SIZE_MD: f32 = 14.0;
|
|
16
|
+
pub const FONT_SIZE_LG: f32 = 16.0;
|
|
17
|
+
pub const FONT_SIZE_XL: f32 = 20.0;
|
|
18
|
+
pub const FONT_SIZE_2XL: f32 = 28.0;
|
|
19
|
+
pub const FONT_SIZE_3XL: f32 = 36.0;
|
|
20
|
+
|
|
21
|
+
// =============================================================================
|
|
22
|
+
// SPACING TOKENS
|
|
23
|
+
// =============================================================================
|
|
24
|
+
|
|
25
|
+
pub const SPACE_1: f32 = 4.0;
|
|
26
|
+
pub const SPACE_2: f32 = 8.0;
|
|
27
|
+
pub const SPACE_3: f32 = 12.0;
|
|
28
|
+
pub const SPACE_4: f32 = 16.0;
|
|
29
|
+
pub const SPACE_5: f32 = 20.0;
|
|
30
|
+
pub const SPACE_6: f32 = 24.0;
|
|
31
|
+
pub const SPACE_8: f32 = 32.0;
|
|
32
|
+
pub const SPACE_10: f32 = 40.0;
|
|
33
|
+
pub const SPACE_12: f32 = 48.0;
|
|
34
|
+
|
|
35
|
+
// =============================================================================
|
|
36
|
+
// BORDER RADIUS TOKENS
|
|
37
|
+
// =============================================================================
|
|
38
|
+
|
|
39
|
+
pub const RADIUS_SM: f32 = 6.0;
|
|
40
|
+
pub const RADIUS: f32 = 10.0;
|
|
41
|
+
pub const RADIUS_LG: f32 = 14.0;
|
|
42
|
+
pub const RADIUS_XL: f32 = 20.0;
|
|
43
|
+
pub const RADIUS_FULL: f32 = 9999.0;
|
|
44
|
+
|
|
45
|
+
/// Get rounded corners
|
|
46
|
+
pub fn rounded() -> Rounding {
|
|
47
|
+
Rounding::same(RADIUS)
|
|
12
48
|
}
|
|
13
49
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
write!(f, "{}", self.hex)
|
|
17
|
-
}
|
|
50
|
+
pub fn rounded_sm() -> Rounding {
|
|
51
|
+
Rounding::same(RADIUS_SM)
|
|
18
52
|
}
|
|
19
53
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
pub const
|
|
29
|
-
pub const
|
|
30
|
-
pub const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
pub const
|
|
34
|
-
pub const
|
|
35
|
-
pub const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
pub const
|
|
42
|
-
pub const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// Semantic colors - Error
|
|
50
|
-
pub const ERROR: Color = Color { hex: "#501414", r: 80, g: 20, b: 20 };
|
|
51
|
-
pub const ERROR_BORDER: &str = "rgba(180, 60, 60, 0.4)";
|
|
52
|
-
pub const ERROR_TEXT: Color = Color { hex: "#c46b6b", r: 196, g: 107, b: 107 };
|
|
53
|
-
|
|
54
|
-
// Semantic colors - Info
|
|
55
|
-
pub const INFO: Color = Color { hex: "#143550", r: 20, g: 53, b: 80 };
|
|
56
|
-
pub const INFO_BORDER: &str = "rgba(60, 140, 200, 0.4)";
|
|
57
|
-
pub const INFO_TEXT: Color = Color { hex: "#6ba8c4", r: 107, g: 168, b: 196 };
|
|
58
|
-
|
|
59
|
-
// Border colors
|
|
60
|
-
pub const BORDER: &str = "rgba(255, 255, 255, 0.08)";
|
|
61
|
-
pub const BORDER_HOVER: &str = "rgba(255, 255, 255, 0.15)";
|
|
62
|
-
pub const BORDER_FOCUS: &str = "rgba(255, 255, 255, 0.25)";
|
|
63
|
-
|
|
64
|
-
// Typography
|
|
65
|
-
pub const FONT_FAMILY: &str = "'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif";
|
|
66
|
-
pub const FONT_MONO: &str = "'JetBrains Mono', 'Fira Code', 'Consolas', monospace";
|
|
67
|
-
|
|
68
|
-
pub const FONT_SIZE_XS: u8 = 11;
|
|
69
|
-
pub const FONT_SIZE_SM: u8 = 12;
|
|
70
|
-
pub const FONT_SIZE_BASE: u8 = 13;
|
|
71
|
-
pub const FONT_SIZE_MD: u8 = 14;
|
|
72
|
-
pub const FONT_SIZE_LG: u8 = 16;
|
|
73
|
-
pub const FONT_SIZE_XL: u8 = 20;
|
|
74
|
-
pub const FONT_SIZE_2XL: u8 = 28;
|
|
75
|
-
pub const FONT_SIZE_3XL: u8 = 36;
|
|
76
|
-
|
|
77
|
-
// Spacing
|
|
78
|
-
pub const SPACE_1: u8 = 4;
|
|
79
|
-
pub const SPACE_2: u8 = 8;
|
|
80
|
-
pub const SPACE_3: u8 = 12;
|
|
81
|
-
pub const SPACE_4: u8 = 16;
|
|
82
|
-
pub const SPACE_5: u8 = 20;
|
|
83
|
-
pub const SPACE_6: u8 = 24;
|
|
84
|
-
pub const SPACE_8: u8 = 32;
|
|
85
|
-
pub const SPACE_10: u8 = 40;
|
|
86
|
-
pub const SPACE_12: u8 = 48;
|
|
87
|
-
|
|
88
|
-
// Border radius
|
|
89
|
-
pub const RADIUS_SM: u8 = 6;
|
|
90
|
-
pub const RADIUS: u8 = 10;
|
|
91
|
-
pub const RADIUS_LG: u8 = 14;
|
|
92
|
-
pub const RADIUS_XL: u8 = 20;
|
|
93
|
-
pub const RADIUS_FULL: u16 = 9999;
|
|
94
|
-
|
|
95
|
-
// Shadows
|
|
54
|
+
pub fn rounded_lg() -> Rounding {
|
|
55
|
+
Rounding::same(RADIUS_LG)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// =============================================================================
|
|
59
|
+
// Z-INDEX TOKENS
|
|
60
|
+
// =============================================================================
|
|
61
|
+
|
|
62
|
+
pub const Z_INDEX_DROPDOWN: f32 = 100.0;
|
|
63
|
+
pub const Z_INDEX_STICKY: f32 = 200.0;
|
|
64
|
+
pub const Z_INDEX_FIXED: f32 = 300.0;
|
|
65
|
+
pub const Z_INDEX_MODAL_BACKDROP: f32 = 400.0;
|
|
66
|
+
pub const Z_INDEX_MODAL: f32 = 500.0;
|
|
67
|
+
pub const Z_INDEX_POPOVER: f32 = 600.0;
|
|
68
|
+
pub const Z_INDEX_TOOLTIP: f32 = 700.0;
|
|
69
|
+
pub const Z_INDEX_TOAST: f32 = 800.0;
|
|
70
|
+
|
|
71
|
+
// =============================================================================
|
|
72
|
+
// LAYOUT TOKENS
|
|
73
|
+
// =============================================================================
|
|
74
|
+
|
|
75
|
+
pub const CONTAINER_MAX: f32 = 1200.0;
|
|
76
|
+
pub const SIDEBAR_WIDTH: f32 = 260.0;
|
|
77
|
+
pub const HEADER_HEIGHT: f32 = 60.0;
|
|
78
|
+
|
|
79
|
+
// =============================================================================
|
|
80
|
+
// SHADOW TOKENS (as string descriptions)
|
|
81
|
+
// =============================================================================
|
|
82
|
+
|
|
96
83
|
pub const SHADOW_SM: &str = "0 1px 2px rgba(0, 0, 0, 0.3)";
|
|
97
84
|
pub const SHADOW: &str = "0 4px 12px rgba(0, 0, 0, 0.4)";
|
|
98
85
|
pub const SHADOW_LG: &str = "0 8px 24px rgba(0, 0, 0, 0.5)";
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
pub const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
pub const
|
|
113
|
-
pub const
|
|
114
|
-
pub const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
pub
|
|
119
|
-
|
|
120
|
-
#[cfg(test)]
|
|
121
|
-
mod tests {
|
|
122
|
-
use super::*;
|
|
123
|
-
|
|
124
|
-
#[test]
|
|
125
|
-
fn test_colors() {
|
|
126
|
-
assert_eq!(BG.hex, "#0a0a0a");
|
|
127
|
-
assert_eq!(ACCENT.hex, "#6b2323");
|
|
128
|
-
assert_eq!(TEXT.r, 240);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
#[test]
|
|
132
|
-
fn test_spacing() {
|
|
133
|
-
assert_eq!(SPACE_1, 4);
|
|
134
|
-
assert_eq!(SPACE_4, 16);
|
|
135
|
-
assert_eq!(SPACE_12, 48);
|
|
136
|
-
}
|
|
86
|
+
|
|
87
|
+
// =============================================================================
|
|
88
|
+
// TRANSITION TOKENS
|
|
89
|
+
// =============================================================================
|
|
90
|
+
|
|
91
|
+
pub const TRANSITION_FAST: f32 = 0.1;
|
|
92
|
+
pub const TRANSITION: f32 = 0.15;
|
|
93
|
+
pub const TRANSITION_SLOW: f32 = 0.25;
|
|
94
|
+
|
|
95
|
+
// =============================================================================
|
|
96
|
+
// CONTAINER SIZES
|
|
97
|
+
// =============================================================================
|
|
98
|
+
|
|
99
|
+
pub const CONTAINER_SM: f32 = 640.0;
|
|
100
|
+
pub const CONTAINER_MD: f32 = 900.0;
|
|
101
|
+
pub const CONTAINER_LG: f32 = 1200.0;
|
|
102
|
+
pub const CONTAINER_XL: f32 = 1400.0;
|
|
103
|
+
|
|
104
|
+
/// Get container padding
|
|
105
|
+
pub fn container_padding() -> vec2 {
|
|
106
|
+
vec2(SPACE_6, SPACE_6)
|
|
137
107
|
}
|