Skip to content

Commit c782fcd

Browse files
authored
Feat/button block (#135)
* feat: Button adds class block prop * feat: ButtonGroup adds class prop
1 parent eecf86c commit c782fcd

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

demo_markdown/docs/button/mod.md

+16-4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,16 @@ view! {
136136
}
137137
```
138138

139+
### Block
140+
141+
```rust demo
142+
view! {
143+
<Space vertical=true>
144+
<Button block=true>"Primary"</Button>
145+
</Space>
146+
}
147+
```
148+
139149
### Group
140150

141151
```rust demo
@@ -163,6 +173,7 @@ view! {
163173
| style | `Option<MaybeSignal<String>>` | `Default::default()` | Button's style. |
164174
| variant | `MaybeSignal<ButtonVariant>` | `ButtonVariant::Primary` | Button's variant. |
165175
| color | `MaybeSignal<ButtonColor>` | `ButtonColor::Primary` | Button's color. |
176+
| block | `MaybeSignal<bool>` | `false` | Whether the button is displayed as block. |
166177
| round | `MaybeSignal<bool>` | `false` | Whether the button shows rounded corners. |
167178
| circle | `MaybeSignal<bool>` | `false` | Whether the button is round. |
168179
| icon | `OptionalMaybeSignal<icondata_core::Icon>` | `None` | The icon of the button. |
@@ -174,7 +185,8 @@ view! {
174185

175186
### ButtonGroup props
176187

177-
| Name | Type | Default | Description |
178-
| -------- | ---------- | ------- | ----------------------------------- |
179-
| vertical | `bool` | `false` | Directions of buttons in the group. |
180-
| children | `Children` | | ButtonGroup's content. |
188+
| Name | Type | Default | Description |
189+
| -------- | ----------------------------------- | -------------------- | ----------------------------------------- |
190+
| class | `OptionalProp<MaybeSignal<String>>` | `Default::default()` | Additional classes for the group element. |
191+
| vertical | `bool` | `false` | Directions of buttons in the group. |
192+
| children | `Children` | | ButtonGroup's content. |

thaw/src/button/button.css

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
transition: all 0.3s;
2222
}
2323

24+
.thaw-button--block {
25+
display: flex;
26+
width: 100%;
27+
}
28+
2429
.thaw-button--disabled:not(.thaw-button--text, .thaw-button--link) {
2530
border-color: var(--thaw-border-color-disabled);
2631
background-color: var(--thaw-background-color-disabled);

thaw/src/button/button_group.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
use crate::utils::mount_style;
1+
use crate::utils::{class_list::class_list, mount_style, OptionalProp};
22
use leptos::*;
33

44
#[component]
5-
pub fn ButtonGroup(#[prop(optional)] vertical: bool, children: Children) -> impl IntoView {
5+
pub fn ButtonGroup(
6+
#[prop(optional, into)] class: OptionalProp<MaybeSignal<String>>,
7+
#[prop(optional)] vertical: bool,
8+
children: Children,
9+
) -> impl IntoView {
610
mount_style("button-group", include_str!("./button-group.css"));
711
view! {
8-
<div class="thaw-button-group" class=("thaw-button-group--vertical", vertical)>
12+
<div class=class_list!["thaw-button-group", class.map(| c | move || c.get())] class=("thaw-button-group--vertical", vertical)>
913
{children()}
1014
</div>
1115
}

thaw/src/button/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ pub fn Button(
102102
#[prop(optional, into)] variant: MaybeSignal<ButtonVariant>,
103103
#[prop(optional, into)] color: MaybeSignal<ButtonColor>,
104104
#[prop(optional, into)] size: MaybeSignal<ButtonSize>,
105+
#[prop(optional, into)] block: MaybeSignal<bool>,
105106
#[prop(optional, into)] round: MaybeSignal<bool>,
106107
#[prop(optional, into)] circle: MaybeSignal<bool>,
107108
#[prop(optional, into)] icon: OptionalMaybeSignal<icondata_core::Icon>,
@@ -228,7 +229,7 @@ pub fn Button(
228229
ButtonVariant::Text), ("thaw-button--link", move || variant.get() ==
229230
ButtonVariant::Link), ("thaw-button--round", move || round.get()),
230231
("thaw-button--circle", move || circle.get()), ("thaw-button--disabled", move ||
231-
disabled.get()), class.map(| c | move || c.get())
232+
disabled.get()), ("thaw-button--block", move || block.get()), class.map(| c | move || c.get())
232233
]
233234

234235
style=move || {

0 commit comments

Comments
 (0)