feat: update style

This commit is contained in:
tux
2025-06-09 05:00:00 +05:30
parent 72f9c24482
commit 9f7a23809e
8 changed files with 42 additions and 61 deletions

View File

@@ -5,9 +5,11 @@ export const Battery = () => {
const battery = AstalBattery.get_default();
return (
<box cssClasses={["battery"]} visible={bind(battery, "isPresent")}>
<box cssClasses={["pill"]} visible={bind(battery, "isPresent")}>
<label
label={bind(battery, "percentage").as((p) => `${Math.floor(p * 100)}%`)}
label={bind(battery, "percentage").as(
(p) => `Bat: ${Math.floor(p * 100)}%`,
)}
/>
</box>
);

View File

@@ -1,15 +1,13 @@
import { App, Astal, Gdk } from "astal/gtk4";
import { FocusedClient, WorkspaceButton } from "./workspace";
import { Battery } from "./battery";
import { Launcher } from "./launcher";
import { Tailscale } from "./tailscale";
import { Tray } from "./tray";
import { Time } from "./time";
export const WINDOW_NAME = "bar";
export const Bar = (gdkmonitor: Gdk.Monitor) => {
const { TOP, LEFT, RIGHT } = Astal.WindowAnchor;
const { TOP } = Astal.WindowAnchor;
return (
<window
@@ -18,7 +16,7 @@ export const Bar = (gdkmonitor: Gdk.Monitor) => {
cssClasses={["Bar"]}
gdkmonitor={gdkmonitor}
exclusivity={Astal.Exclusivity.EXCLUSIVE}
anchor={TOP | LEFT | RIGHT}
anchor={TOP}
application={App}
>
<centerbox>
@@ -32,8 +30,7 @@ export const Bar = (gdkmonitor: Gdk.Monitor) => {
const Start = () => {
return (
<box spacing={15}>
<Launcher />
<box spacing={10}>
<WorkspaceButton />
</box>
);
@@ -45,10 +42,9 @@ const Center = () => {
const End = () => {
return (
<box spacing={15}>
<box spacing={10}>
<Tailscale />
<Battery />
<Tray />
<Time />
</box>
);

View File

@@ -7,6 +7,7 @@ window.Bar {
margin: 5px;
border-radius: $rounded;
padding: 10px;
min-width: 100rem;
.launcher {
background-color: $inactive-color;
@@ -30,8 +31,8 @@ window.Bar {
border: 0px;
margin: 2px;
background-color: $inactive-color;
min-height: 1.3rem;
min-width: 1.3rem;
min-height: 1rem;
min-width: 1rem;
border-radius: calc(list.nth(8px, 1) * 1.5);
transition: min-width 0.15s ease-out;
@@ -43,8 +44,8 @@ window.Bar {
}
&.active {
min-width: 3.5rem;
min-height: 1.3rem;
min-width: 2.5rem;
min-height: 1rem;
background-color: $accent;
}
@@ -59,42 +60,14 @@ window.Bar {
.focused-client {
font-size: $font-size;
font-weight: 900;
color: $fg-color;
}
.tailscale {
.pill {
font-size: $font-size;
font-weight: 900;
color: $bg-color;
color: $fg-color;
background-color: $inactive-color;
border-radius: $rounded;
padding: 0px 10px;
}
.tray {
font-size: $font-size;
font-weight: 900;
color: #fff;
background-color: $inactive-color;
border-radius: $rounded;
padding: 0px 10px;
}
.battery {
font-size: $font-size;
font-weight: 900;
color: $bg-color;
background-color: $inactive-color;
border-radius: $rounded;
padding: 0px 10px;
}
.time {
font-size: $font-size;
font-weight: 900;
color: $bg-color;
background-color: $inactive-color;
border-radius: $rounded;
padding: 0px 10px;
border-radius: calc($rounded / 1.5);
padding: 5px 10px;
}
}

View File

@@ -8,11 +8,11 @@ export const Tailscale = () => {
]);
return (
<box cssClasses={["tailscale"]}>
<box cssClasses={["pill"]}>
<label
label={bind(tailscale).as((val) => {
const data = val.split(" ");
return data[data.length - 1];
return "Home: " + data[data.length - 1];
})}
/>
</box>

View File

@@ -3,10 +3,10 @@ import { GLib, Variable } from "astal";
export const Time = () => {
const time = Variable("").poll(
1000,
() => GLib.DateTime.new_now_local().format("%I:%M:%S %p")!,
() => GLib.DateTime.new_now_local().format("%a %b %d - %I:%M:%S %p")!,
);
return (
<label cssClasses={["time"]} onDestroy={() => time.drop()} label={time()} />
<label cssClasses={["pill"]} onDestroy={() => time.drop()} label={time()} />
);
};

View File

@@ -9,7 +9,7 @@ export const Tray = () => {
}
return (
<box cssClasses={["tray"]}>
<box cssClasses={["pill"]}>
{bind(tray, "items").as((items) =>
items.map((item) => <image gicon={bind(item, "gicon")} />),
)}

View File

@@ -48,9 +48,14 @@ export const WorkspaceButton = () => {
export const FocusedClient = () => {
const hyprland = AstalHyprland.get_default();
const title = bind(hyprland, "focusedClient").as(
(fcsClient) => fcsClient.title,
);
const focused = bind(hyprland, "focusedClient");
return <label cssClasses={["focused-client"]}>{title}</label>;
return (
<box cssClasses={["focused-client"]} visible={focused.as(Boolean)}>
{focused.as(
(client) =>
client && <label label={bind(client, "initialTitle").as(String)} />,
)}
</box>
);
};