Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit 6064474

Browse files
committed
feat: allow customizing today format
1 parent 9a07a7f commit 6064474

File tree

8 files changed

+49
-23
lines changed

8 files changed

+49
-23
lines changed

app/assets/backgrounds/gradient.svg

+1-1
Loading

app/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const {
2727
const defaultPreferences = {
2828
calendarBackground: resolve(integratedBackgroundsDirectory, 'empty.svg'),
2929
calendarLegendFormat: 'MMM y',
30+
calendarTodayFormat: 'EEEE, do MMMM',
3031
clockFormat: 'PPPP',
3132
openAtLogin: false,
3233
};

app/locales/de.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@ module.exports = {
1818
},
1919
clockFormat: {
2020
label: 'Format der Uhr',
21-
description: 'Die System-Tray-Uhr verwendet die Formatfunktion von [date-fns](https://date-fns.org/docs/format). Verwenden Sie ein beliebiges Muster, das Ihnen gefällt.',
21+
description: 'Das [Format](https://date-fns.org/docs/format) der Uhrzeitanzeige im System-Tray.',
2222
},
2323
calendarBackground: {
2424
label: 'Hintergrund',
25-
description: 'Passen Sie den Kalenderhintergrund an Ihre persönlichen Wünsche an.',
25+
description: 'Wählen Sie einen Kalenderhintergrund aus der Ihrem Geschmack entspricht.',
2626
},
2727
calendarLegendFormat: {
2828
label: 'Format der Legende',
29-
description: 'Das Format der Legende über dem Monat. Verwendet auch die Formatfunktion von [date-fns](https://date-fns.org/docs/format).',
29+
description: 'Das [Format](https://date-fns.org/docs/format) der Legende über dem Monat.',
30+
},
31+
calendarTodayFormat: {
32+
label: 'Format des aktuellen Tages',
33+
description: 'Das [Format](https://date-fns.org/docs/format) des aktuellen Tages welches im Kalenderkopf angezeigt wird.',
3034
},
3135
shortcuts: {
3236
description: 'Im Folgenden finden Sie eine vollständige Liste der Tastenkombinationen, die Sie im Kalenderfenster verwenden können.',

app/locales/en.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,19 @@ module.exports = {
1818
},
1919
clockFormat: {
2020
label: 'Clock format',
21-
description: 'The system tray clock is using the format function of [date-fns](https://date-fns.org/docs/format). Use any pattern you may like.',
21+
description: 'The format [pattern](https://date-fns.org/docs/format) of the system tray clock.',
2222
},
2323
calendarBackground: {
2424
label: 'Background',
25-
description: 'Customize the calendar background to your personal liking.',
25+
description: 'Choose a calendar background that suits your personal liking.',
2626
},
2727
calendarLegendFormat: {
2828
label: 'Legend format',
29-
description: 'The format of the legend above the month. Uses the format function of [date-fns](https://date-fns.org/docs/format) as well.',
29+
description: 'The format [pattern](https://date-fns.org/docs/format) of the legend above the month.',
30+
},
31+
calendarTodayFormat: {
32+
label: 'Today format',
33+
description: 'The format [pattern](https://date-fns.org/docs/format) of the today display in the calendar head.',
3034
},
3135
shortcuts: {
3236
description: 'See below for a complete list of keyboard shortcuts that you can use in the calendar window.',

app/styles/components/form-group.css

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
.form-group {
22
display: grid;
3-
grid-gap: calc(var(--grid-gap) / 3) calc(var(--grid-gap) * 2);
4-
grid-template-areas: "label action" "description .";
3+
grid-gap: calc(var(--grid-gap) / 3) calc(var(--grid-gap) * 3);
4+
grid-template-areas: "label action" "description action";
55
grid-template-columns: 1fr min-content;
6-
grid-template-rows: minmax(30px, min-content) min-content;
76
}
87

98
.form-group > .label {
@@ -18,7 +17,7 @@
1817
}
1918

2019
.form-group > .action {
21-
align-self: center;
20+
align-self: flex-start;
2221
grid-area: action;
2322
margin: 0;
2423
outline: 0;
@@ -29,6 +28,8 @@
2928
font: inherit;
3029
outline: 0;
3130
padding: 2px 4px;
31+
resize: none;
32+
text-align: center;
3233
}
3334

3435
.form-group > .action.-toggle {
@@ -37,6 +38,6 @@
3738
}
3839

3940
.form-group > .action.-select {
40-
padding: 4px;
41+
padding: 5px;
4142
text-transform: capitalize;
4243
}

app/views/calendar/calendar-today/calendar-today.css

+2-5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
display: block;
88
font-size: calc(var(--type-size) * 2.5);
99
font-weight: 100;
10-
padding: calc(var(--grid-gap) * 2.5) 0 calc(var(--grid-gap) * 1.5);
11-
}
12-
13-
.calendar-today > .day {
14-
font-weight: 300;
10+
padding: calc(var(--grid-gap) * 2.5) var(--grid-gap);
11+
white-space: pre;
1512
}

app/views/calendar/calendar-today/calendar-today.js

+20-6
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,31 @@ export default class CalendarToday extends HTMLElement {
77
upgrade(this, `
88
<template>
99
<link rel="stylesheet" href="calendar-today/calendar-today.css">
10-
<span class="calendar-today" @postupdate.window="onPostUpdate" #$content>&nbsp;</span>
10+
<slot class="calendar-today">&nbsp;</slot>
1111
</template>
1212
`);
13+
14+
const { preferences } = window;
15+
16+
preferences.on('changed', this.onPreferencesChanged.bind(this));
17+
18+
this.render();
19+
}
20+
21+
onPreferencesChanged(event, key, value) {
22+
if (key !== 'calendarTodayFormat') {
23+
return;
24+
}
25+
26+
this.render(value);
1327
}
1428

15-
async onPostUpdate() {
16-
const { calendar } = window;
17-
const { $content } = this.$refs;
18-
const [day, date, month] = (await calendar.getDate({ format: 'EEEE do MMMM' })).split(' ');
29+
async render(format) {
30+
const { calendar, preferences } = window;
1931

20-
$content.innerHTML = `${day},<br><strong class="day">${date}</strong> ${month}`;
32+
this.innerHTML = await calendar.getDate({
33+
format: (format || await preferences.get('calendarTodayFormat')).replace(/\n/g, '\'<br>\''),
34+
});
2135

2236
dispatch(this, 'postrender');
2337
}

app/views/preferences/preferences-view/preferences-view.js

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ export default class PreferencesView extends HTMLElement {
8282
<translation-key class="label">preferences.calendarLegendFormat.label</translation-key>
8383
<translation-key class="description" markdown>preferences.calendarLegendFormat.description</translation-key>
8484
</label>
85+
<label class="form-group">
86+
<textarea name="calendarTodayFormat" class="action -text" cols="10"></textarea>
87+
<translation-key class="label">preferences.calendarTodayFormat.label</translation-key>
88+
<translation-key class="description" markdown>preferences.calendarTodayFormat.description</translation-key>
89+
</label>
8590
</section>
8691
<section class="content" #$content>
8792
<translation-key class="description">preferences.shortcuts.description</translation-key>

0 commit comments

Comments
 (0)