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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = [
]
dependencies = [
"httpx>=0.27.2",
"textual>=3.1",
"textual>=6.6",
"xdg-base-dirs>=6.0.2",
"pytz>=2024.2",
"humanize>=4.11.0",
Expand Down
32 changes: 5 additions & 27 deletions src/braindrop/app/widgets/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
# Backward compatibility.
from __future__ import annotations

##############################################################################
# Python imports.
from typing import Any

##############################################################################
# Rich imports.
from rich.console import Group, RenderableType
Expand All @@ -17,6 +13,7 @@
##############################################################################
# Textual imports.
from textual import on
from textual.content import Content
from textual.message import Message
from textual.reactive import var
from textual.widgets import OptionList
Expand Down Expand Up @@ -66,15 +63,13 @@ def build_prompt(
count: int,
indent: int = 0,
key: str | None = None,
key_colour: str | None = None,
) -> RenderableType:
"""The prompt for the option.

Args:
title: The title for the prompt.
count: The count for the prompt.
key: The optional key for the prompt.
key_colour: The optional colour for the key.

Returns:
A renderable that is the prompt.
Expand All @@ -83,8 +78,10 @@ def build_prompt(
prompt.add_column(ratio=1)
prompt.add_column(justify="right")
prompt.add_row(
f"{'[dim]>[/dim] ' * indent}{title}"
+ (f" [{key_colour or 'dim'}]\\[{key or ''}][/]" if key else ""),
Content.from_markup(
f"{'[dim]>[/dim] ' * indent}{title}"
+ (f" [$footer-key-foreground]\\[{key or ''}][/]" if key else "")
),
f"[dim i]{count}[/]",
)
return prompt
Expand All @@ -111,7 +108,6 @@ def __init__(
collection: Collection,
indent: int = 0,
key: str | None = None,
key_colour: str | None = None,
count: int = 0,
) -> None:
"""Initialise the object.
Expand All @@ -120,7 +116,6 @@ def __init__(
collection: The collection to show.
indent: The indent level for the collection.
key: The associated with the collection.
key_colour: The colour to show the key in.
count: The count of raindrops in the collection.
"""
self._collection = collection
Expand All @@ -131,7 +126,6 @@ def __init__(
count or collection.count,
indent,
key,
key_colour,
),
id=self.id_of(collection),
)
Expand Down Expand Up @@ -229,19 +223,6 @@ def __init__(
self._api = api
"""The API client object."""

def on_mount(self) -> None:
"""Configure the widget once the DIM is ready."""

def redraw(*_: Any) -> None:
"""Force a redraw of the content of the widget."""
self.active_collection = self.active_collection

# While the user will almost never notice, if the theme changes the
# accent colour for the keys will go out of sync, so here we watch
# for a theme change and then force a redraw of the content so we do
# keep in sync.
self.app.theme_changed_signal.subscribe(self, redraw)

def highlight_collection(self, collection: Collection) -> None:
"""Ensure the given collection is highlighted.

Expand Down Expand Up @@ -285,9 +266,6 @@ def _add_collection(
collection,
indent,
key,
None
if self.app.current_theme is None
else self.app.current_theme.accent,
0 if self.data is None else self.data.collection_size(collection),
)
)
Expand Down
20 changes: 9 additions & 11 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.