Skip to content

Commit

Permalink
Further docs updates to get rid of App.dark
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Oct 24, 2024
1 parent 0c5f611 commit 6ad521d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 81 deletions.
2 changes: 1 addition & 1 deletion docs/blog/posts/release0-38-0.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ If you do want to style something outside of the widget you can set `SCOPED_CSS=
## Light and Dark pseudo selectors

We've also made a slight quality of life improvement to the CSS, by adding `:light` and `:dark` pseudo selectors.
This allows you to change styles depending on whether you have dark mode enabled or not.
This allows you to change styles depending on whether the app is currently using a light or dark theme.

This was possible before, just a little verbose.
Here's how you would do it in 0.37.0:
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/command_palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Textual will suggest commands as you type in that input.
Press ++up++ or ++down++ to select a command from the list, and ++enter++ to invoke it.

Commands are looked up via a *fuzzy* search, which means Textual will show commands that match the keys you type in the same order, but not necessarily at the start of the command.
For instance the "Toggle light/dark mode" command will be shown if you type "to" (for **to**ggle), but you could also type "dm" (to match **d**ark **m**ode).
This scheme allows the user to quickly get to a particular command with a minimum of key-presses.
For instance the "Change theme" command will be shown if you type "ch" (for **ch**ange), but you could also type "th" (to match **t**heme).
This scheme allows the user to quickly get to a particular command with fewer key-presses.


=== "Command Palette"
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ If you run this code, you should see something like the following:
```{.textual path="docs/examples/tutorial/stopwatch01.py" title="stopwatch01.py"}
```

Hit the ++d++ key to toggle between light and dark mode.
Hit the ++d++ key to toggle between light and dark themes.

```{.textual path="docs/examples/tutorial/stopwatch01.py" press="d" title="stopwatch01.py"}
```
Expand Down
73 changes: 0 additions & 73 deletions reference/_color_system.md

This file was deleted.

13 changes: 11 additions & 2 deletions src/textual/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,10 +519,10 @@ class MyApp(App[None]):
"""The name of the currently active theme."""

ansi_theme_dark = Reactive(MONOKAI, init=False)
"""Maps ANSI colors to hex colors using a Rich TerminalTheme object while in dark mode."""
"""Maps ANSI colors to hex colors using a Rich TerminalTheme object while using a dark theme."""

ansi_theme_light = Reactive(ALABASTER, init=False)
"""Maps ANSI colors to hex colors using a Rich TerminalTheme object while in light mode."""
"""Maps ANSI colors to hex colors using a Rich TerminalTheme object while using a light theme."""

ansi_color = Reactive(False)
"""Allow ANSI colors in UI?"""
Expand Down Expand Up @@ -4056,6 +4056,15 @@ async def action_toggle_class(self, selector: str, class_name: str) -> None:
"""
self.screen.query(selector).toggle_class(class_name)

def action_toggle_dark(self) -> None:
"""An [action](/guide/actions) to toggle the theme between textual-light
and textual-dark. This is offered as a convenience to simplify backwards
compatibility with previous versions of Textual which only had light mode
and dark mode."""
self.theme = (
"textual-dark" if self.theme == "textual-light" else "textual-light"
)

def action_focus_next(self) -> None:
"""An [action](/guide/actions) to focus the next widget."""
self.screen.focus_next()
Expand Down
4 changes: 2 additions & 2 deletions src/textual/widgets/_toggle_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ToggleButton(Static, can_focus=True):
/* Base button colors (including in dark mode). */
/* Base button colors (including in dark themes). */
ToggleButton > .toggle--button {
text-style: $block-cursor-text-style;
Expand All @@ -110,7 +110,7 @@ class ToggleButton(Static, can_focus=True):
background: $foreground 25%;
}
/* Light mode overrides. */
/* Light theme overrides. */
ToggleButton:light {
color: $text;
& > .toggle--button {
Expand Down

0 comments on commit 6ad521d

Please sign in to comment.