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

Commit a1d7595

Browse files
committed
feat: add customization for GDialogOverlay background
1 parent fea0e22 commit a1d7595

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/components/GDialog.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:active="isActive"
77
:deactivating="deactivating"
88
:active-z-index="activeZIndex"
9+
:background="overlayBackground"
910
@click="onClickOutside"
1011
/>
1112

@@ -98,6 +99,11 @@ export default defineComponent({
9899
default: false,
99100
},
100101
102+
overlayBackground: {
103+
type: [Boolean, String],
104+
default: true,
105+
},
106+
101107
/**
102108
* clicking outside content will not close modal
103109
*/

src/components/GDialogOverlay.vue

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ export default defineComponent({
3232
type: Boolean,
3333
required: true,
3434
},
35+
36+
background: {
37+
type: [Boolean, String],
38+
required: true,
39+
},
3540
},
3641
3742
emits: ['click'],
@@ -47,13 +52,24 @@ export default defineComponent({
4752
},
4853
])
4954
55+
const computedBackground = computed(() => {
56+
if (typeof props.background === 'string') {
57+
return props.background
58+
} else if(props.background) {
59+
return 'var(--overlay-bg)'
60+
}
61+
62+
return 'transparent'
63+
})
64+
5065
const onClick = () => {
5166
emit('click')
5267
}
5368
5469
return {
5570
styles,
5671
classes,
72+
computedBackground,
5773
onClick,
5874
}
5975
},
@@ -62,6 +78,8 @@ export default defineComponent({
6278

6379
<style lang="scss">
6480
.g-dialog-overlay {
81+
--overlay-bg: var(--g-dialog-overlay-bg, rgba(33, 33, 33, 0.46));
82+
6583
position: fixed;
6684
left: 0;
6785
top: 0;
@@ -71,8 +89,7 @@ export default defineComponent({
7189
justify-content: center;
7290
align-items: center;
7391
pointer-events: none;
74-
opacity: 0.46;
75-
background-color: rgb(33, 33, 33);
92+
background: v-bind('computedBackground');
7693
z-index: 200;
7794
7895
&--active {

0 commit comments

Comments
 (0)