UNPKG

@zhsz/cool-design-dv

Version:

42 lines (41 loc) 1.36 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const vue = require("vue"); const color = require("../utils/color.js"); function useAdorn($emit, color$1, props, page) { const width = vue.ref(0); const height = vue.ref(0); const dark = vue.computed(() => { const colorArray = color.getRgbaValue(color$1); colorArray[3] = 0.3; return `rgba(${colorArray.join(",")})`; }); const light = vue.computed(() => { const colorArray = color.getRgbaValue(color$1); colorArray[3] = 0.6; return `rgba(${colorArray.join(",")})`; }); const classes = vue.computed(() => { return { "my-dv-adorn": true, "is-reverse": props.reverse }; }); const styles = vue.computed(() => { return { opacity: props.opacity }; }); function resize($el) { var _a, _b; const rect = $el == null ? void 0 : $el.getBoundingClientRect(); if (!rect) { return; } width.value = rect.width / (((_a = page == null ? void 0 : page.widthScale) == null ? void 0 : _a.value) ?? 1); height.value = rect.height / (((_b = page == null ? void 0 : page.heightScale) == null ? void 0 : _b.value) ?? 1); $emit("resize", [width.value, height.value]); } return { dark, light, resize, color: color$1, classes, styles, width, height }; } exports.useAdorn = useAdorn;