rustcn_ui/input/
style.rs

1//ui/input/style.rs
2
3use super::props::{InputSize, InputVariants};
4
5pub const BASE_CLASS: &str = "flex h-9 rounded-md border border-input bg-transparent text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50";
6
7const VARIANT_DEFAULT: &str = "bg-white";
8const VARIANT_OUTLINE: &str = "border-2";
9const VARIANT_UNDERLINE: &str = "border-b-2 border-t-0 border-l-0 border-r-0";
10const VARIANT_FLUSHED: &str = "border-b-2";
11const VARIANT_FILLED: &str = "bg-gray-200";
12
13const SIZE_DEFAULT: &str = "px-3 py-1";
14const SIZE_SM: &str = "text-xs px-2 py-0.5";
15const SIZE_LG: &str = "text-lg px-4 py-2";
16
17pub fn get_variant_class(variant: &InputVariants) -> &str {
18    match variant {
19        InputVariants::Default => VARIANT_DEFAULT,
20        InputVariants::_Outline => VARIANT_OUTLINE,
21        InputVariants::_Filled => VARIANT_FILLED,
22        InputVariants::_Flushed => VARIANT_FLUSHED,
23        InputVariants::_Underline => VARIANT_UNDERLINE,
24    }
25}
26
27// Function to get the size CSS class
28pub fn get_size_class(size: &InputSize) -> &str {
29    match size {
30        InputSize::_SM => SIZE_SM,
31        InputSize::_LG => SIZE_LG,
32        _ => SIZE_DEFAULT,
33    }
34}