rooting_forms/
css.rs

1use {
2    rooting::{
3        el,
4        El,
5    },
6};
7
8/// Used for the text label before form fields.
9pub const CSS_CLASS_LABEL: &'static str = "rf_label";
10
11/// Used for single-column inputs (text entry, checkbox). Exclusive with other
12/// `rf_input_` classes.
13pub const CSS_CLASS_SMALL_INPUT: &'static str = "rf_input_small";
14
15/// Used for two-column inputs like text area. Exclusive with other `rf_input_`
16/// classes.
17pub const CSS_CLASS_BIG_INPUT: &'static str = "rf_input_big";
18
19/// Used by the checkbox for options. Exclusive with other `rf_input_` classes.
20pub const CSS_CLASS_OPTION_ENABLE: &'static str = "rf_input_option";
21
22/// Used for validation errors, appears before the input (also before the
23/// associated label, if there is one).
24pub const CSS_CLASS_ERROR: &'static str = "rf_error";
25
26/// Used for nested struct/enum fields, namely within variants or options.
27pub const CSS_CLASS_SUBFORM: &'static str = "rf_subform";
28pub const CSS_CLASS_BUTTON_ICON: &'static str = "rf_button_icon";
29
30/// Text input (div plus contenteditable, get contents with text_contents)
31pub const CSS_CLASS_TEXT: &'static str = "rf_input_text";
32
33/// Used to hide disabled variants - hidden to keep user input in case they
34/// re-enable later.
35pub const CSS_CLASS_HIDDEN: &'static str = "disable_hide";
36pub const CSS_CLASS_VEC: &'static str = "rf_vec";
37pub const CSS_CLASS_VEC_ITEMS: &'static str = "rf_vec_items";
38pub const CSS_CLASS_VEC_ITEM_HEADER: &'static str = "rf_vec_item_header";
39pub const CSS_CLASS_BUTTON_ICON_DELETE: &'static str = "rf_button_delete";
40pub const CSS_CLASS_BUTTON_ICON_ADD: &'static str = "rf_button_add";
41pub const CSS_CLASS_BUTTON_ICON_MOVE_DOWN: &'static str = "rf_button_move_up";
42pub const CSS_CLASS_BUTTON_ICON_MOVE_UP: &'static str = "rf_button_move_down";
43
44/// This should be used on all inputs, since `<label>` isn't used.
45pub const ATTR_LABEL: &'static str = "aria-label";
46
47pub fn css_class_depth(depth: usize) -> String {
48    return format!("rf_depth_m7_{}", 1 + depth % 7);
49}
50
51pub fn err_el() -> El {
52    return el("span").classes(&[CSS_CLASS_ERROR]);
53}