layui-vue/es/avatar/index.js
2022-11-14 11:59:26 +08:00

52 lines
2.3 KiB
JavaScript

import { w as withInstall } from "../badge/index2.js";
import { defineComponent, useSlots, computed, unref, openBlock, createElementBlock, normalizeClass, renderSlot, createBlock } from "vue";
import { _ as _sfc_main$2E } from "../checkbox/index2.js";
var index = /* @__PURE__ */ (() => ".layui-avatar{font-size:14px;font-variant:tabular-nums;border-radius:var(--global-border-radius);box-sizing:border-box;color:#fff;list-style:none;position:relative;display:inline-block;background:#eeeeee;overflow:hidden;white-space:nowrap;text-align:center;width:32px;height:32px;line-height:32px;vertical-align:middle}.layui-avatar.layui-avatar-radius{border-radius:50%}.layui-avatar.layui-avatar-sm{height:30px;width:30px}.layui-avatar.layui-avatar-lg{height:36px;width:36px}.layui-avatar.layui-avatar-xs{height:28px;width:28px}.layui-avatar-list .layui-avatar{margin-left:-10px;display:inline-block}.layui-avatar>img{width:100%;height:100%;display:block;object-fit:cover}\n")();
const _hoisted_1 = ["src", "alt"];
const __default__ = {
name: "LayAvatar"
};
const _sfc_main = defineComponent({
...__default__,
props: {
src: null,
size: { default: "md" },
radius: { type: Boolean, default: false },
icon: { default: "layui-icon-username" },
alt: null
},
setup(__props) {
const props = __props;
const slot = useSlots();
const classes = computed(() => {
return [
"layui-avatar",
props.radius ? "layui-avatar-radius" : "",
props.size ? `layui-avatar-${props.size}` : ""
];
});
return (_ctx, _cache) => {
return unref(slot).default ? (openBlock(), createElementBlock("span", {
key: 0,
class: normalizeClass(unref(classes))
}, [
renderSlot(_ctx.$slots, "default")
], 2)) : (openBlock(), createElementBlock("span", {
key: 1,
class: normalizeClass(unref(classes))
}, [
__props.src ? (openBlock(), createElementBlock("img", {
key: 0,
src: __props.src,
alt: __props.alt
}, null, 8, _hoisted_1)) : (openBlock(), createBlock(unref(_sfc_main$2E), {
key: 1,
type: __props.icon
}, null, 8, ["type"]))
], 2));
};
}
});
const component = withInstall(_sfc_main);
export { component as default };