📝(component): [tag]更新文档

tag: 更新文档
space 垂直方向对齐方式修改为 start
This commit is contained in:
sight 2022-08-27 15:22:47 +08:00
parent b0bccc3292
commit 863a627ef2
4 changed files with 72 additions and 88 deletions

View File

@ -35,13 +35,16 @@ export interface LaySpaceProps {
} }
const props = withDefaults(defineProps<LaySpaceProps>(), { const props = withDefaults(defineProps<LaySpaceProps>(), {
align: "center",
direction: "horizontal", direction: "horizontal",
size: "sm", size: "sm",
}); });
const slots = useSlots(); const slots = useSlots();
const computAlign = computed(
() => props.align ?? (props.direction === 'horizontal' ? 'center' : '')
);
const extractChildren = () => { const extractChildren = () => {
const result: VNode[] = []; const result: VNode[] = [];
const children = slots.default && (slots?.default() as VNodeArrayChildren); const children = slots.default && (slots?.default() as VNodeArrayChildren);
@ -73,7 +76,7 @@ const extractChildren = () => {
const spaceClass = computed(() => [ const spaceClass = computed(() => [
"layui-space", "layui-space",
{ {
[`layui-space-align-${props.align}`]: props.align, [`layui-space-align-${props.align}`]: computAlign.value,
[`layui-space-${props.direction}`]: props.direction, [`layui-space-${props.direction}`]: props.direction,
[`layui-space-wrap`]: props.wrap, [`layui-space-wrap`]: props.wrap,
[`layui-space-fill`]: props.fill, [`layui-space-fill`]: props.fill,

View File

@ -23,7 +23,7 @@
.layui-tag { .layui-tag {
display: inline-flex; display: inline-flex;
align-items: center; align-items: baseline;
vertical-align: middle; vertical-align: middle;
box-sizing: border-box; box-sizing: border-box;
height: @tag-size-md; height: @tag-size-md;

View File

@ -89,6 +89,7 @@ import LayPageHeader from "./component/pageHeader/index";
import LayCascader from "./component/cascader/index"; import LayCascader from "./component/cascader/index";
import LayAffix from "./component/affix/index"; import LayAffix from "./component/affix/index";
import LaySpace from "./component/space/index"; import LaySpace from "./component/space/index";
import LayTag from "./component/tag/index";
import LayConfigProvider from "./provider"; import LayConfigProvider from "./provider";
import { InstallOptions } from "./types"; import { InstallOptions } from "./types";
@ -176,6 +177,7 @@ const components: Record<string, Plugin> = {
LayCascader, LayCascader,
LayAffix, LayAffix,
LaySpace, LaySpace,
LayTag,
}; };
const install = (app: App, options?: InstallOptions): void => { const install = (app: App, options?: InstallOptions): void => {
@ -270,6 +272,7 @@ export {
LayCascader, LayCascader,
LayAffix, LayAffix,
LaySpace, LaySpace,
LayTag,
install, install,
}; };

View File

@ -13,27 +13,17 @@
::: demo 标签的基本用法。 ::: demo 标签的基本用法。
<template> <template>
<div class="tag-demo"> <lay-space size="md">
<lay-tag>tag</lay-tag> <lay-tag>标签</lay-tag>
<lay-tag bordered color="#FFF">tag</lay-tag> <lay-tag bordered color="#FFF">标签</lay-tag>
<lay-tag closable>tag</lay-tag> <lay-tag closable>标签</lay-tag>
<lay-tag closable disabled>tag</lay-tag> <lay-tag closable disabled>标签</lay-tag>
<lay-tag closable max-width="120px" title="超过设置长度省略文本">超过设置长度省略文本</lay-tag> <lay-tag closable max-width="120px" title="超过设置长度省略文本">超过设置长度省略文本</lay-tag>
</div> </lay-space>
</template> </template>
<script> <script>
</script> </script>
<style>
.tag-demo {
width: 500px;
display: flex;
margin-bottom: 15px;
}
.tag-demo .layui-tag{
margin-right: 15px;
}
</style>
::: :::
@ -43,42 +33,44 @@
::: demo 通过 size 属性控制标签尺寸。 ::: demo 通过 size 属性控制标签尺寸。
<template> <template>
<div class="tag-demo"> <lay-space direction="vertical" size="md">
<lay-tag>default</lay-tag> <lay-space size="md">
lg:
<lay-tag size="lg">tag lg</lay-tag> <lay-tag size="lg">tag lg</lay-tag>
<lay-tag size="md">tag md</lay-tag>
<lay-tag size="sm">tag sm</lay-tag>
<lay-tag size="xs">tag xs</lay-tag>
</div>
<div class="tag-demo">
<lay-tag><template #icon><lay-icon type="layui-icon-addition" /></template>default</lay-tag>
<lay-tag size="lg"><template #icon><lay-icon type="layui-icon-addition" /></template>tag lg</lay-tag> <lay-tag size="lg"><template #icon><lay-icon type="layui-icon-addition" /></template>tag lg</lay-tag>
<lay-tag size="md"><template #icon><lay-icon type="layui-icon-addition" /></template>tag md</lay-tag>
<lay-tag size="sm"><template #icon><lay-icon type="layui-icon-addition" /></template>tag sm</lay-tag>
<lay-tag size="xs"><template #icon><lay-icon type="layui-icon-addition" /></template>tag xs</lay-tag>
</div>
<div class="tag-demo">
<lay-tag closable>
<template #icon><lay-icon type="layui-icon-addition" /></template>
default
</lay-tag>
<lay-tag size="lg" closable> <lay-tag size="lg" closable>
<template #icon><lay-icon type="layui-icon-addition" /></template> <template #icon><lay-icon type="layui-icon-addition" /></template>
tag lg tag lg
</lay-tag> </lay-tag>
</lay-space>
<lay-space size="md">
md:
<lay-tag size="md">tag md</lay-tag>
<lay-tag size="md"><template #icon><lay-icon type="layui-icon-addition" /></template>tag md</lay-tag>
<lay-tag size="md" closable> <lay-tag size="md" closable>
<template #icon><lay-icon type="layui-icon-addition" /></template> <template #icon><lay-icon type="layui-icon-addition" /></template>
tag md tag md
</lay-tag> </lay-tag>
</lay-space>
<lay-space size="md">
sm:
<lay-tag size="sm">tag sm</lay-tag>
<lay-tag size="sm"><template #icon><lay-icon type="layui-icon-addition" /></template>tag sm</lay-tag>
<lay-tag size="sm" closable> <lay-tag size="sm" closable>
<template #icon><lay-icon type="layui-icon-addition" /></template> <template #icon><lay-icon type="layui-icon-addition" /></template>
tag sm tag sm
</lay-tag> </lay-tag>
</lay-space>
<lay-space size="md">
xs:
<lay-tag size="xs">tag xs</lay-tag>
<lay-tag size="xs"><template #icon><lay-icon type="layui-icon-addition" /></template>tag xs</lay-tag>
<lay-tag size="xs" closable> <lay-tag size="xs" closable>
<template #icon><lay-icon type="layui-icon-addition" /></template> <template #icon><lay-icon type="layui-icon-addition" /></template>
tag xs tag xs
</lay-tag> </lay-tag>
</div> </lay-space>
</lay-space>
</template> </template>
<script> <script>
@ -102,7 +94,7 @@
::: demo 通过 closable 属性控制标签是否可关闭 ::: demo 通过 closable 属性控制标签是否可关闭
<template> <template>
<div class="tag-demo"> <lay-space size="md">
<lay-tag closable>Tag</lay-tag> <lay-tag closable>Tag</lay-tag>
<lay-tag closable> <lay-tag closable>
<template #icon><lay-icon type="layui-icon-addition" /></template> <template #icon><lay-icon type="layui-icon-addition" /></template>
@ -113,7 +105,7 @@
自定义关闭图标 自定义关闭图标
<template #close-icon><lay-icon type="layui-icon-close-fill" /></template> <template #close-icon><lay-icon type="layui-icon-close-fill" /></template>
</lay-tag> </lay-tag>
</div> </lay-space>
</template> </template>
<script> <script>
@ -137,50 +129,36 @@
::: demo 标签颜色, 非内置颜色只支持默认样式, plain 默认有边框。 ::: demo 标签颜色, 非内置颜色只支持默认样式, plain 默认有边框。
<template> <template>
<p class="tag-demo-variant">default:</p> <lay-space direction="vertical" size="md">
<div class="tag-demo"> default:
<span v-for="color in TAG_COLORS"> <lay-space size="md">
<lay-tag :color="color">Tag</lay-tag> <lay-tag v-for="color in TAG_COLORS" :color="color">标签</lay-tag>
</span> </lay-space>
</div> <lay-space size="md">
<div class="tag-demo"> <lay-tag v-for="color in TAG_COLORS" :color="color" bordered closable>标签</lay-tag>
<span v-for="color in TAG_COLORS"> </lay-space>
<lay-tag :color="color" bordered closable>Tag</lay-tag> light:
</span> <lay-space size="md">
</div> <lay-tag v-for="color in TAG_COLORS" :color="color" variant="light">标签</lay-tag>
<p class="tag-demo-variant">light:</p> </lay-space>
<div class="tag-demo"> <lay-space size="md">
<span v-for="color in TAG_COLORS"> <lay-tag v-for="color in TAG_COLORS" :color="color" variant="light" bordered closable>标签</lay-tag>
<lay-tag :color="color" variant="light">Tag</lay-tag> </lay-space>
</span> plain:
</div> <lay-space size="md">
<div class="tag-demo"> <lay-tag v-for="color in TAG_COLORS" :color="color" variant="plain">标签</lay-tag>
<span v-for="color in TAG_COLORS"> </lay-space>
<lay-tag :color="color" variant="light" bordered closable>Tag</lay-tag> <lay-space size="md">
</span> <lay-tag v-for="color in TAG_COLORS" :color="color" variant="plain" bordered closable>标签</lay-tag>
</div> </lay-space>
<p class="tag-demo-variant">plain:</p> custom:
<div class="tag-demo"> <lay-space size="md">
<span v-for="color in TAG_COLORS"> <lay-tag v-for="color in COLORS" :color="color" variant="plain">标签</lay-tag>
<lay-tag :color="color" variant="plain">Tag</lay-tag> </lay-space>
</span> <lay-space size="md">
</div> <lay-tag v-for="color in COLORS" :color="color" variant="plain" bordered closable>标签</lay-tag>
<div class="tag-demo"> </lay-space>
<span v-for="color in TAG_COLORS"> </lay-space>
<lay-tag :color="color" variant="plain" bordered closable>Tag</lay-tag>
</span>
</div>
<p class="tag-demo-variant">custom:</p>
<div class="tag-demo">
<span v-for="color in COLORS">
<lay-tag :color="color" variant="plain">Tag</lay-tag>
</span>
</div>
<div class="tag-demo">
<span v-for="color in COLORS">
<lay-tag :color="color" variant="plain" bordered closable>Tag</lay-tag>
</span>
</div>
</template> </template>
<script> <script>
@ -232,10 +210,10 @@ const COLORS = [
::: title 图标插槽 ::: title 图标插槽
::: :::
::: demo 标签的基本用法 ::: demo 通过插槽自定义图标。
<template> <template>
<div class="tag-demo"> <lay-space size="md">
<lay-tag bordered size="lg" color="#FFF"> <lay-tag bordered size="lg" color="#FFF">
<template #icon> <template #icon>
<lay-icon type="layui-icon-vercode" /> <lay-icon type="layui-icon-vercode" />
@ -254,7 +232,7 @@ const COLORS = [
</template> </template>
tag tag
</lay-tag> </lay-tag>
</div> </lay-space>
</template> </template>
<script> <script>