react-analog-clock
Version:
A themable analog clock component
41 lines (38 loc) • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.cssTransform = cssTransform;
exports.updateTime = updateTime;
function cssTransform(styles, props) {
return Object.keys(styles).reduce(function (newStyles, rootKey) {
var style = styles[rootKey];
newStyles[rootKey] = Object.keys(style).reduce(function (newStyle, key) {
if (typeof style[key] === 'function') {
newStyle[key] = style[key](props);
} else {
newStyle[key] = style[key];
}
return newStyle;
}, {});
return newStyles;
}, {});
}
function updateTime(_ref) {
var seconds = _ref.seconds,
minutes = _ref.minutes,
hour = _ref.hour;
seconds += 1;
if (seconds === 60) {
seconds = 0;
minutes += 1;
}
if (minutes === 60) {
minutes = 0;
hour += 1;
}
if (hour === 12) {
hour = 0;
}
return { seconds: seconds, minutes: minutes, hour: hour };
}