Skip to content

Commit

Permalink
Merge pull request #5335 from Textualize/tab-border
Browse files Browse the repository at this point in the history
added tab border style
  • Loading branch information
willmcgugan authored Dec 3, 2024
2 parents 5ef3af1 + 93f823f commit 5adfbe5
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 67 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

## Added

- Added "tab" border style https://github.com/Textualize/textual/pull/5335

## Changed

- Fixed Select not scrolling highlight in to view when clicked https://github.com/Textualize/textual/issues/5255
Expand Down
16 changes: 15 additions & 1 deletion src/textual/_border.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@
("▊", " ", "▎"),
("▊", "▁", "▎"),
),
"tab": (
("▁", "▁", "▁"),
("▎", " ", "▊"),
("▔", "▔", "▔"),
),
"wide": (
("▁", "▁", "▁"),
("▎", " ", "▊"),
Expand Down Expand Up @@ -205,6 +210,11 @@
(2, 0, 1),
(2, 0, 1),
),
"tab": (
(1, 1, 1),
(0, 1, 3),
(1, 1, 1),
),
"wide": (
(1, 1, 1),
(0, 1, 3),
Expand All @@ -215,7 +225,10 @@
# Some borders (such as panel) require that the title (and subtitle) be draw in reverse.
# This is a mapping of the border type on to a tuple for the top and bottom borders, to indicate
# reverse colors is required.
BORDER_TITLE_FLIP: dict[str, tuple[bool, bool]] = {"panel": (True, False)}
BORDER_TITLE_FLIP: dict[str, tuple[bool, bool]] = {
"panel": (True, False),
"tab": (True, True),
}

# In a similar fashion, we extract the border _label_ locations for easier access when
# rendering a border label.
Expand Down Expand Up @@ -343,6 +356,7 @@ def render_border_label(
cells_reserved = 2 * corners_needed

text_label, label_style = label

if not text_label.cell_len or width <= cells_reserved:
return

Expand Down
1 change: 1 addition & 0 deletions src/textual/css/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"round",
"solid",
"tall",
"tab",
"thick",
"vkey",
"wide",
Expand Down
1 change: 1 addition & 0 deletions src/textual/css/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"hkey",
"vkey",
"tall",
"tab",
"panel",
"wide",
]
Expand Down
7 changes: 1 addition & 6 deletions src/textual/widgets/_footer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,7 @@ class FooterKey(Widget):
}
&.-disabled {
text-style: dim;
&:hover {
.footer-key--key {
background: $foreground-disabled;
}
}
text-style: dim;
}
&.-compact {
Expand Down
152 changes: 152 additions & 0 deletions tests/snapshot_tests/__snapshots__/test_snapshots/test_border_tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5adfbe5

Please sign in to comment.