33from typing import TYPE_CHECKING , ClassVar
44
55import rich .repr
6- from rich .style import Style
76from rich .text import Text , TextType
87
98from .. import events
10- from ..app import ComposeResult , RenderResult
9+ from ..app import ComposeResult
1110from ..binding import Binding , BindingType
1211from ..containers import Container , Horizontal , Vertical
1312from ..css .query import NoMatches
1413from ..events import Mount
1514from ..geometry import Offset
1615from ..message import Message
1716from ..reactive import reactive
18- from ..renderables .bar import RenderableBar
1917from ..widget import Widget
2018from ..widgets import Static
19+ from ._bar import Bar
2120
2221if TYPE_CHECKING :
2322 from typing_extensions import Self
2423
2524
26- class Underline (Widget ):
25+ class Underline (Bar ):
2726 """The animated underline beneath tabs."""
2827
2928 DEFAULT_CSS = """
30- Underline {
31- width: 1fr;
32- height: 1;
33- }
34- Underline > .underline--bar {
35- background: $foreground 10%;
29+ Underline > .bar--bar {
3630 color: $accent;
3731 }
3832 """
3933
40- COMPONENT_CLASSES = {"underline--bar" }
41- """
42- | Class | Description |
43- | :- | :- |
44- | `underline-bar` | Style of the bar (may be used to change the color). |
45-
46- """
47-
48- highlight_start = reactive (0 )
49- """First cell in highlight."""
50- highlight_end = reactive (0 )
51- """Last cell (inclusive) in highlight."""
52-
5334 class Clicked (Message ):
5435 """Inform ancestors the underline was clicked."""
5536
@@ -60,20 +41,6 @@ def __init__(self, offset: Offset) -> None:
6041 self .offset = offset
6142 super ().__init__ ()
6243
63- @property
64- def _highlight_range (self ) -> tuple [int , int ]:
65- """Highlighted range for underline bar."""
66- return (self .highlight_start , self .highlight_end )
67-
68- def render (self ) -> RenderResult :
69- """Render the bar."""
70- bar_style = self .get_component_rich_style ("underline--bar" )
71- return RenderableBar (
72- highlight_range = self ._highlight_range ,
73- highlight_style = Style .from_color (bar_style .color ),
74- background_style = Style .from_color (bar_style .bgcolor ),
75- )
76-
7744 def _on_click (self , event : events .Click ):
7845 """Catch clicks, so that the underline can activate the tabs."""
7946 event .stop ()
@@ -160,7 +127,7 @@ class Tabs(Widget, can_focus=True):
160127 min-width: 100%;
161128 overflow: hidden hidden;
162129 }
163- Tabs:focus .underline --bar {
130+ Tabs:focus .bar --bar {
164131 background: $foreground 20%;
165132 }
166133 """
0 commit comments