Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Themes and command palette improvements #5087

Merged
merged 174 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
b13e973
Theme class
darrenburns Oct 2, 2024
1a21e2e
Theme class expanded to have attributes from ColorSystem
darrenburns Oct 3, 2024
b8155b2
theme (str) reactive on App, currently unused
darrenburns Oct 3, 2024
57f1285
Get built-in themes
darrenburns Oct 3, 2024
edcf706
Themes and test fixes. Reduce dependence on App.dark
darrenburns Oct 3, 2024
c6da6c9
Merge branch 'main' of github.com:Textualize/textual into themes
darrenburns Oct 3, 2024
538b0ff
Non-static providers for command palette
darrenburns Oct 7, 2024
0fa81a3
ThemeProvider
darrenburns Oct 7, 2024
fb28acf
Typing
darrenburns Oct 7, 2024
d619b80
Updating change theme text in cmd palette, fix snapshots
darrenburns Oct 7, 2024
bb633cf
Re-usable colours for consistency
darrenburns Oct 7, 2024
af34013
Update ListView styling, use blur cursor in DataTable
darrenburns Oct 8, 2024
582a7cf
Making hover cursor more perceptable
darrenburns Oct 8, 2024
ea443a4
Consistency
darrenburns Oct 8, 2024
b505405
CSS tidying - using nesting in SelectionList
darrenburns Oct 9, 2024
b997b39
Renaming variables, ensuring selectionlist is readable on light mode
darrenburns Oct 9, 2024
8e895f3
Fix tree widget example typing
darrenburns Oct 9, 2024
15b7574
Tree styling consistency
darrenburns Oct 9, 2024
6a248be
Fixing switch styles, adding subtle hover effect to suggest which par…
darrenburns Oct 9, 2024
76b181e
Toggle button label styling, not sure if worth keeping
darrenburns Oct 9, 2024
54fb40f
Start working on RadioSet consistency
darrenburns Oct 9, 2024
132e6a4
Merge branch 'main' of github.com:Textualize/textual into themes
darrenburns Oct 9, 2024
831d416
Use nested CSS in radiobutton
darrenburns Oct 10, 2024
b08a6aa
CSS fix
darrenburns Oct 10, 2024
c211a02
More tweaks
darrenburns Oct 10, 2024
793d188
Merge branch 'main' of github.com:Textualize/textual into themes
darrenburns Oct 10, 2024
3033af6
Dont swap around the selectionlist values - i sure hope this doesnt b…
darrenburns Oct 10, 2024
2da1f4c
Color tweaks
darrenburns Oct 10, 2024
c0e3d69
Merge branch 'main' of github.com:Textualize/textual into themes
darrenburns Oct 14, 2024
7e6911b
Remove ToggleButton styling switcheroo
darrenburns Oct 14, 2024
0437fdf
fix toggle button styling
darrenburns Oct 14, 2024
579d7f1
Add $surface-active variable
darrenburns Oct 14, 2024
c245c09
Select focus styling
darrenburns Oct 14, 2024
b41f346
Tree styling
darrenburns Oct 14, 2024
11c2eaf
Tree ansi styling fix. Remove trailing whitespace
darrenburns Oct 14, 2024
79e42fa
Use nested CSS in Underline
darrenburns Oct 14, 2024
83707ad
Use nested CSS in Tabs
darrenburns Oct 14, 2024
0036ca3
More nested CSS
darrenburns Oct 14, 2024
35a139a
Merge branch 'main' of github.com:Textualize/textual into themes
darrenburns Oct 14, 2024
c096a3f
Styling tabs
darrenburns Oct 14, 2024
9af59d6
CSS tweaks
darrenburns Oct 14, 2024
2ff9d2e
Background tint on ToggleButton; use nested CSS
darrenburns Oct 14, 2024
4d0c913
Fix CSS in ToggleButton
darrenburns Oct 14, 2024
183edec
Update tree guides
darrenburns Oct 14, 2024
88f3881
Fix title of tab in MaskedInput in the docs
darrenburns Oct 14, 2024
d17812b
Fixing styles on light mode of RadioSet
darrenburns Oct 15, 2024
472d768
Allow/disallowing ansi color when textual-ansi theme is set/unset
darrenburns Oct 15, 2024
faebfb0
Validating themes
darrenburns Oct 15, 2024
1d8fde2
Add a comment
darrenburns Oct 15, 2024
49a572c
Typing fixes
darrenburns Oct 15, 2024
20100c3
unregister_theme
darrenburns Oct 15, 2024
377e26d
Add `App.search` experimental simpler API way of pulling up a command…
darrenburns Oct 15, 2024
ba84328
Fixing command palette colours
darrenburns Oct 16, 2024
c4b57ba
Styling fixes
darrenburns Oct 16, 2024
55d84c0
Tweaks
darrenburns Oct 16, 2024
6583c77
Fixing theme weirdness
darrenburns Oct 16, 2024
3f87bb5
Fixing some themes
darrenburns Oct 16, 2024
100d4fc
Dracula shuffle
darrenburns Oct 16, 2024
7ecc041
Backing out of `extras` idea
darrenburns Oct 17, 2024
01650b6
Using $foreground instead of $text in places where background is known
darrenburns Oct 17, 2024
cead69c
Theme changes
darrenburns Oct 17, 2024
e5d0eab
Vaaaaariables
darrenburns Oct 17, 2024
2a13416
Overriding generated theme variables
darrenburns Oct 17, 2024
0d1def6
Fixing colors in select widget
darrenburns Oct 17, 2024
4d898e8
Theme sandbox example
darrenburns Oct 17, 2024
89c9859
Footer variables
darrenburns Oct 21, 2024
9f84434
More footer colours
darrenburns Oct 21, 2024
2f97fbf
Merge branch 'main' of github.com:Textualize/textual into themes
darrenburns Oct 21, 2024
51cf2e9
Finish merge
darrenburns Oct 21, 2024
7e26a5d
Cp;pr foxes
darrenburns Oct 21, 2024
c28aa62
Merge branch 'main' of github.com:Textualize/textual into themes
darrenburns Oct 21, 2024
628fd80
More styling
darrenburns Oct 21, 2024
3164127
Input variables
darrenburns Oct 21, 2024
2f993da
Global cursor styling
darrenburns Oct 21, 2024
0b7cd1c
Attempt (and fail) to fix ListView highlighted item style
darrenburns Oct 21, 2024
b1f59f9
Input cursor styling
darrenburns Oct 21, 2024
e82bdba
Input/TextArea selection theme
darrenburns Oct 21, 2024
22fa8a6
Table styles
darrenburns Oct 21, 2024
1a111f8
DataTable tinting
darrenburns Oct 22, 2024
3982ac3
Fix example app
darrenburns Oct 22, 2024
c739b1f
Fix SelectOverlay positioning
darrenburns Oct 22, 2024
2113a4f
Command palette changes
darrenburns Oct 22, 2024
f3271e0
Fixing Dracula theme
darrenburns Oct 22, 2024
0779a80
catpuccin mocha
darrenburns Oct 22, 2024
d39de21
Updating selection list
darrenburns Oct 22, 2024
1a7de72
Catpuccin-latte
darrenburns Oct 22, 2024
50077c8
Command palette help text highlighting
darrenburns Oct 22, 2024
d6965b7
Flexoki
darrenburns Oct 22, 2024
9cbf1f0
Tokyo Night
darrenburns Oct 23, 2024
0598cfb
Primary and secondary switch
darrenburns Oct 23, 2024
4a34548
Tidying some themes
darrenburns Oct 23, 2024
c25ade1
Tweaks
darrenburns Oct 23, 2024
8f1a655
Tweaks
darrenburns Oct 23, 2024
9bddc4c
Remove unused component style from OptionList, updating Markdown rela…
darrenburns Oct 23, 2024
0c555ef
Markdown widget inside MarkdownViewer is focusable
darrenburns Oct 23, 2024
be4a816
Markdown transparent background
darrenburns Oct 23, 2024
076c107
Theme tweaks and fixes, swap primary and secondary of textual-dark
darrenburns Oct 23, 2024
e3e063d
RichLog foreground
darrenburns Oct 23, 2024
bded1bc
Updating progress bar colors
darrenburns Oct 24, 2024
a2a75d1
Allow developers to expose additional theme variables.
darrenburns Oct 24, 2024
c4b0fc4
Writing down stuff about themes
darrenburns Oct 24, 2024
e7c8b0d
Fixing invalid docs
darrenburns Oct 24, 2024
c6312bb
Documenting additional variables
darrenburns Oct 24, 2024
eab07e6
Fixing some descriptions in the theme docs
darrenburns Oct 24, 2024
f8af200
Remove App.dark from App and docs examples
darrenburns Oct 24, 2024
0c5f611
Further removal of App.dark from various places, swapping in App.them…
darrenburns Oct 24, 2024
6ad521d
Further docs updates to get rid of App.dark
darrenburns Oct 24, 2024
796a6ae
Merge branch 'main' of github.com:Textualize/textual into themes
darrenburns Oct 28, 2024
b34be61
Fixing Select widget styling
darrenburns Oct 28, 2024
56d17b2
Remove some unused variables in app.py
darrenburns Oct 28, 2024
8c8a6ad
Fix Select widget sometimes immediately re-opening when closed with a…
darrenburns Oct 28, 2024
317465c
Fix demo
darrenburns Oct 28, 2024
420f0c0
Fix import in demo app
darrenburns Oct 28, 2024
001fcf6
Prevent VerticalScroll focus
darrenburns Oct 28, 2024
596f3d4
Merge branch 'fix-demo' into themes
darrenburns Oct 28, 2024
8442bb3
Adding Markdown widget variables
darrenburns Oct 28, 2024
0809312
Progress bar variables
darrenburns Oct 28, 2024
cd9ed5d
More docs
darrenburns Oct 28, 2024
9ce4792
Reverting progress bar - not needed
darrenburns Oct 28, 2024
4589f09
$foreground instead of $text in more places
darrenburns Oct 28, 2024
2608413
Merge branch 'main' of github.com:Textualize/textual into themes
darrenburns Oct 28, 2024
5fc78ae
Merge branch 'main' of github.com:Textualize/textual into themes
darrenburns Oct 28, 2024
62d2151
Fix some tests
darrenburns Oct 28, 2024
a274129
Fixing yet more tests
darrenburns Oct 28, 2024
54c6f78
Snapshot fixes
darrenburns Oct 29, 2024
e591646
Merge branch 'main' of github.com:Textualize/textual into themes
darrenburns Oct 29, 2024
7ed0bd6
Updating snapshots on disk
darrenburns Oct 29, 2024
c75efbf
Snapshot tests for changing themes
darrenburns Oct 29, 2024
de64fb8
Fixing additional variables not working
darrenburns Oct 29, 2024
80af329
Remove debug print
darrenburns Oct 29, 2024
7f40cbd
Test ensure custom theme variables work as expected
darrenburns Oct 29, 2024
6ed7b54
Snapshot for App.search
darrenburns Oct 29, 2024
39568b8
Pilot tests for command palettes
darrenburns Oct 29, 2024
fa7afb4
Merge branch 'main' of github.com:Textualize/textual into themes
darrenburns Oct 29, 2024
ace924f
Snapshot fixes part 41
darrenburns Oct 29, 2024
cd5aeeb
Tabs styled with block cursor
darrenburns Oct 30, 2024
d2c588c
Tabs hover styling fix
darrenburns Oct 30, 2024
12a83ef
Fixing ListView item cs
darrenburns Oct 30, 2024
f9cc4b8
Styling fixes
darrenburns Oct 30, 2024
51da5cf
Testing fixes
darrenburns Oct 30, 2024
378dcd9
Theme fixes
darrenburns Oct 30, 2024
422241f
Button foreground colors
darrenburns Oct 31, 2024
27d8079
Buttons styles and their docs, updating snapshots
darrenburns Oct 31, 2024
29d0087
Fixing RadioSet styles
darrenburns Oct 31, 2024
735a99b
Updating radio_set snapshots
darrenburns Oct 31, 2024
2c5735b
Set App CSS `color` to `$foreground`
darrenburns Nov 5, 2024
0cbaa22
Merge branch 'themes' of github.com:Textualize/textual into themes
darrenburns Nov 5, 2024
1f56054
Text color vars
darrenburns Nov 5, 2024
1f0ffba
Fix demo background color
darrenburns Nov 5, 2024
365b758
Adding text-colors to theme sandbox, fixing warning color in gruvbox
darrenburns Nov 5, 2024
affbdc1
Muted color variations
darrenburns Nov 5, 2024
232ad2e
Non-alpha muted backgrounds
darrenburns Nov 5, 2024
994e0a5
Docs for text color
darrenburns Nov 5, 2024
be9f8eb
Themes docs
darrenburns Nov 5, 2024
ff92e72
Enumerating CSS variables
darrenburns Nov 6, 2024
2357785
Highlight lines in docs code
darrenburns Nov 6, 2024
62b8da1
Fix highlighting in tutorial
darrenburns Nov 6, 2024
e23a0ef
Theme examples
darrenburns Nov 6, 2024
b3c9089
Snapshot updates
darrenburns Nov 6, 2024
d41f062
Docs updates
darrenburns Nov 6, 2024
d78af48
Add Label variants
darrenburns Nov 7, 2024
1d21101
Typing for label variants
darrenburns Nov 7, 2024
7fad696
Ansi theme related changes
darrenburns Nov 7, 2024
778d78e
Merge remote-tracking branch 'origin' into themes
darrenburns Nov 7, 2024
1de46af
Updating snapshots
darrenburns Nov 7, 2024
e3d0fd2
Import annotations from future in label py
darrenburns Nov 7, 2024
fb7fb60
Various DataTable style fixes - fix text colors, fixed header styling…
darrenburns Nov 11, 2024
f2f7606
Updating toasts to follow new theme system conventions
darrenburns Nov 11, 2024
8905b66
Fixing snapshots, updating toasts to work better with themes
darrenburns Nov 11, 2024
05a6314
Refactor theme selection (add `search_themes`)
darrenburns Nov 12, 2024
472e94a
Merge branch 'main' into themes
darrenburns Nov 12, 2024
1ba9a03
Formatting
darrenburns Nov 12, 2024
e3badea
Changelog
darrenburns Nov 12, 2024
e735762
Merge branch 'main' into themes
darrenburns Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Added

