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

added tab border style #5335

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading