based/src/ui/primitives/mod.rs
2025-01-15 19:20:46 +01:00

112 lines
2.2 KiB
Rust

use maud::{PreEscaped, html};
pub mod aspect;
pub mod background;
pub mod container;
pub mod div;
pub mod flex;
pub mod header;
pub mod image;
pub mod input;
pub mod link;
pub mod margin;
pub mod padding;
pub mod rounded;
pub mod shadow;
pub mod sized;
pub mod space;
pub mod text;
pub mod width;
#[allow(non_snake_case)]
#[must_use]
pub fn Nothing() -> PreEscaped<String> {
html! {}
}
/// Generates a `<script>` element containing the provided JavaScript code.
///
/// This function wraps the provided JavaScript code in a `<script>` tag,
/// allowing for easy inclusion of custom scripts in the rendered HTML.
///
/// # Arguments
/// * `script` - The JavaScript code to include.
///
/// # Returns
/// A `PreEscaped<String>` containing the rendered `<script>` element.
#[must_use]
pub fn script(script: &str) -> PreEscaped<String> {
html!(
script {
(PreEscaped(script))
};
)
}
pub enum Size {
None,
Small,
Regular,
Medium,
Large,
XL,
_2XL,
_3XL,
Full,
}
impl Size {
#[must_use]
pub const fn to_value(&self) -> &str {
match self {
Self::None => "none",
Self::Small => "sm",
Self::Regular => "",
Self::Medium => "md",
Self::Large => "lg",
Self::XL => "xl",
Self::_2XL => "2xl",
Self::_3XL => "3xl",
Self::Full => "full",
}
}
}
pub enum Side {
Start,
End,
Top,
Right,
Bottom,
Left,
StartStart,
StartEnd,
EndEnd,
EndStart,
TopLeft,
TopRight,
BottomRight,
BottomLeft,
}
impl Side {
#[must_use]
pub const fn to_value(&self) -> &str {
match self {
Self::Start => "s",
Self::End => "e",
Self::Top => "t",
Self::Right => "r",
Self::Bottom => "b",
Self::Left => "l",
Self::StartStart => "ss",
Self::StartEnd => "se",
Self::EndEnd => "ee",
Self::EndStart => "es",
Self::TopLeft => "tl",
Self::TopRight => "tr",
Self::BottomRight => "br",
Self::BottomLeft => "bl",
}
}
}