sidebar: fall back to theme sidebar color when opaque

This commit is contained in:
2026-11-16 05:16:46 +07:00
parent 1cb86c497a
commit a7abeea8c6
7 changed files with 83 additions and 20 deletions
+7 -1
View File
@@ -371,7 +371,13 @@ impl RenderOnce for Sidebar {
.w(width)
.flex()
.flex_col()
.when(material, |sidebar| sidebar.bg(theme.material.background))
.map(|sidebar| {
if material {
sidebar.bg(theme.material.background)
} else {
sidebar.bg(theme.colors.sidebar)
}
})
.text_size(theme.sizes.medium.text_size)
.when(border_right, |sidebar| {
sidebar
+4
View File
@@ -21,6 +21,8 @@ pub struct ColorTokens {
pub foreground: Hsla,
pub surface: Hsla,
pub surface_foreground: Hsla,
/// The docked sidebar's backdrop, matching the platform's window chrome.
pub sidebar: Hsla,
pub primary: Hsla,
pub primary_foreground: Hsla,
pub secondary: Hsla,
@@ -56,6 +58,7 @@ impl ColorTokens {
foreground: hex(0x18181b),
surface: hex(0xfafafa),
surface_foreground: hex(0x18181b),
sidebar: hex(0xf4f4f5),
primary: hex(0x2563eb),
primary_foreground: hex(0xffffff),
secondary: hex(0xf4f4f5),
@@ -90,6 +93,7 @@ impl ColorTokens {
foreground: hex(0xfafafa),
surface: hex(0x18181b),
surface_foreground: hex(0xfafafa),
sidebar: hex(0x18181b),
primary: hex(0x3b82f6),
primary_foreground: hex(0xffffff),
secondary: hex(0x27272a),
+5
View File
@@ -19,6 +19,7 @@ pub struct ThemeDefinition {
foreground: Option<String>,
surface: Option<String>,
surface_foreground: Option<String>,
sidebar: Option<String>,
primary: Option<String>,
primary_foreground: Option<String>,
secondary: Option<String>,
@@ -87,6 +88,10 @@ impl ThemeDefinition {
self.color(&self.surface_foreground, "surface_foreground")
}
pub fn sidebar(&self) -> Option<Hsla> {
self.color(&self.sidebar, "sidebar")
}
pub fn primary(&self) -> Option<Hsla> {
self.color(&self.primary, "primary")
}
+5
View File
@@ -117,6 +117,11 @@ pub(crate) fn resolve(
system_palette.surface_foreground,
base.surface_foreground,
),
sidebar: pick(
def_color(|d| d.sidebar()),
system_palette.sidebar,
base.sidebar,
),
primary,
primary_foreground: pick(
def_color(|d| d.primary_foreground()),
+1
View File
@@ -86,6 +86,7 @@ impl MacosSource {
foreground: Self::color_to_hsla(&NSColor::labelColor()),
surface: Self::color_to_hsla(&NSColor::textBackgroundColor()),
surface_foreground: Self::color_to_hsla(&NSColor::labelColor()),
sidebar: Self::color_to_hsla(&NSColor::windowBackgroundColor()),
primary_foreground: Self::color_to_hsla(&NSColor::alternateSelectedControlTextColor()),
accent_foreground: Self::color_to_hsla(&NSColor::alternateSelectedControlTextColor()),
secondary: None,
+2
View File
@@ -63,6 +63,8 @@ pub struct PartialPalette {
pub foreground: Option<Hsla>,
pub surface: Option<Hsla>,
pub surface_foreground: Option<Hsla>,
/// Only macOS states it, the window backdrop its sidebars show.
pub sidebar: Option<Hsla>,
pub primary_foreground: Option<Hsla>,
pub accent_foreground: Option<Hsla>,
pub secondary: Option<Hsla>,