Skip to content

Open source personal finance application

update TrnForm design and code

ilkomef2b8c447be73
diff --git a/components/trnForm/TrnForm.vue b/components/trnForm/TrnForm.vue
index f3dcdd8b..aac3fa9f 100644
--- a/components/trnForm/TrnForm.vue
+++ b/components/trnForm/TrnForm.vue
@@ -1,7 +1,7 @@
<script>
import dayjs from 'dayjs'
import generateId from '~/utils/id'
-import { successEmo, errorEmo, random } from '~/assets/js/emo'
+import { successEmo, random } from '~/assets/js/emo'
import Amount from '~/components/amount/Amount'
import CategoriesView from '~/components/categories/list/CategoriesView'
@@ -42,10 +42,19 @@ export default {
WalletsList
},
+ data () {
+ return {
+ initialY: 0,
+ currentY: 0,
+ isDragging: false
+ }
+ },
+
computed: {
show () {
return this.$store.state.trnForm.show
},
+
isTransfer () {
return this.$store.state.trnForm.values.amountType === 2
},
@@ -65,6 +74,11 @@ export default {
show: {
handler (show) {
if (show) {
+ // this.initialY = 0
+ // this.currentY = 0
+ // this.isDragging = false
+ this.setTranslate()
+
this.$nextTick(() => {
this.setTrnFormHeight()
})
@@ -80,6 +94,10 @@ export default {
}
},
+ mounted () {
+ this.adddListeners()
+ },
+
methods: {
handleSubmitForm () {
try {
@@ -245,49 +263,166 @@ export default {
text: 'Excellent transaction!',
title: emo
})
+ },
+
+ adddListeners () {
+ const modalContainer = this.$refs.trnForm
+ if (modalContainer) {
+ modalContainer.addEventListener('touchstart', this.onDragStart, false)
+ modalContainer.addEventListener('touchend', this.onDragEnd, false)
+ modalContainer.addEventListener('touchmove', this.onDragging, false)
+ modalContainer.addEventListener('mouseup', this.onDragEnd, false)
+ }
+ },
+
+ onDragStart (e) {
+ // stop trnFormModal drag when content has scroll
+ // wait until content scroll up to top
+ const scrollBlock = this.$refs.trnForm.querySelector('.trnForm__scroll')
+ if (scrollBlock && scrollBlock.scrollTop > 0) {
+ return
+ }
+
+ // same as above but for any block
+ // const swiperSlideActive = this.$el.querySelector('.trnFormActiveSlide')
+ // if (swiperSlideActive) {
+ // const sliderWithScroll = swiperSlideActive.querySelector('.waitForScroll')
+ // if (sliderWithScroll) {
+ // if (sliderWithScroll.scrollTop > 0) { return }
+ // }
+ // }
+
+ const dragItem = this.$refs.trnForm.querySelector('.trnForm__wrap')
+ if (dragItem) {
+ dragItem.classList.remove('_anim')
+
+ if (e.type === 'touchstart') {
+ this.initialY = e.touches[0].clientY
+ }
+ else {
+ this.initialY = e.clientY
+ }
+
+ if (e.target.closest('.trnForm__wrap')) {
+ this.isDragging = true
+ }
+
+ if (e.target.closest('.noDrag')) {
+ this.isDragging = false
+ }
+ }
+ },
+
+ onDragging (e) {
+ if (this.isDragging) {
+ if (e.type === 'touchmove') {
+ this.currentY = e.touches[0].clientY - this.initialY
+ }
+ else {
+ this.currentY = e.clientY - this.initialY
+ }
+
+ if ((Math.abs(this.currentY) < Math.abs(this.currentX))) {
+ return
+ }
+
+ this.setTranslate()
+ }
+ },
+
+ onDragEnd (e) {
+ const dragItem = this.$refs.trnForm.querySelector('.trnForm__wrap')
+
+ // do not close
+ if (this.currentY >= 80) {
+ dragItem.classList.add('_anim')
+ this.currentY = this.$refs.trnForm.clientHeight
+ this.setTranslate()
+ this.onClose()
+ }
+ // close
+ else {
+ this.currentY = 0
+ this.currentX = 0
+ this.setTranslate()
+ if (this.isDragging) { dragItem.classList.add('_anim') }
+ }
+
+ this.isDragging = false
+ },
+
+ setTranslate () {
+ if (this.$refs.trnForm) {
+ const modalHeight = this.$refs.trnForm.clientHeight
+ const diff = (modalHeight - this.currentY) / (modalHeight / 100)
+ const diffTrunc = Math.trunc(diff)
+
+ const modalContainer = this.$refs.trnForm
+ const dragItem = modalContainer.querySelector('.trnForm__wrap')
+ const overflow = modalContainer.querySelector('.trnForm__overflow')
+
+ if (this.currentY === 0 && dragItem) {
+ dragItem.style.transform = ''
+ overflow.style.opacity = ''
+ }
+ else if (this.currentY > 0 && dragItem) {
+ dragItem.style.transform = `translate3d(0, ${this.currentY}px, 0)`
+ overflow.style.opacity = diffTrunc === 100 ? 1 : `0.${diffTrunc}`
+ }
+ }
+ },
+
+ onClose () {
+ this.initialY = 0
+ this.currentY = 0
+ this.isDragging = false
+
+ this.$store.dispatch('trnForm/closeTrnForm')
}
}
}
</script>
<template lang="pug">
-.trnForm(v-if="$store.getters['wallets/hasWallets'] && $store.getters['categories/hasCategories']")
- //- Overflow
+.trnForm(
+ v-if="$store.getters['wallets/hasWallets'] && $store.getters['categories/hasCategories']"
+ ref="trnForm"
+)
+ //- overflow
transition(name="fadeIn")
.trnForm__overflow(
v-show="show"
- @click.prevent="$store.dispatch('trnForm/closeTrnForm')"
+ @click.prevent="onClose"
)
- //- Wrap
+ //- wrap
transition(name="trnFormAnimation")
.trnForm__wrap(
v-show="show"
ref="trnFormWrapRef"
)
- //- Header
- TrnFormHeaderTransfer(
- v-if="$store.getters['wallets/walletsSortedIds'].length > 1"
- v-show="isTransfer")
- TrnFormHeader(v-show="!isTransfer")
- //- Content
+ //- content
.trnForm__scroll
.trnForm__content
+ //- laptop
template(v-if="$store.state.ui.pc")
- .trnForm__dateAndDesc
- .trnForm__dateAndDesc-date
- TrnFormCalendar
- .trnForm__dateAndDesc-desc(@click="$store.commit('trnForm/toogleTrnFormModal', 'description')")
- .mdi.mdi-comment-text-outline
+ TrnFormCalendar
+
+ //- header
+ TrnFormHeaderTransfer(
+ v-if="$store.getters['wallets/walletsSortedIds'].length > 1"
+ v-show="isTransfer"
+ )
+ TrnFormHeader(v-show="!isTransfer")
template(v-if="$store.state.ui.mobile && !isTransfer && $store.getters['categories/quickSelectorCategoriesIds'].length")
.trnForm__quickWallets(v-if="isShowFirstWallets")
WalletsList(
:limit="3"
ui="widget"
- v-on:onClick="walletId => $store.commit('trnForm/setTrnFormValues', { walletId })")
-
+ v-on:onClick="walletId => $store.commit('trnForm/setTrnFormValues', { walletId })"
+ )
.trnForm__quickCats
CategoriesView(
:ids="$store.getters['categories/quickSelectorCategoriesIds']"
@@ -295,8 +430,9 @@ export default {
@onClick="categoryId => $store.commit('trnForm/setTrnFormValues', { categoryId })")
TrnFormAmount(
- @onFormSubmit="handleSubmitForm"
+ v-if="$store.state.ui.mobile"
@handleMath="handleMath"
+ @onFormSubmit="handleSubmitForm"
)
TrnFormAmountInput(
v-if="$store.state.ui.pc"
@@ -304,33 +440,13 @@ export default {
)
template(v-if="$store.state.ui.mobile")
- .trnForm__dateAndDesc
- .trnForm__dateAndDesc-date
- TrnFormCalendar
- .trnForm__dateAndDesc-desc(@click="$store.commit('trnForm/toogleTrnFormModal', 'description')")
- .mdi.mdi-comment-text-outline
+ TrnFormCalendar
//- pc
template(v-if="$store.state.ui.pc")
- div(
- v-if="$store.getters['wallets/walletsSortedIds'].length > 1"
- v-show="isTransfer")
- .formWallets
- .formTitle(@click="$store.commit('trnForm/toogleTrnFormModal', 'transferFrom')") From
- WalletsList(
- :limit="6"
- ui="tile"
- v-on:onClick="walletId => $store.commit('trnForm/setTrnFormTransfer', { tranferType: 'from', walletId })")
- .formWallets
- .formTitle(@click="$store.commit('trnForm/toogleTrnFormModal', 'transferTo')") To
- WalletsList(
- :limit="6"
- ui="tile"
- v-on:onClick="walletId => $store.commit('trnForm/setTrnFormTransfer', { tranferType: 'to', walletId })")
-
div(v-show="!isTransfer")
.formWallets
- .formTitle(@click="$store.commit('trnForm/toogleTrnFormModal', 'wallets')") Wallets
+ .formTitle(@click="$store.commit('trnForm/toogleTrnFormModal', 'wallets')") Favorite Wallets
.trnForm__quickWallets
WalletsList(
:limit="3"
@@ -346,9 +462,17 @@ export default {
v-on:onClick="categoryId => $store.commit('trnForm/setTrnFormValues', { categoryId })")
//- pc: end
+ //- mobile
template(v-if="$store.state.ui.mobile")
TrnFormCalculator(v-on:onFormSubmit="handleSubmitForm")
+ //- header
+ TrnFormHeaderTransfer(
+ v-if="$store.getters['wallets/walletsSortedIds'].length > 1"
+ v-show="isTransfer"
+ )
+ TrnFormHeader(v-show="!isTransfer")
+
//- Modals
TrnFormModalCats
TrnFormModalCatsChild
@@ -367,6 +491,7 @@ export default {
padding-bottom 16px
.walletsWidget
+ opacity .6
display grid
grid-template-columns repeat(3, minmax(auto, 1fr))
grid-column-gap 12px
@@ -385,38 +510,21 @@ export default {
</style>
<style lang="stylus" scoped>
+@import "~assets/stylus/variables/animations"
@import "~assets/stylus/variables/margins"
@import "~assets/stylus/variables/media"
.trnForm
+ &__quickCats
+ opacity .8
+
&__wrap
overflow hidden
border-radius 16px 16px 0 0
+ &._anim
+ anim(300ms)
+
@media $media-laptop
border-radius 16px
-
-.trnForm__dateAndDesc
- display flex
- align-items stretch
- border-top 1px solid var(--c-bg-3)
- border-bottom 1px solid var(--c-bg-3)
-
- @media $media-laptop
- min-height 54px
- color var(--c-font-4)
- background var(--c-bg-4)
- border-bottom 1px solid var(--c-bg-3)
- border-top 0
-
- &-date
- flex-grow 1
-
- &-desc
- width calc(100%/5)
- padding $m7 $m9
- color var(--c-font-4)
- font-size 20px
- text-align center
- border-left 1px solid var(--c-bg-3)
</style>
diff --git a/components/trnForm/TrnFormAmount.vue b/components/trnForm/TrnFormAmount.vue
index 5d428dc2..2facc094 100644
--- a/components/trnForm/TrnFormAmount.vue
+++ b/components/trnForm/TrnFormAmount.vue
@@ -53,17 +53,15 @@ export default {
<template lang="pug">
.trnFormAmount(:class="className")
- //- mobile
- template(v-if="$store.state.ui.mobile")
- .trnFormAmount__in(@click="handleChangeAmountType")
- .trnFormAmount__type
- template(v-if="amountType === 0") {{ $lang.money.expenses }}
- template(v-if="amountType === 1") {{ $lang.money.incomes }}
- template(v-if="amountType === 2 && $store.getters['wallets/walletsSortedIds'].length > 1") {{ $lang.money.transfer }}
-
- .trnFormAmount__content
- .trnFormAmount__value {{ amountString }}
- .trnFormAmount__evaluation {{ $store.state.trnForm.values.amountEvaluation }}
+ .trnFormAmount__in(@click="handleChangeAmountType")
+ .trnFormAmount__type
+ template(v-if="amountType === 0") {{ $lang.money.expenses }}
+ template(v-if="amountType === 1") {{ $lang.money.incomes }}
+ template(v-if="amountType === 2 && $store.getters['wallets/walletsSortedIds'].length > 1") {{ $lang.money.transfer }}
+
+ .trnFormAmount__content
+ .trnFormAmount__value {{ amountString }}
+ .trnFormAmount__evaluation {{ $store.state.trnForm.values.amountEvaluation }}
</template>
<style lang="stylus" scoped>
diff --git a/components/trnForm/TrnFormAmountInput.vue b/components/trnForm/TrnFormAmountInput.vue
index 9007a8c1..6ecfc164 100644
--- a/components/trnForm/TrnFormAmountInput.vue
+++ b/components/trnForm/TrnFormAmountInput.vue
@@ -10,7 +10,7 @@ export default {
},
computed: {
- amountValue () {
+ amountString () {
return this.$store.state.trnForm.values.amount
},
@@ -24,7 +24,7 @@ export default {
amounIsNumber () {
if (!this.amountString || this.amountString == 0) { return true }
- const amountString = String(this.amountValue).replace(/\s/g, '')
+ const amountString = String(this.amountString).replace(/\s/g, '')
if (Number(amountString)) {
return true
}
@@ -66,18 +66,17 @@ export default {
const value = event.target.value
if (value) {
const lastItem = value.length > 0 ? value.slice(-1) : value
- console.log(lastItem)
if (/[\d*+\-*/]/g.test(Number(lastItem))) {
this.$store.commit('trnForm/setTrnFormValues', {
amount: value,
- evaluateAmount: this.evaluateAmount(value)
+ amountEvaluation: this.evaluateAmount(value)
})
}
}
else {
this.$store.commit('trnForm/setTrnFormValues', {
amount: '',
- evaluateAmount: null
+ amountEvaluation: null
})
}
},
@@ -128,10 +127,12 @@ export default {
@click="() => setAmountType(0)"
:class="{ _active: amountType === 0 }"
) {{ $lang.money.expenses }}
+
.trnFormAmountPc__type._incomes(
@click="() => setAmountType(1)"
:class="{ _active: amountType === 1 }"
) {{ $lang.money.incomes }}
+
.trnFormAmountPc__type(
v-if="$store.getters['wallets/walletsSortedIds'].length > 1"
@click="() => setAmountType(2)"
@@ -142,16 +143,16 @@ export default {
input.trnFormAmountPc__input__value(
placeholder="0"
ref="amountInput"
- :value="amountValue == 0 ? '' : amountValue"
+ :value="amountString == 0 ? '' : amountString"
@input="changeValue"
@focus="setCaretPosition"
)
.amountInputLaptop__evaluation
- template(v-if="$store.state.trnForm.values.amount != 0 && $store.state.trnForm.values.amount != $store.state.trnForm.values.evaluateAmount") {{ $store.state.trnForm.values.evaluateAmount }}
+ template(v-if="$store.state.trnForm.values.amount != 0 && $store.state.trnForm.values.amount != $store.state.trnForm.values.amountEvaluation") {{ $store.state.trnForm.values.amountEvaluation }}
.action
- template(v-if="!amountValue")
+ template(v-if="!amountString")
Button(
className="_grey _text-center"
size="lg"
@@ -175,7 +176,7 @@ export default {
@onClick="$emit('onFormSubmit')"
)
- template(v-if="amountValue && !amounIsNumber")
+ template(v-if="amountString && !amounIsNumber")
Button(
className="_blue _text-center"
size="lg"
@@ -206,7 +207,8 @@ export default {
color var(--c-incomes-1)
.action
- padding $m9
+ padding $m7
+ padding-bottom $m7
.trnFormAmountPc
background var(--c-bg-2)
diff --git a/components/trnForm/TrnFormCalendar.vue b/components/trnForm/TrnFormCalendar.vue
index ce36c98e..f59aad18 100644
--- a/components/trnForm/TrnFormCalendar.vue
+++ b/components/trnForm/TrnFormCalendar.vue
@@ -1,6 +1,5 @@
<script>
import dayjs from 'dayjs'
-
import { formatDate } from '~/utils/formatDate'
export default {
@@ -33,15 +32,63 @@ export default {
</script>
<template lang="pug">
-.trnFormDate
- .trnFormDate__item._icon(@click="setPrevDay()"): .mdi.mdi-chevron-left
- .trnFormDate__item(@click="$store.commit('trnForm/toogleTrnFormModal', 'calendar')") {{ formatedDate }}
- .trnFormDate__item._icon(:class="{ _disable: isToday }" @click="setNextDay()"): .mdi.mdi-chevron-right
+.trnFormMeta
+ .trnFormMeta__date
+ .trnFormDate
+ .trnFormDate__item._icon(@click="setPrevDay()"): .mdi.mdi-chevron-left
+ .trnFormDate__item(@click="$store.commit('trnForm/toogleTrnFormModal', 'calendar')") {{ formatedDate }}
+ .trnFormDate__item._icon(:class="{ _disable: isToday }" @click="setNextDay()"): .mdi.mdi-chevron-right
+
+ .trnFormMeta__desc(
+ @click="$store.commit('trnForm/toogleTrnFormModal', 'description')"
+ )
+ .mdi.mdi-comment-text-outline
+ .dot(v-if="$store.state.trnForm.values.description")
</template>
<style lang="stylus" scoped>
@import "~assets/stylus/variables"
+.trnFormMeta
+ display flex
+ align-items stretch
+ border-top 1px solid var(--c-bg-5)
+
+ @media $media-laptop
+ color var(--c-font-4)
+ background var(--c-bg-4)
+ border-top 0
+
+ &__date
+ flex-grow 1
+
+ &__desc
+ position relative
+ width calc(100%/5)
+ padding $m7 $m9
+ color var(--c-font-4)
+ font-size 20px
+ text-align center
+
+ &:hover
+ @media $media-laptop
+ background var(--c-bg-5)
+
+ &:active
+ background var(--c-bg-5)
+
+ &._active
+ color var(--c-font-1)
+
+ .dot
+ position absolute
+ top $m7
+ right $m7
+ width 6px
+ height 6px
+ background var(--c-bg-9)
+ border-radius 50%
+
.trnFormDate
display flex
align-items center
@@ -69,5 +116,9 @@ export default {
font-size 28px
&._disable
- opacity 0
+ opacity .4
+
+ &:hover
+ &:active
+ background none
</style>
diff --git a/components/trnForm/TrnFormHeader.vue b/components/trnForm/TrnFormHeader.vue
index 81a45930..61db54f4 100644
--- a/components/trnForm/TrnFormHeader.vue
+++ b/components/trnForm/TrnFormHeader.vue
@@ -11,16 +11,20 @@ export default {
computed: {
category () {
const categoryId = this.$store.state.trnForm.values.categoryId
- const categories = this.$store.state.categories.items
- return categories[categoryId]
+ return this.$store.state.categories.items[categoryId]
},
+
+ parentCategory () {
+ return this.$store.state.categories.items[this.category.parentId]
+ },
+
values () {
return this.$store.state.trnForm.values
},
+
wallet () {
const walletId = this.$store.state.trnForm.values.walletId
- const wallets = this.$store.state.wallets.items
- return wallets[walletId]
+ return this.$store.state.wallets.items[walletId]
}
}
}
@@ -28,16 +32,16 @@ export default {
<template lang="pug">
.trnFormHeader
- //- Wallet
+ //- wallet
transition(name="fadeIn")
template(v-if="wallet")
- .trnFormHeader__item(
+ .trnFormHeaderItem(
:style="{ background: wallet.color || $store.state.ui.defaultBgColor }"
- @click="$store.commit('trnForm/toogleTrnFormModal', 'wallets')")
-
- div
- .trnFormHeader__name {{ wallet.name }}
- .trnFormHeader__total
+ @click="$store.commit('trnForm/toogleTrnFormModal', 'wallets')"
+ )
+ .trnFormHeaderItem__in
+ .trnFormHeaderItem__name {{ wallet.name }}
+ .trnFormHeaderItem__total
template(v-if="$store.getters['wallets/walletsTotal'][values.walletId]")
Amount(
:value="$store.getters['wallets/walletsTotal'][values.walletId].base"
@@ -49,21 +53,26 @@ export default {
:value="0"
:currency="$store.state.currencies.base"
vertical="left"
- )
+ )
+ .trnFormHeaderItem__dots: .mdi.mdi-dots-vertical
- //- Category
+ //- category
template(v-if="category")
- .trnFormHeader__item(
+ .trnFormHeaderItem._category(
:style="{ background: category.color || $store.state.ui.defaultBgColor }"
- @click="$store.commit('trnForm/toogleTrnFormModal', 'categories')")
-
- transition(name="slide")
- .trnFormHeader__icon(v-show="true" :key="category.icon")
- Icon(
- :icon="category.icon"
+ @click="$store.commit('trnForm/toogleTrnFormModal', 'categories')"
+ )
+ .trnFormHeaderItem__in
+ transition(name="slide")
+ .trnFormHeaderItem__icon(
+ v-show="true"
+ :key="category.icon"
)
-
- .trnFormHeader__name {{ category.name }}
+ Icon(:icon="category.icon")
+ .trnFormHeaderItem__name
+ .parent(v-if="parentCategory") {{ parentCategory.name }}
+ .child {{ category.name }}
+ .trnFormHeaderItem__dots: .mdi.mdi-dots-vertical
</template>
<style lang="stylus">
@@ -73,43 +82,57 @@ export default {
.trnFormHeader
display grid
grid-template-columns repeat(2, 1fr)
- grid-column-gap 8px
- grid-row-gap 2px
- // padding 8px
+ // grid-column-gap 1px
+ // padding 16px
background var(--c-bg-4)
+ @media $media-phone
+ // padding-bottom $m5
+
@media $media-laptop
- min-height 81px
+ // padding-top 8px
+ // min-height 81px
+
+ /.theme-light &
+ background var(--c-bg-2)
- &__item
- position relative
- display flex
- align-items center
- flex-grow 1
- padding 16px 16px
- color var(--c-bg-5)
- border-radius 0 16px 16px 0
+.trnFormHeaderItem
+ position relative
+ flex-grow 1
+ padding $m7 $m7
+ color var(--c-bg-5)
+ // border-radius $m6 $m6 0 0
- @media $media-laptop
- min-height 61px
+ @media $media-laptop
+ min-height 61px
- &:last-child
- border-left-color var(--c-bg-5)
- border-radius 16px 0 0 16px
+ &__in
+ ~/._category &
+ display flex
+ align-items center
&__icon
z-index 2
+ margin-left -8px
+ padding-right 4px
&__total
padding-top $m5
- .amount__wrap
- justify-content flex-start
- color var(--c-font-1)
-
- .amount__wrap._small
- display none
&__name
- font-size 14px
color var(--c-font-1)
+
+ .parent
+ font-size 12px
+ padding-bottom $m2
+
+ .child
+ font-size 16px
+
+ &__dots
+ position absolute
+ top $m6
+ right $m4
+ color var(--c-font-2)
+ font-size 16px
</style>
diff --git a/components/trnForm/TrnFormHeaderTransfer.vue b/components/trnForm/TrnFormHeaderTransfer.vue
index 16a5a772..64b01499 100644
--- a/components/trnForm/TrnFormHeaderTransfer.vue
+++ b/components/trnForm/TrnFormHeaderTransfer.vue
@@ -38,40 +38,83 @@ export default {
.trnFormHeader
//- Wallet from
template(v-if="walletFrom")
- .trnFormHeader__item(
+ .trnFormHeaderItem(
:style="{ background: walletFrom.color || $store.state.ui.defaultBgColor }"
@click="$store.commit('trnForm/toogleTrnFormModal', 'transferFrom')"
)
- div
- .trnFormHeader__desc From wallet
- .trnFormHeader__name {{ walletFrom.name }}
- .trnFormHeader__total
+ .trnFormHeaderItem__in
+ .trnFormHeaderItem__desc From wallet
+ .trnFormHeaderItem__name {{ walletFrom.name }}
+ .trnFormHeaderItem__total
Amount(
:value="$store.getters['wallets/walletsTotal'][walletFromId].base"
:currency="$store.state.currencies.base"
+ vertical="left"
)
+ .trnFormHeaderSeparator: .mdi.mdi-chevron-right
+
//- Wallet to
template(v-if="walletTo")
- .trnFormHeader__item(
+ .trnFormHeaderItem(
:style="{ background: walletTo.color || $store.state.ui.defaultBgColor }"
@click="$store.commit('trnForm/toogleTrnFormModal', 'transferTo')"
)
- div
- .trnFormHeader__desc To wallet
- .trnFormHeader__name {{ walletTo.name }}
- .trnFormHeader__total
+ .trnFormHeaderItem__in
+ .trnFormHeaderItem__desc To wallet
+ .trnFormHeaderItem__name {{ walletTo.name }}
+ .trnFormHeaderItem__total
Amount(
:value="$store.getters['wallets/walletsTotal'][walletToId].base"
:currency="$store.state.currencies.base"
+ vertical="left"
)
</template>
<style lang="stylus" scoped>
-.trnFormHeader__desc
- color var(--c-font-2)
- font-size 12px
- margin-bottom 12px
- padding-bottom 6px
- border-bottom 1px solid var(--c-bg-10)
+.trnFormHeader
+ position relative
+
+.trnFormHeaderSeparator
+ z-index 2
+ position absolute
+ top 45%
+ left 50%
+ color var(--c-font-3)
+ font-size 28px
+ transform translate(-50%)
+
+.trnFormHeaderItem
+ position relative
+ flex-grow 1
+ padding 16px 16px
+ color var(--c-bg-5)
+ border-radius 12px
+
+ @media $media-laptop
+ min-height 61px
+
+ &__desc
+ color var(--c-font-2)
+ font-size 12px
+ margin-bottom 12px
+ padding-bottom 6px
+ border-bottom 1px solid var(--c-bg-10)
+
+ &__icon
+ z-index 2
+
+ &__total
+ padding-top $m5
+
+ &__name
+ color var(--c-font-1)
+ font-size 14px
+
+ &__dots
+ position absolute
+ top $m6
+ right $m4
+ color var(--c-font-2)
+ font-size 16px
</style>
diff --git a/components/trnForm/TrnFormModal.vue b/components/trnForm/TrnFormModal.vue
index d06e294f..ef37bf26 100644
--- a/components/trnForm/TrnFormModal.vue
+++ b/components/trnForm/TrnFormModal.vue
@@ -8,18 +8,31 @@ export default {
show: {
type: Boolean,
required: true
+ },
+ position: {
+ type: String,
+ default: null
}
},
data () {
return {
- headerHeight: 0
+ headerHeight: 0,
+
+ initialY: 0,
+ currentY: 0,
+ isDragging: false
}
},
computed: {
modalStyle () {
if (this.$store.state.trnForm.height < this.$store.state.ui.height) {
+ if (this.position === 'bottom') {
+ return {
+ maxHeight: `${this.$store.state.trnForm.height - this.headerHeight}px`
+ }
+ }
return {
height: `${this.$store.state.trnForm.height - this.headerHeight}px`
}
@@ -29,6 +42,9 @@ export default {
height: `${this.$store.state.ui.height - this.headerHeight}px`
}
}
+ // }
+ // if (this.position === 'top') {
+ // }
}
},
@@ -39,6 +55,10 @@ export default {
}
},
+ mounted () {
+ this.adddListeners()
+ },
+
methods: {
afterClose () {
if (this.$listeners.afterClose) {
@@ -50,30 +70,233 @@ export default {
this.$nextTick(() => {
this.headerHeight = this.$refs.header.clientHeight
})
+ },
+
+ adddListeners () {
+ const modalContainer = this.$refs.trnFormModal
+ if (modalContainer) {
+ modalContainer.addEventListener('touchstart', this.onDragStart, false)
+ modalContainer.addEventListener('touchend', this.onDragEnd, false)
+ modalContainer.addEventListener('touchmove', this.onDragging, false)
+ modalContainer.addEventListener('mouseup', this.onDragEnd, false)
+ }
+ },
+
+ onDragStart (e) {
+ // stop trnFormModal drag when content has scroll
+ // wait until content scroll up to top
+ const scrollBlock = this.$refs.trnFormModal.querySelector('.trnFormModal__scroll')
+ if (scrollBlock && scrollBlock.scrollTop > 0) {
+ return
+ }
+
+ // same as above but for any block
+ // const swiperSlideActive = this.$el.querySelector('.trnFormActiveSlide')
+ // if (swiperSlideActive) {
+ // const sliderWithScroll = swiperSlideActive.querySelector('.waitForScroll')
+ // if (sliderWithScroll) {
+ // if (sliderWithScroll.scrollTop > 0) { return }
+ // }
+ // }
+
+ const dragItem = this.$refs.trnFormModal.querySelector('.trnFormModal__wrap')
+ if (dragItem) {
+ dragItem.classList.remove('_anim')
+
+ if (e.type === 'touchstart') {
+ this.initialY = e.touches[0].clientY
+ }
+ else {
+ this.initialY = e.clientY
+ }
+
+ if (e.target.closest('.trnFormModal__wrap')) {
+ this.isDragging = true
+ }
+
+ // if (e.target.closest('.noDrag')) {
+ // this.isDragging = false
+ // }
+ }
+ },
+
+ onDragging (e) {
+ if (this.isDragging) {
+ if (e.type === 'touchmove') {
+ this.currentY = e.touches[0].clientY - this.initialY
+ }
+ else {
+ this.currentY = e.clientY - this.initialY
+ this.currentX = e.clientX - this.initialX
+ }
+
+ if ((Math.abs(this.currentY) < Math.abs(this.currentX))) {
+ return
+ }
+
+ this.setTranslate()
+ }
+ },
+
+ onDragEnd (e) {
+ const dragItem = this.$refs.trnFormModal.querySelector('.trnFormModal__wrap')
+
+ // do not close
+ if (this.currentY >= 80) {
+ dragItem.classList.add('_anim')
+ this.currentY = this.$refs.trnFormModal.clientHeight
+ this.setTranslate()
+ this.onClose()
+ }
+ // close
+ else {
+ this.currentY = 0
+ this.currentX = 0
+ this.setTranslate()
+ if (this.isDragging) { dragItem.classList.add('_anim') }
+ }
+
+ this.isDragging = false
+ },
+
+ setTranslate () {
+ const modalHeight = this.$refs.trnFormModal.clientHeight
+ const diff = (modalHeight - this.currentY) / (modalHeight / 100)
+ const diffTrunc = Math.trunc(diff)
+
+ const modalContainer = this.$refs.trnFormModal
+ const dragItem = modalContainer.querySelector('.trnFormModal__wrap')
+ const overflow = modalContainer.querySelector('.trnFormModal__overflow')
+
+ if (this.currentY === 0 && dragItem) {
+ dragItem.style.transform = ''
+ overflow.style.opacity = ''
+ }
+ else if (this.currentY > 0 && dragItem) {
+ dragItem.style.transform = `translate3d(0, ${this.currentY}px, 0)`
+ overflow.style.opacity = diffTrunc === 100 ? 1 : `0.${diffTrunc}`
+ }
+ },
+
+ onClose () {
+ this.initialY = 0
+ this.currentY = 0
+ this.isDragging = false
+
+ if (this.$listeners.onClose) {
+ this.$listeners.onClose()
+ }
}
}
}
</script>
<template lang="pug">
-.trnFormModal
+.trnFormModal.noDrag(ref="trnFormModal")
transition(name="fadeIn" appear)
- .trnFormModal__overflow(@click="$listeners.onClose" v-show="show")
+ .trnFormModal__overflow(
+ v-show="show"
+ @click="onClose"
+ )
transition(name="slide" appear v-on:after-leave="afterClose")
.trnFormModal__wrap(v-show="show")
- //- Header
.trnFormModal__header(
- @click="$listeners.onClose"
+ @click="onClose"
ref="header"
)
- template(v-if="$slots.header")
- slot(name="header")
- template(v-else)
- .trnFormModal__header__back: .mdi.mdi-chevron-left
- .trnFormModal__header__title(v-if="title") {{ title }}
+ .trnFormModal__header__title(v-if="title") {{ title }}
+ .trnFormModal__header__close: .mdi.mdi-close
- //- Content
.trnFormModal__scroll(:style="modalStyle")
slot()
</template>
+
+<style lang="stylus" scoped>
+@import "~assets/stylus/variables/animations"
+@import "~assets/stylus/variables/fonts"
+@import "~assets/stylus/variables/media"
+@import "~assets/stylus/variables/margins"
+
+.trnFormModal
+ z-index 3
+ position absolute
+ left 0
+ width 100%
+
+ @media $media-phone
+ bottom 0
+
+ @media $media-laptop
+ top 0
+ left 0px
+
+ &__overflow
+ position fixed
+ left 0
+ bottom 0
+ width 100%
+ height 100%
+ background var(--c-bg-overflow)
+ anim()
+
+ @media $media-laptop
+ display none
+
+ &__wrap
+ overflow hidden
+ position relative
+ display flex
+ flex-grow 1
+ flex-flow column nowrap
+ background var(--c-bg-4)
+ border-radius $m6
+
+ &._anim
+ anim(400ms)
+
+ @media $media-phone
+ border-radius $m6 $m6 0 0
+
+ /.theme-light &
+ background var(--c-bg-2)
+
+ &__scroll
+ overflow hidden
+ overflow-y auto
+ max-height 100%
+ padding $m7 0
+ scrollbar()
+
+ &__header
+ cursor pointer
+ position relative
+ display flex
+ align-items center
+ justify-content space-between
+ padding $m7
+ color var(--c-font-3)
+ font-size 22px
+ font-weight 700
+ letter-spacing 1px
+ fontFamilyNunito()
+
+ /.theme-light &
+ color var(--c-font-4)
+
+ &:hover
+ &:active
+ background var(--c-bg-5)
+
+ &__title
+ flex-grow 1
+
+ &__close
+ color var(--c-font-4)
+ font-size 20px
+
+ &__icon
+ position absolute
+ top -24px
+ right $m7
+</style>
diff --git a/components/trnForm/TrnFormModalCalendar.vue b/components/trnForm/TrnFormModalCalendar.vue
index cc652b05..58d0b9d1 100644
--- a/components/trnForm/TrnFormModalCalendar.vue
+++ b/components/trnForm/TrnFormModalCalendar.vue
@@ -48,9 +48,11 @@ export default {
<template lang="pug">
TrnFormModal(
+ v-if="$store.state.trnForm.modal.calendar"
:show="$store.state.trnForm.modal.calendar"
title="Date"
- v-on:onClose="$store.commit('trnForm/toogleTrnFormModal', 'calendar')"
+ :position="$store.state.ui.mobile ? 'bottom' : null"
+ @onClose="$store.commit('trnForm/toogleTrnFormModal', 'calendar')"
)
Datepicker(
:inline="true"
@@ -65,16 +67,16 @@ TrnFormModal(
ModalButton(
name="2 days ago"
icon="mdi mdi-calendar-clock"
- v-on:onClick="() => handleSelectDateDaysAgo(2)"
+ @onClick="() => handleSelectDateDaysAgo(2)"
)
ModalButton(
name="Yesterday"
icon="mdi mdi-weather-night"
- v-on:onClick="() => handleSelectDateDaysAgo(1)"
+ @onClick="() => handleSelectDateDaysAgo(1)"
)
ModalButton(
name="Today"
icon="mdi mdi-weather-sunset-up"
- v-on:onClick="() => handleSelectDateDaysAgo(0)"
+ @onClick="() => handleSelectDateDaysAgo(0)"
)
</template>
diff --git a/components/trnForm/TrnFormModalCats.vue b/components/trnForm/TrnFormModalCats.vue
index 4867f87f..94c1b08c 100644
--- a/components/trnForm/TrnFormModalCats.vue
+++ b/components/trnForm/TrnFormModalCats.vue
@@ -30,33 +30,33 @@ export default {
<template lang="pug">
TrnFormModal(
+ v-if="$store.state.trnForm.modal.categories"
:show="$store.state.trnForm.modal.categories"
- v-on:onClose="$store.commit('trnForm/toogleTrnFormModal', 'categories')"
+ :title="$lang.categories.name"
+ :position="$store.state.ui.mobile ? 'bottom' : null"
+ @onClose="$store.commit('trnForm/toogleTrnFormModal', 'categories')"
)
- template(slot="header")
- .trnFormModal__header__back: .mdi.mdi-chevron-left
- .trnFormModal__header__title {{ $lang.categories.name }}
-
- //- pc
- template(v-if="$store.state.ui.lastUsedCatsInTrnForm === 'visible'")
+ template(v-if="$store.state.ui.lastUsedCatsInTrnForm === 'visible' && $store.getters['categories/lastUsedCategoriesIdsByDate'].length > 0")
.marginBottom
.formTitle Last used categories
CategoriesView(
:ids="$store.getters['categories/lastUsedCategoriesIdsByDate']"
:noPaddingBottom="true"
- v-on:onClick="handleCategoryClick"
+ @onClick="handleCategoryClick"
)
-
- template(v-if="$store.state.ui.lastUsedCatsInTrnForm === 'visible'")
.formTitle All categories
+
CategoriesView(
:ids="$store.getters['categories/categoriesRootIds']"
:noPaddingBottom="true"
- v-on:onClick="handleCategoryClick"
+ @onClick="handleCategoryClick"
)
</template>
<style lang="stylus" scoped>
+@import "~assets/stylus/variables/margins"
+
.marginBottom
- margin-bottom 30px
+ margin-top (- $m8)
+ margin-bottom $m9
</style>
diff --git a/components/trnForm/TrnFormModalCatsChild.vue b/components/trnForm/TrnFormModalCatsChild.vue
index 25a3a3da..846d04b2 100644
--- a/components/trnForm/TrnFormModalCatsChild.vue
+++ b/components/trnForm/TrnFormModalCatsChild.vue
@@ -27,6 +27,13 @@ export default {
this.$store.commit('trnForm/closeTrnFormModal', 'categories')
this.$store.commit('trnForm/closeTrnFormModal', 'categoriesChild')
this.$store.commit('trnForm/setTrnFormValues', { categoryId })
+ },
+
+ onClose () {
+ this.$store.commit('trnForm/closeTrnFormModal', 'categoriesChild')
+ setTimeout(() => {
+ this.$store.commit('trnForm/setTrnFormModalCategoryId', null)
+ }, 100)
}
}
}
@@ -34,18 +41,16 @@ export default {
<template lang="pug">
TrnFormModal(
+ v-if="$store.state.trnForm.modal.categoriesChild"
:show="$store.state.trnForm.modal.categoriesChild"
- v-on:afterClose="$store.commit('trnForm/setTrnFormModalCategoryId', null)"
- v-on:onClose="$store.commit('trnForm/closeTrnFormModal', 'categoriesChild')"
+ :title="id && category && category.name"
+ :position="$store.state.ui.mobile ? 'bottom' : null"
+ @onClose="onClose"
)
template(v-if="id && category")
- template(slot="header")
- .trnFormModal__header__back: .mdi.mdi-chevron-left
- .trnFormModal__header__title {{ category.name }}
-
CategoriesView(
:ids="childCategoriesIds"
:noPaddingBottom="true"
- v-on:onClick="handleCategoryClick"
+ @onClick="handleCategoryClick"
)
</template>
diff --git a/components/trnForm/TrnFormModalDescription.vue b/components/trnForm/TrnFormModalDescription.vue
index 111fa039..f9e3a553 100644
--- a/components/trnForm/TrnFormModalDescription.vue
+++ b/components/trnForm/TrnFormModalDescription.vue
@@ -50,14 +50,18 @@ export default {
<template lang="pug">
TrnFormModal(
+ v-if="show"
:show="show"
:title="$lang.trnForm.description.title"
- v-on:onClose="$store.commit('trnForm/toogleTrnFormModal', 'description')")
+ :position="$store.state.ui.mobile ? 'bottom' : null"
+ @onClose="$store.commit('trnForm/toogleTrnFormModal', 'description')"
+)
.description
.description__filed
textarea.textarea(
v-model="description"
- :placeholder="$lang.trnForm.description.placeholder")
+ :placeholder="$lang.trnForm.description.placeholder"
+ )
.description__action
.description__action-ok
diff --git a/components/trnForm/TrnFormModalTransferFrom.vue b/components/trnForm/TrnFormModalTransferFrom.vue
index 049f6ab4..2dd1242e 100644
--- a/components/trnForm/TrnFormModalTransferFrom.vue
+++ b/components/trnForm/TrnFormModalTransferFrom.vue
@@ -22,14 +22,11 @@ export default {
<template lang="pug">
TrnFormModal(
+ v-if="$store.state.trnForm.modal.transferFrom"
:show="$store.state.trnForm.modal.transferFrom"
- title=""
+ title="Transfer from wallet"
v-on:onClose="$store.commit('trnForm/toogleTrnFormModal', 'transferFrom')"
)
- template(slot="header")
- .trnFormModal__header__back: .mdi.mdi-chevron-left
- .trnFormModal__header__title Transfer from wallet
-
WalletsList(
ui="tile"
v-on:onClick="handleSetWallet"
diff --git a/components/trnForm/TrnFormModalTransferTo.vue b/components/trnForm/TrnFormModalTransferTo.vue
index 7992242e..a1163f9c 100644
--- a/components/trnForm/TrnFormModalTransferTo.vue
+++ b/components/trnForm/TrnFormModalTransferTo.vue
@@ -22,14 +22,11 @@ export default {
<template lang="pug">
TrnFormModal(
+ v-if="$store.state.trnForm.modal.transferTo"
:show="$store.state.trnForm.modal.transferTo"
- title=""
+ title="Transfer to wallet"
v-on:onClose="$store.commit('trnForm/toogleTrnFormModal', 'transferTo')"
)
- template(slot="header")
- .trnFormModal__header__back: .mdi.mdi-chevron-left
- .trnFormModal__header__title Transfer to wallet
-
WalletsList(
ui="tile"
v-on:onClick="handleSetWallet"
diff --git a/components/trnForm/TrnFormModalWallets.vue b/components/trnForm/TrnFormModalWallets.vue
index 0014c762..74d65340 100644
--- a/components/trnForm/TrnFormModalWallets.vue
+++ b/components/trnForm/TrnFormModalWallets.vue
@@ -21,23 +21,39 @@ export default {
<template lang="pug">
TrnFormModal(
+ v-if="$store.state.trnForm.modal.wallets"
:show="$store.state.trnForm.modal.wallets"
- title=""
- v-on:onClose="$store.commit('trnForm/toogleTrnFormModal', 'wallets')"
+ :title="$lang.wallets.title"
+ :position="$store.state.ui.mobile ? 'bottom' : null"
+ @onClose="$store.commit('trnForm/toogleTrnFormModal', 'wallets')"
)
- template(slot="header")
- .trnFormModal__header__back: .mdi.mdi-chevron-left
- .trnFormModal__header__title {{ $lang.wallets.title }}
-
.trnFormWalletsList
WalletsList(
- ui="tile"
+ :limit="6"
+ showToogle
+ ui="widget"
@onClick="handleSetWallet"
)
</template>
<style lang="stylus">
+@import "~assets/stylus/variables/margins"
+
.trnFormWalletsList
- .walletsTiles
- grid-template-columns repeat(2, 1fr)
+ .walletsWidget
+ display grid
+ grid-template-columns repeat(3, minmax(auto, 1fr))
+ grid-column-gap 12px
+ grid-row-gap 12px
+ padding 0 16px
+
+ .walletItemWidget
+ overflow hidden
+ cursor pointer
+ padding $m6
+ border-radius $m4
+
+ .walletsList__toogle
+ border-top 0
+ padding-bottom 0
</style>
diff --git a/components/trnForm/styles/trnForm.styl b/components/trnForm/styles/trnForm.styl
index eb938dd4..177c507b 100644
--- a/components/trnForm/styles/trnForm.styl
+++ b/components/trnForm/styles/trnForm.styl
@@ -60,18 +60,22 @@
padding-bottom 0
.formTitle
- padding 0 $m7
- padding-bottom $m7
- font-header-1()
+ padding $m7
+ fontFamilyNunito()
+ font-weight 700
+ font-size 18px
color var(--c-font-4)
+ &:active
+ &:hover
+ background var(--c-bg-5)
+
.formCategories
- padding 0 $m6
- padding-bottom $m9
+ padding 0
+ padding-bottom $m7
.formWallets
- padding 0 $m6
- padding-bottom $m10
+ padding-bottom $m4
&__input
position relative
diff --git a/components/trnForm/styles/trnFormCalendar.styl b/components/trnForm/styles/trnFormCalendar.styl
index 3ddc8b7f..45b3237e 100644
--- a/components/trnForm/styles/trnFormCalendar.styl
+++ b/components/trnForm/styles/trnFormCalendar.styl
@@ -21,8 +21,8 @@
.next
margin 0
padding $m6 $m9
- border 1px solid var(--c-bg-5)
background none
+ border 1px solid var(--c-bg-5)
border-radius 3px
anim()
@@ -41,39 +41,40 @@
.day__month_btn
.month__year_btn.up
span
- padding $m6 0
margin 0 $m7
+ padding $m6 0
font-header-1()
border-radius $m3
&:hover
background none !important
+
@media $media-laptop
background var(--c-bg-6) !important
.cell
- height 42px
+ height 46px
.cell.day-header
height auto
- padding-bottom $m3
- line-height 1
+ padding-bottom $m5
color rgb(117, 117, 117)
+ line-height 1
.day
+ cursor pointer
position relative
- padding 0
+ padding-top $m2
text-align center
- border 1px solid alpha(grey, .1)
- cursor pointer
+ border-radius $m5
.today
- background var(--c-bg-5)
color var(--c-font-1)
+ background var(--c-bg-5)
.disabled
color var(--c-font-4)
.selected
- background var(--c-blue-1)
color var(--c-font-1)
+ background var(--c-blue-1)
diff --git a/components/trnForm/styles/trnFormModal.styl b/components/trnForm/styles/trnFormModal.styl
deleted file mode 100644
index fa95d829..00000000
--- a/components/trnForm/styles/trnFormModal.styl
+++ /dev/null
@@ -1,60 +0,0 @@
-.trnFormModal
- z-index 3
- position absolute
- left 0
- width 100%
-
- @media $media-phone
- bottom 0
-
- @media $media-laptop
- top 0
- left 0px
-
- &__overflow
- position fixed
- left 0
- bottom 0
- width 100%
- height 100%
-
- &__wrap
- position relative
- display flex
- flex-grow 1
- flex-flow column nowrap
- background var(--c-bg-4)
-
- /.theme-light &
- background var(--c-bg-2)
-
- &__scroll
- overflow hidden
- overflow-y auto
- max-height 100%
- padding $m7 0
- scrollbar()
-
- .swipe-slide
- height 100%
-
- &__header
- display flex
- align-items center
- padding $m7
- font-header-1()
- color var(--c-font-1)
- background var(--c-bg-8)
-
- /.theme-light &
- color var(--c-font-4)
-
- &__back
- font-size 18px
- margin-right $m5
- margin-top $m2
-
- &__icon
- position absolute
- right $m7
- top -24px
diff --git a/store/trnForm/actions.js b/store/trnForm/actions.js
index d2ee19aa..7bc5f5ca 100644
--- a/store/trnForm/actions.js
+++ b/store/trnForm/actions.js
@@ -4,7 +4,8 @@ export default {
closeTrnForm ({ commit }) {
commit('closeTrnForm')
commit('setTrnFormValues', {
- trnId: null
+ trnId: null,
+ amountEvaluation: null
})
},