Skip to content

Commit 37f51b5

Browse files
authored
Merge branch 'development' into feature/issue-117-editing-screen
2 parents e8e4542 + 05dbbb5 commit 37f51b5

File tree

1 file changed

+115
-0
lines changed

1 file changed

+115
-0
lines changed

src/components/BaseDialog.vue

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<template>
2+
<v-dialog :value="value" :persistent="modal" @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+
modal: boolean
49+
value: boolean
50+
}
51+
52+
type Methods = {
53+
doDialogAction(buttonIndex: number): void
54+
}
55+
56+
export default Vue.extend<unknown, Methods, unknown, Props>({
57+
name: 'BaseDialog',
58+
components: { ActionButton },
59+
props: {
60+
iconName: {
61+
type: String,
62+
required: true
63+
},
64+
hideDefaultCancelButton: {
65+
type: Boolean,
66+
required: false,
67+
default: false
68+
},
69+
defaultCancelButtonLabel: {
70+
type: String,
71+
required: false,
72+
default: 'キャンセル'
73+
},
74+
actions: {
75+
type: Array as () => DialogAction[],
76+
required: true
77+
},
78+
modal: {
79+
type: Boolean,
80+
required: false,
81+
default: false
82+
},
83+
value: {
84+
type: Boolean,
85+
default: false
86+
}
87+
},
88+
methods: {
89+
doDialogAction(index) {
90+
if (!this.actions[index].action()) {
91+
this.$emit('input', false)
92+
}
93+
}
94+
}
95+
})
96+
</script>
97+
98+
<style lang="scss" scoped>
99+
.v-dialog {
100+
.DialogCard {
101+
border-radius: 14px;
102+
103+
&Title,
104+
&Buttons {
105+
flex-direction: column;
106+
}
107+
108+
&Title,
109+
&TitleIcon {
110+
color: $color-base-color-01;
111+
font-size: 16px;
112+
}
113+
}
114+
}
115+
</style>

0 commit comments

Comments
 (0)