button: Apply disable color to ButtonStyleCustom.

This commit is contained in:
Jason Lee 2024-09-17 21:15:48 +08:00
parent d641c219a1
commit 08a160e543
2 changed files with 26 additions and 5 deletions

View file

@ -194,11 +194,31 @@ impl Render for ButtonStory {
Button::new("button-6-custom", cx) Button::new("button-6-custom", cx)
.custom( .custom(
ButtonCustomStyle::new(cx) ButtonCustomStyle::new(cx)
.color(cx.theme().muted) .color(if cx.theme().mode.is_dark() {
.foreground(cx.theme().destructive) ui::green_900()
.border(cx.theme().scrollbar) } else {
.hover(cx.theme().tab_active_foreground) ui::green_500()
.active(cx.theme().selection), })
.foreground(if cx.theme().mode.is_dark() {
ui::white()
} else {
ui::black()
})
.border(if cx.theme().mode.is_dark() {
ui::green_800()
} else {
ui::green_600()
})
.hover(if cx.theme().mode.is_dark() {
ui::green_800()
} else {
ui::green_500()
})
.active(if cx.theme().mode.is_dark() {
ui::green_950()
} else {
ui::green_600()
}),
) )
.label("Custom Button") .label("Custom Button")
.disabled(disabled) .disabled(disabled)

View file

@ -594,6 +594,7 @@ impl ButtonStyle {
ButtonStyle::Link | ButtonStyle::Ghost | ButtonStyle::Text => cx.theme().transparent, ButtonStyle::Link | ButtonStyle::Ghost | ButtonStyle::Text => cx.theme().transparent,
ButtonStyle::Primary => cx.theme().primary.opacity(0.15), ButtonStyle::Primary => cx.theme().primary.opacity(0.15),
ButtonStyle::Danger => cx.theme().destructive.opacity(0.15), ButtonStyle::Danger => cx.theme().destructive.opacity(0.15),
ButtonStyle::Custom(style) => style.color.opacity(0.15),
_ => cx.theme().secondary.darken(0.2).grayscale(), _ => cx.theme().secondary.darken(0.2).grayscale(),
}; };
let fg = match self { let fg = match self {