1
1
<script lang="ts" setup>
2
2
import { chromeRuntimeId } from ' @dvcol/web-extension-utils/chrome/runtime' ;
3
- import { NAvatar , NButton , NCard , NFlex , NIcon } from ' naive-ui' ;
3
+ import { NAvatar , NButton , NCard , NFlex , NIcon , NSwitch } from ' naive-ui' ;
4
4
5
- import { computed , ref , watch } from ' vue' ;
5
+ import { computed , ref , Transition , watch } from ' vue' ;
6
6
7
7
import TextField from ' ~/components/common/typography/TextField.vue' ;
8
8
import IconLogIn from ' ~/components/icons/IconLogIn.vue' ;
9
9
import IconLogOut from ' ~/components/icons/IconLogOut.vue' ;
10
10
import IconSimkl from ' ~/components/icons/IconSimkl.vue' ;
11
+ import SettingsFormItem from ' ~/components/views/settings/SettingsFormItem.vue' ;
11
12
import { Logger } from ' ~/services/logger.service' ;
12
13
import { TraktService } from ' ~/services/trakt.service' ;
13
14
import { ResolveExternalLinks } from ' ~/settings/external.links' ;
@@ -20,7 +21,7 @@ import { useWatchActivated } from '~/utils/watching.utils';
20
21
21
22
const i18n = useI18n (' settings' , ' connect' );
22
23
23
- const { userSetting, userSettingLoading } = useSimklStoreRefs ();
24
+ const { userSetting, userSettingLoading, simklEnabled } = useSimklStoreRefs ();
24
25
25
26
const fallback = ref <boolean >(! chromeRuntimeId );
26
27
const avatar = computed (() => {
@@ -68,7 +69,13 @@ useWatchActivated(
68
69
</script >
69
70
70
71
<template >
71
- <NFlex vertical align =" center" >
72
+ <NFlex align =" center" >
73
+ <SettingsFormItem :label =" i18n('label_enable')" class =" flex-auto" >
74
+ <NSwitch v-model:value =" simklEnabled" class =" form-switch" >
75
+ <template #checked >{{ i18n('on', 'common', 'button') }}</template >
76
+ <template #unchecked >{{ i18n('off', 'common', 'button') }}</template >
77
+ </NSwitch >
78
+ </SettingsFormItem >
72
79
<NCard
73
80
class =" account-card"
74
81
:style =" { '--n-border-color': 'var(--border-color)' }"
@@ -90,61 +97,86 @@ useWatchActivated(
90
97
</NIcon >
91
98
</NButton >
92
99
93
- <NFlex class =" names" size =" large" vertical wrap >
94
- <NFlex class =" flex-auto" justify =" center" >
95
- <TextField
96
- :label =" i18n('username')"
97
- :value =" name"
98
- :loading =" userSettingLoading"
99
- label-width =" 4.5rem"
100
- grow
101
- />
102
- <TextField
103
- :label =" i18n('joined')"
104
- :value =" joined"
105
- :loading =" userSettingLoading"
106
- label-width =" auto"
107
- grow
108
- />
100
+ <Transition name =" scale" mode =" out-in" >
101
+ <NFlex
102
+ v-if =" isSimklAuthenticated"
103
+ class =" flex-auto names"
104
+ size =" large"
105
+ vertical
106
+ wrap
107
+ >
108
+ <NFlex class =" flex-auto" justify =" center" >
109
+ <TextField
110
+ :label =" i18n('username')"
111
+ :value =" name"
112
+ :loading =" userSettingLoading"
113
+ label-width =" 4.5rem"
114
+ grow
115
+ />
116
+ <TextField
117
+ :label =" i18n('joined')"
118
+ :value =" joined"
119
+ :loading =" userSettingLoading"
120
+ label-width =" auto"
121
+ grow
122
+ />
123
+ </NFlex >
124
+ <NFlex justify =" center" >
125
+ <TextField
126
+ :label =" i18n('bio')"
127
+ :value =" bio"
128
+ :loading =" userSettingLoading"
129
+ label-width =" 4.5rem"
130
+ value-width =" auto"
131
+ grow
132
+ />
133
+ </NFlex >
109
134
</NFlex >
110
- <NFlex justify =" center" >
111
- <TextField
112
- :label =" i18n('bio')"
113
- :value =" bio"
114
- :loading =" userSettingLoading"
115
- label-width =" 4.5rem"
116
- value-width =" auto"
117
- grow
118
- />
135
+ <NFlex v-else class =" flex-auto names" size =" large" vertical wrap >
136
+ <NFlex class =" logged-out flex-auto" justify =" center" >
137
+ <NButton
138
+ secondary
139
+ type =" success"
140
+ :disabled =" !simklEnabled"
141
+ @click =" loginLogout"
142
+ >
143
+ <span >{{ i18n('login', 'common', 'button') }}</span >
144
+ <template #icon >
145
+ <NIcon :component =" IconLogIn" />
146
+ </template >
147
+ </NButton >
148
+ </NFlex >
119
149
</NFlex >
120
- </NFlex >
150
+ </Transition >
121
151
</NFlex >
122
152
</NCard >
123
153
</NFlex >
124
154
125
155
<!-- Footer -->
126
- <NFlex class =" footer" align =" center" justify =" center" >
127
- <NButton
128
- secondary
129
- :type =" isSimklAuthenticated ? 'error' : 'success'"
130
- @click =" loginLogout"
131
- >
132
- <span >{{
133
- i18n(isSimklAuthenticated ? 'logout' : 'login', 'common', 'button')
134
- }}</span >
156
+ <NFlex
157
+ class =" footer"
158
+ :class =" { show: isSimklAuthenticated }"
159
+ align =" center"
160
+ justify =" center"
161
+ >
162
+ <NButton secondary :type =" 'error'" @click =" loginLogout" >
163
+ <span >{{ i18n('logout', 'common', 'button') }}</span >
135
164
<template #icon >
136
- <NIcon :component =" isSimklAuthenticated ? IconLogOut : IconLogIn " />
165
+ <NIcon :component =" IconLogOut" />
137
166
</template >
138
167
</NButton >
139
168
</NFlex >
140
169
</template >
141
170
142
171
<style lang="scss" scoped>
143
172
@use ' ~/styles/mixin' as mixin ;
173
+ @use ' ~/styles/transition' as transition ;
174
+ @include transition .scale ($transition : 0.375s var (--n-bezier ));
144
175
145
176
.account-card {
146
177
--border-color : var (--white-10 );
147
178
179
+ flex : 1 0 100% ;
148
180
margin-bottom : 1.5rem ;
149
181
background : var (--bg-black-soft );
150
182
@@ -174,10 +206,34 @@ useWatchActivated(
174
206
.flex-auto {
175
207
flex : 1 1 auto ;
176
208
}
209
+
210
+ .logged-out {
211
+ margin-right : 10rem ;
212
+ }
213
+ }
214
+
215
+ .form-switch {
216
+ display : flex ;
217
+ flex : 1 1 auto ;
218
+ justify-content : center ;
219
+ min-width : 5rem ;
220
+ padding : 0 0.5rem ;
221
+ font-size : 0.75rem ;
177
222
}
178
223
179
224
.footer {
225
+ max-height : 0 ;
180
226
margin-bottom : 0.5rem ;
181
227
padding : 0.5rem ;
228
+ overflow : hidden ;
229
+ opacity : 0 ;
230
+ transition :
231
+ max-height 0.75s var (--n-bezier ),
232
+ opacity 0.75s var (--n-bezier );
233
+
234
+ & .show {
235
+ max-height : 6rem ;
236
+ opacity : 1 ;
237
+ }
182
238
}
183
239
</style >
0 commit comments