thaw/demo/src/pages/checkbox/mod.rs

143 lines
4.7 KiB
Rust
Raw Normal View History

2023-10-03 15:57:35 +08:00
use std::collections::HashSet;
2023-09-21 22:59:35 +08:00
use crate::components::{Demo, DemoCode};
2023-06-13 12:43:15 +08:00
use leptos::*;
2023-10-04 00:11:38 +08:00
use prisms::highlight_str;
use thaw::*;
2023-06-13 12:43:15 +08:00
#[component]
2023-08-29 09:11:22 +08:00
pub fn CheckboxPage() -> impl IntoView {
2023-10-11 09:28:44 +08:00
let checked = create_rw_signal(false);
2023-10-03 15:57:35 +08:00
let value = create_rw_signal(HashSet::new());
2023-08-29 09:11:22 +08:00
view! {
2023-09-21 22:59:35 +08:00
<div style="width: 896px; margin: 0 auto;">
<h1>"Checkbox"</h1>
<Demo>
2023-10-11 09:28:44 +08:00
<Checkbox value=checked>"Click"</Checkbox>
2023-10-08 09:28:13 +08:00
<DemoCode
slot
html=highlight_str!(
r#"
2023-10-10 17:00:08 +08:00
let value = create_rw_signal(false);
2023-09-21 22:59:35 +08:00
2023-10-07 15:43:39 +08:00
view! {
2023-10-10 17:00:08 +08:00
<Checkbox value>
2023-10-07 15:43:39 +08:00
"Click"
</Checkbox>
}
2023-10-08 09:28:13 +08:00
"#,
"rust"
)
>
2023-10-04 00:11:38 +08:00
""
2023-09-21 22:59:35 +08:00
</DemoCode>
</Demo>
2023-10-03 17:57:37 +08:00
<h3>"group"</h3>
2023-10-03 15:57:35 +08:00
<Demo>
<CheckboxGroup value>
2023-10-08 09:28:13 +08:00
<CheckboxItem label="apple" key="a"/>
<CheckboxItem label="b" key="b"/>
<CheckboxItem label="c" key="c"/>
2023-10-03 15:57:35 +08:00
</CheckboxGroup>
2023-10-08 09:28:13 +08:00
<div style="margin-top: 1rem">"value: " {move || format!("{:?}", value.get())}</div>
<DemoCode
slot
html=highlight_str!(
r#"
2023-10-04 00:11:38 +08:00
let value = create_rw_signal(HashSet::new());
2023-10-03 15:57:35 +08:00
2023-10-07 15:43:39 +08:00
view! {
<CheckboxGroup value>
<CheckboxItem label="apple" key="a" />
<CheckboxItem label="b" key="b" />
<CheckboxItem label="c" key="c" />
</CheckboxGroup>
}
2023-10-08 09:28:13 +08:00
"#,
"rust"
)
>
2023-10-04 00:11:38 +08:00
""
2023-10-03 15:57:35 +08:00
</DemoCode>
</Demo>
<h3>"Checkbox Props"</h3>
<Table single_column=true>
<thead>
<tr>
<th>"Name"</th>
<th>"Type"</th>
<th>"Default"</th>
<th>"Description"</th>
</tr>
</thead>
<tbody>
<tr>
<td>"value"</td>
<td>"RwSignal<bool>"</td>
<td>"false"</td>
<td>"Whether the checkbox is being checked."</td>
</tr>
<tr>
<td>"children"</td>
<td>"Children"</td>
<td></td>
<td>"Checkbox's content."</td>
</tr>
</tbody>
</Table>
<h3>"CheckboxGroup Props"</h3>
<Table single_column=true>
<thead>
<tr>
<th>"Name"</th>
<th>"Type"</th>
<th>"Default"</th>
<th>"Description"</th>
</tr>
</thead>
<tbody>
<tr>
<td>"value"</td>
<td>"RwSignal<HashSet<String>>,"</td>
<td>"false"</td>
<td>"Sets the value of the checkbox group."</td>
</tr>
<tr>
<td>"children"</td>
<td>"Children"</td>
<td></td>
<td>"CheckboxGroup's content."</td>
</tr>
</tbody>
</Table>
<h3>"CheckboxItem Props"</h3>
<Table single_column=true>
<thead>
<tr>
<th>"Name"</th>
<th>"Type"</th>
<th>"Default"</th>
<th>"Description"</th>
</tr>
</thead>
<tbody>
<tr>
<td>"key"</td>
<td>"String"</td>
<td></td>
<td>"The key of the checkbox to be used in a checkbox group."</td>
</tr>
<tr>
<td>"label"</td>
<td>"Option<String>"</td>
<td>"None"</td>
<td>"Checkbox's label."</td>
</tr>
</tbody>
</Table>
2023-06-13 12:43:15 +08:00
</div>
}
}