diff --git a/pgml-dashboard/src/components/inputs/checkbox/checkbox.scss b/pgml-dashboard/src/components/inputs/checkbox/checkbox.scss new file mode 100644 index 000000000..dba90026b --- /dev/null +++ b/pgml-dashboard/src/components/inputs/checkbox/checkbox.scss @@ -0,0 +1,17 @@ +div[data-controller="inputs-checkbox"] { + .form-check-label { + padding-left: 8px; + user-select: none; // Annoying to constantly highlight the text when clicking too fast. + } + + .form-check-input { + &:not(:checked) { + border-color: #{$neon-tint-100}; + } + + &:hover { + cursor: pointer; + } + } +} + diff --git a/pgml-dashboard/src/components/inputs/checkbox/mod.rs b/pgml-dashboard/src/components/inputs/checkbox/mod.rs new file mode 100644 index 000000000..24ab7e324 --- /dev/null +++ b/pgml-dashboard/src/components/inputs/checkbox/mod.rs @@ -0,0 +1,26 @@ +use pgml_components::{component, Component}; +use sailfish::TemplateOnce; + +use crate::utils::random_string; + +#[derive(TemplateOnce, Default)] +#[template(path = "inputs/checkbox/template.html")] +pub struct Checkbox { + name: String, + value: String, + label: Component, + id: String, +} + +impl Checkbox { + pub fn new(name: &str, value: &str) -> Checkbox { + Checkbox { + name: name.to_string(), + value: value.to_string(), + label: Component::from(name), + id: random_string(16).to_lowercase(), + } + } +} + +component!(Checkbox); diff --git a/pgml-dashboard/src/components/inputs/checkbox/template.html b/pgml-dashboard/src/components/inputs/checkbox/template.html new file mode 100644 index 000000000..9c2515e55 --- /dev/null +++ b/pgml-dashboard/src/components/inputs/checkbox/template.html @@ -0,0 +1,6 @@ +