Skip to content

Commit b505405

Browse files
committed
CSS tidying - using nesting in SelectionList
1 parent ea443a4 commit b505405

File tree

3 files changed

+53
-48
lines changed

3 files changed

+53
-48
lines changed

src/textual/screen.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ class Screen(Generic[ScreenResultType], Widget):
147147

148148
DEFAULT_CSS = """
149149
Screen {
150-
151150
layout: vertical;
152151
overflow-y: auto;
153152
background: $background;

src/textual/widgets/_option_list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class OptionList(ScrollView, can_focus=True):
143143
overflow-x: hidden;
144144
border: tall transparent;
145145
padding: 0 1;
146-
background: $surface ;
146+
background: $surface;
147147
}
148148
149149
OptionList:focus {

src/textual/widgets/_selection_list.py

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -96,62 +96,68 @@ class SelectionList(Generic[SelectionType], OptionList):
9696
DEFAULT_CSS = """
9797
SelectionList {
9898
height: auto;
99-
}
100-
101-
SelectionList:light:focus > .selection-list--button-selected {
102-
color: $primary;
103-
}
99+
100+
& > .selection-list--button {
101+
text-style: bold;
102+
background: $foreground 15%;
103+
}
104104
105-
SelectionList:light > .selection-list--button-selected-highlighted {
106-
color: $primary;
107-
}
105+
& > .selection-list--button-highlighted {
106+
text-style: bold;
107+
background: $foreground 15%;
108+
}
108109
109-
SelectionList:light:focus > .selection-list--button-selected-highlighted {
110-
color: $primary;
111-
}
110+
& > .selection-list--button-selected {
111+
text-style: bold;
112+
color: $success;
113+
background: $foreground 15%;
114+
}
112115
113-
SelectionList > .selection-list--button {
114-
text-style: bold;
115-
background: $foreground 15%;
116-
}
116+
& > .selection-list--button-selected-highlighted {
117+
text-style: bold;
118+
color: $success;
119+
background: $foreground 15%;
120+
}
117121
118-
SelectionList:focus > .selection-list--button {
119-
text-style: bold;
120-
background: $foreground 25%;
121-
}
122+
&:light {
123+
& > .selection-list--button-selected-highlighted {
124+
color: $primary;
125+
}
122126
123-
SelectionList > .selection-list--button-highlighted {
124-
text-style: bold;
125-
background: $foreground 15%;
126-
}
127+
&:focus {
128+
& > .selection-list--button-selected {
129+
color: $primary;
130+
}
131+
& > .selection-list--button-selected-highlighted {
132+
color: $primary;
133+
}
134+
}
135+
}
127136
128-
SelectionList:focus > .selection-list--button-highlighted {
129-
text-style: bold;
130-
background: $foreground 25%;
131-
}
137+
&:focus {
138+
& > .selection-list--button {
139+
text-style: bold;
140+
background: $foreground 25%;
141+
}
132142
133-
SelectionList > .selection-list--button-selected {
134-
text-style: bold;
135-
color: $success;
136-
background: $foreground 15%;
137-
}
143+
& > .selection-list--button-highlighted {
144+
text-style: bold;
145+
background: $foreground 25%;
146+
}
138147
139-
SelectionList:focus > .selection-list--button-selected {
140-
text-style: bold;
141-
color: $success;
142-
background: $foreground 25%;
143-
}
148+
& > .selection-list--button-selected {
149+
text-style: bold;
150+
color: $success;
151+
background: $foreground 25%;
152+
}
144153
145-
SelectionList > .selection-list--button-selected-highlighted {
146-
text-style: bold;
147-
color: $success;
148-
background: $foreground 15%;
149-
}
154+
& > .selection-list--button-selected-highlighted {
155+
text-style: bold;
156+
color: $success;
157+
background: $foreground 25%;
158+
}
159+
}
150160
151-
SelectionList:focus > .selection-list--button-selected-highlighted {
152-
text-style: bold;
153-
color: $success;
154-
background: $foreground 25%;
155161
}
156162
"""
157163

0 commit comments

Comments
 (0)