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
3 changes: 3 additions & 0 deletions changelog.d/dark-tabs-selected-style.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Changed

- Use a translucent foreground fill and softer shadow for `TabsSegmented`'s selected indicator in dark mode so it stays clear over the track.
5 changes: 5 additions & 0 deletions ui/tabs.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ func (t Tabs[T]) Render(cx *core.Scope) core.Node {
}
s.Left, s.Top, s.Width, s.Height = core.Pt(left), core.Pt(f.Origin.Y), core.Pt(f.Size.Width), core.Pt(f.Size.Height)
s.CornerRadius = f.Size.Height / 2
if cx.Dark() {
s.Background = Alpha(colors.Text(), 0.14)
s.Shadows = shadows(Shadow(0, 1, 2, 0, Black(0.16)))
return s.Merge(t.IndicatorStyle)
}
return FinOf(cx).Pill().Over(s).Merge(t.IndicatorStyle)
}}
tabLook := func() core.Style {
Expand Down
21 changes: 21 additions & 0 deletions ui/tabs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,24 @@ func TestTabsOptionsFuncUpdatesInPlace(t *testing.T) {
t.Fatalf("the retained tab's accessibility label is %q, want the new one", got)
}
}

// TestTabsSegmentedDarkIndicator uses a translucent foreground fill and a softer
// shadow for the segmented indicator in dark mode so it stays clear over the track.
func TestTabsSegmentedDarkIndicator(t *testing.T) {
headless(t)
lightApp, lightPalette := start(t, desktopEnv, tabsContent)
lightThumb := lightApp.Find("segmented").Children[0].Style
if lightThumb.Background != lightPalette.Raised {
t.Fatalf("light segmented indicator background = %x, want raised %x", lightThumb.Background, lightPalette.Raised)
}
darkEnv := desktopEnv
darkEnv.Dark = true
darkApp, darkPalette := start(t, darkEnv, tabsContent)
darkThumb := darkApp.Find("segmented").Children[0].Style
if want := Alpha(darkPalette.Text, 0.14); darkThumb.Background != want {
t.Fatalf("dark segmented indicator background = %x, want %x", darkThumb.Background, want)
}
if darkThumb.Effects == nil || len(darkThumb.Effects.Shadows) != 1 || darkThumb.Effects.Shadows[0] != Shadow(0, 1, 2, 0, Black(0.16)) {
t.Fatalf("dark segmented indicator effects = %+v, want softer shadow", darkThumb.Effects)
}
}
Loading