- Added `App.theme` reactive attribute https://github.com/Textualize/textual/pull/5087
- Added various starter themes https://github.com/Textualize/textual/pull/5087
- Added "Change theme" command to command palette https://github.com/Textualize/textual/pull/5087
- Added `variant` parameter to `Label` widget for quick access to common styles https://github.com/Textualize/textual/pull/5087
- Added `App.get_theme` which returns a theme by name https://github.com/Textualize/textual/pull/5087
- Added `App.register_theme` and `App.unregister_theme` https://github.com/Textualize/textual/pull/5087
- Added `App.theme_changed_signal` https://github.com/Textualize/textual/pull/5087
- Added `App.available_themes` property which returns a mapping of theme names to `Theme` instances https://github.com/Textualize/textual/pull/5087
- Added `App.current_theme` property which returns the currently active theme object https://github.com/Textualize/textual/pull/5087
- Added `App.get_theme_variable_defaults` which returns a mapping of theme variables to their default values https://github.com/Textualize/textual/pull/5087
- Added `App.search` which allows bringing up a fuzzy search list of commands on-demand https://github.com/Textualize/textual/pull/5087
- Added `App.search_themes` which allows bringing up a fuzzy search list of themes on-demand https://github.com/Textualize/textual/pull/5087
- Added `textual.theme.ThemeProvider`, a command palette provider which returns all registered themes https://github.com/Textualize/textual/pull/5087
- Added several new built-in CSS variables https://github.com/Textualize/textual/pull/5087
- Added support for in-band terminal resize protocol https://github.com/Textualize/textual/pull/5217

