Skip to content

Commit 6607044

Browse files
authored
Merge pull request #57 from KristjanESPERANTO/seconds
Seconds
2 parents d96172e + 6bb8a8c commit 6607044

File tree

5 files changed

+46
-36
lines changed

5 files changed

+46
-36
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ planned for 2025-04-01
1616
### Added
1717

1818
- Added Arabic translation.
19-
- add support for css on digital clock hour/minute thru css using clock_hour and clock_minute classes
19+
- Add CSS support to the digital clock hour/minute/second through the use of the classes `clock-hour-digital`, `clock-minute-digital`, and `clock-second-digital`.
20+
- Mark option `secondsColor` as deprecated in clock module.
2021

2122
### Changed
2223

js/app.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,23 @@ function App () {
153153
*/
154154
function checkDeprecatedOptions (userConfig) {
155155
const deprecated = require(`${global.root_path}/js/deprecated`);
156-
const deprecatedOptions = deprecated.configs;
157156

157+
// check for deprecated core options
158+
const deprecatedOptions = deprecated.configs;
158159
const usedDeprecated = deprecatedOptions.filter((option) => userConfig.hasOwnProperty(option));
159160
if (usedDeprecated.length > 0) {
160-
Log.warn(`WARNING! Your config is using deprecated options: ${usedDeprecated.join(", ")}. Check README and CHANGELOG for more up-to-date ways of getting the same functionality.`);
161+
Log.warn(`WARNING! Your config is using deprecated option(s): ${usedDeprecated.join(", ")}. Check README and CHANGELOG for more up-to-date ways of getting the same functionality.`);
162+
}
163+
164+
// check for deprecated module options
165+
for (const element of userConfig.modules) {
166+
if (deprecated[element.module] !== undefined && element.config !== undefined) {
167+
const deprecatedModuleOptions = deprecated[element.module];
168+
const usedDeprecatedModuleOptions = deprecatedModuleOptions.filter((option) => element.config.hasOwnProperty(option));
169+
if (usedDeprecatedModuleOptions.length > 0) {
170+
Log.warn(`WARNING! Your config for module ${element.module} is using deprecated option(s): ${usedDeprecatedModuleOptions.join(", ")}. Check README and CHANGELOG for more up-to-date ways of getting the same functionality.`);
171+
}
172+
}
161173
}
162174
}
163175

js/deprecated.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
module.exports = {
2-
configs: ["kioskmode"]
2+
configs: ["kioskmode"],
3+
clock: ["secondsColor"]
34
};

modules/default/clock/clock.js

+21-29
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ Module.register("clock", {
2323
analogFace: "simple", // options: 'none', 'simple', 'face-###' (where ### is 001 to 012 inclusive)
2424
analogPlacement: "bottom", // options: 'top', 'bottom', 'left', 'right'
2525
analogShowDate: "top", // OBSOLETE, can be replaced with analogPlacement and showTime, options: false, 'top', or 'bottom'
26-
secondsColor: "#888888",
27-
minutesColor: "#fff",
28-
hoursColor: "#fff",
26+
secondsColor: "#888888", // DEPRECATED, use CSS instead. Class "clock-second-digital" for digital clock, "clock-second" for analog clock.
2927

3028
showSunTimes: false,
3129
showMoonTimes: false, // options: false, 'times' (rise/set), 'percent' (lit percent), 'phase' (current phase), or 'both' (percent & phase)
@@ -107,6 +105,8 @@ Module.register("clock", {
107105
*/
108106
const dateWrapper = document.createElement("div");
109107
const timeWrapper = document.createElement("div");
108+
const hoursWrapper = document.createElement("span");
109+
const minutesWrapper = document.createElement("span");
110110
const secondsWrapper = document.createElement("sup");
111111
const periodWrapper = document.createElement("span");
112112
const sunWrapper = document.createElement("div");
@@ -116,45 +116,40 @@ Module.register("clock", {
116116
// Style Wrappers
117117
dateWrapper.className = "date normal medium";
118118
timeWrapper.className = "time bright large light";
119-
secondsWrapper.className = "seconds dimmed";
119+
hoursWrapper.className = "clock-hour-digital";
120+
minutesWrapper.className = "clock-minute-digital";
121+
secondsWrapper.className = "clock-second-digital dimmed";
120122
sunWrapper.className = "sun dimmed small";
121123
moonWrapper.className = "moon dimmed small";
122124
weekWrapper.className = "week dimmed medium";
123125

124126
// Set content of wrappers.
125-
// The moment().format("h") method has a bug on the Raspberry Pi.
126-
// So we need to generate the timestring manually.
127-
// See issue: https://github.com/MagicMirrorOrg/MagicMirror/issues/181
128-
let timeString;
129127
const now = moment();
130128
if (this.config.timezone) {
131129
now.tz(this.config.timezone);
132130
}
133131

134-
let hourSymbol = "HH";
135-
if (this.config.timeFormat !== 24) {
136-
hourSymbol = "h";
137-
}
138-
139-
if (this.config.clockBold) {
140-
timeString = now.format(`${hourSymbol}[<span class="bold">]mm[</span>]`);
141-
} else {
142-
timeString = now.format(`${hourSymbol}:mm`);
143-
}
144-
145132
if (this.config.showDate) {
146133
dateWrapper.innerHTML = now.format(this.config.dateFormat);
147134
digitalWrapper.appendChild(dateWrapper);
148135
}
149136

150137
if (this.config.displayType !== "analog" && this.config.showTime) {
151-
let ts = timeString.split(":");
152-
let hour_style_string = "";
153-
let minute_style_string = "";
154-
if (this.defaults.hoursColor !== this.config.hoursColor) hour_style_string = ` style="color:${this.config.hoursColor}"`;
155-
if (this.defaults.minutesColor !== this.config.minutesColor) minute_style_string = ` style="color:${this.config.minutesColor}"`;
156-
timeString = `<span class="clock-hour-digital" ${hour_style_string} ">${ts[0]}</span>:<span class="clock-minute-digital" ${minute_style_string}>${ts[1]}</span>`;
157-
timeWrapper.innerHTML = timeString;
138+
let hourSymbol = "HH";
139+
if (this.config.timeFormat !== 24) {
140+
hourSymbol = "h";
141+
}
142+
143+
hoursWrapper.innerHTML = now.format(hourSymbol);
144+
minutesWrapper.innerHTML = now.format("mm");
145+
146+
timeWrapper.appendChild(hoursWrapper);
147+
if (this.config.clockBold) {
148+
minutesWrapper.classList.add("bold");
149+
} else {
150+
timeWrapper.innerHTML += ":";
151+
}
152+
timeWrapper.appendChild(minutesWrapper);
158153
secondsWrapper.innerHTML = now.format("ss");
159154
if (this.config.showPeriodUpper) {
160155
periodWrapper.innerHTML = now.format("A");
@@ -260,12 +255,10 @@ Module.register("clock", {
260255
const clockHour = document.createElement("div");
261256
clockHour.id = "clock-hour";
262257
clockHour.style.transform = `rotate(${hour}deg)`;
263-
clockHour.style.backgroundColor = this.config.hoursColor;
264258
clockHour.className = "clock-hour";
265259
const clockMinute = document.createElement("div");
266260
clockMinute.id = "clock-minute";
267261
clockMinute.style.transform = `rotate(${minute}deg)`;
268-
clockMinute.style.backgroundColor = this.config.minutesColor;
269262
clockMinute.className = "clock-minute";
270263

271264
// Combine analog wrappers
@@ -277,7 +270,6 @@ Module.register("clock", {
277270
clockSecond.id = "clock-second";
278271
clockSecond.style.transform = `rotate(${second}deg)`;
279272
clockSecond.className = "clock-second";
280-
clockSecond.style.backgroundColor = this.config.secondsColor;
281273
clockFace.appendChild(clockSecond);
282274
}
283275
analogWrapper.appendChild(clockFace);

modules/default/clock/clock_styles.css

+7-3
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,14 @@
9292
flex: 1;
9393
}
9494

95-
/*
9695
.module.clock .clock-hour-digital {
97-
96+
color: var(--color-text-bright);
9897
}
98+
9999
.module.clock .clock-minute-digital {
100+
color: var(--color-text-bright);
101+
}
100102

101-
} */
103+
.module.clock .clock-second-digital {
104+
color: var(--color-text-dimmed);
105+
}

0 commit comments

Comments
 (0)