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)
.custom(
ButtonCustomStyle::new(cx)
.color(cx.theme().muted)
.foreground(cx.theme().destructive)
.border(cx.theme().scrollbar)
.hover(cx.theme().tab_active_foreground)
.active(cx.theme().selection),
.color(if cx.theme().mode.is_dark() {
ui::green_900()
} else {
ui::green_500()
})
.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")
.disabled(disabled)

View file

@ -594,6 +594,7 @@ impl ButtonStyle {
ButtonStyle::Link | ButtonStyle::Ghost | ButtonStyle::Text => cx.theme().transparent,
ButtonStyle::Primary => cx.theme().primary.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(),
};
let fg = match self {