style: fix basic tree style alignment (#3487)

This commit is contained in:
xachary
2024-01-01 14:10:44 +08:00
committed by GitHub
parent 2f921cfb88
commit 78234e2ef0
5 changed files with 17 additions and 8 deletions

View File

@@ -402,12 +402,12 @@
const iconDom = icon ? (
<TreeIcon icon={icon} />
) : slots.icon ? (
<span class="mr-1">{getSlot(slots, 'icon')}</span>
<span class="mr-2">{getSlot(slots, 'icon')}</span>
) : null;
item[titleField] = (
<span
class={`${bem('title')} pl-2`}
class={`${bem('title')}`}
onClick={handleClickNode.bind(null, item[keyField], item[childrenField])}
>
{slots?.title ? (

View File

@@ -6,7 +6,7 @@ import Icon from '@/components/Icon/Icon.vue';
export const TreeIcon = ({ icon }: { icon: VNode | string | undefined }) => {
if (!icon) return null;
if (isString(icon)) {
return h(Icon, { icon, class: 'mr-1' });
return h(Icon, { icon, class: 'mr-2' });
}
return h(Icon);
};

View File

@@ -1,5 +1,5 @@
<template>
<div :class="bem()" class="flex px-2 py-1.5 items-center">
<div :class="bem()" class="flex mb-1 px-2 py-1.5 items-center">
<slot name="headerTitle" v-if="slots.headerTitle"></slot>
<BasicTitle :helpMessage="helpMessage" v-if="!slots.headerTitle && title">
{{ title }}

View File

@@ -3,13 +3,22 @@
.@{tree-prefix-cls} {
background-color: @component-background;
.ant-tree {
.ant-tree-checkbox {
margin-block-start: 0;
margin-inline-start: 4px;
margin-inline-end: 4px;
& + span {
padding-left: 4px;
}
}
}
.ant-tree-node-content-wrapper {
position: relative;
.ant-tree-title {
position: absolute;
left: 0;
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;

View File

@@ -3,7 +3,7 @@
<Row :gutter="[16, 16]">
<Col :span="8">
<BasicTree title="基础示例,默认展开第一层" :treeData="treeData" defaultExpandLevel="1">
<template #icon><SmileTwoTone /></template>
<template #icon><SmileTwoTone style="font-size: 16px" /></template>
<template #title>666</template>
<template #switcherIcon> <CarryOutOutlined /></template>
</BasicTree>