@opensig/opendesign
Version:
<p align="center"><img src="../docs/public/opendesign-logo-light.png"/></p> <h1 align="center">opendesign</h1> <p align="center">一个 Vue 3 组件库</p> <p align="center"><b>皮肤可定制,使用 TypeScript</b></p>
65 lines (64 loc) • 1.8 kB
JavaScript
;
const vue = require("vue");
const types = require("./types.js");
const is = require("../_utils/is.js");
const _hoisted_1 = { class: "o-badge-label" };
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
__name: "OBadge",
props: types.badgeProps,
setup(__props) {
const props = __props;
const content = vue.computed(() => {
if (props.dot) {
return "";
}
if (is.isNumber(props.value) && is.isNumber(props.max)) {
return props.value < props.max ? `${props.value}` : `${props.max}+`;
}
return props.value;
});
const style = vue.computed(() => {
const [x, y] = props.offset;
const right = is.isNumber(x) ? `-${x}px` : `-${x}`;
const top = is.isNumber(y) ? `${y}px` : `${y}`;
return {
right,
top
};
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock(
"div",
{
class: vue.normalizeClass(["o-badge", [`o-badge-${props.color}`, { "o-badge-dot": props.dot, "o-badge-only": !_ctx.$slots.default }]])
},
[
vue.renderSlot(_ctx.$slots, "default"),
vue.createElementVNode(
"sup",
{
class: "o-badge-content",
style: vue.normalizeStyle(style.value)
},
[
vue.renderSlot(_ctx.$slots, "content", {}, () => [
vue.createElementVNode(
"div",
_hoisted_1,
vue.toDisplayString(content.value),
1
/* TEXT */
)
])
],
4
/* STYLE */
)
],
2
/* CLASS */
);
};
}
});
module.exports = _sfc_main;