use dioxus::events::MouseEvent;
use dioxus::prelude::EventHandler;
#[derive(PartialEq, Clone)]
pub enum DropdownColorScheme {
Freyr,
Dark,
Light,
Custom(&'static str),
}
impl DropdownColorScheme {
pub fn as_css_class(&self) -> &'static str {
match self {
DropdownColorScheme::Freyr => "#3795BD",
DropdownColorScheme::Dark => "#1E201E",
DropdownColorScheme::Light => "#F7F7F8",
DropdownColorScheme::Custom(color) => color,
}
}
}
#[derive(PartialEq, Clone)]
pub enum DropdownTitleColor {
Freyr,
Dark,
Light,
Custom(&'static str),
}
impl DropdownTitleColor {
pub fn as_css_class(&self) -> &'static str {
match self {
DropdownTitleColor::Freyr => "#3795BD",
DropdownTitleColor::Dark => "#1E201E",
DropdownTitleColor::Light => "#F7F7F8",
DropdownTitleColor::Custom(color) => color,
}
}
}
#[derive(PartialEq, Clone)]
pub enum DropdownLabelsColor {
Freyr,
Dark,
Light,
Custom(&'static str),
}
impl DropdownLabelsColor {
pub fn as_css_class(&self) -> &'static str {
match self {
DropdownLabelsColor::Freyr => "#3795BD",
DropdownLabelsColor::Dark => "#1E201E",
DropdownLabelsColor::Light => "#F7F7F8",
DropdownLabelsColor::Custom(color) => color,
}
}
}
#[derive(PartialEq, Clone)]
pub enum DropdownHoverColor {
Freyr,
Dark,
Light,
Custom(&'static str),
}
impl DropdownHoverColor {
pub fn as_css_class(&self) -> &'static str {
match self {
DropdownHoverColor::Freyr => "#3795BD",
DropdownHoverColor::Dark => "#1E201E",
DropdownHoverColor::Light => "#F7F7F8",
DropdownHoverColor::Custom(color) => color,
}
}
}
#[derive(PartialEq, Clone)]
pub struct DropdownItem {
pub label: String,
pub url: Option<String>,
}
impl DropdownItem {
pub fn new(label: impl Into<String>, url: Option<String>) -> Self {
Self {
label: label.into(),
url,
}
}
pub fn without_url(label: impl Into<String>) -> Self {
Self {
label: label.into(),
url: None,
}
}
}
#[derive(PartialEq, Clone)]
pub struct DropdownConfig {
pub title: String,
pub label: Vec<DropdownItem>,
pub background_color: DropdownColorScheme,
pub title_color: DropdownTitleColor,
pub labels_color: DropdownLabelsColor,
pub hover_color: DropdownHoverColor,
}
#[derive(PartialEq, Clone)]
pub struct DropdownButtonConfig {
pub title: String,
pub labels: Vec<String>,
pub onclick: Vec<EventHandler<MouseEvent>>,
pub background_color: DropdownColorScheme,
pub title_color: DropdownTitleColor,
pub labels_color: DropdownLabelsColor,
pub hover_color: DropdownHoverColor,
}