Skip to content

Commit deb9901

Browse files
committed
feat(dao_address_bar): enhance NavIconButton with adaptive hover background color and update DaoTabItem close button styles for improved UX
1 parent 0bdc308 commit deb9901

2 files changed

Lines changed: 36 additions & 9 deletions

File tree

src/dao/browser/ui/views/dao_address_bar_view.cc

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class NavIconButton : public views::Button {
9999
if (!nav_enabled_) return;
100100
Button::OnMouseEntered(event);
101101
SetBackground(views::CreateRoundedRectBackground(
102-
SkColorSetARGB(20, 0, 0, 0), kNavButtonRadius));
102+
hover_bg_color_, kNavButtonRadius));
103103
SchedulePaint();
104104
}
105105

@@ -116,6 +116,17 @@ class NavIconButton : public views::Button {
116116
SchedulePaint();
117117
}
118118

119+
void SetHoverBgColor(SkColor color) {
120+
if (hover_bg_color_ == color) return;
121+
hover_bg_color_ = color;
122+
if (background()) {
123+
// Refresh the active hover background with the new color.
124+
SetBackground(views::CreateRoundedRectBackground(
125+
hover_bg_color_, kNavButtonRadius));
126+
SchedulePaint();
127+
}
128+
}
129+
119130
void SetNavEnabled(bool enabled) {
120131
nav_enabled_ = enabled;
121132
SetEnabled(enabled);
@@ -187,6 +198,7 @@ class NavIconButton : public views::Button {
187198
LucideIcon icon_;
188199
SkColor icon_color_ = SkColorSetARGB(180, 100, 100, 100);
189200
SkColor disabled_color_ = SkColorSetARGB(60, 100, 100, 100);
201+
SkColor hover_bg_color_ = SkColorSetARGB(20, 0, 0, 0);
190202
bool nav_enabled_ = true;
191203
bool highlighted_ = false;
192204
bool animate_on_press_ = false;
@@ -606,11 +618,16 @@ void DaoAddressBarView::UpdateToggleButtonColor() {
606618
int g = SkColorGetG(bg_color);
607619
int b = SkColorGetB(bg_color);
608620
double luminance = 0.299 * r + 0.587 * g + 0.114 * b;
609-
SkColor icon_color = luminance < 128
621+
bool dark_background = luminance < 128;
622+
SkColor icon_color = dark_background
610623
? SkColorSetARGB(230, 255, 255, 255) // dark bg → white icon
611624
: SkColorSetARGB(200, 0, 0, 0); // light bg → dark icon
612-
static_cast<NavIconButton*>(sidebar_toggle_button_.get())
613-
->SetIconColor(icon_color);
625+
SkColor hover_bg = dark_background
626+
? SkColorSetARGB(20, 255, 255, 255)
627+
: SkColorSetARGB(20, 0, 0, 0);
628+
auto* toggle = static_cast<NavIconButton*>(sidebar_toggle_button_.get());
629+
toggle->SetIconColor(icon_color);
630+
toggle->SetHoverBgColor(hover_bg);
614631
}
615632

616633
void DaoAddressBarView::OnToggleButtonPressed() {
@@ -746,14 +763,22 @@ void DaoAddressBarView::UpdateNavButtonColors() {
746763
int g = SkColorGetG(bg_color);
747764
int b = SkColorGetB(bg_color);
748765
double luminance = 0.299 * r + 0.587 * g + 0.114 * b;
749-
SkColor icon_color = luminance < 128
766+
bool dark_background = luminance < 128;
767+
SkColor icon_color = dark_background
750768
? SkColorSetARGB(180, 255, 255, 255)
751769
: SkColorSetARGB(160, 0, 0, 0);
770+
// Adaptive hover background: dark surfaces need white tint, light surfaces
771+
// need black tint, to keep the rounded highlight visible against any page.
772+
SkColor hover_bg = dark_background
773+
? SkColorSetARGB(20, 255, 255, 255)
774+
: SkColorSetARGB(20, 0, 0, 0);
752775

753776
for (views::Button* btn : {back_button_.get(), forward_button_.get(),
754777
stop_refresh_button_.get(), chat_button_.get()}) {
755778
if (btn) {
756-
static_cast<NavIconButton*>(btn)->SetIconColor(icon_color);
779+
auto* nav_btn = static_cast<NavIconButton*>(btn);
780+
nav_btn->SetIconColor(icon_color);
781+
nav_btn->SetHoverBgColor(hover_bg);
757782
}
758783
}
759784
if (control_center_button_) {

src/dao/browser/ui/webui/resources/sidebar/dao_tab_item.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ export class DaoTabItem extends CrLitElement {
106106
}
107107
108108
.close-btn {
109-
width: 16px;
110-
height: 16px;
109+
width: 20px;
110+
height: 20px;
111111
border: none;
112112
background: transparent;
113113
color: var(--text-muted);
@@ -118,14 +118,16 @@ export class DaoTabItem extends CrLitElement {
118118
display: flex;
119119
align-items: center;
120120
justify-content: center;
121-
transition: opacity 0.1s ease;
121+
border-radius: 6px;
122+
transition: opacity 0.1s ease, background 0.12s ease, color 0.12s ease;
122123
}
123124
124125
.tab-row:hover .close-btn {
125126
opacity: 1;
126127
}
127128
128129
.close-btn:hover {
130+
background: var(--ink-drop);
129131
color: var(--text-primary);
130132
}
131133

0 commit comments

Comments
 (0)