feat: add option to hide seconds on calendar (#343)

This commit is contained in:
Rubin Bhandari
2024-10-21 01:52:29 +05:45
committed by GitHub
parent 166120f603
commit 5b01d3e60e
3 changed files with 35 additions and 28 deletions

View File

@@ -1,7 +1,7 @@
import { BoxWidget } from 'lib/types/widget';
import options from 'options';
const { military } = options.menus.clock.time;
const { military, hideSeconds } = options.menus.clock.time;
const time = Variable('', {
poll: [1000, 'date "+%I:%M:%S"'],
@@ -26,43 +26,48 @@ const TimeWidget = (): BoxWidget => {
vpack: 'center',
hpack: 'center',
class_name: 'clock-content-items',
children: military.bind('value').as((is24hr) => {
if (!is24hr) {
children: Utils.merge(
[military.bind('value'), hideSeconds.bind('value')],
(is24hr: boolean, hideSeconds: boolean) => {
if (!is24hr) {
return [
Widget.Box({
hpack: 'center',
children: [
Widget.Label({
class_name: 'clock-content-time',
label: hideSeconds ? time.bind().as((str) => str.slice(0, -3)) : time.bind(),
}),
],
}),
Widget.Box({
hpack: 'center',
children: [
Widget.Label({
vpack: 'end',
class_name: 'clock-content-period',
label: period.bind(),
}),
],
}),
];
}
return [
Widget.Box({
hpack: 'center',
children: [
Widget.Label({
class_name: 'clock-content-time',
label: time.bind(),
}),
],
}),
Widget.Box({
hpack: 'center',
children: [
Widget.Label({
vpack: 'end',
class_name: 'clock-content-period',
label: period.bind(),
label: hideSeconds
? militaryTime.bind().as((str) => str.slice(0, -3))
: militaryTime.bind(),
}),
],
}),
];
}
return [
Widget.Box({
hpack: 'center',
children: [
Widget.Label({
class_name: 'clock-content-time',
label: militaryTime.bind(),
}),
],
}),
];
}),
},
),
}),
});
};