use egui::{Color32, CornerRadius, FontId, Style, TextStyle, Vec2, Visuals};
pub mod shadcn {
use super::*;
pub const BG1: Color32 = Color32::from_rgb(0x0A, 0x0A, 0x0A);
pub const BG2: Color32 = Color32::from_rgb(0x17, 0x17, 0x17);
pub const BG4: Color32 = Color32::from_rgb(0x26, 0x26, 0x26);
pub const BG5: Color32 = Color32::from_rgb(0x40, 0x40, 0x40);
pub const BG6: Color32 = Color32::from_rgb(0x52, 0x52, 0x52);
pub const TEXT1: Color32 = Color32::from_rgb(0xFA, 0xFA, 0xFA);
pub const TEXT3: Color32 = Color32::from_rgb(0xA1, 0xA1, 0xA1);
pub const ACCENT2: Color32 = Color32::from_rgb(0x52, 0x52, 0x52);
pub const ACCENT4: Color32 = Color32::from_rgb(0xE5, 0xE5, 0xE5);
pub const BORDER: Color32 = Color32::from_rgba_unmultiplied_const(0xFF, 0xFF, 0xFF, 26);
}
pub mod alert {
use egui::Color32;
pub const INFO: Color32 = Color32::from_rgb(0x18, 0x90, 0xFF);
pub const WARNING: Color32 = Color32::from_rgb(0xFA, 0xAD, 0x14);
pub const ERROR: Color32 = Color32::from_rgb(0xFF, 0x4D, 0x4F);
}
pub mod semantic {
use super::*;
pub const RISE: Color32 = Color32::from_rgb(0xE0, 0x50, 0x50);
pub const FALL: Color32 = Color32::from_rgb(0x2E, 0x9E, 0x2E);
pub const WARN: Color32 = Color32::from_rgb(0xE0, 0x88, 0x10);
pub const ERROR: Color32 = Color32::from_rgb(0xC0, 0x30, 0x30);
pub const OK: Color32 = Color32::from_rgb(0x2E, 0x7D, 0x32);
pub const INFO: Color32 = Color32::from_rgb(0x9A, 0xA8, 0xC0);
pub const MUTED: Color32 = Color32::from_rgb(0x88, 0x88, 0x88);
}
pub const FONT_HEADING: f32 = 22.0;
pub const FONT_BODY: f32 = 16.0;
pub const FONT_SMALL: f32 = 14.0;
pub const FONT_MONO: f32 = 15.0;
pub const CORNER_CARD: u8 = 10;
pub const CORNER_WIDGET: u8 = 8;
pub const STROKE_WIDTH: f32 = 1.0;
pub const SPACING_ITEM_X: f32 = 8.0;
pub const SPACING_ITEM_Y: f32 = 6.0;
pub const INTERACT_HEIGHT: f32 = 26.0;
pub const SCROLL_BAR_WIDTH: f32 = 5.0;
pub const FRAME_INNER: f32 = 8.0;
pub const GROUP_GAP: f32 = 12.0;
pub const MARKET_BAND_HEIGHT: f32 = 240.0;
pub const ORDER_SIDE_WIDTH: f32 = 300.0;
pub fn apply(style: &mut Style) {
style
.text_styles
.insert(TextStyle::Body, FontId::proportional(FONT_BODY));
style
.text_styles
.insert(TextStyle::Button, FontId::proportional(FONT_BODY));
style
.text_styles
.insert(TextStyle::Small, FontId::proportional(FONT_SMALL));
style
.text_styles
.insert(TextStyle::Heading, FontId::proportional(FONT_HEADING));
style
.text_styles
.insert(TextStyle::Monospace, FontId::monospace(FONT_MONO));
style.spacing.item_spacing = Vec2::new(SPACING_ITEM_X, SPACING_ITEM_Y);
style.spacing.interact_size = Vec2::new(40.0, INTERACT_HEIGHT);
style.spacing.scroll = egui::style::ScrollStyle {
bar_width: SCROLL_BAR_WIDTH,
bar_inner_margin: 2.0,
..egui::style::ScrollStyle::solid()
};
}
pub fn visuals() -> Visuals {
use shadcn::*;
let r_card = CornerRadius::same(CORNER_CARD);
let r_widget = CornerRadius::same(CORNER_WIDGET);
let mut v = Visuals::dark();
v.dark_mode = true;
v.window_fill = BG1;
v.panel_fill = BG1;
v.extreme_bg_color = BG1; v.faint_bg_color = BG2; v.hyperlink_color = ACCENT4;
v.weak_text_color = Some(TEXT3);
v.window_stroke = egui::Stroke::new(STROKE_WIDTH, BORDER);
v.window_corner_radius = r_card;
v.menu_corner_radius = r_card;
let stroke1 = egui::Stroke::new(STROKE_WIDTH, TEXT1);
let border = egui::Stroke::new(STROKE_WIDTH, BORDER);
v.widgets.noninteractive = egui::style::WidgetVisuals {
bg_fill: BG1,
weak_bg_fill: BG1,
bg_stroke: border, corner_radius: r_widget,
fg_stroke: stroke1,
expansion: 0.0,
};
v.widgets.inactive = egui::style::WidgetVisuals {
bg_fill: BG4,
weak_bg_fill: BG4,
bg_stroke: border, corner_radius: r_widget,
fg_stroke: stroke1,
expansion: 0.0,
};
v.widgets.hovered = egui::style::WidgetVisuals {
bg_fill: BG5,
weak_bg_fill: BG5,
bg_stroke: border,
corner_radius: r_widget,
fg_stroke: stroke1,
expansion: 0.0,
};
v.widgets.active = egui::style::WidgetVisuals {
bg_fill: BG6,
weak_bg_fill: BG6,
bg_stroke: border,
corner_radius: r_widget,
fg_stroke: stroke1,
expansion: 0.0,
};
v.widgets.open = egui::style::WidgetVisuals {
bg_fill: BG6,
weak_bg_fill: BG6,
bg_stroke: border,
corner_radius: r_widget,
fg_stroke: stroke1,
expansion: 0.0,
};
v.selection = egui::style::Selection {
bg_fill: ACCENT2,
stroke: egui::Stroke::new(STROKE_WIDTH, TEXT1), };
v.interact_cursor = Some(egui::CursorIcon::PointingHand);
v
}
pub fn rise_fall(v: f64) -> Color32 {
if v > 0.0 {
semantic::RISE
} else if v < 0.0 {
semantic::FALL
} else {
shadcn::TEXT1
}
}