This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
/
InputGridItem.vue
117 lines (110 loc) · 2.56 KB
/
InputGridItem.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<template>
<div
:style="imagePath ? `backgroundImage: url('${assets_loadImage(imagePath)}')` : ''"
:class="{ 'InputGridItem--selected': isSelected }"
class="InputGridItem relative bg-cover bg-no-repeat bg-center rounded-full w-16 h-16 cursor-pointer transition text-center hover:opacity-75"
>
<span
v-if="textContent && !onlyLetter"
class="InputGridItem__text"
>
{{ textContent }}
</span>
<div
v-else-if="onlyLetter"
:class="{
'pt-5 pb-0': isForModal
}"
class="flex h-full flex-col items-center justify-between"
>
<span
v-if="isForModal"
class="font-semibold text-theme-button-text"
>
{{ title }}
</span>
<ButtonLetter
:value="label"
:size="isForModal ? null : '2xl'"
:class="{
'w-24 h-24 text-5xl': isForModal
}"
tag="div"
/>
</div>
<div
v-else-if="component"
:class="{
'pt-5 pb-0': isForModal
}"
class="flex h-full flex-col items-center justify-between"
>
<Component :is="component" />
</div>
<span
v-if="isSelected"
class="InputGridItem__check rounded-full p-1 flex items-center justify-center absolute pin-b pin-r w-6 h-6 bg-green border-2 border-theme-feature text-white"
>
<SvgIcon
name="checkmark"
view-box="0 0 10 9"
/>
</span>
</div>
</template>
<script>
import { ButtonLetter } from '@/components/Button'
import { SvgIcon } from '@/components/SvgIcon'
export default {
name: 'InputGridItem',
components: {
ButtonLetter,
SvgIcon
},
props: {
imagePath: {
type: [String, Boolean],
required: false,
default: null
},
textContent: {
type: String,
default: null
},
onlyLetter: {
type: Boolean,
required: false,
default: false
},
component: {
type: [Object, Function],
required: false,
default: () => {}
},
isForModal: {
type: Boolean,
required: false,
default: true
},
isSelected: {
type: Boolean,
required: true
},
title: {
type: String,
required: false,
default: null
}
},
computed: {
currentNetwork () {
// To avoid failing after removing the current and last profile
return this.$store.getters['session/profile'] ? this.session_network : null
},
label () {
const symbol = this.currentNetwork ? this.currentNetwork.symbol : null
return this.textContent || symbol
}
}
}
</script>