Skip to content

Commit 6c84e4f

Browse files
committed
Add components/BaseModalDialog.vue
1 parent d6037c5 commit 6c84e4f

File tree

1 file changed

+109
-0
lines changed

1 file changed

+109
-0
lines changed

src/components/BaseModalDialog.vue

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<template>
2+
<v-dialog :value="value" @input="$emit('input', $event)">
3+
<v-card class="DialogCard">
4+
<v-card-title class="DialogCardTitle">
5+
<v-icon class="DialogCardTitleIcon" size="48">{{ iconName }}</v-icon>
6+
<slot class="DialogCardTitleText" name="title" />
7+
</v-card-title>
8+
<v-container class="DialogCardContentContainer">
9+
<slot />
10+
</v-container>
11+
<v-card-actions class="DialogCardButtons px-4">
12+
<action-button
13+
v-for="(action, i) in actions"
14+
:key="i"
15+
class="my-3"
16+
:text="action.buttonLabel"
17+
@click="doDialogAction(i)"
18+
/>
19+
<action-button
20+
v-if="!hideDefaultCancelButton"
21+
:text="defaultCancelButtonLabel"
22+
theme="border"
23+
class="my-3"
24+
@click="$emit('input', false)"
25+
/>
26+
</v-card-actions>
27+
</v-card>
28+
</v-dialog>
29+
</template>
30+
31+
<script lang="ts">
32+
import Vue from 'vue'
33+
import ActionButton from '@/components/ActionButton.vue'
34+
35+
export type DialogAction = {
36+
buttonLabel: string
37+
/**
38+
* ボタン押下時に実行する処理。実行後に BaseModalDialog を閉じないようにするには true を返す。
39+
*/
40+
action: () => boolean | void
41+
}
42+
43+
type Props = {
44+
iconName: string
45+
hideDefaultCancelButton: boolean
46+
defaultCancelButtonLabel: string
47+
actions: DialogAction[]
48+
value: boolean
49+
}
50+
51+
type Methods = {
52+
doDialogAction(buttonIndex: number): void
53+
}
54+
55+
export default Vue.extend<unknown, Methods, unknown, Props>({
56+
name: 'SimpleModalDialog',
57+
components: { ActionButton },
58+
props: {
59+
iconName: {
60+
type: String,
61+
required: true
62+
},
63+
hideDefaultCancelButton: {
64+
type: Boolean,
65+
required: false,
66+
default: false
67+
},
68+
defaultCancelButtonLabel: {
69+
type: String,
70+
required: false,
71+
default: 'キャンセル'
72+
},
73+
actions: {
74+
type: Array as () => DialogAction[],
75+
required: true
76+
},
77+
value: {
78+
type: Boolean,
79+
default: false
80+
}
81+
},
82+
methods: {
83+
doDialogAction(index) {
84+
if (!this.actions[index].action()) {
85+
this.$emit('input', false)
86+
}
87+
}
88+
}
89+
})
90+
</script>
91+
92+
<style lang="scss" scoped>
93+
.v-dialog {
94+
.DialogCard {
95+
border-radius: 14px;
96+
97+
&Title,
98+
&Buttons {
99+
flex-direction: column;
100+
}
101+
102+
&Title,
103+
&TitleIcon {
104+
color: $color-base-color-01;
105+
font-size: 16px;
106+
}
107+
}
108+
}
109+
</style>

0 commit comments

Comments
 (0)