Skip to content

Commit

Permalink
change hardcoded key padding to component CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
TomJGooding committed Jun 21, 2024
1 parent 61add04 commit 1a26506
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/textual/widgets/_footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class FooterKey(Widget):
background: $panel;
text-style: bold;
margin-right: 0;
padding: 0 1;
}
&:light .footer-key--key {
Expand All @@ -60,6 +61,7 @@ class FooterKey(Widget):
&.-compact .footer-key--key {
margin-right: 1;
padding: 0;
}
}
Expand Down Expand Up @@ -89,21 +91,27 @@ def render(self) -> Text:
description_style = self.get_component_rich_style("footer-key--description")
key_display = self.key_display
key_margin = self.get_component_styles("footer-key--key").margin
# key_padding = self.get_component_styles("footer-key--key").padding
key_padding = self.get_component_styles("footer-key--key").padding
if self.upper_case_keys:
key_display = key_display.upper()
if self.ctrl_to_caret and key_display.lower().startswith("ctrl+"):
key_display = "^" + key_display.split("+", 1)[1]
description = self.description
if self.compact:
label_text = Text.assemble(
(key_display, key_style),
(
" " * key_padding.left + key_display + " " * key_padding.right,
key_style,
),
" " * key_margin.right,
(description, description_style),
)
else:
label_text = Text.assemble(
(f" {key_display} ", key_style),
(
" " * key_padding.left + key_display + " " * key_padding.right,
key_style,
),
" " * key_margin.right,
(description, description_style),
" ",
Expand Down

0 comments on commit 1a26506

Please sign in to comment.