-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(footer): enable spacing between key and description (#4651)
* fix(footer): enable padding between key and description * add snapshot test for compact footer * change space between key and description to margin * change hardcoded key padding to component CSS * simplify space between FooterKeys to grid gutter * update snapshot tests that contain a footer * simplify by removing now unnecessary if/else * tweak regression test docstring wording * update changelog * Revert "update snapshot tests that contain a footer" This reverts commit 36ecb04. * Update snapshots using latest Textual version. * update the changelog * fix sizing issue by setting reactive layout * revert grid-gutter change * change key margin to description padding * add footer hover snapshot tests * update snapshots * update changelog description * remove old commented out code * remove now unnecessary reactive layout update --------- Co-authored-by: Darren Burns <[email protected]>
- Loading branch information
1 parent
19adafd
commit 49008ef
Showing
6 changed files
with
948 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
50 changes: 50 additions & 0 deletions
50
tests/snapshot_tests/snapshot_apps/footer_classic_styling.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
from textual.app import App, ComposeResult | ||
from textual.widgets import Footer | ||
|
||
|
||
class ClassicFooterStylingApp(App): | ||
""" | ||
This app attempts to replicate the styling of the classic footer in | ||
Textual before v0.63.0, in particular the distinct background color | ||
for the binding keys and spacing between the key and binding description. | ||
Regression test for https://github.com/Textualize/textual/issues/4557 | ||
""" | ||
|
||
CSS = """ | ||
Footer { | ||
background: $accent; | ||
FooterKey { | ||
background: $accent; | ||
color: $text; | ||
.footer-key--key { | ||
background: $accent-darken-2; | ||
color: $text; | ||
} | ||
.footer-key--description { | ||
padding: 0 1; | ||
} | ||
} | ||
} | ||
""" | ||
|
||
BINDINGS = [ | ||
("ctrl+t", "app.toggle_dark", "Toggle Dark mode"), | ||
("ctrl+q", "quit", "Quit"), | ||
] | ||
|
||
def compose(self) -> ComposeResult: | ||
yield Footer() | ||
|
||
def on_mount(self) -> None: | ||
footer = self.query_one(Footer) | ||
footer.upper_case_keys = True | ||
footer.ctrl_to_caret = False | ||
|
||
|
||
if __name__ == "__main__": | ||
app = ClassicFooterStylingApp() | ||
app.run() |
34 changes: 34 additions & 0 deletions
34
tests/snapshot_tests/snapshot_apps/footer_toggle_compact.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from textual.app import App, ComposeResult | ||
from textual.widgets import Footer, Label | ||
|
||
|
||
class ToggleCompactFooterApp(App): | ||
CSS = """ | ||
Screen { | ||
align: center middle; | ||
} | ||
""" | ||
|
||
BINDINGS = [ | ||
("ctrl+t", "toggle_compact_footer", "Toggle Compact Footer"), | ||
("ctrl+q", "quit", "Quit"), | ||
] | ||
|
||
def compose(self) -> ComposeResult: | ||
yield Label("Compact Footer") | ||
yield Footer() | ||
|
||
def on_mount(self) -> None: | ||
footer = self.query_one(Footer) | ||
footer.compact = True | ||
|
||
def action_toggle_compact_footer(self) -> None: | ||
footer = self.query_one(Footer) | ||
footer.compact = not footer.compact | ||
footer_type = "Compact" if footer.compact else "Standard" | ||
self.query_one(Label).update(f"{footer_type} Footer") | ||
|
||
|
||
if __name__ == "__main__": | ||
app = ToggleCompactFooterApp() | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters