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

Commit 23f0b81

Browse files
committed
feat: remove absolute path alias. add disabling scroll
1 parent 19fb882 commit 23f0b81

File tree

9 files changed

+37
-34
lines changed

9 files changed

+37
-34
lines changed

src/components/GDialog.vue

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,17 @@
3030
</template>
3131

3232
<script lang="ts">
33-
import { defineComponent, computed, ref } from 'vue'
33+
import {
34+
defineComponent, computed, ref, watch,
35+
} from 'vue'
3436
35-
import { useStackable } from '@/composable/stackable'
36-
import { useLazyActivation } from '@/composable/lazyActivation'
37+
import { useStackable } from '../composable/stackable'
38+
import { useLazyActivation } from '../composable/lazyActivation'
3739
38-
import GDialogOverlay from '@/components/GDialogOverlay.vue'
39-
import GDialogContent from '@/components/GDialogContent.vue'
40+
import { disableScroll, enableScroll } from '../helper/scroll.helper'
41+
42+
import GDialogOverlay from './GDialogOverlay.vue'
43+
import GDialogContent from './GDialogContent.vue'
4044
4145
export default defineComponent({
4246
name: 'GDialog',
@@ -97,6 +101,14 @@ export default defineComponent({
97101
type: Boolean,
98102
default: false,
99103
},
104+
105+
/**
106+
* hide scrollbar after opening the dialog
107+
*/
108+
hideScrollbar: {
109+
type: Boolean,
110+
default: false,
111+
},
100112
},
101113
102114
emits: ['update:modelValue'],
@@ -131,6 +143,14 @@ export default defineComponent({
131143
zIndex: activeZIndex.value,
132144
}))
133145
146+
watch(isActive, (active) => {
147+
if(active) {
148+
disableScroll(props.hideScrollbar)
149+
} else {
150+
enableScroll()
151+
}
152+
})
153+
134154
return {
135155
onClickOutside,
136156
activatedOnce,

src/components/GDialogContent.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<script lang="ts">
88
import { computed, defineComponent } from 'vue'
9-
import { useWidthStyle } from '@/composable/widthStyle'
9+
import { useWidthStyle } from '../composable/widthStyle'
1010
1111
export default defineComponent({
1212
name: 'GDialogContent',

src/components/GDialogOverlay.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
</template>
1212

1313
<script lang="ts">
14-
import { computed, defineComponent } from 'vue'
14+
import {
15+
computed, defineComponent,
16+
} from 'vue'
1517
1618
export default defineComponent({
1719
name: 'GDialogOverlay',
@@ -38,7 +40,6 @@ export default defineComponent({
3840
const styles = computed(() => ({
3941
zIndex: props.activeZIndex - 1,
4042
}))
41-
4243
const classes = computed(() => [
4344
'q-dialog-overlay',
4445
{

src/composable/stackable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
} from 'vue'
44

55
// helpers
6-
import { getZIndex } from '@/helper'
6+
import { getZIndex } from '../helper'
77

88
interface IUseStackableParams {
99
activeElSelector: string

src/composable/widthStyle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { computed } from 'vue'
22

33
// helpers
4-
import { convertToUnit } from '@/helper'
4+
import { convertToUnit } from '../helper'
55

66
export interface WidthProps {
77
maxWidth?: number | string

src/helper/scroll.helper.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,19 @@ export const getScrollbarWidth = () => {
1414
return scrollbarWidth
1515
}
1616

17-
/**
18-
*
19-
* @param {boolean} hideScroll
20-
*/
21-
const disableScroll = (hideScroll = false) => {
22-
if (hideScroll) {
17+
export const disableScroll = (hideScrollbar = false) => {
18+
if (hideScrollbar) {
19+
disableBodyScroll(document.body)
20+
} else {
2321
const scrollWidth = getScrollbarWidth()
2422
disableBodyScroll(document.body)
2523
if (scrollWidth > 0) {
2624
document.body.style.paddingRight = scrollWidth + 'px'
2725
}
28-
} else {
29-
disableBodyScroll(document.body)
3026
}
3127
}
3228

33-
const enableScroll = () => {
29+
export const enableScroll = () => {
3430
enableBodyScroll(document.body)
3531
document.body.style.paddingRight = '0'
3632
}
37-
38-
export default {
39-
getScrollbarWidth,
40-
disableScroll,
41-
enableScroll,
42-
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import GDialogComponent from '@/components/GDialog.vue'
1+
import GDialogComponent from './components/GDialog.vue'
22

33
export const GDialog = GDialogComponent
44
export default {

tsconfig.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
"resolveJsonModule": true,
1212
"esModuleInterop": true,
1313
"lib": ["esnext", "dom"],
14-
"paths": {
15-
"@/*": ["./src/*"],
16-
}
1714
},
1815
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
1916
}

vite.config.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ export default defineConfig({
1111
allow: ['..'],
1212
},
1313
},
14-
resolve: {
15-
alias: {
16-
'@': resolvePath('/src'),
17-
},
18-
},
1914
build: {
2015
lib: {
2116
entry: resolvePath('src/index.ts'),

0 commit comments

Comments
 (0)