Visual Console Client: improvements into the clock item

Former-commit-id: c328ea72b00857d10317de6f0812df05c30ec856
This commit is contained in:
Alejandro Gallardo Escobar 2019-03-05 16:17:57 +01:00
parent f34c9df172
commit b5ddabb9de
4 changed files with 83 additions and 12 deletions

View File

@ -0,0 +1,48 @@
@font-face {
font-family: Alarm Clock;
src: url(./alarm-clock.ttf);
}
/* Digital clock */
.visual-console-item .digital-clock {
display: flex;
flex-direction: column;
justify-content: center;
justify-items: center;
align-content: center;
align-items: center;
}
.visual-console-item .digital-clock > span {
font-family: "Alarm Clock", "Courier New", Courier, monospace;
font-size: 50px;
/* To improve legibility */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-rendering: optimizeLegibility;
text-shadow: rgba(0, 0, 0, 0.01) 0 0 1px;
}
.visual-console-item .digital-clock > span.date {
font-size: 25px;
}
.visual-console-item .digital-clock > span.timezone {
font-size: 25px;
}
/* Analog clock */
.visual-console-item .analogic-clock .hour-hand {
animation: rotate-hour 43200s infinite linear;
}
.visual-console-item .analogic-clock .minute-hand {
animation: rotate-minute 3600s infinite linear;
}
.visual-console-item .analogic-clock .second-hand {
animation: rotate-second 60s infinite linear;
}

View File

@ -1,4 +1,4 @@
import Clock, { clockPropsDecoder } from "./Clock"; import Clock, { clockPropsDecoder } from ".";
const genericRawProps = { const genericRawProps = {
id: 1, id: 1,
@ -24,7 +24,9 @@ const digitalClockProps = {
clockType: "digital", clockType: "digital",
clockFormat: "datetime", clockFormat: "datetime",
clockTimezone: "Madrid", clockTimezone: "Madrid",
clockTimezoneOffset: 60 clockTimezoneOffset: 60,
showClockTimezone: true,
color: "white"
}; };
const linkedModuleProps = { const linkedModuleProps = {

View File

@ -1,17 +1,20 @@
import { LinkedVisualConsoleProps, UnknownObject } from "../types"; import "./Clock.css";
import { LinkedVisualConsoleProps, UnknownObject } from "../../types";
import { import {
linkedVCPropsDecoder, linkedVCPropsDecoder,
parseIntOr, parseIntOr,
padLeft, padLeft,
parseBoolean parseBoolean,
} from "../lib"; prefixedCssRules
} from "../../lib";
import VisualConsoleItem, { import VisualConsoleItem, {
VisualConsoleItemProps, VisualConsoleItemProps,
itemBasePropsDecoder, itemBasePropsDecoder,
VisualConsoleItemType VisualConsoleItemType
} from "../VisualConsoleItem"; } from "../../VisualConsoleItem";
export type ClockProps = { export type ClockProps = {
type: VisualConsoleItemType.CLOCK; type: VisualConsoleItemType.CLOCK;
@ -417,26 +420,44 @@ export default class Clock extends VisualConsoleItem<ClockProps> {
<style> <style>
@keyframes rotate-hour { @keyframes rotate-hour {
from { from {
transform: translate(50px, 50px) rotate(${hourAngle}deg); ${prefixedCssRules(
"transform",
`translate(50px, 50px) rotate(${hourAngle}deg)`
).join("\n")}
} }
to { to {
transform: translate(50px, 50px) rotate(${hourAngle + 360}deg); ${prefixedCssRules(
"transform",
`translate(50px, 50px) rotate(${hourAngle + 360}deg)`
).join("\n")}
} }
} }
@keyframes rotate-minute { @keyframes rotate-minute {
from { from {
transform: translate(50px, 50px) rotate(${minuteAngle}deg); ${prefixedCssRules(
"transform",
`translate(50px, 50px) rotate(${minuteAngle}deg)`
).join("\n")}
} }
to { to {
transform: translate(50px, 50px) rotate(${minuteAngle + 360}deg); ${prefixedCssRules(
"transform",
`translate(50px, 50px) rotate(${minuteAngle + 360}deg)`
).join("\n")}
} }
} }
@keyframes rotate-second { @keyframes rotate-second {
from { from {
transform: translate(50px, 50px) rotate(${secAngle}deg); ${prefixedCssRules(
"transform",
`translate(50px, 50px) rotate(${secAngle}deg)`
).join("\n")}
} }
to { to {
transform: translate(50px, 50px) rotate(${secAngle + 360}deg); ${prefixedCssRules(
"transform",
`translate(50px, 50px) rotate(${minuteAngle + 360}deg)`
).join("\n")}
} }
} }
</style> </style>