-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into golota60-patch-1
- Loading branch information
Showing
12 changed files
with
205 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
use floem::{ | ||
style::Style, | ||
view::View, | ||
views::{h_stack, Decorators}, | ||
}; | ||
use oxytail_base::widgets::{ | ||
badge::{badge, BadgeProps}, | ||
common_props::{OxySize, OxyVariant}, | ||
}; | ||
|
||
fn variant_badge(name: &'static str, variant: OxyVariant) -> impl View { | ||
badge( | ||
name, | ||
Some(BadgeProps { | ||
variant, | ||
..Default::default() | ||
}), | ||
) | ||
} | ||
|
||
pub fn badges_variants() -> impl View { | ||
h_stack(( | ||
variant_badge("default", OxyVariant::Default), | ||
variant_badge("neutral", OxyVariant::Neutral), | ||
variant_badge("primary", OxyVariant::Primary), | ||
variant_badge("secondary", OxyVariant::Secondary), | ||
variant_badge("accent", OxyVariant::Accent), | ||
variant_badge("ghost", OxyVariant::Ghost), | ||
variant_badge("link", OxyVariant::Link), | ||
variant_badge("info", OxyVariant::Info), | ||
variant_badge("success", OxyVariant::Success), | ||
variant_badge("warning", OxyVariant::Warning), | ||
variant_badge("error", OxyVariant::Error), | ||
)) | ||
.style(|s: Style| s.gap(4., 4.)) | ||
} | ||
|
||
fn size_badge(name: &'static str, size: OxySize) -> impl View { | ||
badge( | ||
name, | ||
Some(BadgeProps { | ||
size, | ||
..Default::default() | ||
}), | ||
) | ||
} | ||
|
||
pub fn badges_sizes() -> impl View { | ||
h_stack(( | ||
size_badge("large", OxySize::Large), | ||
size_badge("normal", OxySize::Normal), | ||
size_badge("small", OxySize::Small), | ||
size_badge("tiny", OxySize::Tiny), | ||
)) | ||
.style(|s: Style| s.gap(4., 4.)) | ||
} | ||
|
||
pub fn badges_outlines() -> impl View { | ||
h_stack(( | ||
badge( | ||
"outlined default", | ||
Some(BadgeProps { | ||
outlined: true, | ||
..Default::default() | ||
}), | ||
), | ||
badge( | ||
"outlined primary", | ||
Some(BadgeProps { | ||
outlined: true, | ||
variant: OxyVariant::Primary, | ||
..Default::default() | ||
}), | ||
), | ||
badge( | ||
"outlined secondary", | ||
Some(BadgeProps { | ||
outlined: true, | ||
variant: OxyVariant::Secondary, | ||
..Default::default() | ||
}), | ||
), | ||
)) | ||
.style(|s: Style| s.gap(4., 4.)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use floem::{ | ||
view::View, | ||
views::{label as upstreamlabel, Decorators}, | ||
}; | ||
|
||
use crate::get_current_theme; | ||
|
||
use super::common_props::{OxySize, OxyVariant}; | ||
|
||
#[derive(Default, Copy, Clone)] | ||
pub struct BadgeProps { | ||
pub variant: OxyVariant, | ||
pub size: OxySize, | ||
pub outlined: bool, | ||
} | ||
|
||
pub fn badge(label: &'static str, props: Option<BadgeProps>) -> impl View { | ||
let base_widget = upstreamlabel(move || label); | ||
let theme = get_current_theme(); | ||
|
||
let props = props.unwrap_or(BadgeProps::default()); | ||
let styles_enhancer = theme.get_badge_style(props); | ||
|
||
let styled_badge = base_widget.style(move |s| styles_enhancer(s)); | ||
|
||
styled_badge | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ pub mod radio_button; | |
pub mod text_header; | ||
pub mod text_divider; | ||
pub mod tooltip; | ||
pub mod badge; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters