Dioxus-components, tested button,checkbox,alert-dialog works bad
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 49/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- rust
- Domain
- frontend, testing-qa
Research direction
Start by reading the reported main.rs usage of Checkbox, Button, and AlertDialog, then compare it with the component examples and tests in the repository. Reproduce the reported behavior with Dioxus 0.7.10 and the listed component versions; the issue includes no repository test or specific expected behavior, so first pin down which component fails and what correct behavior should be.
Written by the indexing model from the issue text.
Description
develop environment:
macOS 27.0.1
rust 1.99.1
problem
Cargo.toml
dioxus = { version = "0.7.10", features = ["desktop"] }
after dx components add ...
Cargo.toml
dioxus = { version = "0.7.10", features = ["desktop"] }
dioxus-icons = { version = "0.1.0", default-features = false }
dioxus-primitives = { git = "https://github.com/DioxusLabs/components", version = "0.0.1", default-features = false }
using terminal.app add components
ai2soft@Mac-Mini test_Dioxus % dx components add button
Updating git repository `https://github.com/DioxusLabs/components`
warning: spurious network error (3 tries remaining): error receiving data from socket: Broken pipe; class=Net (12)
warning: spurious network error (2 tries remaining): error receiving data from socket: Broken pipe; class=Net (12)
warning: spurious network error (1 try remaining): SecureTransport error: connection closed via error; class=Net (12)
Adding dioxus-primitives (git) to dependencies
Features:
- router
- web
Updating git repository `https://github.com/DioxusLabs/components`
Updating crates.io index
Locking 12 packages to highest Rust 1.99.1 compatible versions
Adding approx v0.5.1
Adding by_address v1.2.1
Adding dioxus-attributes v0.1.0 (https://github.com/DioxusLabs/components#9a758255)
Adding dioxus-primitives v0.0.1 (https://github.com/DioxusLabs/components#9a758255)
Adding dioxus-sdk-time v0.7.0
Adding futures v0.3.34
Adding num_threads v0.1.8
Adding palette v0.7.7
Adding palette_derive v0.7.7
Adding palette_math v0.7.7
Adding phf v0.13.1
Adding phf_shared v0.13.1
ai2soft@Mac-Mini test_Dioxus % dx components add checkbox
warning: Waiting for cargo-metadata...
Updating git repository `https://github.com/DioxusLabs/components`
Adding dioxus-primitives (git) to dependencies
Features:
- router
- web
Updating crates.io index
Adding dioxus-icons v0.1.0 to dependencies
Updating crates.io index
Locking 1 package to highest Rust 1.99.1 compatible version
Adding dioxus-icons v0.1.0
ai2soft@Mac-Mini test_Dioxus % dx components add alert_dialog
Updating git repository `https://github.com/DioxusLabs/components`
Adding dioxus-primitives (git) to dependencies
Features:
- router
- web
ai2soft@Mac-Mini test_Dioxus %
main.rs
mod hooks;
mod components;
use dioxus::prelude::*;
use components::checkbox::*;
use components::alert_dialog::*;
use components::button::*;
static CSS: Asset = asset!("/assets/main.css");
static metro_ui_main: Asset = asset!("/assets/metroUI/5.1.2/metro.css");
static metro_ui_icon: Asset = asset!("/assets/metroUI/5.1.2/icons.css");
static metro_ui_js: Asset = asset!("/assets/metroUI/5.1.2/metro.js");
static dx_componens: Asset = asset!("/assets/dx-components-theme.css");
fn main() {
launch(app);
}
#[component]
fn app() -> Element {
hooks::metro::use_metro();
// 每次DOM挂载/更新后执行 Metro.init(),解决Dioxus diff后控件失效
// use_effect(|| {
// // 调用全局 Metro.init
// let _ = document::eval(r#"
// if (window.Metro) {
// Metro.init();
// }
// "#);
// });
//let mut count = use_signal(|| 0);
// rsx! {
// h1 { "Hello Dioxus, counter: {count}" }
// button { onclick: move |_| count += 1, "加 1" }
// button { onclick: move |_| count -= 1, "减 1" }
// }
const img1: &'static str = "/Users/ai2soft/Pictures/【哲风壁纸】书法背景-国风.jpg";
const img2: &'static str = "/Users/ai2soft/Pictures/【哲风壁纸】人像写真-侧颜-吊带.jpg";
// 钩子适合处理组件的局部状态
let mut img_src = use_signal(||{ img1 });
let mut open = use_signal(|| false);
let mut confirmed = use_signal(|| false);
rsx! {
document::Stylesheet { href: dx_componens} // ?? is it need ?
/*
document::Stylesheet { href: metro_ui_main }
document::Stylesheet { href: metro_ui_icon }
document::Script { src : metro_ui_js } // JS 必须写在 Stylesheet 后面,并且在 App 根 rsx 里全局引入一次即可
*/
/*
div {
id : "title",
h1 { "Hot Dog! 👻" }
}
div {
id : "dogView",
img {
src: "{img_src}",
width: 200,
height: 433
}
}
div {
id : "buttons",
button {
id: "button1",
onclick: move |_| {
img_src.set(img2)
},
"change"
}
button {
id: "button2",
onclick: move |_| {
img_src.set(img1)
},
"change back",
}
}
h2 { "Dioxus + MetroUI 5.1.2 Demo" }
// MetroUI 原生控件示例
button { class: "button primary", "Primary Button" }
button { class: "button success", "Success Button" }
button { class: "button danger", "Danger Button" }
br {}
br {}
div { class: "input-group",
input { r#type: "text", placeholder: "Metro input" }
button { class: "button", "Search" }
}
br {}
// Dropdown 下拉(需要Metro.init才能生效)
div { class: "dropdown",
button { class: "button dropdown-toggle", "Dropdown Menu" }
ul { class: "dropdown-menu",
"data-role" : "dropmenu",
li { a { href: "#", "Item 1" } }
li { a { href: "#", "Item 2" } }
li { a { href: "#", "Item 3" } }
}
}
div {
class : "container p-4",
br {}
button {
class : "button primary",
onclick: move |_| {
// 弹窗示例
let ret = document::eval(r#"Metro.dialog.open("Hello from Dioxus + MetroUI!")"#);
println!("result = .....")
},
"Hello Metro UI",
}
}
*/
br {}
form {
"data-testid": "checkbox-form",
style: "display: grid; gap: 1rem; max-width: 24rem;",
Checkbox {
name: "tos-check",
value: "accepted",
// label: "Accept terms and conditions",
aria_label: "Accept terms and conditions",
}
Checkbox {
name: "managed-setting",
value: "locked",
// label: "Managed setting",
default_checked: dioxus_primitives::checkbox::CheckboxState::Checked,
disabled: true,
}
}
br {}
div {
Button {
r#type: "button",
"data-style": "outline",
style: "margin-bottom: 1.5rem;",
onclick: move |_| open.set(true),
"Show Alert Dialog"
}
AlertDialog { open: open(), on_open_change: move |v| open.set(v),
AlertDialogTitle { "Delete item" }
AlertDialogDescription { "Are you sure you want to delete this item? This action cannot be undone." }
AlertDialogActions {
AlertDialogCancel { "Cancel" }
AlertDialogAction { on_click: move |_| confirmed.set(true), "Delete" }
}
}
if confirmed() {
p { style: "color: var(--contrast-error-color); margin-top: 16px; font-weight: 600;",
"Item deleted!"
}
}
}
}
}
run video
https://mega.nz/file/I79XCZhK#dVZ2e7jpoDuLe4rK9te605w8Xkon95ehdpbYxJa_Ytw
- Dominant language
- Rust
- Stars
- 358
- Forks
- 90
- Avg merge
- 54m
- Merged PRs (30d)
- 1
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DioxusLabs/dioxus-components
-
Roving-focus re-focus dismisses a just-opened modal Dialog (focusin light-dismiss)Possibly taken @5at15h claimed this 44 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
DioxusLabs/dioxus-components#303 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
DioxusLabs/dioxus-components#294 ·
-
Range SliderOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DioxusLabs/dioxus-components#292 · 2 comments ·
-
Component library depends on `dioxus` crate with default features enabledPossibly taken @ealmloff claimed this 185 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
DioxusLabs/dioxus-components#272 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
DioxusLabs/dioxus-components#321 ·
All issues in DioxusLabs/dioxus-components
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
mongodb/kingfisher#588 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
bug rust
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
franciscoBSalgueiro/en-croissant#1111 ·
Maintainers usually reply within 2 days
-
[bug] Toolchain versions from `.prototools` are not inherited when moon runs from a subdirectoryOpen
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day