Skip to content

Commit

Permalink
Fixing switch styles, adding subtle hover effect to suggest which par…
Browse files Browse the repository at this point in the history
…t will move
  • Loading branch information
darrenburns committed Oct 9, 2024
1 parent 15b7574 commit 6a248be
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 22 deletions.
62 changes: 40 additions & 22 deletions src/textual/widgets/_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,51 @@ class Switch(Widget, can_focus=True):

DEFAULT_CSS = """
Switch {
border: tall transparent;
background: $boost;
border: tall $border-blurred;
background: $surface;
height: auto;
width: auto;
padding: 0 2;
&.-on > .switch--slider {
color: $success;
}
& > .switch--slider {
background: $surface-darken-1;
color: $surface-lighten-2;
}
&:hover {
border: tall $background;
& > .switch--slider {
color: $surface-lighten-3;
}
&.-on {
& > .switch--slider {
color: $success-lighten-1;
}
}
}
&:focus {
border: tall $border;
}
&:light {
& > .switch--slider {
background: $surface-lighten-2;
color: $surface-darken-1;
}
&.-on {
& > .switch--slider {
color: $success-lighten-1;
}
&:hover > .switch--slider {
color: $success;
}
}
&:hover > .switch--slider {
color: $surface-darken-2;
}
}
}
Switch > .switch--slider {
background: $panel-darken-2;
color: $panel-lighten-2;
}
Switch:hover {
border: tall $background;
}
Switch:focus {
border: tall $accent;
}
Switch.-on {
}
Switch.-on > .switch--slider {
color: $success;
}
"""

value: reactive[bool] = reactive(False, init=False)
Expand Down
13 changes: 13 additions & 0 deletions src/textual/widgets/_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,19 @@ class Tree(Generic[TreeDataType], ScrollView, can_focus=True):
}
}
&:light {
/* In light mode the guides are darker*/
& > .tree--guides {
color: $surface-darken-1;
}
& > .tree--guides-hover {
color: $surface-darken-2;
}
& > .tree--guides-selected {
color: $surface-darken-2;
}
}
&.-ansi {
background: ansi_default;
color: ansi_default;
Expand Down

0 comments on commit 6a248be

Please sign in to comment.