fix(selection): 选中禁用的 Checkbox 容器改用 OnSurface@38%,并补逐格断言(复审 P2-3)
A1:SelectedDisabledContainerColor=OnSurface + SelectedDisabledContainerOpacity=0.38(不是普通禁用容器的 12%)。断言同时钉住三件事:fill == 38% 叠色、fill != 12% 容器色、未选中禁用描边与它是同一个 38%。 (同一提交还带着 P2-2 的命中区单测:两处断言都在 tests.rs,无法按 hunk 切分。)
This commit is contained in:
1 parent
17394b73ff
commit
00dbb5a5d5
1 file changed
+36
-4
@@ -6,7 +6,7 @@
|
|||||||
use unlucky_design::color::{Role, SchemeFlavor};
|
use unlucky_design::color::{Role, SchemeFlavor};
|
||||||
use unlucky_design::typography::Platform;
|
use unlucky_design::typography::Platform;
|
||||||
|
|
||||||
use super::super::interaction::Interaction;
|
use super::super::interaction::{self, Interaction};
|
||||||
use super::geometry::{ChipGeometry, ControlGeometry, SwitchGeometry};
|
use super::geometry::{ChipGeometry, ControlGeometry, SwitchGeometry};
|
||||||
use super::paint::{self, ChipVariant};
|
use super::paint::{self, ChipVariant};
|
||||||
use crate::theme::{Families, Ui};
|
use crate::theme::{Families, Ui};
|
||||||
@@ -21,6 +21,25 @@ fn ui() -> Ui {
|
|||||||
Ui::with_platform(SchemeFlavor::Light, Platform::Windows, FAMILIES)
|
Ui::with_platform(SchemeFlavor::Light, Platform::Windows, FAMILIES)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 复审 P2-2:命中区恒 **48×48**——Ø40 状态层之外左右各 4dp 透明内边距(无标签时行宽才不是 40)。
|
||||||
|
#[test]
|
||||||
|
fn hit_area_is_48_square_even_without_a_label() {
|
||||||
|
let ui = ui();
|
||||||
|
for (name, geometry) in [
|
||||||
|
("checkbox", ControlGeometry::checkbox(&ui)),
|
||||||
|
("radio", ControlGeometry::radio(&ui)),
|
||||||
|
] {
|
||||||
|
assert_eq!(geometry.hit, 48.0, "{name} 命中区必须是 48");
|
||||||
|
assert_eq!(geometry.state_layer, 40.0, "{name} 状态层 Ø40");
|
||||||
|
assert_eq!(geometry.hit_padding(), 4.0, "{name} 左右各留 4dp");
|
||||||
|
assert_eq!(
|
||||||
|
geometry.state_layer + geometry.hit_padding() * 2.0,
|
||||||
|
geometry.hit,
|
||||||
|
"{name}:可见 40 + 左右各 4 = 命中 48"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// §18.1 / §18.5 / §18.9:Checkbox 的四个参考值全部来自令牌层。
|
/// §18.1 / §18.5 / §18.9:Checkbox 的四个参考值全部来自令牌层。
|
||||||
#[test]
|
#[test]
|
||||||
fn checkbox_geometry_comes_from_the_token_layer() {
|
fn checkbox_geometry_comes_from_the_token_layer() {
|
||||||
@@ -161,11 +180,24 @@ fn checkbox_disabled_keeps_the_stroke_and_uses_the_a1_roles() {
|
|||||||
ui.color(Role::Surface),
|
ui.color(Role::Surface),
|
||||||
"A1:SelectedDisabledIconColor = Surface"
|
"A1:SelectedDisabledIconColor = Surface"
|
||||||
);
|
);
|
||||||
assert!(checked.frame.fill.is_some());
|
// 复审 P2-3:**选中且禁用**的填充是 OnSurface@38%(`SelectedDisabledContainerOpacity`),
|
||||||
|
// 不是普通禁用容器的 12%。两格差一眼就能看出来,所以逐字钉住。
|
||||||
|
let ink38 = interaction::disabled_content_over_role(&ui, Role::OnSurface, false);
|
||||||
|
let container12 = interaction::disabled_colors(&ui, Role::Surface).0;
|
||||||
|
assert_eq!(
|
||||||
|
checked.frame.fill,
|
||||||
|
Some(ink38),
|
||||||
|
"A1:SelectedDisabledContainerOpacity = 0.38"
|
||||||
|
);
|
||||||
assert_ne!(
|
assert_ne!(
|
||||||
checked.frame.fill,
|
checked.frame.fill,
|
||||||
Some(ui.color(Role::Primary)),
|
Some(container12),
|
||||||
"禁用不保留 Primary"
|
"选中禁用不是 12% 容器色"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
unchecked.frame.outline,
|
||||||
|
Some(ink38),
|
||||||
|
"同一行里未选中禁用描边与选中禁用填充是同一个 38% 叠色"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user