(component): [tag]添加 shape, disabled 属性

This commit is contained in:
sight 2022-08-06 12:46:29 +08:00
parent d30a3b0012
commit e9e54bb967
3 changed files with 41 additions and 4 deletions

View File

@ -34,6 +34,36 @@
border-color: var(--global-neutral-color-5); border-color: var(--global-neutral-color-5);
} }
&-disabled {
opacity: 0.4;
cursor: not-allowed;
& .layui-tag-close-icon {
.layui-icon {
&:hover {
cursor: not-allowed !important;
opacity: 1;
}
}
}
}
&-shap {
&-square {
border-radius: var(--global-border-radius);
}
&-round {
border-radius: 12px;
}
}
&-ellipsis {
white-space: nowwrap;
text-overflow: ellipsis;
overflow: hidden;
}
&-size-lg { &-size-lg {
height: @tag-size-lg; height: @tag-size-lg;
font-size: @tag-size-lg-font-size; font-size: @tag-size-lg-font-size;
@ -82,6 +112,7 @@
&:hover { &:hover {
cursor: pointer; cursor: pointer;
opacity: 0.5;
} }
} }
} }

View File

@ -14,13 +14,14 @@ export interface LayTagProps {
closable?: boolean; closable?: boolean;
size?: string; size?: string;
bordered?: boolean; bordered?: boolean;
disabled?: boolean;
shape?: "square" | "round";
} }
const props = withDefaults(defineProps<LayTagProps>(), { const props = withDefaults(defineProps<LayTagProps>(), {
color: "green", color: "#EEE",
size: "md", size: "md",
closable: false, shape: "square"
bordered: false,
}); });
const emit = defineEmits(["close"]); const emit = defineEmits(["close"]);
@ -35,6 +36,7 @@ const isCustomColor = computed(
const visible = ref(true); const visible = ref(true);
const handleClose = (e: MouseEvent) => { const handleClose = (e: MouseEvent) => {
if(props.disabled) return;
//visible.value = false; //visible.value = false;
emit("close", e); emit("close", e);
}; };
@ -42,9 +44,11 @@ const handleClose = (e: MouseEvent) => {
const classTag = computed(() => [ const classTag = computed(() => [
"layui-tag", "layui-tag",
`layui-tag-size-${props.size}`, `layui-tag-size-${props.size}`,
`layui-tag-shap-${props.shape}`,
{ {
[`layui-bg-${props.color}`]: isBuiltInColor, [`layui-bg-${props.color}`]: isBuiltInColor,
"layui-tag-bordered": props.bordered, "layui-tag-bordered": props.bordered,
"layui-tag-disabled": props.disabled,
}, },
]); ]);

View File

@ -18,6 +18,8 @@
<lay-tag bordered color="#FFF">tag</lay-tag> <lay-tag bordered color="#FFF">tag</lay-tag>
&nbsp&nbsp &nbsp&nbsp
<lay-tag closable>tag</lay-tag> <lay-tag closable>tag</lay-tag>
&nbsp&nbsp
<lay-tag closable disabled>tag</lay-tag>
</template> </template>
<script> <script>