feat: VerticalButtonGroup style

This commit is contained in:
xingyu4j
2025-11-05 20:08:46 +08:00
parent beec71dbbd
commit e4040520e0
2 changed files with 15 additions and 30 deletions

View File

@@ -108,9 +108,11 @@ const handleDeleteComponent = () => {
class="component-toolbar" class="component-toolbar"
v-if="showToolbar && component.name && active" v-if="showToolbar && component.name && active"
> >
<VerticalButtonGroup type="primary"> <VerticalButtonGroup size="small">
<Button <Button
:disabled="!canMoveUp" :disabled="!canMoveUp"
type="primary"
size="small"
@click.stop="handleMoveComponent(-1)" @click.stop="handleMoveComponent(-1)"
v-tippy="{ v-tippy="{
content: '上移', content: '上移',
@@ -123,6 +125,8 @@ const handleDeleteComponent = () => {
</Button> </Button>
<Button <Button
:disabled="!canMoveDown" :disabled="!canMoveDown"
type="primary"
size="small"
@click.stop="handleMoveComponent(1)" @click.stop="handleMoveComponent(1)"
v-tippy="{ v-tippy="{
content: '下移', content: '下移',
@@ -134,6 +138,8 @@ const handleDeleteComponent = () => {
<IconifyIcon icon="lucide:arrow-down" /> <IconifyIcon icon="lucide:arrow-down" />
</Button> </Button>
<Button <Button
type="primary"
size="small"
@click.stop="handleCopyComponent()" @click.stop="handleCopyComponent()"
v-tippy="{ v-tippy="{
content: '复制', content: '复制',
@@ -145,6 +151,8 @@ const handleDeleteComponent = () => {
<IconifyIcon icon="lucide:copy" /> <IconifyIcon icon="lucide:copy" />
</Button> </Button>
<Button <Button
type="primary"
size="small"
@click.stop="handleDeleteComponent()" @click.stop="handleDeleteComponent()"
v-tippy="{ v-tippy="{
content: '删除', content: '删除',

View File

@@ -1,6 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ButtonGroup } from 'ant-design-vue'; import { Space } from 'ant-design-vue';
/** /**
* 垂直按钮组 * 垂直按钮组
* Ant Design Vue 的按钮组只支持水平显示,通过重写样式实现垂直布局 * Ant Design Vue 的按钮组只支持水平显示,通过重写样式实现垂直布局
@@ -9,31 +8,9 @@ defineOptions({ name: 'VerticalButtonGroup' });
</script> </script>
<template> <template>
<ButtonGroup v-bind="$attrs" class="!inline-flex !flex-col"> <Space v-bind="$attrs">
<slot></slot> <Space.Compact direction="vertical">
</ButtonGroup> <slot></slot>
</Space.Compact>
</Space>
</template> </template>
<style scoped lang="scss">
// TODO @AI:圆角的样式不太对!
.ant-btn-group > :deep(.ant-btn:first-child) {
border-bottom-color: transparent;
border-radius: hsl(var(--radius)) hsl(var(--radius)) 0 0;
}
.ant-btn-group > :deep(.ant-btn:last-child) {
border-top-color: transparent;
border-radius: 0 0 hsl(var(--radius)) hsl(var(--radius));
}
.ant-btn-group :deep(.ant-btn:not(:first-child):not(:last-child)) {
border-top-color: transparent;
border-bottom-color: transparent;
border-radius: 0;
}
.ant-btn-group > :deep(.ant-btn:not(:last-child)) {
margin-right: 0;
margin-bottom: -1px;
}
</style>