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 6719e267
authored
Jan 11, 2025
by
Netfan
Committed by
GitHub
Jan 11, 2025
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat: popup component support overlay blur effect (#5359)
1 parent
cb9c8db5
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
86 additions
and
4 deletions
docs/src/components/common-ui/vben-drawer.md
docs/src/components/common-ui/vben-modal.md
packages/@core/ui-kit/popup-ui/src/drawer/drawer.ts
packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue
packages/@core/ui-kit/popup-ui/src/modal/modal.ts
packages/@core/ui-kit/popup-ui/src/modal/modal.vue
packages/@core/ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue
packages/@core/ui-kit/shadcn-ui/src/ui/sheet/SheetContent.vue
playground/src/views/examples/drawer/base-demo.vue
playground/src/views/examples/drawer/index.vue
playground/src/views/examples/modal/blur-demo.vue
playground/src/views/examples/modal/index.vue
docs/src/components/common-ui/vben-drawer.md
View file @
6719e26
...
@@ -101,6 +101,7 @@ const [Drawer, drawerApi] = useVbenDrawer({
...
@@ -101,6 +101,7 @@ const [Drawer, drawerApi] = useVbenDrawer({
| footerClass | modal底部区域的class |
`string`
| - |
| footerClass | modal底部区域的class |
`string`
| - |
| headerClass | modal顶部区域的class |
`string`
| - |
| headerClass | modal顶部区域的class |
`string`
| - |
| zIndex | 抽屉的ZIndex层级 |
`number`
|
`1000`
|
| zIndex | 抽屉的ZIndex层级 |
`number`
|
`1000`
|
| overlayBlur | 遮罩模糊度 |
`number`
| - |
::: info appendToMain
::: info appendToMain
...
...
docs/src/components/common-ui/vben-modal.md
View file @
6719e26
...
@@ -111,6 +111,7 @@ const [Modal, modalApi] = useVbenModal({
...
@@ -111,6 +111,7 @@ const [Modal, modalApi] = useVbenModal({
| headerClass | modal顶部区域的class |
`string`
| - |
| headerClass | modal顶部区域的class |
`string`
| - |
| bordered | 是否显示border |
`boolean`
|
`false`
|
| bordered | 是否显示border |
`boolean`
|
`false`
|
| zIndex | 弹窗的ZIndex层级 |
`number`
|
`1000`
|
| zIndex | 弹窗的ZIndex层级 |
`number`
|
`1000`
|
| overlayBlur | 遮罩模糊度 |
`number`
| - |
::: info appendToMain
::: info appendToMain
...
...
packages/@core/ui-kit/popup-ui/src/drawer/drawer.ts
View file @
6719e26
...
@@ -86,11 +86,15 @@ export interface DrawerProps {
...
@@ -86,11 +86,15 @@ export interface DrawerProps {
*/
*/
openAutoFocus
?:
boolean
;
openAutoFocus
?:
boolean
;
/**
/**
* 弹窗遮罩模糊效果
*/
overlayBlur
?:
number
;
/**
* 抽屉位置
* 抽屉位置
* @default right
* @default right
*/
*/
placement
?:
DrawerPlacement
;
placement
?:
DrawerPlacement
;
/**
/**
* 是否显示取消按钮
* 是否显示取消按钮
* @default true
* @default true
...
...
packages/@core/ui-kit/popup-ui/src/drawer/drawer.vue
View file @
6719e26
...
@@ -68,6 +68,7 @@ const {
...
@@ -68,6 +68,7 @@ const {
loading
:
showLoading
,
loading
:
showLoading
,
modal
,
modal
,
openAutoFocus
,
openAutoFocus
,
overlayBlur
,
placement
,
placement
,
showCancelButton
,
showCancelButton
,
showConfirmButton
,
showConfirmButton
,
...
@@ -140,6 +141,7 @@ const getAppendTo = computed(() => {
...
@@ -140,6 +141,7 @@ const getAppendTo = computed(() => {
:open="state?.isOpen"
:open="state?.isOpen"
:side="placement"
:side="placement"
:z-index="zIndex"
:z-index="zIndex"
:overlay-blur="overlayBlur"
@close-auto-focus="handleFocusOutside"
@close-auto-focus="handleFocusOutside"
@closed="() => drawerApi?.onClosed()"
@closed="() => drawerApi?.onClosed()"
@escape-key-down="escapeKeyDown"
@escape-key-down="escapeKeyDown"
...
...
packages/@core/ui-kit/popup-ui/src/modal/modal.ts
View file @
6719e26
...
@@ -100,6 +100,10 @@ export interface ModalProps {
...
@@ -100,6 +100,10 @@ export interface ModalProps {
*/
*/
openAutoFocus
?:
boolean
;
openAutoFocus
?:
boolean
;
/**
/**
* 弹窗遮罩模糊效果
*/
overlayBlur
?:
number
;
/**
* 是否显示取消按钮
* 是否显示取消按钮
* @default true
* @default true
*/
*/
...
...
packages/@core/ui-kit/popup-ui/src/modal/modal.vue
View file @
6719e26
...
@@ -77,6 +77,7 @@ const {
...
@@ -77,6 +77,7 @@ const {
loading
:
showLoading
,
loading
:
showLoading
,
modal
,
modal
,
openAutoFocus
,
openAutoFocus
,
overlayBlur
,
showCancelButton
,
showCancelButton
,
showConfirmButton
,
showConfirmButton
,
title
,
title
,
...
@@ -196,6 +197,7 @@ const getAppendTo = computed(() => {
...
@@ -196,6 +197,7 @@ const getAppendTo = computed(() => {
:open="state?.isOpen"
:open="state?.isOpen"
:show-close="closable"
:show-close="closable"
:z-index="zIndex"
:z-index="zIndex"
:overlay-blur="overlayBlur"
close-class="top-3"
close-class="top-3"
@close-auto-focus="handleFocusOutside"
@close-auto-focus="handleFocusOutside"
@closed="() => modalApi?.onClosed()"
@closed="() => modalApi?.onClosed()"
...
...
packages/@core/ui-kit/shadcn-ui/src/ui/dialog/DialogContent.vue
View file @
6719e26
...
@@ -25,6 +25,7 @@ const props = withDefaults(
...
@@ -25,6 +25,7 @@ const props = withDefaults(
closeClass
?:
ClassType
;
closeClass
?:
ClassType
;
modal
?:
boolean
;
modal
?:
boolean
;
open
?:
boolean
;
open
?:
boolean
;
overlayBlur
?:
number
;
showClose
?:
boolean
;
showClose
?:
boolean
;
zIndex
?:
number
;
zIndex
?:
number
;
}
}
...
@@ -82,7 +83,12 @@ defineExpose({
...
@@ -82,7 +83,12 @@ defineExpose({
<Transition
name=
"fade"
>
<Transition
name=
"fade"
>
<DialogOverlay
<DialogOverlay
v-if=
"open && modal"
v-if=
"open && modal"
:style=
"
{ zIndex, position }"
:style=
"
{
zIndex,
position,
backdropFilter:
overlayBlur
&&
overlayBlur > 0 ? `blur(${overlayBlur}px)` : 'none',
}"
@click="() => emits('close')"
@click="() => emits('close')"
/>
/>
</Transition>
</Transition>
...
...
packages/@core/ui-kit/shadcn-ui/src/ui/sheet/SheetContent.vue
View file @
6719e26
...
@@ -17,6 +17,7 @@ interface SheetContentProps extends DialogContentProps {
...
@@ -17,6 +17,7 @@ interface SheetContentProps extends DialogContentProps {
class
?:
any
;
class
?:
any
;
modal
?:
boolean
;
modal
?:
boolean
;
open
?:
boolean
;
open
?:
boolean
;
overlayBlur
?:
number
;
side
?:
SheetVariants
[
'side'
];
side
?:
SheetVariants
[
'side'
];
zIndex
?:
number
;
zIndex
?:
number
;
}
}
...
@@ -75,12 +76,23 @@ function onAnimationEnd(event: AnimationEvent) {
...
@@ -75,12 +76,23 @@ function onAnimationEnd(event: AnimationEvent) {
<
template
>
<
template
>
<DialogPortal
:to=
"appendTo"
>
<DialogPortal
:to=
"appendTo"
>
<Transition
name=
"fade"
>
<Transition
name=
"fade"
>
<SheetOverlay
v-if=
"open && modal"
:style=
"
{ zIndex, position }" />
<SheetOverlay
v-if=
"open && modal"
:style=
"
{
zIndex,
position,
backdropFilter:
overlayBlur
&&
overlayBlur > 0 ? `blur(${overlayBlur}px)` : 'none',
}"
/>
</Transition>
</Transition>
<DialogContent
<DialogContent
ref=
"contentRef"
ref=
"contentRef"
:class=
"cn(sheetVariants(
{ side }), props.class)"
:class=
"cn(sheetVariants(
{ side }), props.class)"
:style="{ zIndex, position }"
:style="{
zIndex,
position,
}"
@animationend="onAnimationEnd"
@animationend="onAnimationEnd"
v-bind="{ ...forwarded, ...$attrs }"
v-bind="{ ...forwarded, ...$attrs }"
>
>
...
...
playground/src/views/examples/drawer/base-demo.vue
View file @
6719e26
...
@@ -7,6 +7,9 @@ const [Drawer, drawerApi] = useVbenDrawer({
...
@@ -7,6 +7,9 @@ const [Drawer, drawerApi] = useVbenDrawer({
onCancel
()
{
onCancel
()
{
drawerApi
.
close
();
drawerApi
.
close
();
},
},
onClosed
()
{
drawerApi
.
setState
({
overlayBlur
:
0
,
placement
:
'right'
});
},
onConfirm
()
{
onConfirm
()
{
message
.
info
(
'onConfirm'
);
message
.
info
(
'onConfirm'
);
// drawerApi.close();
// drawerApi.close();
...
...
playground/src/views/examples/drawer/index.vue
View file @
6719e26
...
@@ -45,6 +45,10 @@ function openBaseDrawer(placement: DrawerPlacement = 'right') {
...
@@ -45,6 +45,10 @@ function openBaseDrawer(placement: DrawerPlacement = 'right') {
baseDrawerApi
.
setState
({
placement
}).
open
();
baseDrawerApi
.
setState
({
placement
}).
open
();
}
}
function
openBlurDrawer
()
{
baseDrawerApi
.
setState
({
overlayBlur
:
5
}).
open
();
}
function
openInContentDrawer
(
placement
:
DrawerPlacement
=
'right'
)
{
function
openInContentDrawer
(
placement
:
DrawerPlacement
=
'right'
)
{
const
state
:
Partial
<
DrawerState
>
=
{
class
:
''
,
placement
};
const
state
:
Partial
<
DrawerState
>
=
{
class
:
''
,
placement
};
if
(
placement
===
'top'
)
{
if
(
placement
===
'top'
)
{
...
@@ -124,6 +128,9 @@ function openFormDrawer() {
...
@@ -124,6 +128,9 @@ function openFormDrawer() {
<Button
class=
"mb-2 ml-2"
type=
"primary"
@
click=
"openBaseDrawer('top')"
>
<Button
class=
"mb-2 ml-2"
type=
"primary"
@
click=
"openBaseDrawer('top')"
>
顶部打开
顶部打开
</Button>
</Button>
<Button
class=
"mb-2 ml-2"
type=
"primary"
@
click=
"openBlurDrawer"
>
遮罩层模糊效果
</Button>
</Card>
</Card>
<Card
class=
"mb-4"
title=
"在内容区域打开"
>
<Card
class=
"mb-4"
title=
"在内容区域打开"
>
...
...
playground/src/views/examples/modal/blur-demo.vue
0 → 100644
View file @
6719e26
<
script
lang=
"ts"
setup
>
import
{
ref
,
watch
}
from
'vue'
;
import
{
useVbenModal
}
from
'@vben/common-ui'
;
import
{
Slider
}
from
'ant-design-vue'
;
const
blur
=
ref
(
5
);
const
[
Modal
,
modalApi
]
=
useVbenModal
({
overlayBlur
:
blur
.
value
,
});
watch
(
blur
,
(
val
)
=>
{
modalApi
.
setState
({
overlayBlur
:
val
,
});
});
</
script
>
<
template
>
<Modal
title=
"遮罩层模糊"
>
<p>
调整滑块来改变遮罩层模糊程度:
{{
blur
}}
</p>
<Slider
v-model:value=
"blur"
:max=
"30"
:min=
"0"
/>
</Modal>
</
template
>
playground/src/views/examples/modal/index.vue
View file @
6719e26
...
@@ -6,6 +6,7 @@ import { Button, Card, Flex } from 'ant-design-vue';
...
@@ -6,6 +6,7 @@ import { Button, Card, Flex } from 'ant-design-vue';
import
DocButton
from
'../doc-button.vue'
;
import
DocButton
from
'../doc-button.vue'
;
import
AutoHeightDemo
from
'./auto-height-demo.vue'
;
import
AutoHeightDemo
from
'./auto-height-demo.vue'
;
import
BaseDemo
from
'./base-demo.vue'
;
import
BaseDemo
from
'./base-demo.vue'
;
import
BlurDemo
from
'./blur-demo.vue'
;
import
DragDemo
from
'./drag-demo.vue'
;
import
DragDemo
from
'./drag-demo.vue'
;
import
DynamicDemo
from
'./dynamic-demo.vue'
;
import
DynamicDemo
from
'./dynamic-demo.vue'
;
import
FormModalDemo
from
'./form-modal-demo.vue'
;
import
FormModalDemo
from
'./form-modal-demo.vue'
;
...
@@ -47,6 +48,10 @@ const [NestedModal, nestedModalApi] = useVbenModal({
...
@@ -47,6 +48,10 @@ const [NestedModal, nestedModalApi] = useVbenModal({
connectedComponent
:
NestedDemo
,
connectedComponent
:
NestedDemo
,
});
});
const
[
BlurModal
,
blurModalApi
]
=
useVbenModal
({
connectedComponent
:
BlurDemo
,
});
function
openBaseModal
()
{
function
openBaseModal
()
{
baseModalApi
.
open
();
baseModalApi
.
open
();
}
}
...
@@ -80,6 +85,10 @@ function openNestedModal() {
...
@@ -80,6 +85,10 @@ function openNestedModal() {
nestedModalApi
.
open
();
nestedModalApi
.
open
();
}
}
function
openBlurModal
()
{
blurModalApi
.
open
();
}
function
handleUpdateTitle
()
{
function
handleUpdateTitle
()
{
dynamicModalApi
.
setState
({
title
:
'外部动态标题'
}).
open
();
dynamicModalApi
.
setState
({
title
:
'外部动态标题'
}).
open
();
}
}
...
@@ -111,6 +120,7 @@ function openFormModal() {
...
@@ -111,6 +120,7 @@ function openFormModal() {
<SharedDataModal
/>
<SharedDataModal
/>
<FormModal
/>
<FormModal
/>
<NestedModal
/>
<NestedModal
/>
<BlurModal
/>
<Flex
wrap=
"wrap"
class=
"w-full"
gap=
"10"
>
<Flex
wrap=
"wrap"
class=
"w-full"
gap=
"10"
>
<Card
class=
"w-[300px]"
title=
"基本使用"
>
<Card
class=
"w-[300px]"
title=
"基本使用"
>
<p>
一个基础的弹窗示例
</p>
<p>
一个基础的弹窗示例
</p>
...
@@ -176,6 +186,13 @@ function openFormModal() {
...
@@ -176,6 +186,13 @@ function openFormModal() {
<Button
type=
"primary"
@
click=
"openNestedModal"
>
打开嵌套弹窗
</Button>
<Button
type=
"primary"
@
click=
"openNestedModal"
>
打开嵌套弹窗
</Button>
</
template
>
</
template
>
</Card>
</Card>
<Card
class=
"w-[300px]"
title=
"遮罩模糊示例"
>
<p>
遮罩层应用类似毛玻璃的模糊效果
</p>
<
template
#
actions
>
<Button
type=
"primary"
@
click=
"openBlurModal"
>
打开弹窗
</Button>
</
template
>
</Card>
</Flex>
</Flex>
</Page>
</Page>
</template>
</template>
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