Skip to content

Commit 4af458f

Browse files
committed
新增 FaButtonGroup 组件
1 parent 34f2906 commit 4af458f

File tree

4 files changed

+94
-3
lines changed

4 files changed

+94
-3
lines changed

src/layouts/components/MainSidebar/index.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ onUnmounted(() => {
4040
<component :is="useSlots('main-sidebar-top')" />
4141
<Logo :show-title="false" class="sidebar-logo" />
4242
<component :is="useSlots('main-sidebar-after-logo')" />
43-
<FaScrollArea :scrollbar="false" mask gradient-color="var(--g-main-sidebar-bg)" class="menu">
43+
<FaScrollArea :scrollbar="false" mask gradient-color="var(--g-main-sidebar-bg)" class="menu flex-1">
4444
<!-- 侧边栏模式(含主导航) -->
4545
<div class="w-full flex flex-col of-hidden py-1 transition-all -mt-2">
4646
<template v-for="(item, index) in menuStore.allMenus" :key="index">
@@ -92,8 +92,6 @@ onUnmounted(() => {
9292
}
9393
9494
.menu {
95-
flex: 1;
96-
9795
:deep(.menu-item) {
9896
.menu-item-container {
9997
padding-block: 8px;

src/types/components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ declare module 'vue' {
1313
FaAvatar: typeof import('./../ui/components/FaAvatar/index.vue')['default']
1414
FaBackToTop: typeof import('./../ui/components/FaBackToTop/index.vue')['default']
1515
FaButton: typeof import('./../ui/components/FaButton/index.vue')['default']
16+
FaButtonGroup: typeof import('./../ui/components/FaButtonGroup/index.vue')['default']
1617
FaCard: typeof import('./../ui/components/FaCard/index.vue')['default']
1718
FaCheckbox: typeof import('./../ui/components/FaCheckbox/index.vue')['default']
1819
FaContextMenu: typeof import('./../ui/components/FaContextMenu/index.vue')['default']
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<script setup lang="ts">
2+
import { cn } from '@/utils'
3+
4+
defineOptions({
5+
name: 'FaButtonGroup',
6+
})
7+
8+
const props = defineProps<{
9+
vertical?: boolean
10+
}>()
11+
</script>
12+
13+
<template>
14+
<div
15+
:class="cn('inline-flex gap-[1px] items-stretch', {
16+
'horizontal-group flex-row': !props.vertical,
17+
'vertical-group flex-col': props.vertical,
18+
})"
19+
>
20+
<slot />
21+
</div>
22+
</template>
23+
24+
<style scoped>
25+
.horizontal-group {
26+
:deep(> button) {
27+
&:first-child {
28+
border-top-right-radius: 0;
29+
border-bottom-right-radius: 0;
30+
}
31+
32+
&:last-child {
33+
border-top-left-radius: 0;
34+
border-bottom-left-radius: 0;
35+
}
36+
37+
&:not(:first-child, :last-child) {
38+
border-radius: 0;
39+
}
40+
}
41+
}
42+
43+
.vertical-group {
44+
:deep(> button) {
45+
&:first-child {
46+
border-bottom-right-radius: 0;
47+
border-bottom-left-radius: 0;
48+
}
49+
50+
&:last-child {
51+
border-top-left-radius: 0;
52+
border-top-right-radius: 0;
53+
}
54+
55+
&:not(:first-child, :last-child) {
56+
border-radius: 0;
57+
}
58+
}
59+
}
60+
</style>

src/views/component_built_in_example/button.vue

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,37 @@ meta:
3434
</FaButton>
3535
</div>
3636
</FaPageMain>
37+
<FaPageMain title="按钮组">
38+
<div class="flex flex-col items-start gap-4">
39+
<FaButtonGroup>
40+
<FaButton variant="secondary">
41+
<FaIcon name="i-mdi:eye" class="size-4" />
42+
查看详情
43+
</FaButton>
44+
<FaButton>
45+
<FaIcon name="i-mdi:pencil" class="size-4" />
46+
编辑
47+
</FaButton>
48+
<FaButton variant="destructive">
49+
<FaIcon name="i-mdi:delete" class="size-4" />
50+
删除
51+
</FaButton>
52+
</FaButtonGroup>
53+
<FaButtonGroup vertical>
54+
<FaButton variant="secondary">
55+
<FaIcon name="i-mdi:eye" class="size-4" />
56+
查看详情
57+
</FaButton>
58+
<FaButton>
59+
<FaIcon name="i-mdi:pencil" class="size-4" />
60+
编辑
61+
</FaButton>
62+
<FaButton variant="destructive">
63+
<FaIcon name="i-mdi:delete" class="size-4" />
64+
删除
65+
</FaButton>
66+
</FaButtonGroup>
67+
</div>
68+
</FaPageMain>
3769
</div>
3870
</template>

0 commit comments

Comments
 (0)