comic-plus
Version:
<p align="center"> <img width="200px" src="./logo.png"/> </p>
51 lines (50 loc) • 1.79 kB
JavaScript
import { defineComponent, computed, provide, openBlock, createBlock, normalizeClass, normalizeStyle, createCommentVNode } from "vue";
import "../style/clock.css";
import { useNow } from "@vueuse/core";
import _sfc_main$1 from "./components/circle-clock.vue.mjs";
import _sfc_main$2 from "./components/number-clock.vue.mjs";
import { clockProps } from "./main.props.mjs";
import { COLOR_ENUM, CLOCK_PROVIDE } from "./type.mjs";
const _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: "CuClock"
},
__name: "main",
props: clockProps,
setup(__props) {
const props = __props;
const now = useNow({ interval: 1e3 });
const getTimes = computed(() => {
var _a, _b, _c;
return {
hour: (_a = now.value) == null ? void 0 : _a.getHours(),
minute: (_b = now.value) == null ? void 0 : _b.getMinutes(),
second: (_c = now.value) == null ? void 0 : _c.getSeconds()
};
});
const clockStyle = computed(() => {
if (!props.color) return;
return {
"--cu-clock-color": COLOR_ENUM.includes(props.color) ? `var(--cu-color-${props.color})` : props.color
};
});
provide(CLOCK_PROVIDE, {
getTimes,
props
});
return (_ctx, _cache) => {
return _ctx.type === "circle" ? (openBlock(), createBlock(_sfc_main$1, {
key: 0,
class: normalizeClass([_ctx.size, _ctx.shadow]),
style: normalizeStyle(clockStyle.value)
}, null, 8, ["class", "style"])) : _ctx.type === "number" ? (openBlock(), createBlock(_sfc_main$2, {
key: 1,
class: normalizeClass([_ctx.size, _ctx.shadow]),
style: normalizeStyle(clockStyle.value)
}, null, 8, ["class", "style"])) : createCommentVNode("", true);
};
}
});
export {
_sfc_main as default
};