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

Commit 132f72a

Browse files
committed
feat: add fullscreen mode for the GDialog
1 parent 2dfff91 commit 132f72a

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/components/GDialog.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
:height="height"
2424
:scrollable="scrollable"
2525
:depressed="depressed"
26+
:fullscreen="fullscreen"
2627
>
2728
<slot />
2829
</GDialogContent>
@@ -52,7 +53,6 @@ export default defineComponent({
5253
},
5354
5455
props: {
55-
5656
contentClass: {
5757
type: String,
5858
default: '',
@@ -66,6 +66,11 @@ export default defineComponent({
6666
default: false,
6767
},
6868
69+
fullscreen: {
70+
type: Boolean,
71+
default: false,
72+
},
73+
6974
height: {
7075
type: [String, Number],
7176
default: 'auto',
@@ -139,6 +144,7 @@ export default defineComponent({
139144
const { enableScroll, disableScroll } = useScroll({
140145
overlay: overlayElement,
141146
content: contentFrame,
147+
fullscreen: props.fullscreen,
142148
})
143149
144150
watch(isActive, (active) => {

src/components/GDialogContent.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export default defineComponent({
2424
default: false,
2525
},
2626
27+
fullscreen: {
28+
type: Boolean,
29+
default: false,
30+
},
31+
2732
height: {
2833
type: [String, Number],
2934
default: 'auto',
@@ -53,6 +58,7 @@ export default defineComponent({
5358
{
5459
'g-dialog-content--scrollable': props.scrollable,
5560
'g-dialog-content--depressed': props.depressed,
61+
'g-dialog-content--fullscreen': props.fullscreen,
5662
},
5763
])
5864
@@ -69,8 +75,6 @@ export default defineComponent({
6975
$dialog: &;
7076
7177
pointer-events: auto;
72-
border-radius: 4px;
73-
margin: 24px;
7478
overflow-y: auto;
7579
transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
7680
width: 100%;
@@ -84,11 +88,17 @@ export default defineComponent({
8488
}
8589
8690
&:not(#{$dialog}--fullscreen) {
91+
border-radius: 4px;
8792
max-height: 90%;
93+
margin: 24px;
8894
}
8995
9096
&--scrollable {
9197
display: flex;
9298
}
99+
100+
&--fullscreen {
101+
height: 100%;
102+
}
93103
}
94104
</style>

src/composable/scroll.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { noScrollableParent, getScrollbarWidth } from '../helper/scroll.helper'
55
type ScrollParams = {
66
overlay: Ref<Element | undefined>
77
content: Ref<Element | undefined>
8+
fullscreen: boolean
89
}
910

1011
export const useScroll = ({
1112
overlay,
1213
content,
14+
fullscreen,
1315
}: ScrollParams) => {
1416
let disabled = false
1517
let disableType: 'byEvents' | 'byOverflow'
@@ -31,7 +33,7 @@ export const useScroll = ({
3133
const scrollbarWidth = getScrollbarWidth()
3234

3335
// The mobile has a scroll bar width of 0
34-
if (scrollbarWidth === 0) {
36+
if (scrollbarWidth === 0 || fullscreen) {
3537
disableType = 'byOverflow'
3638
document.documentElement.classList.add('overflow-y-hidden')
3739
} else {

0 commit comments

Comments
 (0)