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 @@ +
+
+ + +
+
diff --git a/pgml-dashboard/src/components/inputs/mod.rs b/pgml-dashboard/src/components/inputs/mod.rs index aeb4ce153..cd9cbffac 100644 --- a/pgml-dashboard/src/components/inputs/mod.rs +++ b/pgml-dashboard/src/components/inputs/mod.rs @@ -1,6 +1,10 @@ // This file is automatically generated. // You shouldn't modify it manually. +// src/components/inputs/checkbox +pub mod checkbox; +pub use checkbox::Checkbox; + // src/components/inputs/radio pub mod radio; pub use radio::Radio; diff --git a/pgml-dashboard/src/components/pages/careers/apply/template.html b/pgml-dashboard/src/components/pages/careers/apply/template.html index bb1eafeab..e5b536ee7 100644 --- a/pgml-dashboard/src/components/pages/careers/apply/template.html +++ b/pgml-dashboard/src/components/pages/careers/apply/template.html @@ -4,7 +4,7 @@ use crate::components::sections::Split; use crate::components::PostgresLogo; - let eyebrow_formated = r#"APPLY NOW"#; + let eyebrow_formatted = r#"Apply now"#; let path = format!("/careers/apply/{}",job_title.replace(" ", "-").to_lowercase()); @@ -105,8 +105,7 @@ <%+ Split::new() - .eyebrow(Component::from(eyebrow_formated)) - .title(Component::from(job_title)) + .greeting(Component::from(eyebrow_formatted), Component::from(job_title)) .display_area(Component::from(display_area)) .with_navbar() %> diff --git a/pgml-dashboard/src/components/pages/demo/template.html b/pgml-dashboard/src/components/pages/demo/template.html index 187dc1ce7..e64f90b78 100644 --- a/pgml-dashboard/src/components/pages/demo/template.html +++ b/pgml-dashboard/src/components/pages/demo/template.html @@ -6,7 +6,7 @@ <% use crate::components::stimulus::StimulusAction; %> <% use crate::components::inputs::RangeGroupV2; %> <% use crate::components::inputs::select::{Select, Option}; %> -<% use crate::components::inputs::{SwitchV2, Radio}; %> +<% use crate::components::inputs::{SwitchV2, Radio, Checkbox}; %> <% use crate::components::cards::{Rgb, Secondary, Primary}; %>
@@ -186,4 +186,19 @@
+ +
+
+
+
+ <%+ Checkbox::new("Inline checkbox", "inline") %> +
+
+
+
+
+ <%+ Checkbox::new("Take full width checkbox", "block") %> +
+
+
diff --git a/pgml-dashboard/src/components/sections/split/greeting.html b/pgml-dashboard/src/components/sections/split/greeting.html new file mode 100644 index 000000000..480dfcb37 --- /dev/null +++ b/pgml-dashboard/src/components/sections/split/greeting.html @@ -0,0 +1,10 @@ +
+
+ + <%+ eyebrow %> + +
+

+ <%+ title %> +

+
diff --git a/pgml-dashboard/src/components/sections/split/mod.rs b/pgml-dashboard/src/components/sections/split/mod.rs index 25d627f80..04d400c72 100644 --- a/pgml-dashboard/src/components/sections/split/mod.rs +++ b/pgml-dashboard/src/components/sections/split/mod.rs @@ -1,3 +1,5 @@ +//! Left/right split used in onboarding, signup, careers, etc. + use pgml_components::component; use pgml_components::Component; use sailfish::TemplateOnce; @@ -5,29 +7,45 @@ use sailfish::TemplateOnce; #[derive(TemplateOnce, Default)] #[template(path = "sections/split/template.html")] pub struct Split { - eyebrow: Component, - title: Component, + greeting_area: Component, display_area: Component, with_navbar: bool, } +// Greeting with its own styling. +#[derive(TemplateOnce, Default, Clone)] +#[template(path = "sections/split/greeting.html")] +pub struct Greeting { + eyebrow: Component, + title: Component, +} + +component!(Greeting); + +impl Greeting { + pub fn new(eyebrow: Component, title: Component) -> Greeting { + Greeting { eyebrow, title } + } +} + impl Split { pub fn new() -> Split { Split { - eyebrow: Component::from(String::from("")), - title: Component::from(String::from("")), - display_area: Component::from(String::from("")), + greeting_area: Component::default(), + display_area: Component::default(), with_navbar: false, } } - pub fn eyebrow(mut self, eyebrow: Component) -> Split { - self.eyebrow = eyebrow; + // Set the greeting. + pub fn greeting(mut self, eyebrow: Component, title: Component) -> Split { + self.greeting_area = Greeting::new(eyebrow, title).into(); self } - pub fn title(mut self, title: Component) -> Split { - self.title = title; + // Set whatever you want on the left side of the display. + pub fn greeting_area(mut self, greeting_area: Component) -> Split { + self.greeting_area = greeting_area; self } diff --git a/pgml-dashboard/src/components/sections/split/split.scss b/pgml-dashboard/src/components/sections/split/split.scss index d4c03751d..3660204e0 100644 --- a/pgml-dashboard/src/components/sections/split/split.scss +++ b/pgml-dashboard/src/components/sections/split/split.scss @@ -7,11 +7,11 @@ div[data-controller="sections-split"] { } } - .signup-left { + .sections-split-left { background: #{$gray-700}; } - .signup-right { + .sections-split-right { position: relative; background-color: #{$gray-800}; overflow: hidden; diff --git a/pgml-dashboard/src/components/sections/split/template.html b/pgml-dashboard/src/components/sections/split/template.html index 3e1a1bb4a..41b76fccc 100644 --- a/pgml-dashboard/src/components/sections/split/template.html +++ b/pgml-dashboard/src/components/sections/split/template.html @@ -1,42 +1,23 @@ -<% - use pgml_components::Component; - - let greeting = format!(r#" -
-
- - {} - -
-

- {} -

-
- "#, - eyebrow.render_once().unwrap(), - title.render_once().unwrap()); -%> - -
+
-
-