@zhsz/cool-design-dv
Version:
36 lines (35 loc) • 1.09 kB
JavaScript
import { ref, computed } from "vue";
import { getRgbaValue } from "../utils/color.mjs";
function useHeader($emit, color, page) {
const width = ref(0);
const height = ref(0);
const svgStyle = computed(() => {
return {
zoom: width.value / 1920
};
});
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(",")})`;
});
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 { svgStyle, dark, light, resize, color };
}
export {
useHeader
};