Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for multiple options in Select #166

Merged
merged 23 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
3c007c7
feat!: Add support for multiple options in Select
tqwewe Apr 15, 2024
d0e96eb
feat: Sync Select menu when value is updated
tqwewe Apr 15, 2024
5b09c9d
feat: Decrease line height of multi select items
tqwewe Apr 15, 2024
7bfd44b
fix: Invalid callback on multiselect tag close
tqwewe Apr 15, 2024
1e595b5
feat: Sync Select menu only for multiple values
tqwewe Apr 15, 2024
d1b0aff
feat: separate `MultiSelect` from `Select` component
tqwewe Apr 19, 2024
cb77f35
fix: SelectLabel slot implementation
tqwewe Apr 19, 2024
751eb72
feat: rename `MultiSelect` to `SelectMulti`
tqwewe Apr 19, 2024
56576ba
feat: rename and move `MultiSelect`
tqwewe Apr 20, 2024
c47bcdf
feat: add arrow to select component
tqwewe Apr 20, 2024
d91d0d5
feat: lower opacity of select dropdown arrow icon
tqwewe Apr 20, 2024
152ffab
fix: inconsistent select font size
tqwewe Apr 20, 2024
d6abfc9
fix: select menu font size
tqwewe Apr 20, 2024
a4a87c6
feat: add clear button to multi select
tqwewe Apr 20, 2024
f64d086
fix: Multi select icon on click attribute
tqwewe Apr 20, 2024
e2c0b2c
feat: use inline-block for select component
tqwewe Apr 20, 2024
95f2335
feat: detect select min width based on options
tqwewe Apr 20, 2024
183a5a0
feat: add `allow_clear` prop to `MultiSelect`
tqwewe Apr 20, 2024
3314ff7
feat: remove select min width detection
tqwewe Apr 21, 2024
d78e671
feat: use `Children` for `SelectLabel`
tqwewe Apr 22, 2024
eafaeda
feat: rename `allow_clear` to `clearable`
tqwewe Apr 22, 2024
c341f37
fix: follower min width
tqwewe Apr 22, 2024
68928ad
feat: remove inline-block from `Select`
tqwewe Apr 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions demo/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ fn TheRouter(is_routing: RwSignal<bool>) -> impl IntoView {
<Route path="/radio" view=RadioMdPage/>
<Route path="/scrollbar" view=ScrollbarMdPage/>
<Route path="/select" view=SelectMdPage/>
<Route path="/select-multi" view=SelectMultiMdPage/>
<Route path="/skeleton" view=SkeletonMdPage/>
<Route path="/slider" view=SliderMdPage/>
<Route path="/space" view=SpaceMdPage/>
Expand Down
15 changes: 3 additions & 12 deletions demo/src/components/switch_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,9 @@ use thaw::*;
#[component]
pub fn SwitchVersion() -> impl IntoView {
let options = vec![
SelectOption {
label: "main".into(),
value: "https://thawui.vercel.app".into(),
},
SelectOption {
label: "0.2.6".into(),
value: "https://thaw-mzh1656cm-thaw.vercel.app".into(),
},
SelectOption {
label: "0.2.5".into(),
value: "https://thaw-8og1kv8zs-thaw.vercel.app".into(),
},
SelectOption::new("main", "https://thawui.vercel.app".into()),
SelectOption::new("0.2.6", "https://thaw-mzh1656cm-thaw.vercel.app".into()),
SelectOption::new("0.2.5", "https://thaw-8og1kv8zs-thaw.vercel.app".into()),
];

cfg_if::cfg_if! {
Expand Down
4 changes: 4 additions & 0 deletions demo/src/pages/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ pub(crate) fn gen_menu_data() -> Vec<MenuGroupOption> {
value: "select".into(),
label: "Select".into(),
},
MenuItemOption {
value: "select-multi".into(),
label: "Select Multiple".into(),
},
MenuItemOption {
value: "slider".into(),
label: "Slider".into(),
Expand Down
18 changes: 9 additions & 9 deletions demo_markdown/docs/select/mod.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@
let value = create_rw_signal(None::<String>);

let options = vec![
SelectOption {
label: String::from("RwSignal"),
value: String::from("rw_signal"),
},
SelectOption {
label: String::from("Memo"),
value: String::from("memo"),
},
SelectOption::new("RwSignal", String::from("rw_signal")),
SelectOption::new("Memo", String::from("memo")),
];

view! {
<Select value options/>
<Select value options />
}
```

Expand All @@ -26,3 +20,9 @@ view! {
| class | `OptionalProp<MaybeSignal<String>>` | `Default::default()` | Addtional classes for the select element. |
| value | `Model<Option<T>>` | `None` | Checked value. |
| options | `MaybeSignal<Vec<SelectOption<T>>>` | `vec![]` | Options that can be selected. |

### Select Slots

| Name | Default | Description |
| ----------- | ------- | ------------- |
| SelectLabel | `None` | Select label. |
38 changes: 38 additions & 0 deletions demo_markdown/docs/select_multi/mod.md
luoxiaozero marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Select Multiple

```rust demo
let values = create_rw_signal(vec![
"rust".to_string(),
"javascript".to_string(),
"zig".to_string(),
"python".to_string(),
"cpp".to_string(),
]);

let options = vec![
SelectOption::new("Rust", String::from("rust")).with_variant(TagVariant::Success),
SelectOption::new("JavaScript", String::from("javascript")),
SelectOption::new("Python", String::from("python")).with_variant(TagVariant::Warning),
SelectOption::new("C++", String::from("cpp")).with_variant(TagVariant::Error),
SelectOption::new("Lua", String::from("lua")),
SelectOption::new("Zig", String::from("zig")),
];

view! {
<SelectMulti values options />
}
```

### Select Multiple Props

| Name | Type | Default | Description |
| ------- | ----------------------------------- | -------------------- | ----------------------------------------- |
| class | `OptionalProp<MaybeSignal<String>>` | `Default::default()` | Addtional classes for the select element. |
| values | `Model<Vec<T>>` | `vec![]` | Checked values. |
| options | `MaybeSignal<Vec<SelectOption<T>>>` | `vec![]` | Options that can be selected. |

### Select Multiple Slots

| Name | Default | Description |
| ----------- | ------- | ------------- |
| SelectLabel | `None` | Select label. |
13 changes: 7 additions & 6 deletions demo_markdown/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use syn::ItemFn;
macro_rules! file_path {
($($key:expr => $value:expr),*) => {
{
let mut pairs = Vec::new();
$(
pairs.push(($key, include_str!($value)));
)*
pairs
vec![
$(
($key, include_str!($value)),
)*
]
}
}
}
Expand Down Expand Up @@ -57,6 +57,7 @@ pub fn include_md(_token_stream: proc_macro::TokenStream) -> proc_macro::TokenSt
"RadioMdPage" => "../docs/radio/mod.md",
"ScrollbarMdPage" => "../docs/scrollbar/mod.md",
"SelectMdPage" => "../docs/select/mod.md",
"SelectMultiMdPage" => "../docs/select_multi/mod.md",
"SkeletonMdPage" => "../docs/skeleton/mod.md",
"SliderMdPage" => "../docs/slider/mod.md",
"SpaceMdPage" => "../docs/space/mod.md",
Expand Down Expand Up @@ -95,7 +96,7 @@ pub fn include_md(_token_stream: proc_macro::TokenStream) -> proc_macro::TokenSt
})
.map(|demo| {
syn::parse_str::<ItemFn>(&demo)
.expect(&format!("Cannot be resolved as a function: \n {demo}"))
.unwrap_or_else(|_| panic!("Cannot be resolved as a function: \n {demo}"))
})
.collect();

Expand Down
2 changes: 2 additions & 0 deletions thaw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mod progress;
mod radio;
mod scrollbar;
mod select;
mod select_multi;
mod skeleton;
mod slider;
mod space;
Expand Down Expand Up @@ -74,6 +75,7 @@ pub use progress::*;
pub use radio::*;
pub use scrollbar::*;
pub use select::*;
pub use select_multi::*;
pub use skeleton::*;
pub use slider::*;
pub use space::*;
Expand Down
Loading