Skip to content

Open source personal finance application

feat(Login): update components

Ilya Komichev1c8ee2395ad4
diff --git a/components/locale/Switcher.vue b/components/locale/Switcher.vue
new file mode 100644
index 00000000..07d4b3df
--- /dev/null
+++ b/components/locale/Switcher.vue
@@ -0,0 +1,19 @@
+<script setup lang="ts">
+const locales = [{
+ slug: 'ru',
+ name: 'Русский',
+}, {
+ slug: 'en',
+ name: 'English',
+}]
+</script>
+
+<template lang="pug">
+UiTabs2
+ UiTabsItem2.text-secondary(
+ v-for="item in locales"
+ :key="item.slug"
+ :isActive="$store.state.lang.lang === item.slug"
+ @click="$store.dispatch('lang/setLang', item.slug)"
+ ) {{ item.name }}
+</template>
diff --git a/components/shared/appName/AppName.vue b/components/shared/appName/AppName.vue
index e1a3a0dc..e554e22d 100644
--- a/components/shared/appName/AppName.vue
+++ b/components/shared/appName/AppName.vue
@@ -1,25 +1,10 @@
<template lang="pug">
-.appName.text-gray-600.dark_text-neutral-200.font-nunito(
-) {{ $t('appName') }}
+.pb-8.text-6xl.font-extrabold.font-secondary.tracking-wide.text-gray-600.dark_text-neutral-200.appName.font-nunito.
+ {{ $t('appName') }}
</template>
<style lang="stylus" scoped>
-@import '~assets/stylus/variables/margins'
-@import '~assets/stylus/variables/fonts'
-
.appName
- margin-bottom 20px
- font-size 66px
- font-weight 800
- letter-spacing 2px
- text-align center
-
&:first-letter
color var(--c-blue-3)
-
- &:not(:first-child)
- margin-top $m9
-
- @media $media-laptop
- margin-top $mb1
</style>
diff --git a/components/shared/copyright/Copyright.vue b/components/shared/copyright/Copyright.vue
index e706a2df..e8473d1b 100644
--- a/components/shared/copyright/Copyright.vue
+++ b/components/shared/copyright/Copyright.vue
@@ -1,32 +1,18 @@
<template lang="pug">
-a.copyright.py-3.px-5.rounded-md.hocus_bg-white2.dark_hocus_bg-custom1(
+a.flex-center.py-3.px-5.rounded-md.hocus_bg-item-hover.transition(
href="https://ilko.me"
)
| {{ $t('app.madeBy.text') }}
- .copyright__heart.mdi.mdi-heart
+ .mdi.mdi-heart.mx-2.heart.text-2xl(
+ class=`
+ animate-[heartbeat_3s_ease-in-out_infinite]
+ text-[rgb(210,0,20)]
+ `
+ )
| {{ $t('app.madeBy.name') }}
</template>
-<style lang="stylus" scoped>
-// TODO: style
-@import '~assets/stylus/variables/animations'
-@import '~assets/stylus/variables/fonts'
-@import '~assets/stylus/variables/margins'
-@import '~assets/stylus/variables/media'
-
-.copyright
- display flex
- align-items center
- justify-content center
- text-decoration none
-
- &__heart
- display inline-flex
- margin 0 $m5
- color rgba(210, 0, 20, 1)
- font-size 28px
- animation heartbeat 3s ease-in-out infinite
-
+<style lang="stylus">
@keyframes heartbeat
0%
transform scale(.75)
diff --git a/components/theme/Switcher.vue b/components/theme/Switcher.vue
new file mode 100644
index 00000000..e041a650
--- /dev/null
+++ b/components/theme/Switcher.vue
@@ -0,0 +1,25 @@
+<script setup lang="ts">
+const items = [
+ {
+ name: 'Light',
+ slug: 'light',
+ }, {
+ name: 'Dark',
+ slug: 'dark',
+ }, {
+ name: 'System',
+ slug: 'system',
+ },
+]
+</script>
+
+<template lang="pug">
+UiTabs2
+ UiTabsItem2(
+ v-for="item in items"
+ :key="item.name"
+ :isActive="$colorMode.preference === item.slug"
+ @click="$store.dispatch('ui/setTheme', item.slug)"
+ ).
+ {{ item.name }}
+</template>
diff --git a/components/ui/ButtonBlue.vue b/components/ui/ButtonBlue.vue
new file mode 100644
index 00000000..f3d3aa9e
--- /dev/null
+++ b/components/ui/ButtonBlue.vue
@@ -0,0 +1,18 @@
+<script setup lang="ts">
+const emit = defineEmits(['click'])
+</script>
+
+<template lang="pug">
+button(
+ class=`
+ cursor-pointer
+ py-3 px-3 w-full
+ text-accent-primary text-center
+ bg-accent-default rounded-full
+ hocus_bg-accent-default/80
+ transition
+ `
+ @click="emit('click')"
+)
+ slot
+</template>
diff --git a/components/ui/ButtonGrey.vue b/components/ui/ButtonGrey.vue
new file mode 100644
index 00000000..c44157d4
--- /dev/null
+++ b/components/ui/ButtonGrey.vue
@@ -0,0 +1,18 @@
+<script setup lang="ts">
+const emit = defineEmits(['click'])
+</script>
+
+<template lang="pug">
+button(
+ class=`
+ cursor-pointer
+ py-3 px-3 w-full
+ text-accent-primary text-center
+ bg-foreground-active rounded-full
+ hocus_bg-foreground-hover
+ transition
+ `
+ @click="emit('click')"
+)
+ slot
+</template>
diff --git a/components/ui/ItemWrap.vue b/components/ui/ItemWrap.vue
new file mode 100644
index 00000000..48e2b053
--- /dev/null
+++ b/components/ui/ItemWrap.vue
@@ -0,0 +1,19 @@
+<script setup lang="ts">
+
+</script>
+
+<template lang="pug">
+div(
+ class=`
+ cursor-pointer
+ py-1 px-3 min-h-[52px]
+ flex items-center gap-3
+ text-primary
+ bg-item-main hocus_bg-item-hover
+ rounded-md
+ hocus_shadow-2xl hocus_scale-[1.02] hocus_z-10
+ duration-200
+ `
+)
+ slot
+</template>
diff --git a/components/ui/Tabs.vue b/components/ui/Tabs.vue
index 46ae57da..589c794c 100644
--- a/components/ui/Tabs.vue
+++ b/components/ui/Tabs.vue
@@ -1,5 +1,15 @@
-<template lang="pug">
-.overflow-hidden.rounded-md.bg-skin-item-main-bg.dark_shadow
- .overflow-hidden.overflow-x-auto.flex.items-center.text-sm.text-center
- slot
+<template>
+ <div
+ class="
+ @container/tabs
+ overflow-hidden
+ overflow-x-auto
+ grow
+ flex items-center
+ rounded-md
+ bg-item-main
+ "
+ >
+ <slot />
+ </div>
</template>
diff --git a/components/ui/Tabs2.vue b/components/ui/Tabs2.vue
index 0f015286..839073ab 100644
--- a/components/ui/Tabs2.vue
+++ b/components/ui/Tabs2.vue
@@ -1,5 +1,11 @@
-<template lang="pug">
-.overflow-hidden
- .overflow-hidden.overflow-x-auto.flex.items-center.text-sm.font-nunito.font-semibold.text-center
- slot
+<template>
+ <div
+ class="
+ overflow-hidden
+ overflow-x-auto
+ flex
+ "
+ >
+ <slot />
+ </div>
</template>
diff --git a/components/ui/TabsItem.vue b/components/ui/TabsItem.vue
index 63092254..8d1b51b4 100644
--- a/components/ui/TabsItem.vue
+++ b/components/ui/TabsItem.vue
@@ -6,10 +6,21 @@ defineProps<{
const emit = defineEmits(['click'])
</script>
-<template lang="pug">
-.cursor-pointer.max-w-xs.px-5.py-2.md_py-3.grow.whitespace-nowrap.hocus_bg-skin-item-main-hover(
- :class="{ 'cursor-default text-skin-accent-base !bg-skin-item-main-active': isActive }"
- @click="emit('click')"
-)
- slot
+<template>
+ <div
+ :class="{
+ '!bg-item-hover/60 !text-accent-default !cursor-default': isActive,
+ }"
+ class="
+ cursor-pointer select-none
+ grow py-3 px-2 flex gap-1 items-center justify-center
+ text-primary/80 text-sm
+ hocus_bg-item-hover
+ @4xl/tabs_text-lg @4xl/tabs_p-3
+ transition
+ "
+ @click="emit('click')"
+ >
+ <slot />
+ </div>
</template>
diff --git a/components/ui/TabsItem2.vue b/components/ui/TabsItem2.vue
index 70dd9bdd..36b858f1 100644
--- a/components/ui/TabsItem2.vue
+++ b/components/ui/TabsItem2.vue
@@ -6,10 +6,21 @@ defineProps<{
const emit = defineEmits(['click'])
</script>
-<template lang="pug">
-.cursor-pointer.grow.max-w-xs.px-3.py-1.whitespace-nowrap.text-skin-item-base-down.border-b-2.border-skin-item-main-hover(
- :class="{ 'cursor-default text-skin-item-base-up !border-skin-accent-base': isActive }"
- @click="emit('click')"
-)
- slot
+<template>
+ <div
+ :class="{
+ '!cursor-default !text-accent-default !bg-transparent': isActive,
+ }"
+ class="
+ cursor-pointer select-none
+ py-2 px-3 flex gap-1 items-center justify-center
+ border-1 rounded-md
+ text-secondary/70 text-sm leading-none
+ hocus_bg-item-hover
+ transition
+ "
+ @click="emit('click')"
+ >
+ <slot />
+ </div>
</template>
diff --git a/layouts/login.vue b/layouts/login.vue
index 95c68254..9d683ea9 100644
--- a/layouts/login.vue
+++ b/layouts/login.vue
@@ -1,8 +1,14 @@
<script setup lang="ts">
import { usePointer } from '@vueuse/core'
+import '~/assets/css/index.css'
+import '~/assets/css/themes.css'
+import '~/assets/css/fullpage.css'
+import '~/assets/css/reset.css'
+
const { $store } = useNuxtApp()
+// TODO: Put in one separate setup function
const { pointerType } = usePointer()
const classes = computed(() => [
{
@@ -10,8 +16,7 @@ const classes = computed(() => [
touch: pointerType.value === 'touch',
},
`
- overflow-hidden
- flex
+ overflow-hidden relative
h-full min-w-base
font-roboto text-gray-600 dark_text-gray-400 antialiased leading-none
bg-neutral-100 dark_bg-dark3
diff --git a/pages/login.vue b/pages/login.vue
index c00f808c..c0d95fe2 100644
--- a/pages/login.vue
+++ b/pages/login.vue
@@ -6,13 +6,24 @@ export default defineComponent({
layout: 'login',
setup() {
+ const route = useRoute()
+ const router = useRouter()
+
const isLoading = ref(false)
- const route = useRoute()
if (route.query?.loading)
isLoading.value = true
- setTimeout(() => { isLoading.value = false }, 10000)
+ onMounted(() => {
+ if (route.query?.loader) {
+ isLoading.value = true
+ const newRoute = { ...route }
+ delete newRoute.query?.loader
+ router.replace(newRoute)
+ }
+
+ setTimeout(() => isLoading.value = false, 10000)
+ })
return {
isLoading,
@@ -43,48 +54,39 @@ export default defineComponent({
})
this.isLoading = false
},
-
- onSetLocale(lang) {
- this.$store.dispatch('lang/setLang', lang)
- },
},
})
</script>
<template lang="pug">
-.tab
- .py-4.px-3.h-24.justify-between.items-start.flex
- .flex.gap-1.top-3.left-5(
- class="lg_top-7 lg_left-7"
- )
- .linkItem.py-2.px-3.rounded-md(
- :class="[{ 'text-blue2 dark_text-blue1': $store.state.lang.lang === 'ru' }, 'hocus_bg-white2 dark_hocus_bg-custom1']"
- @click="onSetLocale('ru')"
- ) Русский
- .linkItem.py-2.px-3.rounded-md(
- :class="[{ 'text-blue2 dark_text-blue1': $store.state.lang.lang === 'en' }, 'hocus_bg-white2 dark_hocus_bg-custom1']"
- @click="onSetLocale('en')"
- ) English
-
- .flex.gap-3.top-3.right-5(
- class="lg_top-7 lg_right-7"
- )
- .linkItem.py-2.px-3.rounded-md.hocus_bg-white2.dark_hocus_bg-custom1(
- @click="$store.dispatch('ui/changeTheme')"
- ) {{ $t('changeTheme') }}
-
- .tab__content
- SharedAppName
- SharedCopyright
-
- .flex.flex-col.items-center.px-3.py-8
- .loginButton.bg-blue3.hocus_bg-blue1.hocus_shadow(
- :class="[{ _loading: isLoading }]"
- @click.prevent="signInWithGoogle"
+.grid.h-full.text-center(class="grid-rows-[auto,1fr,auto]")
+ //- Top
+ .max-w-xl.mx-auto.p-2.w-full.md_p-6
+ .flex.justify-between
+ LocaleSwitcher
+ ThemeSwitcher
+
+ //- Center
+ .h-full.grid.items-center.gap-8.py-4.px-3.h-full.overflow-hidden.overflow-y-auto
+ .flex.flex-col.items-center.justify-center.pb-10
+ SharedAppName
+ SharedCopyright
+
+ .flex.flex-col.items-center.px-3.py-8
+ .loginButton.bg-blue3.hocus_bg-blue1.hocus_shadow(
+ :class="[{ _loading: isLoading }]"
+ @click.prevent="signInWithGoogle"
+ )
+ transition(name="fadeIn")
+ .loginButton__spinier(v-if="isLoading"): SharedSpinier
+ .loginButton__text.text-white {{ $t('loginWithGoogle') }}
+
+ .p-4.flex.items-center.justify-center
+ a.py-2.px-4.flex.items-center.justify-center.gap-1.rounded-md.hocus_bg-item-hover.transition(
+ href="https://ilko.me"
+ target="_blank"
)
- transition(name="fadeIn")
- .loginButton__spinier(v-if="isLoading"): SharedSpinier
- .loginButton__text.text-white {{ $t('loginWithGoogle') }}
+ | ilko.me
</template>
<style lang="stylus" scoped>
diff --git a/store/ui/actions.js b/store/ui/actions.js
index e4ad5ecb..add66a28 100644
--- a/store/ui/actions.js
+++ b/store/ui/actions.js
@@ -32,6 +32,11 @@ export default {
$nuxt.$colorMode.preference = newTheme
},
+ setTheme(_, theme) {
+ // eslint-disable-next-line no-undef
+ $nuxt.$colorMode.preference = theme
+ },
+
/**
* Set app dimensions
*