Skip to content
This repository was archived by the owner on Jan 9, 2022. It is now read-only.

Commit 0911a5d

Browse files
committed
feat: add local mode for the dialog
- allows fixing dialog to closest relative parent
1 parent 96ce3e3 commit 0911a5d

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

packages/dialog/src/components/GDialog.vue

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
<slot name="activator" v-bind="activatorAttrs" />
33

44
<template v-if="activatedOnce">
5-
<Teleport to="body">
5+
<Teleport to="body" :disabled="local">
66
<GDialogOverlay
77
v-if="!fullscreen"
88
ref="overlay"
99
:active="isActive"
10-
:deactivating="deactivating"
1110
:active-z-index="activeZIndex"
1211
:background="overlayBackground"
12+
:deactivating="deactivating"
13+
:local="local"
1314
@click="onClickOutside"
1415
/>
16+
</Teleport>
1517

18+
<Teleport to="body" :disabled="local">
1619
<Transition :name="transition">
1720
<div
1821
v-show="isActive"
@@ -58,6 +61,7 @@ export default defineComponent({
5861
GDialogContent,
5962
},
6063
64+
inheritAttrs: false,
6165
props: {
6266
background: {
6367
type: [Boolean, String],
@@ -129,6 +133,15 @@ export default defineComponent({
129133
type: [String, Number],
130134
default: 'auto',
131135
},
136+
137+
/**
138+
* enables local mode for the dialog.
139+
* dialog is fixed to first "position: relative;" parant
140+
*/
141+
local: {
142+
type: Boolean,
143+
default: false,
144+
},
132145
},
133146
134147
emits: {
@@ -172,6 +185,7 @@ export default defineComponent({
172185
{
173186
'g-dialog-frame--active': isActive.value,
174187
'g-dialog-frame--fullscreen': props.fullscreen,
188+
'g-dialog-frame--local': props.local,
175189
},
176190
])
177191
@@ -189,6 +203,9 @@ export default defineComponent({
189203
})
190204
191205
watch(isActive, (active) => {
206+
if(props.local)
207+
return
208+
192209
if(active) {
193210
disableScroll()
194211
} else {
@@ -246,6 +263,10 @@ export default defineComponent({
246263
outline: none;
247264
pointer-events: none;
248265
z-index: 201;
266+
267+
&--local {
268+
position: absolute;
269+
}
249270
}
250271
251272
.g-dialog-transition {

packages/dialog/src/components/GDialogContent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export default defineComponent({
125125
background: v-bind('computedBackground');
126126
border-radius: v-bind('computedBorderRadius');
127127
128-
&:not(#{$dialog}--depressed) {
128+
&:not(#{$dialog}--depressed):not(#{$dialog}--fullscreen) {
129129
box-shadow: var(--content-shadow)
130130
}
131131

packages/dialog/src/components/GDialogOverlay.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,19 @@ export default defineComponent({
2828
required: true,
2929
},
3030
31+
background: {
32+
type: [Boolean, String],
33+
required: true,
34+
},
35+
3136
deactivating: {
3237
type: Boolean,
3338
required: true,
3439
},
3540
36-
background: {
37-
type: [Boolean, String],
38-
required: true,
41+
local: {
42+
type: Boolean,
43+
default: false,
3944
},
4045
},
4146
@@ -49,6 +54,7 @@ export default defineComponent({
4954
'g-dialog-overlay',
5055
{
5156
'g-dialog-overlay--active': props.active && !props.deactivating,
57+
'g-dialog-overlay--local': props.local,
5258
},
5359
])
5460
@@ -95,6 +101,10 @@ export default defineComponent({
95101
&--active {
96102
pointer-events: auto;
97103
}
104+
105+
&--local {
106+
position: absolute;
107+
}
98108
}
99109
100110
.fade {

0 commit comments

Comments
 (0)