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

Commit ee7b712

Browse files
committed
refactor(demo): refactor dialogs wrapper
- make single data wrapper using scoped slot
1 parent 8a2905c commit ee7b712

File tree

4 files changed

+37
-54
lines changed

4 files changed

+37
-54
lines changed

demo/src/components/Dialogs/StyledDialog/StyledDialogWrapper.vue renamed to demo/src/components/Dialog/DialogStateWrapper.vue

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
11
<template>
22
<div>
3-
<StyledDialog v-model="model" />
3+
<slot :model="model" :input="onInput" />
44

5-
<Btn @click="open">
6-
Styled
5+
<Btn @click="onInput(true)">
6+
{{ label }}
77
</Btn>
88
</div>
99
</template>
1010

1111
<script lang="ts">
1212
import { ref } from 'vue'
13-
1413
import Btn from '@/components/UI/Btn/Btn.vue'
15-
import StyledDialog from './StyledDialog.vue'
1614
1715
export default {
18-
name: 'StyledDialogWrapper',
16+
name: 'DialogStateWrapper',
1917
components: {
2018
Btn,
21-
StyledDialog,
19+
},
20+
21+
props: {
22+
label: {
23+
type: String,
24+
required: true,
25+
},
2226
},
2327
2428
setup() {
2529
const model = ref(false)
2630
27-
const open = () => {
28-
model.value = true
31+
const onInput = (value: boolean) => {
32+
model.value = value
2933
}
3034
3135
return {
3236
model,
33-
open,
37+
onInput,
3438
}
3539
},
3640
}

demo/src/components/Dialogs/BaseDialog/BaseDialogWrapper.vue

Lines changed: 0 additions & 36 deletions
This file was deleted.

demo/src/components/Dialogs/StyledDialog/StyledDialog.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ export default defineComponent({
4444
},
4545
},
4646
47+
emits: ['update:modelValue'],
48+
4749
setup(props, { emit }) {
4850
const value = useModelWrapper(props, emit)
4951
Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
11
<template>
22
<div class="flex wrap">
3-
<BaseDialogWrapper class="mr-3" />
4-
<StyledDialogWrapper />
3+
<DialogStateWrapper
4+
v-slot="{model, input}"
5+
label="Base"
6+
class="mr-3"
7+
>
8+
<BaseDialog :model-value="model" @update:model-value="input" />
9+
</DialogStateWrapper>
10+
11+
<DialogStateWrapper
12+
v-slot="{model, input}"
13+
label="Styled"
14+
>
15+
<StyledDialog :model-value="model" @update:model-value="input" />
16+
</DialogStateWrapper>
517
</div>
618
</template>
719

820
<script lang="ts">
9-
import BaseDialogWrapper from '@/components/Dialogs/BaseDialog/BaseDialogWrapper.vue'
10-
import StyledDialogWrapper from '@/components/Dialogs/StyledDialog/StyledDialogWrapper.vue'
21+
import DialogStateWrapper from '@/components/Dialog/DialogStateWrapper.vue'
22+
import BaseDialog from '@/components/Dialogs/BaseDialog/BaseDialog.vue'
23+
import StyledDialog from '@/components/Dialogs/StyledDialog/StyledDialog.vue'
1124
1225
export default {
1326
name: 'DialogLayout',
1427
components: {
15-
BaseDialogWrapper,
16-
StyledDialogWrapper,
28+
DialogStateWrapper,
29+
BaseDialog,
30+
StyledDialog,
1731
},
1832
19-
setup() {
20-
},
33+
setup() {},
2134
}
2235
</script>

0 commit comments

Comments
 (0)