Skip to content

Commit 579d7f1

Browse files
committed
Add $surface-active variable
1 parent 0437fdf commit 579d7f1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/textual/design.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def generate(self) -> dict[str, str]:
134134

135135
colors: dict[str, str] = {}
136136

137-
def luminosity_range(spread) -> Iterable[tuple[str, float]]:
137+
def luminosity_range(spread: float) -> Iterable[tuple[str, float]]:
138138
"""Get the range of shades from darken2 to lighten2.
139139
140140
Returns:
@@ -212,6 +212,11 @@ def luminosity_range(spread) -> Iterable[tuple[str, float]]:
212212
# cursor is under.
213213
colors["highlight-hover"] = boost.with_alpha(0.05).hex
214214

215+
# The surface color for builtin focused widgets
216+
# Use half the luminosity spread in order to land half-way between
217+
# surface and the surface-lighten-1 shade.
218+
colors["surface-active"] = surface.lighten(self.luminosity_spread / 3.5).hex
219+
215220
return colors
216221

217222

src/textual/widgets/_tree.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
607607
}
608608
609609
&:focus {
610+
background: $surface-active;
610611
& > .tree--cursor {
611612
background: $highlight-cursor;
612613
}

0 commit comments

Comments
 (0)