Skip to content

Commit 3fe68d8

Browse files
authored
🔀 Merge pull request #195 from davep/simplify-key-markup
Simplify the colouring of keys in the navigation bar
2 parents e95aee6 + 07f63f5 commit 3fe68d8

File tree

3 files changed

+15
-39
lines changed

3 files changed

+15
-39
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors = [
77
]
88
dependencies = [
99
"httpx>=0.27.2",
10-
"textual>=3.1",
10+
"textual>=6.6",
1111
"xdg-base-dirs>=6.0.2",
1212
"pytz>=2024.2",
1313
"humanize>=4.11.0",

src/braindrop/app/widgets/navigation.py

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
# Backward compatibility.
55
from __future__ import annotations
66

7-
##############################################################################
8-
# Python imports.
9-
from typing import Any
10-
117
##############################################################################
128
# Rich imports.
139
from rich.console import Group, RenderableType
@@ -17,6 +13,7 @@
1713
##############################################################################
1814
# Textual imports.
1915
from textual import on
16+
from textual.content import Content
2017
from textual.message import Message
2118
from textual.reactive import var
2219
from textual.widgets import OptionList
@@ -66,15 +63,13 @@ def build_prompt(
6663
count: int,
6764
indent: int = 0,
6865
key: str | None = None,
69-
key_colour: str | None = None,
7066
) -> RenderableType:
7167
"""The prompt for the option.
7268
7369
Args:
7470
title: The title for the prompt.
7571
count: The count for the prompt.
7672
key: The optional key for the prompt.
77-
key_colour: The optional colour for the key.
7873
7974
Returns:
8075
A renderable that is the prompt.
@@ -83,8 +78,10 @@ def build_prompt(
8378
prompt.add_column(ratio=1)
8479
prompt.add_column(justify="right")
8580
prompt.add_row(
86-
f"{'[dim]>[/dim] ' * indent}{title}"
87-
+ (f" [{key_colour or 'dim'}]\\[{key or ''}][/]" if key else ""),
81+
Content.from_markup(
82+
f"{'[dim]>[/dim] ' * indent}{title}"
83+
+ (f" [$footer-key-foreground]\\[{key or ''}][/]" if key else "")
84+
),
8885
f"[dim i]{count}[/]",
8986
)
9087
return prompt
@@ -111,7 +108,6 @@ def __init__(
111108
collection: Collection,
112109
indent: int = 0,
113110
key: str | None = None,
114-
key_colour: str | None = None,
115111
count: int = 0,
116112
) -> None:
117113
"""Initialise the object.
@@ -120,7 +116,6 @@ def __init__(
120116
collection: The collection to show.
121117
indent: The indent level for the collection.
122118
key: The associated with the collection.
123-
key_colour: The colour to show the key in.
124119
count: The count of raindrops in the collection.
125120
"""
126121
self._collection = collection
@@ -131,7 +126,6 @@ def __init__(
131126
count or collection.count,
132127
indent,
133128
key,
134-
key_colour,
135129
),
136130
id=self.id_of(collection),
137131
)
@@ -229,19 +223,6 @@ def __init__(
229223
self._api = api
230224
"""The API client object."""
231225

232-
def on_mount(self) -> None:
233-
"""Configure the widget once the DIM is ready."""
234-
235-
def redraw(*_: Any) -> None:
236-
"""Force a redraw of the content of the widget."""
237-
self.active_collection = self.active_collection
238-
239-
# While the user will almost never notice, if the theme changes the
240-
# accent colour for the keys will go out of sync, so here we watch
241-
# for a theme change and then force a redraw of the content so we do
242-
# keep in sync.
243-
self.app.theme_changed_signal.subscribe(self, redraw)
244-
245226
def highlight_collection(self, collection: Collection) -> None:
246227
"""Ensure the given collection is highlighted.
247228
@@ -285,9 +266,6 @@ def _add_collection(
285266
collection,
286267
indent,
287268
key,
288-
None
289-
if self.app.current_theme is None
290-
else self.app.current_theme.accent,
291269
0 if self.data is None else self.data.collection_size(collection),
292270
)
293271
)

uv.lock

Lines changed: 9 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)