11import { upgrade } from '../../../../node_modules/@browserkids/dom/index.js' ;
22
3+ const { app, preferences } = window ;
4+
35export default class PreferencesView extends HTMLElement {
46 constructor ( ) {
57 super ( ) ;
68
7- const { app } = window ;
8-
99 upgrade ( this , `
10- <template>
11- <link rel="stylesheet" href="../../styles/components/button-primary.css">
12- <link rel="stylesheet" href="../../styles/components/container-alert.css">
13- <link rel="stylesheet" href="../../styles/components/form-group.css">
14- <link rel="stylesheet" href="../../styles/components/list-shortcuts.css">
15- <link rel="stylesheet" href="preferences-view/preferences-view.css">
16-
17- <div class="preferences-view">
18- <aside class="preferences-side side">
19- <img class="logo" src="../../assets/logo.svg" alt="">
20- <h1 class="name">${ app . productName } </h1>
21-
22- <nav class="navigation preferences-navigation">
23- <button #$tab class="item" @click="onCategoryClicked">
24- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>
25- <translation-key class="title">preferences.category.general</translation-key>
26- </button>
27- <button #$tab class="item" @click="onCategoryClicked">
28- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>
29- <translation-key class="title">preferences.category.tray</translation-key>
30- </button>
31- <button #$tab class="item" @click="onCategoryClicked">
32- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>
33- <translation-key class="title">preferences.category.calendar</translation-key>
34- </button>
35- <button #$tab class="item" @click="onCategoryClicked">
36- <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><path d="M18 3a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3H6a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3V6a3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3h12a3 3 0 0 0 3-3 3 3 0 0 0-3-3z"></path></svg>
37- <translation-key class="title">preferences.category.shortcuts</translation-key>
38- </button>
39- </nav>
40- <section class="about preferences-about">v${ app . version } </section>
41- </aside>
42-
43- <section #$alert class="alert -hidden container-alert">
44- <span class="icon">🎉</span>
45- <translation-key>app.updateDownloaded</translation-key>
46- <div class="actions">
47- <button @click="onRestartClicked" class="button-primary">
48- <translation-key>app.restart</translation-key>
49- </button>
50- </div>
10+ <link rel="stylesheet" href="../../styles/components/button-primary.css">
11+ <link rel="stylesheet" href="../../styles/components/container-alert.css">
12+ <link rel="stylesheet" href="../../styles/components/form-group.css">
13+ <link rel="stylesheet" href="../../styles/components/list-shortcuts.css">
14+ <link rel="stylesheet" href="preferences-view/preferences-view.css">
15+
16+ <div class="preferences-view">
17+ <aside class="preferences-side side">
18+ <img class="logo" src="../../assets/logo.svg" alt="">
19+ <h1 class="name">${ app . productName } </h1>
20+
21+ <nav class="navigation preferences-navigation">
22+ <button #$tab class="item" @click="onCategoryClicked">
23+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><circle cx="12" cy="12" r="3"></circle><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"></path></svg>
24+ <translation-key class="title">preferences.category.general</translation-key>
25+ </button>
26+ <button #$tab class="item" @click="onCategoryClicked">
27+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"></path><path d="M13.73 21a2 2 0 0 1-3.46 0"></path></svg>
28+ <translation-key class="title">preferences.category.tray</translation-key>
29+ </button>
30+ <button #$tab class="item" @click="onCategoryClicked">
31+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>
32+ <translation-key class="title">preferences.category.calendar</translation-key>
33+ </button>
34+ <button #$tab class="item" @click="onCategoryClicked">
35+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon"><path d="M18 3a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3H6a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3V6a3 3 0 0 0-3-3 3 3 0 0 0-3 3 3 3 0 0 0 3 3h12a3 3 0 0 0 3-3 3 3 0 0 0-3-3z"></path></svg>
36+ <translation-key class="title">preferences.category.shortcuts</translation-key>
37+ </button>
38+ </nav>
39+ <section class="about preferences-about">v${ app . version } </section>
40+ </aside>
41+
42+ <section #$alert class="alert -hidden container-alert">
43+ <span class="icon">🎉</span>
44+ <translation-key>app.updateDownloaded</translation-key>
45+ <div class="actions">
46+ <button @click="onRestartClicked" class="button-primary">
47+ <translation-key>app.restart</translation-key>
48+ </button>
49+ </div>
50+ </section>
51+
52+ <form
53+ #$form
54+ @input="onInput"
55+ @postrender="onPostRender"
56+ @keydown.window="onKeyDown"
57+ class="contents preferences-contents"
58+ >
59+ <section class="content" #$content>
60+ <label class="form-group">
61+ <input type="checkbox" name="openAtLogin" class="action -toggle">
62+ <translation-key class="label">preferences.openAtLogin.label</translation-key>
63+ <translation-key class="description">preferences.openAtLogin.description</translation-key>
64+ </label>
5165 </section>
52-
53- <form
54- #$form
55- @input="onInput"
56- @postrender="onPostRender"
57- @keydown.window="onKeyDown"
58- class="contents preferences-contents"
59- >
60- <section class="content" #$content>
61- <label class="form-group">
62- <input type="checkbox" name="openAtLogin" class="action -toggle">
63- <translation-key class="label">preferences.openAtLogin.label</translation-key>
64- <translation-key class="description">preferences.openAtLogin.description</translation-key>
65- </label>
66- </section>
67- <section class="content" #$content>
68- <label class="form-group">
69- <input type="text" name="clockFormat" class="action -text" size="12">
70- <translation-key class="label">preferences.clockFormat.label</translation-key>
71- <translation-key class="description" markdown>preferences.clockFormat.description</translation-key>
72- </label>
73- </section>
74- <section class="content" #$content>
75- <label class="form-group">
76- <select #$backgrounds name="calendarBackground" class="action -select"></select>
77- <translation-key class="label">preferences.calendarBackground.label</translation-key>
78- <translation-key class="description">preferences.calendarBackground.description</translation-key>
79- </label>
80- <label class="form-group">
81- <input type="text" name="calendarLegendFormat" class="action -text" size="8">
82- <translation-key class="label">preferences.calendarLegendFormat.label</translation-key>
83- <translation-key class="description" markdown>preferences.calendarLegendFormat.description</translation-key>
84- </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>
90- </section>
91- <section class="content" #$content>
92- <translation-key class="description">preferences.shortcuts.description</translation-key>
93- <dl class="list-shortcuts" #$keys></dl>
94- </section>
95- </form>
96- </div>
97- </template>
66+ <section class="content" #$content>
67+ <label class="form-group">
68+ <input type="text" name="clockFormat" class="action -text" size="12">
69+ <translation-key class="label">preferences.clockFormat.label</translation-key>
70+ <translation-key class="description" markdown>preferences.clockFormat.description</translation-key>
71+ </label>
72+ </section>
73+ <section class="content" #$content>
74+ <label class="form-group">
75+ <select #$backgrounds name="calendarBackground" class="action -select"></select>
76+ <translation-key class="label">preferences.calendarBackground.label</translation-key>
77+ <translation-key class="description">preferences.calendarBackground.description</translation-key>
78+ </label>
79+ <label class="form-group">
80+ <input type="text" name="calendarLegendFormat" class="action -text" size="8">
81+ <translation-key class="label">preferences.calendarLegendFormat.label</translation-key>
82+ <translation-key class="description" markdown>preferences.calendarLegendFormat.description</translation-key>
83+ </label>
84+ <label class="form-group">
85+ <textarea name="calendarTodayFormat" class="action -text" cols="10"></textarea>
86+ <translation-key class="label">preferences.calendarTodayFormat.label</translation-key>
87+ <translation-key class="description" markdown>preferences.calendarTodayFormat.description</translation-key>
88+ </label>
89+ </section>
90+ <section class="content" #$content>
91+ <translation-key class="description">preferences.shortcuts.description</translation-key>
92+ <dl class="list-shortcuts" #$keys></dl>
93+ </section>
94+ </form>
95+ </div>
9896 ` ) ;
9997
10098 this . render ( ) ;
@@ -103,8 +101,6 @@ export default class PreferencesView extends HTMLElement {
103101 }
104102
105103 async render ( ) {
106- const { app, preferences } = window ;
107-
108104 const {
109105 $form,
110106 $backgrounds,
@@ -144,7 +140,6 @@ export default class PreferencesView extends HTMLElement {
144140 checked,
145141 } = target ;
146142
147- const { preferences } = window ;
148143 const isBoolean = [ 'on' , 'off' ] . indexOf ( value ) >= 0 && [ 'checkbox' , 'radio' ] . indexOf ( type ) >= 0 ;
149144
150145 preferences . set ( name , isBoolean ? checked : value ) ;
@@ -163,8 +158,6 @@ export default class PreferencesView extends HTMLElement {
163158 }
164159
165160 onKeyDown ( { key } ) {
166- const { preferences } = window ;
167-
168161 if ( key === 'Escape' ) {
169162 preferences . hide ( ) ;
170163 }
@@ -173,8 +166,6 @@ export default class PreferencesView extends HTMLElement {
173166 }
174167
175168 onRestartClicked ( ) {
176- const { app } = window ;
177-
178169 app . restart ( ) ;
179170
180171 return this ;
@@ -186,8 +177,6 @@ export default class PreferencesView extends HTMLElement {
186177 }
187178
188179 onPostRender ( ) {
189- const { app } = window ;
190-
191180 app . resizeWindow ( {
192181 width : this . offsetWidth ,
193182 height : this . offsetHeight ,
0 commit comments