### Changed
Expand All @@ -23,6 +37,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Added `textual.lazy.Reveal` https://github.com/Textualize/textual/pull/5226
- Added `Screen.action_blur` https://github.com/Textualize/textual/pull/5226

### Changed

- Breaking change: Removed `App.dark` reactive attribute https://github.com/Textualize/textual/pull/5087
- Breaking change: To improve consistency, several changes have been made to default widget CSS and the CSS variables which ship with Textual. On upgrading, your app will likely look different. All of these changes can be overidden with your own CSS. https://github.com/Textualize/textual/pull/5087

## [0.85.2] - 2024-11-02

- Fixed broken focus-within https://github.com/Textualize/textual/pull/5190
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ run := poetry run
test:
$(run) pytest tests/ -n 16 --dist=loadgroup $(ARGS)

.PHONY: testv
testv:
$(run) pytest tests/ -vvv -n 16 --dist=loadgroup $(ARGS)

.PHONY: test-snapshot-update
test-snapshot-update:
$(run) pytest tests/ --snapshot-update -n 16 --dist=loadgroup $(ARGS)
Expand Down
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
2 changes: 1 addition & 1 deletion docs/css_types/color.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A bullet point summary of the formats available follows:
- a color description in the RGB system, [with](#rgba-description) or [without](#rgb-description) opacity (e.g., `rgb(23, 78, 200)`);
- a color description in the HSL system, [with](#hsla-description) or [without](#hsl-description) opacity (e.g., `hsl(290, 70%, 80%)`);

[Textual's default themes](../guide/design.md#theme-reference) also provide many CSS variables with colors that can be used out of the box.
[Textual's default themes](../guide/design.md) also provide many CSS variables with colors that can be used out of the box.

### Named colors

Expand Down
4 changes: 3 additions & 1 deletion docs/examples/events/on_decorator01.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def on_button_pressed(self, event: Button.Pressed) -> None: # (1)!
if event.button.id == "bell":
self.bell()
elif event.button.has_class("toggle", "dark"):
self.dark = not self.dark
self.theme = (
"textual-dark" if self.theme == "textual-light" else "textual-light"
)
elif event.button.id == "quit":
self.exit()

Expand Down
4 changes: 3 additions & 1 deletion docs/examples/events/on_decorator02.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ def play_bell(self):
@on(Button.Pressed, ".toggle.dark") # (2)!
def toggle_dark(self):
"""Called when the 'toggle dark' button is pressed."""
self.dark = not self.dark
self.theme = (
"textual-dark" if self.theme == "textual-light" else "textual-light"
)

@on(Button.Pressed, "#quit") # (3)!
def quit(self):
Expand Down
1 change: 0 additions & 1 deletion docs/examples/getting_started/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

class ConsoleApp(App):
def compose(self):
self.dark = True
yield Static(DevConsoleHeader())


Expand Down
10 changes: 5 additions & 5 deletions docs/examples/styles/background_tint.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ Vertical {
background: $panel;
color: auto 90%;
}
#tint1 { background-tint: $foreground 0%; }
#tint2 { background-tint: $foreground 25%; }
#tint3 { background-tint: $foreground 50%; }
#tint4 { background-tint: $foreground 75% }
#tint5 { background-tint: $foreground 100% }
#tint1 { background-tint: $text 0%; }
#tint2 { background-tint: $text 25%; }
#tint3 { background-tint: $text 50%; }
#tint4 { background-tint: $text 75% }
#tint5 { background-tint: $text 100% }
17 changes: 17 additions & 0 deletions docs/examples/themes/colored_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from textual.app import App, ComposeResult
from textual.widgets import Label

COLORS = ("primary", "secondary", "accent", "warning", "error", "success")


class ColoredText(App[None]):
CSS = "\n".join(f".text-{color} {{color: $text-{color};}}" for color in COLORS)

def compose(self) -> ComposeResult:
for color in COLORS:
yield Label(f"$text-{color}", classes=f"text-{color}")


app = ColoredText()
if __name__ == "__main__":
app.run()
20 changes: 20 additions & 0 deletions docs/examples/themes/muted_backgrounds.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from textual.app import App, ComposeResult
from textual.widgets import Label

COLORS = ("primary", "secondary", "accent", "warning", "error", "success")


class MutedBackgrounds(App[None]):
CSS = "\n".join(
f".text-{color} {{padding: 0 1; color: $text-{color}; background: ${color}-muted;}}"
for color in COLORS
)

def compose(self) -> ComposeResult:
for color in COLORS:
yield Label(f"$text-{color} on ${color}-muted", classes=f"text-{color}")


app = MutedBackgrounds()
if __name__ == "__main__":
app.run()
96 changes: 96 additions & 0 deletions docs/examples/themes/todo_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
from itertools import cycle

from textual.app import App, ComposeResult
from textual.binding import Binding
from textual.containers import Horizontal, Vertical
from textual.widgets import Footer, Header, Input, Label, SelectionList


class TodoList(App[None]):
CSS = """
Screen {
align: center middle;
hatch: right $foreground 10%;
}
#content {
height: auto;
width: 40;
padding: 1 2;
}
#header {
height: 1;
width: auto;
margin-bottom: 1;
}
.title {
text-style: bold;
padding: 0 1;
width: 1fr;
}
#overdue {
color: $text-error;
background: $error-muted;
padding: 0 1;
width: auto;
}
#done {
color: $text-success;
background: $success-muted;
padding: 0 1;
margin: 0 1;
}
#footer {
height: auto;
margin-bottom: 2;
}
#history-header {
height: 1;
width: auto;
}
#history-done {
width: auto;
padding: 0 1;
margin: 0 1;
background: $primary-muted;
color: $text-primary;
}
"""

BINDINGS = [Binding("ctrl+t", "cycle_theme", "Cycle theme")]
THEMES = cycle(
["nord", "gruvbox", "tokyo-night", "textual-dark", "solarized-light"]
)

def compose(self) -> ComposeResult:
yield Header()
with Vertical(id="content"):
with Horizontal(id="header"):
yield Label("Today", classes="title")
yield Label("1 overdue", id="overdue")
yield Label("1 done", id="done")
yield SelectionList(
("Buy milk", 0),
("Buy bread", 1),
("Go and vote", 2, True),
("Return package", 3),
id="todo-list",
)
with Horizontal(id="footer"):
yield Input(placeholder="Add a task")

with Horizontal(id="history-header"):
yield Label("History", classes="title")
yield Label("4 items", id="history-done")

yield Footer()

def on_mount(self) -> None:
self.action_cycle_theme()

def action_cycle_theme(self) -> None:
self.theme = next(self.THEMES)


app = TodoList()
if __name__ == "__main__":
app.run()
4 changes: 3 additions & 1 deletion docs/examples/tutorial/stopwatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def action_remove_stopwatch(self) -> None:

def action_toggle_dark(self) -> None:
"""An action to toggle dark mode."""
self.dark = not self.dark
self.theme = (
"textual-dark" if self.theme == "textual-light" else "textual-light"
)


if __name__ == "__main__":
Expand Down
6 changes: 4 additions & 2 deletions docs/examples/tutorial/stopwatch01.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from textual.app import App, ComposeResult
from textual.widgets import Header, Footer
from textual.widgets import Footer, Header


class StopwatchApp(App):
Expand All @@ -14,7 +14,9 @@ def compose(self) -> ComposeResult:

def action_toggle_dark(self) -> None:
"""An action to toggle dark mode."""
self.dark = not self.dark
self.theme = (
"textual-dark" if self.theme == "textual-light" else "textual-light"
)


if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/tutorial/stopwatch02.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def compose(self) -> ComposeResult:

def action_toggle_dark(self) -> None:
"""An action to toggle dark mode."""
self.dark = not self.dark
self.theme = (
"textual-dark" if self.theme == "textual-light" else "textual-light"
)


if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/tutorial/stopwatch03.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def compose(self) -> ComposeResult:

def action_toggle_dark(self) -> None:
"""An action to toggle dark mode."""
self.dark = not self.dark
self.theme = (
"textual-dark" if self.theme == "textual-light" else "textual-light"
)


if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/tutorial/stopwatch04.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ def compose(self) -> ComposeResult:

def action_toggle_dark(self) -> None:
"""An action to toggle dark mode."""
self.dark = not self.dark
self.theme = (
"textual-dark" if self.theme == "textual-light" else "textual-light"
)


if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/tutorial/stopwatch05.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ def compose(self) -> ComposeResult:

def action_toggle_dark(self) -> None:
"""An action to toggle dark mode."""
self.dark = not self.dark
self.theme = (
"textual-dark" if self.theme == "textual-light" else "textual-light"
)


if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/tutorial/stopwatch06.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ def compose(self) -> ComposeResult:

def action_toggle_dark(self) -> None:
"""An action to toggle dark mode."""
self.dark = not self.dark
self.theme = (
"textual-dark" if self.theme == "textual-light" else "textual-light"
)


if __name__ == "__main__":
Expand Down
9 changes: 2 additions & 7 deletions docs/examples/widgets/content_switcher.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ Screen {
}

ContentSwitcher {
background: $panel;
border: round $primary;
width: 90%;
height: 1fr;
}

DataTable {
background: $panel;
}

MarkdownH2 {
background: $primary;
background: $panel;
color: yellow;
border: none;
padding: 0;
padding: 0 1;
}
4 changes: 2 additions & 2 deletions docs/examples/widgets/sparkline_colors.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ Sparkline {
}

#sxt > .sparkline--max-color {
color: $accent 30%;
color: $primary 30%;
}
#sxt > .sparkline--min-color {
color: $accent;
color: $primary;
}

#svt > .sparkline--max-color {
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/widgets/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class TreeApp(App):
def compose(self) -> ComposeResult:
tree: Tree[dict] = Tree("Dune")
tree: Tree[str] = Tree("Dune")
tree.root.expand()
characters = tree.root.add("Characters", expand=True)
characters.add_leaf("Paul")
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/CSS.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ The `background: green` is only applied to the Button underneath the mouse curso
Here are some other pseudo classes:

- `:blur` Matches widgets which *do not* have input focus.
- `:dark` Matches widgets in dark mode (where `App.dark == True`).
- `:dark` Matches widgets in dark themes (where `App.theme.dark == True`).
- `:disabled` Matches widgets which are in a disabled state.
- `:enabled` Matches widgets which are in an enabled state.
- `:even` Matches a widget at an evenly numbered position within its siblings.
Expand All @@ -336,7 +336,7 @@ Here are some other pseudo classes:
- `:focus` Matches widgets which have input focus.
- `:inline` Matches widgets when the app is running in inline mode.
- `:last-of-type` Matches a widget that is the last of its type amongst its siblings.
- `:light` Matches widgets in dark mode (where `App.dark == False`).
- `:light` Matches widgets in light themes (where `App.theme.dark == False`).
- `:odd` Matches a widget at an oddly numbered position within its siblings.

## Combinators
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
Loading
Loading