nixos-configs/devices/wim/config/ags/js/date.js

89 lines
2.1 KiB
JavaScript
Raw Normal View History

2023-11-06 18:37:23 -05:00
import { Box, Calendar, Label } from 'resource:///com/github/Aylur/ags/widget.js';
import GLib from 'gi://GLib';
const { DateTime } = GLib;
2023-09-11 21:10:00 -04:00
import PopupWindow from './misc/popup.js';
2023-09-11 21:10:00 -04:00
const Divider = () => Box({
className: 'divider',
vertical: true,
2023-09-11 21:10:00 -04:00
});
const Time = () => Box({
className: 'timebox',
vertical: true,
children: [
2023-09-11 21:10:00 -04:00
Box({
className: 'time-container',
2023-11-06 18:37:23 -05:00
hpack: 'center',
vpack: 'center',
children: [
2023-09-11 21:10:00 -04:00
Label({
className: 'content',
label: 'hour',
connections: [[1000, (self) => {
self.label = DateTime.new_now_local().format('%H');
}]],
}),
2023-09-11 21:10:00 -04:00
Divider(),
2023-09-11 21:10:00 -04:00
Label({
className: 'content',
label: 'minute',
connections: [[1000, (self) => {
self.label = DateTime.new_now_local().format('%M');
}]],
}),
2023-09-11 21:10:00 -04:00
],
}),
2023-09-11 21:10:00 -04:00
Box({
className: 'date-container',
2023-11-06 18:37:23 -05:00
hpack: 'center',
child: Label({
2023-11-06 18:37:23 -05:00
css: 'font-size: 20px',
label: 'complete date',
connections: [[1000, (self) => {
const time = DateTime.new_now_local();
self.label = time.format('%A, %B ') +
time.get_day_of_month() +
time.format(', %Y');
}]],
}),
}),
2023-09-11 21:10:00 -04:00
],
2023-09-11 21:10:00 -04:00
});
const CalendarWidget = () => Box({
className: 'cal-box',
2023-11-06 18:37:23 -05:00
child: Calendar({
showDayNames: true,
showHeading: true,
className: 'cal',
}),
2023-09-11 21:10:00 -04:00
});
const TOP_MARGIN = 6;
export default () => PopupWindow({
anchor: ['top'],
margins: [TOP_MARGIN, 0, 0, 0],
name: 'calendar',
child: Box({
className: 'date',
vertical: true,
children: [
Time(),
CalendarWidget(),
],
}),
2023-09-11 21:10:00 -04:00
});