ags(workspaces, style): use eventbox instead of button, better styling

This commit is contained in:
retrozinndev
2025-04-28 15:30:15 -03:00
parent f419f4167a
commit 4cbeaf6f06
5 changed files with 79 additions and 73 deletions
+27 -26
View File
@@ -59,19 +59,23 @@
@include mixins.reset-props; @include mixins.reset-props;
padding: 0 4px; padding: 0 4px;
& button { & > eventbox {
border-radius: 16px; & > box {
transition: 80ms linear; margin: 3px 0;
min-width: 15px; border-radius: 16px;
padding: 0 6px; transition: 80ms linear;
background: colors.$bg-tertiary; min-width: 15px;
margin: 3px 0; padding: 0 6px;
background: colors.$bg-tertiary;
&:not(.focus) { & label.id {
@include mixins.hover-shadow2; font-weight: 600;
margin-right: 4px;
opacity: 0;
}
} }
&.focus { &.focus > box {
background: colors.$fg-primary; background: colors.$fg-primary;
min-width: 32px; min-width: 32px;
@@ -81,29 +85,26 @@
} }
} }
&.show {
// Smooth showing
& label.id {
opacity: 1;
}
}
& label.id {
font-weight: 600;
margin-right: 4px;
opacity: 0;
}
& icon { & icon {
font-size: 16px; font-size: 16px;
} }
&.show label.id {
opacity: 1;
}
&:hover > box {
box-shadow: inset 0 0 0 100px rgba($color: colors.$fg-primary, $alpha: .2);
}
} }
&.special-workspaces { &.special-workspaces {
& button { & > eventbox {
background: wal.$color4; & box {
background: wal.$color4;
}
&:hover { &:hover > box {
background: functions.toRGB(color.adjust(wal.$color4, $lightness: -6%)); background: functions.toRGB(color.adjust(wal.$color4, $lightness: -6%));
} }
} }
+4
View File
@@ -119,6 +119,10 @@
background: transparent; background: transparent;
box-shadow: 0 2px 0 -1px rgba(colors.$bg-secondary, .5); box-shadow: 0 2px 0 -1px rgba(colors.$bg-secondary, .5);
} }
&:focus {
outline: 1px white;
}
} }
} }
} }
+20 -20
View File
@@ -1,26 +1,26 @@
// SCSS Variables // SCSS Variables
// Generated by 'wal' // Generated by 'wal'
$wallpaper: "/home/joaov/wallpapers/Gumi Street Bike.jpg"; $wallpaper: "/home/joaov/wallpapers/Bocchi The Rock!.png";
// Special // Special
$background: #0d101f; $background: #0a0a0c;
$foreground: #c2c3c7; $foreground: #c1c1c2;
$cursor: #c2c3c7; $cursor: #c1c1c2;
// Colors // Colors
$color0: #0d101f; $color0: #0a0a0c;
$color1: #425169; $color1: #935d6d;
$color2: #4b756e; $color2: #967e84;
$color3: #488389; $color3: #ac8486;
$color4: #708078; $color4: #bcae7a;
$color5: #7a997b; $color5: #a49c9c;
$color6: #9ba287; $color6: #bcb79c;
$color7: #90929b; $color7: #8a8a96;
$color8: #5c6071; $color8: #565669;
$color9: #586C8C; $color9: #C57C92;
$color10: #649D93; $color10: #C9A9B0;
$color11: #60AFB7; $color11: #E6B1B3;
$color12: #96ABA0; $color12: #FBE8A3;
$color13: #A3CCA4; $color13: #DBD1D0;
$color14: #CFD8B4; $color14: #FBF5D1;
$color15: #c2c3c7; $color15: #c1c1c2;
+17 -15
View File
@@ -12,29 +12,31 @@ export const SpecialWorkspaces: (() => Gtk.Widget) = () => new Widget.EventBox({
spacing: 4, spacing: 4,
children: bind(AstalHyprland.get_default(), "workspaces").as((workspaces) => children: bind(AstalHyprland.get_default(), "workspaces").as((workspaces) =>
workspaces.filter(ws => ws.id < 0).sort((a, b) => a.id - b.id).map((workspace) => workspaces.filter(ws => ws.id < 0).sort((a, b) => a.id - b.id).map((workspace) =>
new Widget.Button({ new Widget.EventBox({
className: bind(AstalHyprland.get_default(), "focusedWorkspace").as(focusWs => className: bind(AstalHyprland.get_default(), "focusedWorkspace").as(focusWs =>
`${focusWs.id === workspace.id ? "focus" : ""}`), `${focusWs.id === workspace.id ? "focus" : ""}`),
tooltipText: bind(workspace, "name").as((name) => { tooltipText: bind(workspace, "name").as((name) => {
name = name.replace(/^special\:/, ""); name = name.replace(/^special\:/, "");
return name.charAt(0).toUpperCase().concat(name.substring(1, name.length)); return name.charAt(0).toUpperCase().concat(name.substring(1, name.length));
}), }),
child: new Widget.Icon({ child: new Widget.Box({
className: "last-app-icon", child: new Widget.Icon({
visible: Variable.derive([ className: "last-app-icon",
bind(workspace, "lastClient"), visible: Variable.derive([
bind(AstalHyprland.get_default(), "focusedWorkspace") bind(workspace, "lastClient"),
], (lastClient, focusedWorkspace) => focusedWorkspace?.id === workspace.id ? bind(AstalHyprland.get_default(), "focusedWorkspace")
false : Boolean(lastClient))(), ], (lastClient, focusedWorkspace) => focusedWorkspace?.id === workspace.id ?
icon: bind(workspace, "lastClient").as((lastClient) => false : Boolean(lastClient))(),
lastClient ? icon: bind(workspace, "lastClient").as((lastClient) =>
getAppIcon(lastClient.initialClass) || "image-missing" lastClient ?
: "image-missing") getAppIcon(lastClient.initialClass) || "image-missing"
} as Widget.IconProps), : "image-missing")
onClicked: () => AstalHyprland.get_default().dispatch( } as Widget.IconProps)
} as Widget.BoxProps),
onClickRelease: () => AstalHyprland.get_default().dispatch(
"togglespecialworkspace", workspace.name.replace(/^special\:/, "") "togglespecialworkspace", workspace.name.replace(/^special\:/, "")
) )
} as Widget.ButtonProps) } as Widget.EventBoxProps)
) )
) )
} as Widget.BoxProps) } as Widget.BoxProps)
+11 -12
View File
@@ -23,23 +23,24 @@ export function Workspaces(): Gtk.Widget {
(a: AstalHyprland.Workspace, b: AstalHyprland.Workspace) => a.get_id() - b.get_id()); (a: AstalHyprland.Workspace, b: AstalHyprland.Workspace) => a.get_id() - b.get_id());
return sortedWorkspaces.map((workspace: AstalHyprland.Workspace) => return sortedWorkspaces.map((workspace: AstalHyprland.Workspace) =>
new Widget.Button({ new Widget.EventBox({
className: Variable.derive([ className: Variable.derive([
bind(hyprland, "focusedWorkspace"), bind(hyprland, "focusedWorkspace"),
showWorkspaceNumbers() showWorkspaceNumbers()
], (focusedWs, showWsNumbers) => ], (focusedWs, showWsNumbers) =>
`${focusedWs.id === workspace.id ? "focus" : ""} ${showWsNumbers ? "show" : ""}` `${focusedWs.id === workspace.id ? "focus" : ""} ${showWsNumbers ? "show" : ""}`
)(), )(),
visible: true, onClickRelease: () => workspace.focus(),
tooltipText: Variable.derive([ tooltipText: Variable.derive([
bind(workspace, "lastClient"), bind(workspace, "lastClient"),
bind(hyprland, "focusedWorkspace") bind(hyprland, "focusedWorkspace")
],(lastClient, focusWs) => focusWs.id === workspace.id ? "" : ], (lastClient, focusWs) => focusWs.id === workspace.id ? "" :
`Workspace ${workspace.id}${ lastClient ? ` - ${ `Workspace ${workspace.id}${ lastClient ? ` - ${
!lastClient.title.toLowerCase().includes(lastClient.class) ? !lastClient.title.toLowerCase().includes(lastClient.class) ?
`${lastClient.get_class()}: ` `${lastClient.get_class()}: `
: "" : ""
} ${lastClient.title}` : "" }`)(), } ${lastClient.title}` : "" }`
)(),
child: new Widget.Box({ child: new Widget.Box({
children: bind(workspace, "lastClient").as((lastClient) => [ children: bind(workspace, "lastClient").as((lastClient) => [
new Widget.Revealer({ new Widget.Revealer({
@@ -49,8 +50,7 @@ export function Workspaces(): Gtk.Widget {
child: new Widget.Label({ child: new Widget.Label({
label: bind(workspace, "id").as(String), label: bind(workspace, "id").as(String),
className: "id", className: "id",
xalign: 0.5, hexpand: true
hexpand: true,
} as Widget.LabelProps) } as Widget.LabelProps)
} as Widget.RevealerProps), } as Widget.RevealerProps),
new Widget.Icon({ new Widget.Icon({
@@ -65,9 +65,8 @@ export function Workspaces(): Gtk.Widget {
: undefined : undefined
} as Widget.IconProps) } as Widget.IconProps)
]) ])
} as Widget.BoxProps), } as Widget.BoxProps)
onClicked: () => workspace.focus() } as Widget.EventBoxProps)
} as Widget.ButtonProps)
) )
}) })
} as Widget.BoxProps) } as Widget.BoxProps)