This commit is contained in:
Will McGugan
2024-05-22 12:03:18 +01:00
parent 6bdec928bb
commit 86c11a0b4d
6 changed files with 40 additions and 30 deletions

View File

@@ -34,6 +34,21 @@ A classic checkbox control.
```{.textual path="docs/examples/widgets/checkbox.py"}
```
## ClassicFooter
The original Footer widget.
!!! warning
Th has been replaced by [`Footer`](#footer), and will be removed in Textual v1.0
[ClassicFooter reference](./widgets/classic_footer.md){ .md-button .md-button--primary }
```{.textual path="docs/examples/widgets/classic_footer.py" columns="70" lines="12"}
```
## Collapsible
Content that may be toggled on and off by clicking a title.
@@ -90,19 +105,6 @@ A footer to display and interact with key bindings.
```
## ClassicFooter
The original Footer widget.
!!! warning
Th has been replaced by `Footer`, and will be removed in Textual v1.0
[ClassicFooter reference](./widgets/classic_footer.md){ .md-button .md-button--primary }
```{.textual path="docs/examples/widgets/classic_footer.py" columns="70" lines="12"}
```
## Header

View File

@@ -1,5 +1,10 @@
# ClassicFooter
!!! warning "Deprecated widget"
This is an older version of the Textual Footer, and will be replaced with [Footer](./footer.md) in Textual v1.0
A simple footer widget which is docked to the bottom of its parent container. Displays
available keybindings for the currently focused widget.

View File

@@ -1,6 +1,9 @@
# Footer
!!! tip "Added in version 0.62.0"
!!! tip "Added in version 0.63.0"
This is a second iteration of the Footer.
The version prior to 0.63.0 is available as [ClassicFooter](./classic_footer.md) to help with backwards compatibility, but will be removed in v1.0.
A simple footer widget which is docked to the bottom of its parent container. Displays
available keybindings for the currently focused widget.
@@ -8,6 +11,7 @@ available keybindings for the currently focused widget.
- [ ] Focusable
- [ ] Container
## Example
The example below shows an app with a single keybinding that contains only a `Footer`
@@ -26,9 +30,11 @@ widget. Notice how the `Footer` automatically displays the keybinding.
## Reactive Attributes
| Name | Type | Default | Description |
| --------------- | ----- | ------- | --------------------------------------------------------------------------------------------------------- |
| `highlight_key` | `str` | `None` | Stores the currently highlighted key. This is typically the key the cursor is hovered over in the footer. |
| Name | Type | Default | Description |
| ----------------- | ------ | ------- | ----------------------------------------------------------------------- |
| `upper_case_keys` | `bool` | `False` | Display the keys in upper case. |
| `ctrl_to_caret` | `bool` | `True` | Replace "ctrl+" with "^" to denote a key that requires holding ++CTRL++ |
| `compact` | `bool` | `False` | Display a more compact footer. |
## Messages
@@ -40,12 +46,8 @@ This widget has no bindings.
## Component Classes
The footer widget provides the following component classes:
This widget has no component classes.
::: textual.widgets.Footer.COMPONENT_CLASSES
options:
show_root_heading: false
show_root_toc_entry: false
## Additional Notes

View File

@@ -139,6 +139,7 @@ nav:
- Widgets:
- "widgets/button.md"
- "widgets/checkbox.md"
- "widgets/classic_footer.md"
- "widgets/collapsible.md"
- "widgets/content_switcher.md"
- "widgets/data_table.md"

View File

@@ -29,10 +29,10 @@ class ClassicFooter(Widget):
"""
| Class | Description |
| :- | :- |
| `footer--description` | Targets the descriptions of the key bindings. |
| `footer--highlight` | Targets the highlighted key binding. |
| `footer--highlight-key` | Targets the key portion of the highlighted key binding. |
| `footer--key` | Targets the key portions of the key bindings. |
| `classic-footer--description` | Targets the descriptions of the key bindings. |
| `classic-footer--highlight` | Targets the highlighted key binding. |
| `classic-footer--highlight-key` | Targets the key portion of the highlighted key binding. |
| `classic-footer--key` | Targets the key portions of the key bindings. |
"""
__name__ = "Footer"

View File

@@ -53,7 +53,7 @@ class FooterKey(Widget):
}
"""
capitalize_keys = reactive(False)
upper_case_keys = reactive(False)
ctrl_to_caret = reactive(True)
compact = reactive(True)
@@ -70,7 +70,7 @@ class FooterKey(Widget):
key_style = self.get_component_rich_style("footer-key--key")
description_style = self.get_component_rich_style("footer-key--description")
key = self.key
if self.capitalize_keys:
if self.upper_case_keys:
key = key.upper()
if key.lower().startswith("ctrl+"):
key = "^" + key.split("+", 1)[1]
@@ -113,7 +113,7 @@ class Footer(ScrollableContainer, can_focus=False, can_focus_children=False):
}
"""
capitalize_keys = reactive(False)
upper_case_keys = reactive(False)
"""Capitalize the keys."""
ctrl_to_caret = reactive(True)
"""Convert ctrl+ prefix to ^"""
@@ -134,7 +134,7 @@ class Footer(ScrollableContainer, can_focus=False, can_focus_children=False):
binding.action,
disabled=not enabled,
).data_bind(
Footer.capitalize_keys,
Footer.upper_case_keys,
Footer.ctrl_to_caret,
Footer.compact,
)