feat: add option to hide seconds on calendar (#343)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { BoxWidget } from 'lib/types/widget';
|
import { BoxWidget } from 'lib/types/widget';
|
||||||
import options from 'options';
|
import options from 'options';
|
||||||
|
|
||||||
const { military } = options.menus.clock.time;
|
const { military, hideSeconds } = options.menus.clock.time;
|
||||||
|
|
||||||
const time = Variable('', {
|
const time = Variable('', {
|
||||||
poll: [1000, 'date "+%I:%M:%S"'],
|
poll: [1000, 'date "+%I:%M:%S"'],
|
||||||
@@ -26,43 +26,48 @@ const TimeWidget = (): BoxWidget => {
|
|||||||
vpack: 'center',
|
vpack: 'center',
|
||||||
hpack: 'center',
|
hpack: 'center',
|
||||||
class_name: 'clock-content-items',
|
class_name: 'clock-content-items',
|
||||||
children: military.bind('value').as((is24hr) => {
|
children: Utils.merge(
|
||||||
if (!is24hr) {
|
[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 [
|
return [
|
||||||
Widget.Box({
|
Widget.Box({
|
||||||
hpack: 'center',
|
hpack: 'center',
|
||||||
children: [
|
children: [
|
||||||
Widget.Label({
|
Widget.Label({
|
||||||
class_name: 'clock-content-time',
|
class_name: 'clock-content-time',
|
||||||
label: time.bind(),
|
label: hideSeconds
|
||||||
}),
|
? militaryTime.bind().as((str) => str.slice(0, -3))
|
||||||
],
|
: militaryTime.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: militaryTime.bind(),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
];
|
|
||||||
}),
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1137,6 +1137,7 @@ const options = mkOptions(OPTIONS, {
|
|||||||
clock: {
|
clock: {
|
||||||
time: {
|
time: {
|
||||||
military: opt(false),
|
military: opt(false),
|
||||||
|
hideSeconds: opt(false),
|
||||||
},
|
},
|
||||||
weather: {
|
weather: {
|
||||||
enabled: opt(true),
|
enabled: opt(true),
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ export const ClockMenuSettings = (): Scrollable<Child, Attribute> => {
|
|||||||
children: [
|
children: [
|
||||||
Header('Time'),
|
Header('Time'),
|
||||||
Option({ opt: options.menus.clock.time.military, title: 'Use 24hr time', type: 'boolean' }),
|
Option({ opt: options.menus.clock.time.military, title: 'Use 24hr time', type: 'boolean' }),
|
||||||
|
Option({ opt: options.menus.clock.time.hideSeconds, title: 'Hide seconds', type: 'boolean' }),
|
||||||
|
|
||||||
Header('Weather'),
|
Header('Weather'),
|
||||||
Option({ opt: options.menus.clock.weather.enabled, title: 'Enabled', type: 'boolean' }),
|
Option({ opt: options.menus.clock.weather.enabled, title: 'Enabled', type: 'boolean' }),
|
||||||
|
|||||||
Reference in New Issue
Block a user