UNPKG

@zhsz/cool-design-dv

Version:

94 lines (93 loc) 3.4 kB
import { defineComponent, getCurrentInstance, useAttrs, inject, onMounted, onBeforeUnmount, openBlock, createBlock, unref, mergeProps, withCtx, createElementBlock, createElementVNode } from "vue"; import Box from "../dv-box/index.mjs"; import { dvPageSymbols } from "../../symbols/index.mjs"; import { addResizeListener, removeResizeListener } from "../../utils/resize-event.mjs"; import { useAdorn } from "../../hooks/useAdorn.mjs"; import { baseConfig } from "../../hooks/useConfig.mjs"; const _hoisted_1 = ["width", "height"]; const _hoisted_2 = ["stroke", "points"]; const _hoisted_3 = ["stroke", "points"]; const _hoisted_4 = ["stroke", "points"]; const __default__ = defineComponent({ name: "DvAdorn8" }); const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: { duration: { type: Number, default: 3 }, reverse: Boolean, opacity: { type: Number, default: 1 } }, emits: ["resize"], setup(__props, { emit: __emit }) { var _a, _b, _c; const props = __props; const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy; const emits = __emit; const $attrs = useAttrs(); const page = inject(dvPageSymbols, null); const { resize, classes, styles, width, height, dark, light } = useAdorn( emits, ((_c = (_b = page == null ? void 0 : page.settings) == null ? void 0 : _b.value) == null ? void 0 : _c.color) ?? baseConfig.color, props, page ); function xPos(pos) { if (!props.reverse) { return pos; } return width.value - pos; } onMounted(() => { resize(instance == null ? void 0 : instance.$el); addResizeListener(instance == null ? void 0 : instance.$el, () => resize(instance == null ? void 0 : instance.$el)); }); onBeforeUnmount(() => { removeResizeListener(instance == null ? void 0 : instance.$el, () => resize(instance == null ? void 0 : instance.$el)); }); return (_ctx, _cache) => { return openBlock(), createBlock(unref(Box), mergeProps({ class: ["my-dv-adorn-8", unref(classes)], style: unref(styles), "default-width": "300px", "default-height": "50px" }, unref($attrs)), { default: withCtx(() => [ (openBlock(), createElementBlock("svg", { width: `${unref(width)}px`, height: `${unref(height)}px` }, [ createElementVNode("polyline", { stroke: unref(light), "stroke-width": "2", fill: "transparent", points: `${xPos(0)}, 0 ${xPos(30)}, ${unref(height) / 2}` }, null, 8, _hoisted_2), createElementVNode("polyline", { stroke: unref(dark), "stroke-width": "2", fill: "transparent", points: `${xPos(20)}, 0 ${xPos(50)}, ${unref(height) / 2} ${xPos(unref(width))}, ${unref(height) / 2}` }, null, 8, _hoisted_3), createElementVNode("polyline", { stroke: unref(dark), fill: "transparent", "stroke-width": "3", points: `${xPos(0)}, ${unref(height) - 3}, ${xPos(200)}, ${unref(height) - 3}` }, null, 8, _hoisted_4) ], 8, _hoisted_1)) ]), _: 1 }, 16, ["class", "style"]); }; } }); export { _sfc_main as default };