Skip to content

Commit 6230287

Browse files
committed
feat(login): style login component
1 parent c72c173 commit 6230287

File tree

7 files changed

+154
-26
lines changed

7 files changed

+154
-26
lines changed

.stylelintrc.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export default {
2+
extends: ["@dvcol/stylelint-plugin-presets/config/vue"],
3+
rules: {
4+
"@dvcol/progress": null,
5+
"selector-pseudo-class-no-unknown": [
6+
true,
7+
{
8+
ignorePseudoClasses: ['deep'],
9+
}
10+
]
11+
}
12+
}

.stylelintrc.json

-6
This file was deleted.

src/components/AppComponent.vue

+3-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const { isAuthenticated } = useAuthSettingsStoreRefs();
2323
</template>
2424

2525
<style lang="scss" scoped>
26+
@use 'src/styles/mixin' as mixin;
2627
@use '~/styles/z-index' as layers;
2728
2829
$header-height: 2.75rem;
@@ -35,13 +36,9 @@ header {
3536
flex-direction: column;
3637
justify-content: center;
3738
height: $header-height;
38-
background: var(--bg-blur-black);
39-
backdrop-filter: blur(var(--bg-blur));
40-
transition: background 0.5s;
41-
will-change: background;
4239
43-
&:hover {
44-
background: var(--bg-blur-black-hover);
40+
> :first-child {
41+
@include mixin.hover-background;
4542
}
4643
}
4744
+94-13
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,42 @@
11
<script lang="ts" setup>
2-
import { NButton, NFlex } from 'naive-ui';
2+
import { NButton, NCard, NCheckbox, NFlex, NH4, NText } from 'naive-ui';
33
4-
import { onMounted, watch } from 'vue';
4+
import { onMounted, ref, watch } from 'vue';
55
66
import { useRoute, useRouter } from 'vue-router';
77
88
import { TraktService } from '~/services/trakt.service';
99
import { useAuthSettingsStoreRefs } from '~/stores/settings/auth.store';
1010
import { useI18n } from '~/utils';
1111
12-
const i18n = useI18n('global');
12+
const i18n = useI18n('login');
1313
1414
const route = useRoute();
1515
const router = useRouter();
1616
1717
const { isAuthenticated } = useAuthSettingsStoreRefs();
1818
19+
const onRedirect = (authenticated = isAuthenticated.value) => {
20+
if (!authenticated) return;
21+
return router.push((route.query.redirect as string) ?? '/');
22+
};
23+
1924
onMounted(() => {
25+
onRedirect();
2026
watch(isAuthenticated, authenticated => {
21-
const { redirect } = route.query;
22-
if (authenticated && redirect) router.push(route.query.redirect as string);
27+
onRedirect(authenticated);
2328
});
2429
});
2530
26-
const onRedirect = async () => {
31+
const signUp = ref(false);
32+
const useSession = ref(false);
33+
34+
const onSignIn = async () => {
2735
try {
28-
await TraktService.approve();
36+
await TraktService.approve({
37+
signup: signUp.value,
38+
prompt: !useSession.value,
39+
});
2940
} catch (error) {
3041
console.error('Error:', error);
3142
}
@@ -34,15 +45,85 @@ const onRedirect = async () => {
3445

3546
<template>
3647
<NFlex vertical justify="space-around" align="center">
37-
<img alt="Vue logo" class="logo" src="/assets/logo.svg" width="125" height="125" />
38-
<span>This is a login component</span>
39-
<NButton @click="onRedirect">Redirect Url</NButton>
48+
<NCard class="card" :title="i18n('title')" hoverable>
49+
<template #cover>
50+
<div class="spacer" />
51+
<img
52+
alt="Vue logo"
53+
class="logo"
54+
src="/assets/logo.svg"
55+
width="125"
56+
height="125"
57+
/>
58+
</template>
59+
60+
<NFlex vertical>
61+
<NH4 class="title" prefix="bar">{{ i18n('sub_title') }}</NH4>
62+
63+
<NButton class="button" @click="onSignIn">{{ i18n('sign_in') }}</NButton>
64+
65+
<NFlex class="checkboxes" vertical>
66+
<NCheckbox v-model:checked="signUp">
67+
{{ i18n('checkbox__sign_up_for') }}
68+
<NText type="info">{{ i18n('checkbox__new_account') }}</NText>
69+
!
70+
</NCheckbox>
71+
<NCheckbox v-model:checked="useSession">
72+
{{ i18n('checkbox__use') }}
73+
<NText type="info">{{ i18n('checkbox__active_user') }}</NText>
74+
{{ i18n('checkbox__session') }}
75+
</NCheckbox>
76+
</NFlex>
77+
</NFlex>
78+
</NCard>
4079
</NFlex>
4180
</template>
4281

4382
<style lang="scss" scoped>
44-
.logo {
45-
display: block;
46-
margin: 2rem auto;
83+
@use 'src/styles/mixin' as mixin;
84+
85+
.card {
86+
@include mixin.hover-background;
87+
88+
padding: 0 1.5rem;
89+
90+
.spacer {
91+
height: 60px;
92+
}
93+
94+
.logo {
95+
position: absolute;
96+
top: -50px;
97+
left: 0;
98+
}
99+
100+
:deep(.n-card-header) {
101+
font-size: 3em;
102+
text-align: center;
103+
}
104+
105+
.title {
106+
margin: 0;
107+
padding: 1rem;
108+
background: rgb(99 226 184 / 5%);
109+
transition: background 0.5s;
110+
will-change: background;
111+
}
112+
113+
.button {
114+
margin: 2rem;
115+
}
116+
117+
.checkboxes {
118+
align-self: center;
119+
width: fit-content;
120+
margin-bottom: 1.5rem;
121+
}
122+
123+
&:hover {
124+
.title {
125+
background: rgb(99 226 184 / 9%);
126+
}
127+
}
47128
}
48129
</style>

src/i18n/en/global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Extension name."
55
},
66
"global__app_title": {
7-
"message": "Side Trakt (companion app for Traskt.tv)",
7+
"message": "Side Trakt (companion app for Trakt.tv)",
88
"description": "Extension title."
99
},
1010
"global__app_title_popup": {

src/i18n/en/login/login.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"login__title": {
3+
"message": "Trakt",
4+
"description": "Login title"
5+
},
6+
"login__sub_title": {
7+
"message": "Please sign in to access your data.",
8+
"description": "Login sub title"
9+
},
10+
"login__sign_in": {
11+
"message": "Click to Sign In",
12+
"description": "Login button"
13+
},
14+
"login__checkbox__sign_up_for": {
15+
"message": "Sign up for a",
16+
"description": "Checkbox sign up message (uncolored)"
17+
},
18+
"login__checkbox__new_account": {
19+
"message": "new account",
20+
"description": "Checkbox sign up message (colored)"
21+
},
22+
"login__checkbox__use": {
23+
"message": "Use",
24+
"description": "Checkbox message (uncolored)"
25+
},
26+
"login__checkbox__active_user": {
27+
"message": "active user",
28+
"description": "Checkbox message (colored)"
29+
},
30+
"login__checkbox__session": {
31+
"message": "session to login.",
32+
"description": "Checkbox message (uncolored)"
33+
}
34+
}

src/styles/mixin.scss

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@mixin hover-background($from: var(--bg-blur-black), $to: var(--bg-blur-black-hover), $blur: var(--bg-blur)) {
2+
background: $from;
3+
backdrop-filter: blur($blur);
4+
transition: background 0.5s;
5+
will-change: background;
6+
7+
&:hover {
8+
background: $to
9+
}
10+
}

0 commit comments

Comments
 (0)