Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 73502677
authored
Nov 27, 2024
by
Netfan
Committed by
GitHub
Nov 27, 2024
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: add `placement` for `Drawer` (#4958)
1 parent
dedba185
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
4 deletions
docs/src/components/common-ui/vben-drawer.md
packages/@core/ui-kit/popup-ui/src/drawer/drawer-api.ts
packages/@core/ui-kit/popup-ui/src/drawer/drawer.ts
packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue
playground/src/views/examples/drawer/index.vue
docs/src/components/common-ui/vben-drawer.md
View file @
7350267
...
@@ -88,6 +88,7 @@ const [Drawer, drawerApi] = useVbenDrawer({
...
@@ -88,6 +88,7 @@ const [Drawer, drawerApi] = useVbenDrawer({
| closeOnPressEscape | esc 关闭弹窗 |
`boolean`
|
`true`
|
| closeOnPressEscape | esc 关闭弹窗 |
`boolean`
|
`true`
|
| confirmText | 确认按钮文本 |
`string\|slot`
|
`确认`
|
| confirmText | 确认按钮文本 |
`string\|slot`
|
`确认`
|
| cancelText | 取消按钮文本 |
`string\|slot`
|
`取消`
|
| cancelText | 取消按钮文本 |
`string\|slot`
|
`取消`
|
| placement | 抽屉弹出位置 |
`'left'\|'right'\|'top'\|'bottom'`
|
`right`
|
| showCancelButton | 显示取消按钮 |
`boolean`
|
`true`
|
| showCancelButton | 显示取消按钮 |
`boolean`
|
`true`
|
| showConfirmButton | 显示确认按钮文本 |
`boolean`
|
`true`
|
| showConfirmButton | 显示确认按钮文本 |
`boolean`
|
`true`
|
| class | modal的class,宽度通过这个配置 |
`string`
| - |
| class | modal的class,宽度通过这个配置 |
`string`
| - |
...
...
packages/@core/ui-kit/popup-ui/src/drawer/drawer-api.ts
View file @
7350267
...
@@ -41,6 +41,7 @@ export class DrawerApi {
...
@@ -41,6 +41,7 @@ export class DrawerApi {
loading
:
false
,
loading
:
false
,
modal
:
true
,
modal
:
true
,
openAutoFocus
:
false
,
openAutoFocus
:
false
,
placement
:
'right'
,
showCancelButton
:
true
,
showCancelButton
:
true
,
showConfirmButton
:
true
,
showConfirmButton
:
true
,
title
:
''
,
title
:
''
,
...
...
packages/@core/ui-kit/popup-ui/src/drawer/drawer.ts
View file @
7350267
...
@@ -4,6 +4,8 @@ import type { DrawerApi } from './drawer-api';
...
@@ -4,6 +4,8 @@ import type { DrawerApi } from './drawer-api';
import
type
{
Component
,
Ref
}
from
'vue'
;
import
type
{
Component
,
Ref
}
from
'vue'
;
export
type
DrawerPlacement
=
'bottom'
|
'left'
|
'right'
|
'top'
;
export
interface
DrawerProps
{
export
interface
DrawerProps
{
/**
/**
* 取消按钮文字
* 取消按钮文字
...
@@ -72,6 +74,12 @@ export interface DrawerProps {
...
@@ -72,6 +74,12 @@ export interface DrawerProps {
* 是否自动聚焦
* 是否自动聚焦
*/
*/
openAutoFocus
?:
boolean
;
openAutoFocus
?:
boolean
;
/**
* 抽屉位置
* @default right
*/
placement
?:
DrawerPlacement
;
/**
/**
* 是否显示取消按钮
* 是否显示取消按钮
* @default true
* @default true
...
...
packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue
View file @
7350267
...
@@ -62,6 +62,7 @@ const {
...
@@ -62,6 +62,7 @@ const {
loading
:
showLoading
,
loading
:
showLoading
,
modal
,
modal
,
openAutoFocus
,
openAutoFocus
,
placement
,
showCancelButton
,
showCancelButton
,
showConfirmButton
,
showConfirmButton
,
title
,
title
,
...
@@ -119,11 +120,13 @@ function handleFocusOutside(e: Event) {
...
@@ -119,11 +120,13 @@ function handleFocusOutside(e: Event) {
<SheetContent
<SheetContent
:class=
"
:class=
"
cn('flex w-[520px] flex-col', drawerClass,
{
cn('flex w-[520px] flex-col', drawerClass,
{
'!w-full': isMobile,
'!w-full': isMobile || placement === 'bottom' || placement === 'top',
'max-h-[100vh]': placement === 'bottom' || placement === 'top',
})
})
"
"
:modal="modal"
:modal="modal"
:open="state?.isOpen"
:open="state?.isOpen"
:side="placement"
@close-auto-focus="handleFocusOutside"
@close-auto-focus="handleFocusOutside"
@escape-key-down="escapeKeyDown"
@escape-key-down="escapeKeyDown"
@focus-outside="handleFocusOutside"
@focus-outside="handleFocusOutside"
...
...
playground/src/views/examples/drawer/index.vue
View file @
7350267
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
Page
,
useVbenDrawer
}
from
'@vben/common-ui'
;
import
{
type
DrawerPlacement
,
Page
,
useVbenDrawer
}
from
'@vben/common-ui'
;
import
{
Button
,
Card
}
from
'ant-design-vue'
;
import
{
Button
,
Card
}
from
'ant-design-vue'
;
...
@@ -13,6 +13,7 @@ import SharedDataDemo from './shared-data-demo.vue';
...
@@ -13,6 +13,7 @@ import SharedDataDemo from './shared-data-demo.vue';
const
[
BaseDrawer
,
baseDrawerApi
]
=
useVbenDrawer
({
const
[
BaseDrawer
,
baseDrawerApi
]
=
useVbenDrawer
({
// 连接抽离的组件
// 连接抽离的组件
connectedComponent
:
BaseDemo
,
connectedComponent
:
BaseDemo
,
// placement: 'left',
});
});
const
[
AutoHeightDrawer
,
autoHeightDrawerApi
]
=
useVbenDrawer
({
const
[
AutoHeightDrawer
,
autoHeightDrawerApi
]
=
useVbenDrawer
({
...
@@ -31,7 +32,8 @@ const [FormDrawer, formDrawerApi] = useVbenDrawer({
...
@@ -31,7 +32,8 @@ const [FormDrawer, formDrawerApi] = useVbenDrawer({
connectedComponent
:
FormDrawerDemo
,
connectedComponent
:
FormDrawerDemo
,
});
});
function
openBaseDrawer
()
{
function
openBaseDrawer
(
placement
:
DrawerPlacement
=
'right'
)
{
baseDrawerApi
.
setState
({
placement
});
baseDrawerApi
.
open
();
baseDrawerApi
.
open
();
}
}
...
@@ -81,7 +83,16 @@ function openFormDrawer() {
...
@@ -81,7 +83,16 @@ function openFormDrawer() {
<Card
class=
"mb-4"
title=
"基本使用"
>
<Card
class=
"mb-4"
title=
"基本使用"
>
<p
class=
"mb-3"
>
一个基础的抽屉示例
</p>
<p
class=
"mb-3"
>
一个基础的抽屉示例
</p>
<Button
type=
"primary"
@
click=
"openBaseDrawer"
>
打开抽屉
</Button>
<Button
type=
"primary"
@
click=
"openBaseDrawer('right')"
>
右侧打开
</Button>
<Button
class=
"ml-2"
type=
"primary"
@
click=
"openBaseDrawer('bottom')"
>
底部打开
</Button>
<Button
class=
"ml-2"
type=
"primary"
@
click=
"openBaseDrawer('left')"
>
左侧打开
</Button>
<Button
class=
"ml-2"
type=
"primary"
@
click=
"openBaseDrawer('top')"
>
顶部打开
</Button>
</Card>
</Card>
<Card
class=
"mb-4"
title=
"内容高度自适应滚动"
>
<Card
class=
"mb-4"
title=
"内容高度自适应滚动"
>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment