Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions examples/todomvc/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,15 @@ pub fn app() -> Element {
style { {include_str!("./todomvc.css")} }
section { class: "todoapp",
TodoHeader { todos }
section { class: "main",
if !todos.read().is_empty() {
input {
id: "toggle-all",
class: "toggle-all",
r#type: "checkbox",
onchange: toggle_all,
checked: active_todo_count() == 0,
}
label { r#for: "toggle-all" }
if !todos.read().is_empty() {
button {
class: "toggle-all",
class: if active_todo_count() == 0 { "checked" },
onclick: toggle_all,
">"
}

}
section { class: "main",
// Render the todos using the filtered_todos signal
// We pass the ID into the TodoEntry component so it can access the todo from the todos signal.
// Since we store the todos in a signal too, we also need to send down the todo list
Expand Down
31 changes: 12 additions & 19 deletions examples/todomvc/src/todomvc.css
Original file line number Diff line number Diff line change
Expand Up @@ -112,32 +112,26 @@ body {
}

.toggle-all {
text-align: center;
border: none;
/* Mobile Safari */
opacity: 0;
position: absolute;
}

.toggle-all+label {
display: flex;
align-items: center;
justify-content: center;
width: 60px;
height: 34px;
font-size: 0;
font-size: 22px;
line-height: 1;
color: #e6e6e6;
position: absolute;
top: -52px;
top: 13px;
left: -13px;
border: none;
background: none;
cursor: pointer;
z-index: 3;
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}

.toggle-all+label:before {
content: '❯';
font-size: 22px;
color: #e6e6e6;
padding: 10px 27px 10px 27px;
}

.toggle-all:checked+label:before {
.toggle-all.checked {
color: #737373;
}

Expand Down Expand Up @@ -363,7 +357,6 @@ html .clear-completed:active {
*/

@media screen and (-webkit-min-device-pixel-ratio:0) {
.toggle-all,
.todo-list li .toggle {
background: none;
}
Expand Down
1 change: 1 addition & 0 deletions tests/blitz-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ blitz-dom = { workspace = true, features = ["accessibility", "floats", "system-f
blitz-html = { workspace = true }
blitz-traits = { workspace = true }
blitz-paint = { workspace = true, features = ["scrollbars", "svg"] }
dioxus-native = { workspace = true, features = ["svg", "system-fonts", "data-uri", "prelude", "vello-hybrid"] }
dioxus-native-dom = { workspace = true }
anyrender = { workspace = true }
anyrender_vello_cpu = { workspace = true }
Expand Down
43 changes: 43 additions & 0 deletions tests/blitz-tests/tests/todomvc_toggle_all.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
use blitz_test_harness::Harness;
use keyboard_types::Key;

#[path = "../../../examples/todomvc/src/app.rs"]
mod todomvc_app;

#[test]
fn todomvc_toggle_all_has_visible_label_content() {
let mut harness = Harness::from_component(todomvc_app::app);

harness.type_text("first todo");
harness.press(Key::Enter);
harness.type_text("second todo");
harness.press(Key::Enter);

assert!(
harness.query(".toggle-all").is_some(),
"toggle-all control should be rendered once at least one todo exists"
);

assert_eq!(harness.text_content(".toggle-all"), ">");

let label_rect = harness.layout_rect(".toggle-all");
assert!(label_rect.width > 0.0, "toggle-all control should have width");
assert!(
label_rect.height > 0.0,
"toggle-all control should have height"
);

harness.click(".toggle-all");
assert_eq!(
harness.query_all(".todo-list li.completed").len(),
2,
"clicking toggle-all should mark all todos as completed"
);

harness.click(".toggle-all");
assert_eq!(
harness.query_all(".todo-list li.completed").len(),
0,
"clicking toggle-all again should unmark all todos"
);
}