Skip to content

Commit

Permalink
Consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Oct 8, 2024
1 parent 582a7cf commit ea443a4
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 34 deletions.
11 changes: 8 additions & 3 deletions src/textual/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
NUMBER_OF_SHADES = 3

# Where no content exists
DEFAULT_DARK_BACKGROUND = "#121212"
DEFAULT_DARK_BACKGROUND = "#1e1e1e"
# What text usually goes on top off
DEFAULT_DARK_SURFACE = "#1e1e1e"
DEFAULT_DARK_SURFACE = "#232323"
# TODO - update this
# # Where no content exists
# DEFAULT_DARK_BACKGROUND = "#121212"
# # What text usually goes on top off
# DEFAULT_DARK_SURFACE = "#1e1e1e"

DEFAULT_LIGHT_SURFACE = "#f5f5f5"
DEFAULT_LIGHT_BACKGROUND = "#efefef"
Expand Down Expand Up @@ -193,7 +198,7 @@ def luminosity_range(spread) -> Iterable[tuple[str, float]]:
# The cursor color for widgets such as OptionList, DataTable, etc.
colors["cursor"] = accent.hex
# The cursor should dim when the widget is blurred.
colors["cursor-blurred"] = accent.with_alpha(0.4).hex
colors["cursor-blurred"] = accent.with_alpha(0.3).hex

# The border color for focused widgets which have a border.
colors["border"] = accent.hex
Expand Down
2 changes: 1 addition & 1 deletion src/textual/screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Screen(Generic[ScreenResultType], Widget):
layout: vertical;
overflow-y: auto;
background: $surface;
background: $background;
&:inline {
height: auto;
Expand Down
4 changes: 2 additions & 2 deletions src/textual/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ class Widget(DOMNode):
scrollbar-background-hover: $panel-darken-2;
scrollbar-background-active: $panel-darken-3;
scrollbar-color: $primary-lighten-1;
scrollbar-color-active: $warning-darken-1;
scrollbar-color-hover: $primary-lighten-1;
scrollbar-color-active: $secondary;
scrollbar-color-hover: $primary-lighten-2;
scrollbar-corner-color: $panel-darken-1;
scrollbar-size-vertical: 2;
scrollbar-size-horizontal: 1;
Expand Down
7 changes: 2 additions & 5 deletions src/textual/widgets/_data_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,17 +314,14 @@ class DataTable(ScrollView, Generic[CellType], can_focus=True):
"""

DEFAULT_CSS = """
DataTable:dark {
background: initial;
}
DataTable {
background: $surface ;
background: $surface;
color: $text;
height: auto;
max-height: 100%;
&:dark {
background: initial;
background: $surface;
& > .datatable--even-row {
background: $primary 15%;
}
Expand Down
2 changes: 1 addition & 1 deletion src/textual/widgets/_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class Input(Widget, can_focus=True):

DEFAULT_CSS = """
Input {
background: $boost;
background: $surface;
color: $text;
padding: 0 2;
border: tall $border-blurred;
Expand Down
29 changes: 11 additions & 18 deletions src/textual/widgets/_list_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,22 @@ class ListItem(Widget, can_focus=False):
documentation for more details on use.
"""

SCOPED_CSS = False

DEFAULT_CSS = """
ListItem {
color: $text;
height: auto;
background: $background;
overflow: hidden hidden;
}
ListItem > :disabled {
background: $background;
}
ListItem > Widget :hover {
background: $hover;
}
ListView > ListItem.--highlight {
background: $cursor-blurred;
}
ListView:focus > ListItem.--highlight {
background: $cursor;
}
ListItem > Widget {
height: auto;
background: $surface;
& > :disabled {
background: $background;
}
& > Widget {
height: auto;
& :hover {
background: $hover;
}
}
}
"""

Expand Down
12 changes: 12 additions & 0 deletions src/textual/widgets/_list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ class ListView(VerticalScroll, can_focus=True, can_focus_children=False):
index: The index in the list that's currently highlighted.
"""

DEFAULT_CSS = """
ListView {
background: transparent;
& > ListItem.--highlight {
background: $cursor-blurred;
}
&:focus > ListItem.--highlight {
background: $cursor;
}
}
"""

BINDINGS: ClassVar[list[BindingType]] = [
Binding("enter", "select_cursor", "Select", show=False),
Binding("up", "cursor_up", "Cursor up", show=False),
Expand Down
5 changes: 2 additions & 3 deletions src/textual/widgets/_option_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class OptionList(ScrollView, can_focus=True):
overflow-x: hidden;
border: tall transparent;
padding: 0 1;
background: $surface ;
}
OptionList:focus {
Expand All @@ -155,7 +156,7 @@ class OptionList(ScrollView, can_focus=True):
OptionList > .option-list--option-highlighted {
color: $text;
text-style: bold;
background: $cursor-blurred;
}
OptionList:focus > .option-list--option-highlighted {
Expand All @@ -173,13 +174,11 @@ class OptionList(ScrollView, can_focus=True):
OptionList > .option-list--option-hover-highlighted {
background: $accent 60%;
color: $text;
text-style: bold;
}
OptionList:focus > .option-list--option-hover-highlighted {
background: $accent;
color: $text;
text-style: bold;
}
"""

Expand Down
2 changes: 1 addition & 1 deletion src/textual/widgets/_text_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class TextArea(ScrollView):
height: 1fr;
border: tall $background;
padding: 0 1;
background: $surface;
& .text-area--gutter {
color: $text 40%;
}
Expand Down

0 comments on commit ea443a4

Please sign in to comment.