nixos-configs/modules/ags/gtk4/widget/bar.tsx

49 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-12-31 23:54:29 -05:00
import { App, Astal, Gtk } from 'astal/gtk4';
import { Variable } from 'astal';
2025-01-01 13:38:44 -05:00
import { Box, Button, Calendar, CenterBox, Label, MenuButton, Popover, Window } from './subclasses';
2024-12-31 23:54:29 -05:00
const { EXCLUSIVE } = Astal.Exclusivity;
const { TOP, LEFT, RIGHT } = Astal.WindowAnchor;
const { CENTER } = Gtk.Align;
const time = Variable(0);
setInterval(() => {
time.set(time.get() + 1);
}, 1000);
export default () => {
const styledBox = (
2025-01-01 02:55:15 -05:00
<Box
2024-12-31 23:54:29 -05:00
css={time().as((t) => `* { background: red; min-height: 10px; min-width: ${t}px; }`)}
/>
2025-01-01 02:55:15 -05:00
) as Box;
2024-12-31 23:54:29 -05:00
return (
2025-01-01 13:38:44 -05:00
<Window
2024-12-31 23:54:29 -05:00
visible
cssClasses={['Bar']}
exclusivity={EXCLUSIVE}
anchor={TOP | LEFT | RIGHT}
application={App}
>
2025-01-01 02:55:15 -05:00
<CenterBox cssName="centerbox">
<Button onClicked="echo hi" />
2024-12-31 23:54:29 -05:00
{styledBox}
2025-01-01 13:38:44 -05:00
<MenuButton
2024-12-31 23:54:29 -05:00
hexpand
halign={CENTER}
>
2025-01-01 13:38:44 -05:00
<Label label={time().as(String)} />
<Popover>
<Calendar />
</Popover>
</MenuButton>
2025-01-01 02:55:15 -05:00
</CenterBox>
2025-01-01 13:38:44 -05:00
</Window>
2024-12-31 23:54:29 -05:00
);
};