Skip to content

Commit

Permalink
Updating theme styles preview code
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Nov 17, 2024
1 parent 275eabf commit 9898935
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
3 changes: 2 additions & 1 deletion docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ If you have any feedback or suggestions, please open a new discussion on GitHub.

- Keymaps. ✅
- Pre-request and post-response scripts. ✅
- Parse cURL commands.
- Parse cURL commands.
- Watching environment files for changes & updating the UI. ✅
- Editing key/value editor rows without having to delete/re-add them.
- Realtime - WebSocket and SSE.
- Quickly open MDN links for headers.
- Templates. Create a `_template.posting.yaml` file (perhaps a checkbox in the new request modal for this). Any requests created in a collection will be based off of the nearest template (looking upwards to the collection root). Note that this is not "inheritance" - it's a means of quickly pre-filling values in requests based on a template request.
- Saving recently used environments to a file.
Expand Down
24 changes: 9 additions & 15 deletions src/posting/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Any, Literal, cast

import httpx
from textual.content import Content

from posting.importing.curl import CurlImport
from rich.console import Group
Expand Down Expand Up @@ -1008,7 +1009,7 @@ def command_layout(self, layout: Literal["vertical", "horizontal"]) -> None:
def action_save_screenshot(
self,
) -> str:
return self.save_screenshot()
self.search_themes()

@on(CommandPalette.Opened)
def palette_opened(self) -> None:
Expand All @@ -1029,22 +1030,15 @@ def palette_option_highlighted(
if not self.settings.command_palette.theme_preview:
return

prompt: Group = event.highlighted_event.option.prompt
# TODO: This is making quite a lot of assumptions. Fragile, but the only
# way I can think of doing it given the current Textual APIs.
command_name = prompt.renderables[0]
if isinstance(command_name, Text):
command_name = command_name.plain
command_name = command_name.strip()
if ":" in command_name:
name, value = command_name.split(":", maxsplit=1)
name = name.strip()
value = value.strip()
if name == "theme":
if value in self.themes:
self.theme = value
prompt = event.highlighted_event.option.prompt
themes = self.available_themes.keys()
if isinstance(prompt, Content):
candidate = prompt.plain
if candidate in themes:
self.theme = candidate
else:
self.theme = self._original_theme
self.call_next(self.screen._update_styles)

@on(CommandPalette.Closed)
def palette_closed(self, event: CommandPalette.Closed) -> None:
Expand Down
1 change: 1 addition & 0 deletions src/posting/posting.scss
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ Button {
}

CommandPalette {
background: black 20%;

& > Vertical {
margin-top: 5;
Expand Down
2 changes: 1 addition & 1 deletion tests/test_snapshots.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ async def run_before(pilot: Pilot):
await pilot.pause() # wait for focus to switch
await pilot.wait_for_scheduled_animations()

assert snap_compare(POSTING_MAIN, run_before=run_before, terminal_size=(80, 34))
assert snap_compare(POSTING_MAIN, run_before=run_before, terminal_size=(80, 60))


@use_config("general.yaml")
Expand Down

0 comments on commit 9898935

Please sign in to comment.