comic-plus
Version:
<p align="center"> <img width="200px" src="./logo.png"/> </p>
89 lines (88 loc) • 3.4 kB
JavaScript
import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, renderSlot, createBlock, resolveDynamicComponent, unref, createCommentVNode, Transition, withCtx } from "vue";
import "../style/tag.css";
import { tagProps, tagEmits } from "./main.props.mjs";
import "../../../icons/index.mjs";
import { CloseSmall, CloseOne } from "../../../icons/components/components.mjs";
const _hoisted_1 = { class: "cu-tag-content" };
const _hoisted_2 = { class: "cu-tag-content" };
const _sfc_main = /* @__PURE__ */ defineComponent({
...{
name: "CuTag"
},
__name: "main",
props: tagProps,
emits: tagEmits,
setup(__props, { emit: __emit }) {
const props = __props;
const emit = __emit;
function handleClose() {
emit("close");
}
const tagMode = computed(() => {
return props.plain ? "plain" : props.light ? "light" : void 0;
});
const customStyle = computed(() => {
if (!props.color) return void 0;
let calcColor = tagMode.value === "plain" ? `color-mix(in srgb, ${props.color}, white 90%)` : tagMode.value === "light" ? "#fff" : props.color;
return {
borderColor: props.color,
backgroundColor: calcColor,
color: tagMode.value ? props.color : "#fff"
};
});
const handleVNodeMounted = (vnode) => {
vnode.component.subTree.component.bum = null;
};
return (_ctx, _cache) => {
return !_ctx.transition ? (openBlock(), createElementBlock("span", {
key: 0,
class: normalizeClass(["cu-tag", [
_ctx.type ? "cu-tag--" + _ctx.type : void 0,
tagMode.value ? "is-" + tagMode.value : void 0,
{ "is-border": _ctx.border },
{ "is-round": _ctx.round }
]]),
style: normalizeStyle([{ "--tag-size": _ctx.size + "px" }, customStyle.value])
}, [
createElementVNode("span", _hoisted_1, [
renderSlot(_ctx.$slots, "default")
]),
_ctx.closable ? (openBlock(), createBlock(resolveDynamicComponent(tagMode.value ? unref(CloseSmall) : unref(CloseOne)), {
key: 0,
class: "closeicon",
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("close"))
})) : createCommentVNode("", true)
], 6)) : (openBlock(), createBlock(Transition, {
key: 1,
name: "cu-zoom-x",
appear: "",
onVnodeMounted: handleVNodeMounted
}, {
default: withCtx(() => [
createElementVNode("span", {
class: normalizeClass(["cu-tag", [
_ctx.type ? "cu-tag--" + _ctx.type : void 0,
tagMode.value ? "is-" + tagMode.value : void 0,
{ "is-border": _ctx.border },
{ "is-round": _ctx.round }
]]),
style: normalizeStyle([{ "--tag-size": _ctx.size + "px" }, customStyle.value])
}, [
createElementVNode("span", _hoisted_2, [
renderSlot(_ctx.$slots, "default")
]),
_ctx.closable ? (openBlock(), createBlock(resolveDynamicComponent(tagMode.value ? unref(CloseSmall) : unref(CloseOne)), {
key: 0,
class: "closeicon",
onClick: handleClose
})) : createCommentVNode("", true)
], 6)
]),
_: 3
}, 512));
};
}
});
export {
_sfc_main as default
};