UNPKG

@zhsz/cool-design-dv

Version:

120 lines (119 loc) 4.45 kB
import { defineComponent, getCurrentInstance, useAttrs, inject, ref, computed, onMounted, onBeforeUnmount, openBlock, createBlock, unref, mergeProps, withCtx, createElementBlock, normalizeStyle, createElementVNode, Fragment, renderList, normalizeClass, createVNode, renderSlot } from "vue"; import "./style.css"; import Box from "../dv-box/index.mjs"; import BoxContent from "../dv-content/index.mjs"; import { dvPageSymbols } from "../../symbols/index.mjs"; import { addResizeListener, removeResizeListener } from "../../utils/resize-event.mjs"; import { useBorder } from "../../hooks/useBorder.mjs"; import { baseConfig } from "../../hooks/useConfig.mjs"; const _hoisted_1 = ["width", "height"]; const _hoisted_2 = ["fill", "points"]; const _hoisted_3 = ["fill"]; const __default__ = defineComponent({ name: "DvBorder9" }); const _sfc_main = /* @__PURE__ */ defineComponent({ ...__default__, props: { fill: { type: String, default() { return "transparent"; } }, reverse: Boolean, opacity: { type: Number, default: 1 } }, emits: ["resize"], setup(__props, { emit: __emit }) { var _a, _b, _c; const instance = (_a = getCurrentInstance()) == null ? void 0 : _a.proxy; const emits = __emit; const $attrs = useAttrs(); const props = __props; const page = inject(dvPageSymbols, null); const border = ref(["left-top", "right-top", "left-bottom", "right-bottom"]); const fill = computed(() => { var _a2, _b2; return props.fill || ((_b2 = (_a2 = page == null ? void 0 : page.settings) == null ? void 0 : _a2.value) == null ? void 0 : _b2.fill); }); const { resize, classes, styles, width, height, dark, light } = useBorder( emits, ((_c = (_b = page == null ? void 0 : page.settings) == null ? void 0 : _b.value) == null ? void 0 : _c.color) ?? baseConfig.color, props, page ); const svgStyle = computed(() => { return { ...styles.value, "box-shadow": `inset 0 0 30px 3px ${dark.value}`, "border-radius": "15px" }; }); const boxStyles = computed(() => { return { backgroundColor: fill.value }; }); 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-border-9", unref(classes)], "default-width": "400px", "default-height": "300px", padding: "0" }, { ...unref($attrs), ...props }, { style: boxStyles.value }), { default: withCtx(() => [ (openBlock(), createElementBlock("svg", { class: "my-dv-border__svg", width: unref(width), height: unref(height), style: normalizeStyle(svgStyle.value) }, [ createElementVNode("polygon", { fill: fill.value, points: ` 4, 0 ${unref(width) - 4}, 0 ${unref(width)}, 4 ${unref(width)}, ${unref(height) - 4} ${unref(width) - 4}, ${unref(height)} 4, ${unref(height)} 0, ${unref(height) - 4} 0, 4 ` }, null, 8, _hoisted_2) ], 12, _hoisted_1)), (openBlock(true), createElementBlock(Fragment, null, renderList(border.value, (item) => { return openBlock(), createElementBlock("svg", { width: "150px", height: "150px", key: item, class: normalizeClass(`my-dv-border-9__${item} my-dv-border-9__item`) }, [ createElementVNode("polygon", { fill: unref(light), points: "40, 0 5, 0 0, 5 0, 16 3, 19 3, 7 7, 3 35, 3" }, null, 8, _hoisted_3) ], 2); }), 128)), createVNode(unref(BoxContent), { padding: unref($attrs).padding }, { default: withCtx(() => [ renderSlot(_ctx.$slots, "default") ]), _: 3 }, 8, ["padding"]) ]), _: 3 }, 16, ["class", "style"]); }; } }); export { _sfc_main as default };