Skip to content

Open source personal finance application

switch to @nuxtjs/color-mode

ilkomed414bcc476e5
diff --git a/assets/stylus/index.styl b/assets/stylus/index.styl
index 17842a7b..9cf17ec5 100644
--- a/assets/stylus/index.styl
+++ b/assets/stylus/index.styl
@@ -1,5 +1,5 @@
// Created by Ilya Komichev
-// github.com/ilkome
+// github.com/ilkome/finapp
@import "variables"
@import "mixins/*"
diff --git a/assets/stylus/variables/colors-dark.styl b/assets/stylus/variables/colors-dark.styl
index 83560187..c5674c0a 100644
--- a/assets/stylus/variables/colors-dark.styl
+++ b/assets/stylus/variables/colors-dark.styl
@@ -1,4 +1,4 @@
-html.theme-dark
+html.dark-mode
// colors
// --------------------------------------------
--c-red-1 rgba(184, 20, 20, 1)
diff --git a/assets/stylus/variables/colors-light.styl b/assets/stylus/variables/colors-light.styl
index 54b6a68f..5aa0398b 100644
--- a/assets/stylus/variables/colors-light.styl
+++ b/assets/stylus/variables/colors-light.styl
@@ -1,4 +1,4 @@
-html.theme-light
+html
// colors
// --------------------------------------------
--c-red-1 rgba(184, 20, 20, 1)
@@ -22,7 +22,7 @@ html.theme-light
--c-bg-8 rgba(190, 190, 190, 1)
--c-bg-9 rgba(190, 190, 190, 1)
--c-bg-10 rgba(230, 230, 230, 1)
- --c-bg-11 rgba(0, 0, 0, 0.04)
+ --c-bg-11 rgba(0, 0, 0, .04)
--c-bg-12 rgba(100, 100, 100, 1)
--c-bg-13 rgba(120, 120, 120, 1)
--c-bg-overflow rgba(0, 0, 0, .6)
diff --git a/components/budgets/BudgetFormTrn.vue b/components/budgets/BudgetFormTrn.vue
index e0fd653b..260089c5 100644
--- a/components/budgets/BudgetFormTrn.vue
+++ b/components/budgets/BudgetFormTrn.vue
@@ -87,7 +87,7 @@ export default {
padding 11px 20px 10px 20px
background var(--c-bg-5)
border-color transparent
- /.theme-light &
+ /.light-mode &
background var(--c-bg-5)
&:last-child
border-color transparent
diff --git a/components/budgets/BudgetItemTrn.vue b/components/budgets/BudgetItemTrn.vue
index 44a8f384..d289a855 100644
--- a/components/budgets/BudgetItemTrn.vue
+++ b/components/budgets/BudgetItemTrn.vue
@@ -83,7 +83,7 @@ export default {
padding 11px 20px 10px 20px
background var(--c-bg-5)
border-color transparent
- /.theme-light &
+ /.light-mode &
background var(--c-bg-5)
&:last-child
border-color transparent
diff --git a/components/dashboard/DashboardStatControl.vue b/components/dashboard/DashboardStatControl.vue
index 7ed274a2..02a3ff51 100644
--- a/components/dashboard/DashboardStatControl.vue
+++ b/components/dashboard/DashboardStatControl.vue
@@ -67,7 +67,7 @@ $text-disable = var(--c-font-5)
&._active
&:hover
color $text-active
- /.theme-light &
+ /.light-mode &
color $text-active_light
&._disable
diff --git a/components/filter/FilterItem.vue b/components/filter/FilterItem.vue
index f05036fb..f5ba506e 100644
--- a/components/filter/FilterItem.vue
+++ b/components/filter/FilterItem.vue
@@ -123,7 +123,7 @@ export default {
border-radius $m3
anim()
- /.theme-light &
+ /.light-mode &
color var(--c-font-2)
background var(--c-bg-10)
diff --git a/components/groups/BudgetFormTrn.vue b/components/groups/BudgetFormTrn.vue
index fafa5d90..a6aa15dd 100644
--- a/components/groups/BudgetFormTrn.vue
+++ b/components/groups/BudgetFormTrn.vue
@@ -88,7 +88,7 @@ export default {
background var(--c-bg-5)
border-color transparent
- /.theme-light &
+ /.light-mode &
background var(--c-bg-5)
&:last-child
diff --git a/components/groups/BudgetItemTrn.vue b/components/groups/BudgetItemTrn.vue
index 9cdbd3f7..51787537 100644
--- a/components/groups/BudgetItemTrn.vue
+++ b/components/groups/BudgetItemTrn.vue
@@ -84,7 +84,7 @@ export default {
background var(--c-bg-5)
border-color transparent
- /.theme-light &
+ /.light-mode &
background var(--c-bg-5)
&:last-child
diff --git a/components/layout/LayoutMobileMenu.vue b/components/layout/LayoutMobileMenu.vue
index be700b07..8fa09902 100644
--- a/components/layout/LayoutMobileMenu.vue
+++ b/components/layout/LayoutMobileMenu.vue
@@ -155,7 +155,7 @@ export default {
max-width 620px
margin 0 auto
- /.theme-light &
+ /.light-mode &
background var(--c-bg-4)
&__row
@@ -179,7 +179,7 @@ export default {
&._active
color var(--c-font-1)
- /.theme-light &
+ /.light-mode &
color var(--c-font-5)
&__icon
diff --git a/components/modal/ModalButton.vue b/components/modal/ModalButton.vue
index 0a7e21d9..59988d6b 100644
--- a/components/modal/ModalButton.vue
+++ b/components/modal/ModalButton.vue
@@ -37,7 +37,7 @@ export default {
background var(--c-bg-5)
border-radius $m3
- /.theme-light &
+ /.light-mode &
background var(--c-bg-1)
color var(--c-font-2)
diff --git a/components/modal/styles/modalBottom.styl b/components/modal/styles/modalBottom.styl
index 1cbdffb6..f0bbe0df 100644
--- a/components/modal/styles/modalBottom.styl
+++ b/components/modal/styles/modalBottom.styl
@@ -44,7 +44,7 @@
padding 0
- /.theme-light &
+ /.light-mode &
background var(--c-bg-2)
&__header
@@ -56,7 +56,7 @@
background var(--c-bg-8)
border-radius $m3 $m3 0 0
- /.theme-light &
+ /.light-mode &
color var(--c-font-4)
background var(--c-bg-1)
diff --git a/components/shared/button/Button.vue b/components/shared/button/Button.vue
index 1b5cd403..bac06b2d 100644
--- a/components/shared/button/Button.vue
+++ b/components/shared/button/Button.vue
@@ -82,7 +82,7 @@ export default {
box-shadow 2px 2px 6px 0px var(--c-bg-2)
border-radius 50px
- /.theme-light &
+ /.light-mode &
box-shadow 2px 2px 6px 0px var(--c-bg-11)
&:active:not(._disable)
@@ -137,7 +137,7 @@ export default {
border-radius 3px
anim()
- /.theme-light &
+ /.light-mode &
box-shadow 2px 2px 6px 0px var(--c-bg-11)
&:active:not(._disable)
@@ -174,14 +174,14 @@ export default {
color var(--c-font-2)
border-radius $m3
- /.theme-light &
+ /.light-mode &
color var(--c-font-1)
background var(--c-bg-12)
&:hover
@media $media-laptop
background var(--c-bg-6)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-13)
&._small
@@ -193,7 +193,7 @@ export default {
box-shadow 2px 2px 6px 0px var(--c-bg-2)
border-radius $m3
- /.theme-light &
+ /.light-mode &
box-shadow 2px 2px 6px 0px var(--c-bg-11)
^[0]:active &
diff --git a/components/shared/contextMenu/ContextMenu.vue b/components/shared/contextMenu/ContextMenu.vue
index 2e3f7d15..eaa147ba 100644
--- a/components/shared/contextMenu/ContextMenu.vue
+++ b/components/shared/contextMenu/ContextMenu.vue
@@ -105,7 +105,7 @@ export default {
border-radius $m3
box-shadow 0 10px 20px -5px var(--c-bg-1)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-7)
&._right
@@ -120,7 +120,7 @@ export default {
position relative
background var(--c-bg-7)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-7-a)
&__desc
@@ -131,6 +131,6 @@ export default {
color var(--c-font-4)
background var(--c-bg-8)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-1)
</style>
diff --git a/components/shared/contextMenu/ContextMenuItem.vue b/components/shared/contextMenu/ContextMenuItem.vue
index a9d43959..3053f41c 100644
--- a/components/shared/contextMenu/ContextMenuItem.vue
+++ b/components/shared/contextMenu/ContextMenuItem.vue
@@ -73,18 +73,18 @@ export default {
&:active
background var(--c-bg-2)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-7)
&:hover
@media $media-laptop
background var(--c-bg-2)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-7)
&._selected
background var(--c-bg-4)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-4)
&__icon
diff --git a/components/shared/inputs/Checkbox.vue b/components/shared/inputs/Checkbox.vue
index 042abd97..c7e5bc3c 100644
--- a/components/shared/inputs/Checkbox.vue
+++ b/components/shared/inputs/Checkbox.vue
@@ -69,7 +69,7 @@ label.checkbox(:class="{ _alt: alt }")
box-shadow inset 0px 1px 1px background var(--c-bg-12)
^[0]._alt &
background var(--c-bg-7)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-13)
+ .checkbox__helper:after
animation switch .2s ease-out
@@ -105,7 +105,7 @@ label.checkbox(:class="{ _alt: alt }")
background $color-rail
animation switch .2s ease-out
box-shadow 0px 2px 5px 0px rgba(0, 0, 0, 0.3)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-1)
&__toogle
@@ -130,7 +130,7 @@ label.checkbox(:class="{ _alt: alt }")
text-transform uppercase
^[0]._small &
font-size .5em
- /.theme-light &
+ /.light-mode &
color var(--c-font-1)
&._on
content 'on'
diff --git a/components/stat/StatItem.vue b/components/stat/StatItem.vue
index 1135f0dc..a9bee549 100644
--- a/components/stat/StatItem.vue
+++ b/components/stat/StatItem.vue
@@ -127,7 +127,7 @@ export default {
background var(--c-bg-1)
border 1px solid var(--c-bg-5)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-3)
&._active
@@ -150,7 +150,7 @@ export default {
background var(--c-bg-5)
border-bottom 1px solid var(--c-bg-7)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-10)
border-bottom 1px solid var(--c-bg-5)
diff --git a/components/trnForm/TrnFormHeader.vue b/components/trnForm/TrnFormHeader.vue
index 61db54f4..26ccd51a 100644
--- a/components/trnForm/TrnFormHeader.vue
+++ b/components/trnForm/TrnFormHeader.vue
@@ -93,7 +93,7 @@ export default {
// padding-top 8px
// min-height 81px
- /.theme-light &
+ /.light-mode &
background var(--c-bg-2)
.trnFormHeaderItem
diff --git a/components/trnForm/TrnFormModal.vue b/components/trnForm/TrnFormModal.vue
index ef37bf26..da104bd0 100644
--- a/components/trnForm/TrnFormModal.vue
+++ b/components/trnForm/TrnFormModal.vue
@@ -258,7 +258,7 @@ export default {
@media $media-phone
border-radius $m6 $m6 0 0
- /.theme-light &
+ /.light-mode &
background var(--c-bg-2)
&__scroll
@@ -281,7 +281,7 @@ export default {
letter-spacing 1px
fontFamilyNunito()
- /.theme-light &
+ /.light-mode &
color var(--c-font-4)
&:hover
diff --git a/components/trnForm/styles/trnForm.styl b/components/trnForm/styles/trnForm.styl
index 177c507b..622fbd8b 100644
--- a/components/trnForm/styles/trnForm.styl
+++ b/components/trnForm/styles/trnForm.styl
@@ -34,7 +34,7 @@
margin 0 auto
background var(--c-bg-4)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-2)
@media $media-phone
diff --git a/components/trns/item/TrnItem.vue b/components/trns/item/TrnItem.vue
index 950fecce..229b6844 100644
--- a/components/trns/item/TrnItem.vue
+++ b/components/trns/item/TrnItem.vue
@@ -252,7 +252,7 @@ export default {
@media $media-laptop
background var(--c-bg-5)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-5)
&__amount
diff --git a/components/trns/modal/TrnModal.vue b/components/trns/modal/TrnModal.vue
index 9b70c959..0662a585 100644
--- a/components/trns/modal/TrnModal.vue
+++ b/components/trns/modal/TrnModal.vue
@@ -222,7 +222,7 @@ ModalBottom(
&:hover
background var(--c-bg-5)
- /.theme-light &
+ /.light-mode &
background var(--c-bg-5)
&__active
diff --git a/components/welcome/LangSelector.vue b/components/welcome/LangSelector.vue
index a349ed71..7763279e 100644
--- a/components/welcome/LangSelector.vue
+++ b/components/welcome/LangSelector.vue
@@ -46,7 +46,7 @@ export default {
color rgba(150, 150, 150, 1)
background rgba(10, 10, 10, 1)
- /.theme-light &
+ /.light-mode &
color rgba(50, 50, 50, 1)
background rgba(229, 229, 229, 1)
border-color rgba(190, 190, 190, 1)
diff --git a/layouts/default.vue b/layouts/default.vue
index f75415d5..971abeb5 100644
--- a/layouts/default.vue
+++ b/layouts/default.vue
@@ -63,23 +63,12 @@ export default {
const height = document.documentElement.clientHeight
this.$store.dispatch('ui/setAppDimensions', { width, height })
}
- },
-
- head () {
- const classes = [`theme-${this.$store.state.ui.theme}`]
-
- return {
- htmlAttrs: {
- class: classes
- }
- }
}
}
</script>
<template lang="pug">
.finapp(:style="layoutStyles")
-
//- loading
template(v-if="$fetchState.pending || $store.state.app.status.loading")
Loader
@@ -109,7 +98,6 @@ export default {
<style lang="stylus">
@import "~assets/stylus/variables/fonts"
@import "~assets/stylus/common/notifications"
-@import "~assets/stylus/index"
*
box-sizing border-box
diff --git a/nuxt.config.js b/nuxt.config.js
index ff069497..9ba06df2 100644
--- a/nuxt.config.js
+++ b/nuxt.config.js
@@ -2,15 +2,17 @@ export default {
publicRuntimeConfig: {
testerEmail: '[email protected]'
},
- /*
- ** Nuxt rendering mode
- ** See https://nuxtjs.org/api/configuration-mode
- */
+
+ /**
+ * Nuxt rendering mode
+ * See https://nuxtjs.org/api/configuration-mode
+ */
mode: 'spa',
- /*
- ** Headers of the page
- ** See https://nuxtjs.org/api/configuration-head
- */
+
+ /**
+ * Headers of the page
+ * See https://nuxtjs.org/api/configuration-head
+ */
head: {
title: 'Finapp',
meta: [
@@ -19,9 +21,6 @@ export default {
{ hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
],
link: [{
- rel: 'stylesheet',
- href: '/init.css'
- }, {
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css?family=Roboto:400,500,700|Unica+One|Nunito:400,700,800&display=swap&subset=cyrillic'
}, {
@@ -32,40 +31,55 @@ export default {
href: 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css'
}]
},
- /*
- ** Global CSS
- */
+
+ /**
+ * Global CSS
+ */
css: [
+ { src: '~/assets/stylus/index.styl' }
],
- /*
- ** Plugins to load before mounting the App
- ** https://nuxtjs.org/guide/plugins
- */
+
+ /**
+ * Plugins to load before mounting the App
+ * https://nuxtjs.org/guide/plugins
+ */
plugins: [
{ src: '~/plugins/dayjs' },
{ src: '~/plugins/notifications' },
{ src: '~/plugins/vueLang' }
],
- /*
- ** Nuxt.js dev-modules
- */
+
+ /**
+ * Nuxt.js dev-modules
+ */
buildModules: [
+ '@nuxtjs/color-mode'
],
- /*
- ** Nuxt.js modules
- */
+
+ /**
+ * Color mode
+ */
+ colorMode: {
+ preference: 'system', // default value of $colorMode.preference
+ fallback: 'dark' // fallback value if not system preference found
+ },
+
+ /**
+ * Nuxt.js modules
+ */
modules: [
'@nuxtjs/pwa'
],
- /*
- ** Axios module configuration
- ** See https://axios.nuxtjs.org/options
- */
+
+ /**
+ * Axios module configuration
+ * See https://axios.nuxtjs.org/options
+ */
axios: {},
- /*
- ** Manifest
- */
+ /**
+ * Manifest
+ */
manifest: {
name: 'Finapp',
short_name: 'Finapp',
@@ -76,12 +90,5 @@ export default {
size: '64x64',
type: 'image/png'
}]
- },
-
- /*
- ** Build configuration
- ** See https://nuxtjs.org/api/configuration-build/
- */
- build: {
}
}
diff --git a/package-lock.json b/package-lock.json
index 14b33d10..caf2b9c0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "finapp",
- "version": "3.0.1",
+ "version": "3.0.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -2800,6 +2800,24 @@
}
}
},
+ "@nuxtjs/color-mode": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/@nuxtjs/color-mode/-/color-mode-1.0.0.tgz",
+ "integrity": "sha512-AkBGTQSXZF2+6KUr7u1M/LpP+zeTk1U/ysVfGotGX2yVDufADE90dCC93+Rfu+Z7U/SW59KJD3MD3/S6s5d6Gg==",
+ "dev": true,
+ "requires": {
+ "defu": "^1.0.0",
+ "lodash.template": "^4.5.0"
+ },
+ "dependencies": {
+ "defu": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/defu/-/defu-1.0.0.tgz",
+ "integrity": "sha512-1Y1KRFxiiq+LYsZ3iP7xYSR8bHfmHFOUpDunZCN1ld1fGfDJWJIvkUBtjl3apnBwPuJtL/H7cwwlLYX8xPkraQ==",
+ "dev": true
+ }
+ }
+ },
"@nuxtjs/eslint-config": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@nuxtjs/eslint-config/-/eslint-config-3.0.0.tgz",
@@ -4098,7 +4116,7 @@
},
"babel-plugin-syntax-object-rest-spread": {
"version": "6.13.0",
- "resolved": "https://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz",
+ "resolved": "http://registry.npmjs.org/babel-plugin-syntax-object-rest-spread/-/babel-plugin-syntax-object-rest-spread-6.13.0.tgz",
"integrity": "sha1-/WU28rzhODb/o6VFjEkDpZe7O/U=",
"dev": true
},
diff --git a/package.json b/package.json
index a2195cec..6703f322 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "finapp",
- "version": "3.0.2",
+ "version": "3.0.3",
"scripts": {
"dev": "cross-env NUXT_HOST=0.0.0.0 nuxt",
"build": "nuxt build --modern",
@@ -31,6 +31,7 @@
"vuejs-datepicker": "^1.6.2"
},
"devDependencies": {
+ "@nuxtjs/color-mode": "^1.0.0",
"@nuxtjs/eslint-config": "^3.0.0",
"@nuxtjs/pwa": "^2.6.0",
"babel-eslint": "^10.1.0",
diff --git a/store/app/actions.js b/store/app/actions.js
index db60392a..cd2f06fd 100644
--- a/store/app/actions.js
+++ b/store/app/actions.js
@@ -38,9 +38,6 @@ export default {
dispatch('ui/initUi', null, { root: true })
dispatch('chart/initChart', null, { root: true })
- const theme = await localforage.getItem('next.theme')
- if (theme) { dispatch('ui/changeTheme', theme, { root: true }) }
-
const ativeTab = await localforage.getItem('next.activeTab')
if (ativeTab) { dispatch('ui/setActiveTab', ativeTab, { root: true }) }
diff --git a/store/ui/actions.js b/store/ui/actions.js
index 4b90e97f..43ea047b 100644
--- a/store/ui/actions.js
+++ b/store/ui/actions.js
@@ -23,28 +23,22 @@ export default {
},
/**
- * Change theme
- * Commit new theme and save to localStorage
- *
- * @param {string} theme - New theme value (light, dark).
- */
+ * Change theme
+ * Commit new theme and save to localStorage
+ *
+ * @param {string} theme - New theme value (light, dark).
+ */
changeTheme ({ commit, rootState }, theme) {
+ // eslint-disable-next-line no-undef
+ const currentTheme = $nuxt.$colorMode.value
let newTheme
- const changeToDark = () => {
- newTheme = 'dark'
- }
-
- const changeToLight = () => {
- newTheme = 'light'
- }
-
theme
- ? theme === 'dark' ? changeToDark() : changeToLight()
- : rootState.ui.theme === 'dark' ? changeToLight() : changeToDark()
+ ? newTheme = theme
+ : currentTheme === 'dark' ? newTheme = 'light' : newTheme = 'dark'
- commit('setTheme', newTheme)
- localforage.setItem('next.theme', newTheme)
+ // eslint-disable-next-line no-undef
+ $nuxt.$colorMode.preference = newTheme
},
/**
diff --git a/store/ui/index.js b/store/ui/index.js
index a7de2c0c..c971b641 100644
--- a/store/ui/index.js
+++ b/store/ui/index.js
@@ -17,7 +17,6 @@ const state = () => ({
activeTab: 'stat',
walletsVisibility: 'visible'
},
- theme: 'dark',
width: 0
})
diff --git a/store/ui/mutations.js b/store/ui/mutations.js
index 2861ea34..9244b8ed 100644
--- a/store/ui/mutations.js
+++ b/store/ui/mutations.js
@@ -13,10 +13,6 @@ export default {
state.width = props.width
},
- setTheme (state, theme) {
- state.theme = theme
- },
-
showStatGraphs (state) {
state.statGraphsVisibility = 'visible'
},