diff --git a/demo/src/app.rs b/demo/src/app.rs index 1afd4ac..979405e 100644 --- a/demo/src/app.rs +++ b/demo/src/app.rs @@ -84,6 +84,7 @@ fn TheRouter() -> impl IntoView { + diff --git a/demo/src/pages/components.rs b/demo/src/pages/components.rs index 54e97c9..afacbff 100644 --- a/demo/src/pages/components.rs +++ b/demo/src/pages/components.rs @@ -297,6 +297,11 @@ pub(crate) fn gen_nav_data() -> Vec { value: "/components/input", label: "Input", }, + NavItemOption { + group: None, + value: "/components/label", + label: "Label", + }, NavItemOption { group: None, value: "/components/layout", diff --git a/demo_markdown/docs/_guide/installation.md b/demo_markdown/docs/_guide/installation.md index cd69fa2..67ecd0e 100644 --- a/demo_markdown/docs/_guide/installation.md +++ b/demo_markdown/docs/_guide/installation.md @@ -8,7 +8,9 @@ cargo add thaw --features=csr - "If you are using the nightly feature in Leptos, please enable Thaw's nightly as well." +
+ "If you are using the nightly feature in Leptos, please enable Thaw's nightly as well." +
diff --git a/demo_markdown/src/lib.rs b/demo_markdown/src/lib.rs index cce3490..b581023 100644 --- a/demo_markdown/src/lib.rs +++ b/demo_markdown/src/lib.rs @@ -47,6 +47,7 @@ pub fn include_md(_token_stream: proc_macro::TokenStream) -> proc_macro::TokenSt "IconMdPage" => "../../thaw/src/icon/docs/mod.md", "ImageMdPage" => "../../thaw/src/image/docs/mod.md", "InputMdPage" => "../../thaw/src/input/docs/mod.md", + "LabelMdPage" => "../../thaw/src/label/docs/mod.md", "LayoutMdPage" => "../../thaw/src/layout/docs/mod.md", "LinkMdPage" => "../../thaw/src/link/docs/mod.md", "LoadingBarMdPage" => "../../thaw/src/loading_bar/docs/mod.md", diff --git a/thaw/src/drawer/mod.rs b/thaw/src/drawer/mod.rs index 13500a8..6a0b562 100644 --- a/thaw/src/drawer/mod.rs +++ b/thaw/src/drawer/mod.rs @@ -58,7 +58,7 @@ impl DrawerSize { #[derive(Debug, Default, PartialEq)] pub enum DrawerModalType { /// When this type of dialog is open, - /// the rest of the page is dimmed out and cannot be interacted with. + /// the rest of the page is dimmed out and cannot be interacted with. #[default] Modal, /// When a non-modal dialog is open, diff --git a/thaw/src/field/docs/mod.md b/thaw/src/field/docs/mod.md index 91706f1..62b13a1 100644 --- a/thaw/src/field/docs/mod.md +++ b/thaw/src/field/docs/mod.md @@ -154,7 +154,7 @@ view! { | label | `MaybeProp` | `Default::default()` | The label associated with the field. | | name | `MaybeProp` | `Default::default()` | A string specifying a name for the input control. This name is submitted along with the control's value when the form data is submitted. | | orientation | `MaybeSignal` | `FieldOrientation::Vertical` | The orientation of the label relative to the field component. | -| reqired | `MaybeSignal` | `false` | If set to true this field will be marked as required. | +| required | `MaybeSignal` | `false` | If set to true this field will be marked as required. | | children | `Children` | | | ### FieldContextProvider Props diff --git a/thaw/src/field/field.css b/thaw/src/field/field.css index 579a3d1..f8ee98f 100644 --- a/thaw/src/field/field.css +++ b/thaw/src/field/field.css @@ -6,15 +6,6 @@ margin-bottom: var(--spacingVerticalXXS); padding-bottom: var(--spacingVerticalXXS); padding-top: var(--spacingVerticalXXS); - line-height: var(--lineHeightBase300); - font-size: var(--fontSizeBase300); - font-family: var(--fontFamilyBase); - color: var(--colorNeutralForeground1); -} - -.thaw-field__label--required { - padding-left: var(--spacingHorizontalXS); - color: var(--colorPaletteRedForeground3); } .thaw-field--horizontal { diff --git a/thaw/src/field/field.rs b/thaw/src/field/field.rs index eecfcfa..0383101 100644 --- a/thaw/src/field/field.rs +++ b/thaw/src/field/field.rs @@ -1,5 +1,6 @@ +use crate::Label; use leptos::{context::Provider, either::EitherOf3, prelude::*}; -use thaw_components::{OptionComp, If, Then}; +use thaw_components::OptionComp; use thaw_utils::{class_list, mount_style}; use uuid::Uuid; @@ -47,14 +48,13 @@ pub fn Field( move || { view! { - } } diff --git a/thaw/src/label/docs/mod.md b/thaw/src/label/docs/mod.md new file mode 100644 index 0000000..8882da1 --- /dev/null +++ b/thaw/src/label/docs/mod.md @@ -0,0 +1,57 @@ +# Label + +```rust demo +view! { + +} +``` + +### Size + +```rust demo +view! { + + + + + +} +``` + +### Weight + +```rust demo +view! { + + + + +} +``` + +### Disabled + +```rust demo +view! { + +} +``` + +### Required + +```rust demo +view! { + +} +``` + +### Label Props + +| Name | Type | Default | Desciption | +| --- | --- | --- | --- | +| class | `MaybeProp` | `Default::default()` | | +| size | `MaybeSignal` | `LabelSize::Medium` | A label supports different sizes. | +| weight | `MaybeSignal` | `LabelWeight::Regular` | A label supports regular and semibold fontweight. | +| disabled | `MaybeSignal` | `false` | Renders the label as disabled. | +| required | `MaybeSignal` | `false` | Displays an indicator that the label is for a required field. | +| children | `Children` | | | diff --git a/thaw/src/label/label.css b/thaw/src/label/label.css new file mode 100644 index 0000000..e445668 --- /dev/null +++ b/thaw/src/label/label.css @@ -0,0 +1,34 @@ +.thaw-label { + line-height: var(--lineHeightBase300); + font-size: var(--fontSizeBase300); + font-family: var(--fontFamilyBase); + color: var(--colorNeutralForeground1); +} + +.thaw-label__required { + padding-left: var(--spacingHorizontalXS); + color: var(--colorPaletteRedForeground3); +} + +.thaw-label--disabled { + color: var(--colorNeutralForegroundDisabled); +} + +.thaw-label--disabled .thaw-label__required { + color: var(--colorNeutralForegroundDisabled); +} + +.thaw-label--small { + font-size: var(--fontSizeBase200); + line-height: var(--lineHeightBase200); +} + +.thaw-label--large { + font-weight: var(--fontWeightSemibold); + font-size: var(--fontSizeBase400); + line-height: var(--lineHeightBase400); +} + +.thaw-label--semibold { + font-weight: var(--fontWeightSemibold); +} diff --git a/thaw/src/label/label.rs b/thaw/src/label/label.rs new file mode 100644 index 0000000..3fa77a0 --- /dev/null +++ b/thaw/src/label/label.rs @@ -0,0 +1,75 @@ +use leptos::prelude::*; +use thaw_components::{If, Then}; +use thaw_utils::{class_list, mount_style}; + +#[component] +pub fn Label( + #[prop(optional, into)] class: MaybeProp, + /// A label supports different sizes. + #[prop(optional, into)] + size: MaybeSignal, + /// A label supports regular and semibold fontweight. + #[prop(optional, into)] + weight: MaybeSignal, + /// Displays an indicator that the label is for a required field. + #[prop(optional, into)] + required: MaybeSignal, + /// Renders the label as disabled. + #[prop(optional, into)] + disabled: MaybeSignal, + children: Children, +) -> impl IntoView { + mount_style("label", include_str!("./label.css")); + + view! { + + } +} + +#[derive(Debug, Default, Clone)] +pub enum LabelSize { + Small, + #[default] + Medium, + Large, +} + +impl LabelSize { + pub fn as_str(&self) -> &'static str { + match self { + Self::Small => "small", + Self::Medium => "medium", + Self::Large => "large", + } + } +} + +#[derive(Debug, Default, Clone)] +pub enum LabelWeight { + #[default] + Regular, + Semibold, +} + +impl LabelWeight { + pub fn as_str(&self) -> &'static str { + match self { + Self::Regular => "regular", + Self::Semibold => "semibold", + } + } +} diff --git a/thaw/src/label/mod.rs b/thaw/src/label/mod.rs new file mode 100644 index 0000000..ea3183f --- /dev/null +++ b/thaw/src/label/mod.rs @@ -0,0 +1,3 @@ +mod label; + +pub use label::*; diff --git a/thaw/src/lib.rs b/thaw/src/lib.rs index 856fab1..9e253aa 100644 --- a/thaw/src/lib.rs +++ b/thaw/src/lib.rs @@ -24,6 +24,7 @@ mod grid; mod icon; mod image; mod input; +mod label; mod layout; mod link; mod loading_bar; @@ -79,6 +80,7 @@ pub use grid::*; pub use icon::*; pub use image::*; pub use input::*; +pub use label::*; pub use layout::*; pub use link::*; pub use loading_bar::*; diff --git a/thaw/src/space/docs/mod.md b/thaw/src/space/docs/mod.md index 0fe719b..3a03e4e 100644 --- a/thaw/src/space/docs/mod.md +++ b/thaw/src/space/docs/mod.md @@ -1,5 +1,13 @@ # Space + + +
+ "The Space component may be removed in future versions. It is recommended to use the Flex component." +
+
+
+ ```rust demo view! {