Files
colorshell/ags/widget/bar/Clock.ts
T

19 lines
706 B
TypeScript

import { Gtk, Widget } from "astal/gtk3";
import { getDateTime } from "../../scripts/time";
import { bind, GLib } from "astal";
import { Windows } from "../../windows";
import { CenterWindow } from "../../window/CenterWindow";
export function Clock(): Gtk.Widget {
return new Widget.Box({
className: bind(CenterWindow, "visible").as((visible: boolean) =>
visible ? "clock open" : "clock"),
child: new Widget.Button({
onClick: () => Windows.toggle(CenterWindow),
label: getDateTime().as((dateTime: GLib.DateTime) => {
return dateTime.format("%A %d, %H:%M")
})
} as Widget.ButtonProps)
} as Widget.BoxProps);
}