UNPKG

@zhsz/cool-design-dv

Version:

42 lines (41 loc) 1.23 kB
import { ref, computed } from "vue"; import { getRgbaValue } from "../utils/color.mjs"; function useAdorn($emit, color, props, page) { const width = ref(0); const height = ref(0); const dark = computed(() => { const colorArray = getRgbaValue(color); colorArray[3] = 0.3; return `rgba(${colorArray.join(",")})`; }); const light = computed(() => { const colorArray = getRgbaValue(color); colorArray[3] = 0.6; return `rgba(${colorArray.join(",")})`; }); const classes = computed(() => { return { "my-dv-adorn": true, "is-reverse": props.reverse }; }); const styles = 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, classes, styles, width, height }; } export { useAdorn };