Skip to content

Open source personal finance application

ui (PeriodSelector): update

ilkome064fc7884f98
diff --git a/components/date/MobileSelector.vue b/components/date/MobileSelector.vue
deleted file mode 100644
index 82fb5257..00000000
--- a/components/date/MobileSelector.vue
+++ /dev/null
@@ -1,104 +0,0 @@
-<script>
-import { ref, useContext } from '@nuxtjs/composition-api'
-import usePeriods from '~/components/periods/usePeriods'
-
-export default {
- name: 'DateMobileSelector',
-
- setup () {
- const { store } = useContext()
- const { periodsNames } = usePeriods()
-
- const visiblePeriodMenu = ref(false)
-
- const onSelectPeriod = period => store.dispatch('filter/setPeriod', period)
-
- return {
- visiblePeriodMenu,
- periodsNames,
- onSelectPeriod
- }
- }
-}
-</script>
-
-<template lang="pug">
-.dateSelector
- .dateSelector__in
- SharedContextMenu(
- :position="{ left: '-24px', top: true }"
- :visible="visiblePeriodMenu"
- @onClickOpener="visiblePeriodMenu = !visiblePeriodMenu"
- )
- template(slot="opener")
- .menuDots
- .menuDots__name: SharedDate(:type="2")
- .menuDots__dots: .mdi.mdi-dots-vertical
-
- template(slot="content")
- SharedContextMenuItem(
- v-for="periodItem in periodsNames"
- :key="periodItem.slug"
- :icon="periodItem.icon"
- :selected="filterPeriod === periodItem.slug"
- :title="$t(`dates.${periodItem.slug}.simple`)"
- @onClick="onSelectPeriod(periodItem.slug)"
- @onClose="visiblePeriodMenu = !visiblePeriodMenu"
- )
- SharedContextMenuItem(
- :selected="filterPeriod === 'all'"
- :title="$t('dates.all.simple')"
- icon="mdi mdi-database"
- @onClick="onSelectPeriod('all')"
- @onClose="visiblePeriodMenu = !visiblePeriodMenu"
- )
-</template>
-
-<style lang="stylus" scoped>
-@import '~assets/stylus/variables'
-
-.hey
- max-width 200px
-
-.dateSelector
- display flex
- align-items center
- justify-content center
- padding-top $m5
-
- &__in
- position relative
-
-.menuDots
- cursor pointer
- display flex
- align-items center
- justify-content center
- padding $m6 $m8
- color var(--c-font-3)
- font-size 22px
- font-weight 500
- border-radius $m8
- anim()
-
- +media(600px)
- font-size 26px
- font-weight 600
- fontFamilyNunito()
- background none
-
- +media-hover()
- color var(--c-blue-1)
-
- &__dots
- margin-top -2px
- margin-right -5px
- padding-top 3px
- padding-left 4px
- color var(--c-font-2)
- font-size 16px
-
- +media(600px)
- padding-left 6px
- font-size 22px
-</style>
diff --git a/components/modal/ModalButton.vue b/components/modal/ModalButton.vue
index 343ff83f..295fdba8 100644
--- a/components/modal/ModalButton.vue
+++ b/components/modal/ModalButton.vue
@@ -26,7 +26,7 @@ export default {
.button-link__icon(v-if="$slots.icon")
slot(name="icon")
- template(v-if="!$slots.icon")
+ template(v-if="!$slots.icon && icon")
.button-link__icon: div(:class="icon")
.button-link__name {{ name }}
@@ -37,8 +37,13 @@ export default {
.button-link
cursor pointer
+ display flex
+ align-items center
+ flex-flow column
+ justify-content center
width auto
max-width 100%
+ min-height 48px
padding $m6 $m6
text-align center
border 1px solid transparent
@@ -46,8 +51,8 @@ export default {
anim()
&._active
- background var(--c-bg-3)
- border 1px solid var(--c-bg-6)
+ cursor default
+ background var(--c-item-bg-hover)
+media-hover()
&:not(._active)
@@ -64,9 +69,14 @@ export default {
color var(--c-font-2)
font-size 32px
+ ~/._active &
+ color var(--c-blue-1)
&__name
color var(--c-font-3)
font-size 12px
line-height 16px
+
+ ~/._active &
+ color var(--c-blue-1)
</style>
diff --git a/components/stat/Dashboard.vue b/components/stat/Dashboard.vue
index c866c258..8ef8912b 100644
--- a/components/stat/Dashboard.vue
+++ b/components/stat/Dashboard.vue
@@ -151,8 +151,8 @@ export default {
<template lang="pug">
.pageWrapScroll
.baseBox._date
- StatDashboardDatesArrows
- DateMobileSelector
+ StatPeriodArrows
+ StatPeriodSelector
//-
//- Chart graph
diff --git a/components/stat/DashboardDatesArrows.vue b/components/stat/PeriodArrows.vue
similarity index 98%
rename from components/stat/DashboardDatesArrows.vue
rename to components/stat/PeriodArrows.vue
index 95fc6eae..328ac7c4 100644
--- a/components/stat/DashboardDatesArrows.vue
+++ b/components/stat/PeriodArrows.vue
@@ -1,5 +1,6 @@
<script>
export default {
+ name: 'StatPeriodArrows'
}
</script>
diff --git a/components/stat/PeriodSelector.vue b/components/stat/PeriodSelector.vue
new file mode 100644
index 00000000..47fadaae
--- /dev/null
+++ b/components/stat/PeriodSelector.vue
@@ -0,0 +1,178 @@
+<script>
+import { ref, computed, useContext } from '@nuxtjs/composition-api'
+import useFilter from '~/modules/filter/useFilter'
+import usePeriods from '~/components/periods/usePeriods'
+
+export default {
+ name: 'StatPeriodSelector',
+
+ setup () {
+ const { store } = useContext()
+ const { periodsNames } = usePeriods()
+ const { filterPeriodNameAllReplacedToYear } = useFilter()
+ const filterPeriod = computed(() => store.state.filter.period)
+
+ const visiblePeriodMenu = ref(false)
+
+ const onSelectPeriod = (period) => {
+ store.dispatch('filter/setPeriod', period)
+ }
+
+ const periodCounts = {
+ items: [1, 3, 6, 12, 16, 24, 36, 48, 60],
+ onSelect: (value) => {
+ store.commit('chart/setElementsToChart', {
+ period: filterPeriod.value,
+ value
+ })
+ }
+ }
+
+ return {
+ periodsNames,
+ filterPeriodNameAllReplacedToYear,
+ filterPeriod,
+ visiblePeriodMenu,
+ onSelectPeriod,
+ periodCounts
+ }
+ }
+}
+</script>
+
+<template lang="pug">
+.dateSelector
+ .menuDots(@click="visiblePeriodMenu = true")
+ .menuDots__name: SharedDate(:type="2")
+ .menuDots__dots: .mdi.mdi-dots-vertical
+
+ Portal(to="modal")
+ LazyBaseBottomSheet(
+ v-if="visiblePeriodMenu"
+ @closed="visiblePeriodMenu = false"
+ )
+ template(#handler="{ close }")
+ .handler
+ BaseBottomSheetClose(@onClick="close")
+
+ template(#default="{ close }")
+ .title {{ $t('dates.period') }}
+
+ .content
+ .modalLinks
+ ModalButton(
+ v-for="periodItem in periodsNames"
+ :key="periodItem.slug"
+ :icon="periodItem.icon"
+ :isActive="filterPeriod === periodItem.slug"
+ :name="$t(`dates.${periodItem.slug}.simple`)"
+ @onClick="onSelectPeriod(periodItem.slug)"
+ )
+
+ ModalButton(
+ :isActive="filterPeriod === 'all'"
+ :name="$t('dates.all.simple')"
+ icon="mdi mdi-database"
+ @onClick="onSelectPeriod('all')"
+ )
+
+ .title {{ $t('dates.count') }}
+ .modalLinks
+ ModalButton(
+ v-for="periodCount in periodCounts.items"
+ :key="periodCount"
+ :isActive="periodCount === $store.state.chart.periods[filterPeriodNameAllReplacedToYear].showedPeriods"
+ :name="periodCount"
+ @onClick="periodCounts.onSelect(periodCount)"
+ )
+
+ .wrap
+ .button(
+ @click="close()"
+ ) {{ $t('close') }}
+</template>
+
+<style lang="stylus" scoped>
+@import '~assets/stylus/variables'
+
+.handler
+ z-index 2
+ position absolute
+ top 0
+ left 0
+ display flex
+ align-items center
+ justify-content center
+ width 100%
+ height 16px
+
+ &:after
+ content ''
+ display block
+ width 32px
+ height 4px
+ background var(--c-bg-8)
+ border-radius 4px
+
+.content
+ +media(600px)
+ border-radius 0 0 $m7 $m7
+
+.dateSelector
+ display flex
+ align-items center
+ justify-content center
+ padding-top $m5
+
+.menuDots
+ cursor pointer
+ display flex
+ align-items center
+ justify-content center
+ padding $m6 $m8
+ color var(--c-font-3)
+ font-size 22px
+ font-weight 500
+ border-radius $m8
+ anim()
+
+ +media(600px)
+ font-size 26px
+ font-weight 600
+ fontFamilyNunito()
+ background none
+
+ +media-hover()
+ color var(--c-blue-1)
+
+ &__dots
+ margin-top -2px
+ margin-right -5px
+ padding-top 3px
+ padding-left 4px
+ color var(--c-font-2)
+ font-size 16px
+
+ +media(600px)
+ padding-left 6px
+ font-size 22px
+
+.wrap
+ display flex
+ padding 0 $m8
+
+.button
+ button-base-1()
+ margin $m8 auto $m5 auto
+
+.title
+ padding $m9
+ padding-bottom $m6
+ color var(--c-font-2)
+ fontFamilyNunito()
+ font-size 28px
+ font-weight 700
+ text-align center
+ background var(--c-bg-3)
+ border-radius $m7 $m7 0 0
+</style>
diff --git a/locales/en-US.js b/locales/en-US.js
index 03236549..5e4ccd4d 100644
--- a/locales/en-US.js
+++ b/locales/en-US.js
@@ -286,6 +286,8 @@ export default {
},
dates: {
+ period: 'Period',
+ count: 'Count',
twoDaysAgo: '2 days ago',
day: {
current: 'Today',
diff --git a/locales/ru-RU.js b/locales/ru-RU.js
index 8295f394..7db6d3f4 100644
--- a/locales/ru-RU.js
+++ b/locales/ru-RU.js
@@ -288,6 +288,8 @@ export default {
},
dates: {
+ period: 'Период',
+ count: 'Количество',
twoDaysAgo: '2 дня назад',
day: {
current: 'Сегодня',
diff --git a/package.json b/package.json
index fa2fa10e..2d8a14da 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "finapp",
- "version": "3.18.2",
+ "version": "3.18.4",
"scripts": {
"dev": "cross-env NUXT_HOST=0.0.0.0 nuxt",
"build": "nuxt build",
diff --git a/store/chart/mutations.js b/store/chart/mutations.js
index 387036af..b17eeb0a 100644
--- a/store/chart/mutations.js
+++ b/store/chart/mutations.js
@@ -13,14 +13,20 @@ export default {
addElementsToChart (state, { periodName, periodType }) {
state.periods[periodName][periodType] = state.periods[periodName][periodType] + 1
},
+
removeElementsFromChart (state, { periodName, periodType }) {
state.periods[periodName][periodType] = state.periods[periodName][periodType] - 1
},
+ setElementsToChart (state, { period, value }) {
+ state.periods[period].showedPeriods = value
+ },
+
setHoveredPeriodValues (state, { values, offset }) {
if (values) state.hoveredPeriod.values = values
if (offset) state.hoveredPeriod.offset = offset
},
+
clearHoveredPeriodValues (state) {
state.hoveredPeriod.values = null
state.hoveredPeriod.offset = null