Skip to content
Merged
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
2 changes: 1 addition & 1 deletion gallery/tests/blitz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ fn a_submenu_opens_beside_its_item() {
let mut doc = page(1200, 800);
let edit = find(&doc, "button", "Edit ▾");
click(&mut doc, edit);
let heading = find(&doc, ".unit-item", "Heading▸");
let heading = find(&doc, ".unit-item", "Heading");
let (hx, hy, hw, hh) = rect(&doc, heading);
doc.handle_ui_event(UiEvent::PointerMove(pointer(
BlitzPointerId::Mouse,
Expand Down
3 changes: 2 additions & 1 deletion src/components/choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use dioxus::html::{Key, Modifiers, NamedKey};
use dioxus::prelude::*;

use crate::icon::{Icon, paths};
use crate::unit::{Kind, next_id, use_focus};

fn is_space(key: &Key) -> bool {
Expand Down Expand Up @@ -49,7 +50,7 @@ pub fn Checkbox(
}
},
span { class: "unit-check-box", "aria-hidden": "true",
if checked { "✓" }
if checked { Icon { d: paths::CHECK, size: 12.0 } }
}
span { class: "unit-check-label", {children} }
}
Expand Down
6 changes: 4 additions & 2 deletions src/components/menus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use dioxus::prelude::*;
use crate::components::button::{Variant, is_press};
use crate::components::choice::{Orientation, arrow_step};
use crate::components::hold::use_hold;
use crate::icon::Icon;
use crate::icon::{Icon, paths};
use crate::menu::{Entry, Item};
use crate::unit::{Kind, Unit, use_focus, use_unit};

Expand Down Expand Up @@ -262,7 +262,9 @@ pub fn Select(
rsx! {
MenuButton { class: "unit-select", entries, onpick, height, label: name, disabled,
span { class: "unit-select-label", "{shown}" }
span { class: "unit-select-arrows", "aria-hidden": "true", "▾" }
span { class: "unit-select-arrows", "aria-hidden": "true",
Icon { d: paths::CHEVRON_DOWN, size: 14.0 }
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub fn Disclosure(title: String, #[props(default)] open: bool, children: Element
shown.toggle();
},
span { class: "unit-disclosure-arrow", "aria-hidden": "true",
if is_open { "▾" } else { "▸" }
Icon { d: if is_open { paths::CHEVRON_DOWN } else { paths::CHEVRON_RIGHT }, size: 14.0 }
}
"{title}"
}
Expand Down
10 changes: 10 additions & 0 deletions src/components/text_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ pub fn TextField(
#[props(default)] required: bool,
minlength: Option<u32>,
maxlength: Option<u32>,
/// Whether the field has the keys when the page opens, as a browser's
/// `autofocus`: a dialog's one field.
#[props(default)]
autofocus: bool,
) -> Element {
let focus = use_focus(Kind::Text, |_, _| false);
let id = use_hook(next_id);
Expand Down Expand Up @@ -113,6 +117,7 @@ pub fn TextField(
"aria-required": required.then_some("true"),
minlength: minlength.map(|n| n.to_string()),
maxlength: maxlength.map(|n| n.to_string()),
autofocus: autofocus.then_some("true"),
"aria-label": label.clone(),
onpointerdown: move |_| focus.press(),
onfocus: move |_| focus.dom_focus(),
Expand Down Expand Up @@ -219,6 +224,10 @@ pub fn SearchField(
label: String,
#[props(default = "Search".to_string())] placeholder: String,
onsubmit: Option<EventHandler<String>>,
/// Whether the field has the keys when the page opens, as a browser's
/// `autofocus`: a launcher's search.
#[props(default)]
autofocus: bool,
#[props(default)] class: String,
) -> Element {
let focus = use_focus(Kind::Text, |_, _| false);
Expand All @@ -233,6 +242,7 @@ pub fn SearchField(
r#type: "search",
value: "{value}",
placeholder: "{placeholder}",
autofocus: autofocus.then_some("true"),
"aria-label": "{label}",
onpointerdown: move |_| focus.press(),
onfocus: move |_| focus.dom_focus(),
Expand Down
13 changes: 8 additions & 5 deletions src/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use dioxus::prelude::*;

use crate::actions::{ActionSheet, SheetAction};
use crate::dialog::{Answer, Dialog, Field, FieldKey};
use crate::icon::{Icon, Ink};
use crate::icon::{Icon, Ink, paths};
use crate::menu::{Entry, Level, Menu, Outcome, Sizes};
use crate::unit::{Keys, Unit, next_id};

Expand Down Expand Up @@ -662,7 +662,6 @@ fn entry_view(unit: Unit, depth: usize, i: usize, entry: &Entry, lit: Option<usi
}
},
Entry::Item(item) => {
let tick = if item.checked { "✓" } else { "" };
let shortcut = item.shortcut.clone().unwrap_or_default();
let role = if item.checkable {
"menuitemcheckbox"
Expand All @@ -681,7 +680,9 @@ fn entry_view(unit: Unit, depth: usize, i: usize, entry: &Entry, lit: Option<usi
"aria-disabled": (!item.enabled).then_some("true"),
"aria-label": "{item.label}",
onpointermove: hover, onpointerup: release,
span { class: "unit-tick", "aria-hidden": "true", "{tick}" }
span { class: "unit-tick", "aria-hidden": "true",
if item.checked { Icon { d: paths::CHECK, size: 14.0 } }
}
if let Some(d) = item.icon {
Icon { d, ink, size: 16.0 }
}
Expand All @@ -697,7 +698,9 @@ fn entry_view(unit: Unit, depth: usize, i: usize, entry: &Entry, lit: Option<usi
onpointermove: hover, onpointerup: release,
span { class: "unit-tick" }
span { class: "unit-label", "{label}" }
span { class: "unit-key", "aria-hidden": "true", "▸" }
span { class: "unit-key", "aria-hidden": "true",
Icon { d: paths::CHEVRON_RIGHT, size: 14.0 }
}
}
},
Entry::Palette(_) => unreachable!("drawn by palette_view"),
Expand Down Expand Up @@ -992,7 +995,7 @@ fn ToastView(unit: Unit, id: u64, toast: Toast, #[props(default)] leaving: bool)
e.stop_propagation();
unit.dismiss(id);
},
"✕"
Icon { d: paths::CLOSE, size: 16.0 }
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ pub const CSS: &str = r#"
.unit-label { flex: 1; }
.unit-key { flex: none; padding-left: 18px; color: var(--unit-dim); }
.unit-item.hot .unit-key { color: var(--unit-accent-text); }
/* A tick and a submenu's arrow are icons in a column of their own: no gap after them. */
.unit-tick .unit-svg, .unit-key .unit-svg { margin-right: 0; }
.unit-sep { height: 9px; padding: 4px 10px; }
.unit-item.unit-header { color: var(--unit-dim); font-size: 0.85em; font-weight: 600; }
.unit-rule { height: 1px; background: var(--unit-separator); }
Expand Down