Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/chart 6 - add v-select date range for mobile chart #167

Open
wants to merge 4 commits into
base: feature/chart-5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
164 changes: 153 additions & 11 deletions src/components/Wallets/Chart/DateFilters.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,64 @@
<template>
<div class="chart-date-filters">
<button
v-for="(label, range) in options"
:key="range"
class="chart-date-filters__filter-button"
:class="{ 'chart-date-filters__filter-button--active': dateRange === range }"
@click="changeDateRange(range)"
<match-media v-slot="{ phone }" tag="div">
<div v-if="!phone" class="chart-date-filters">
<button
v-for="{ id, value, label } in options"
:key="id"
class="chart-date-filters__filter-button"
:class="{ 'chart-date-filters__filter-button--active': dateRange === value }"
@click="changeDateRange(value)"
>
{{ label }}
</button>
</div>
<v-select
v-else
:value="dateRange"
height="27"
item-text="label"
item-value="value"
class="chart-date-select__item"
tany31 marked this conversation as resolved.
Show resolved Hide resolved
hide-details
dense
flat
filled
append-icon="mdi-chevron-down"
:menu-props="{ 'content-class': 'chart-date-select__select-menu' }"
:items="options"
@input="changeDateRange"
>
{{ label }}
</button>
</div>
</v-select>
</match-media>
</template>

<script>
import { MatchMedia } from 'vue-component-media-queries'

export default {
name: 'ChartDateFilters',
components: {
MatchMedia
},
props: {
dateRange: { type: String, default: '' },
options: { type: [Array, Object], default: () => [] }
},
data() {
return {
isOpenPanel: false
tany31 marked this conversation as resolved.
Show resolved Hide resolved
}
},
computed: {
selectDateRange() {
return this.data
}
},
methods: {
changeDateRange(dateRange) {
this.$emit('change', dateRange)
},
closePanel() {
this.isOpenPanel = false
}
}
}
Expand All @@ -43,12 +80,117 @@ export default {
color: get-theme-for($text, 'primary');
padding: 4px 8px;

&:hover {
&:not(.chart-date-filters__filter-button--active) {
background-color: get-theme-for($button, 'primary', 'hover');
}
}

&--active {
background: get-theme-for($background, 'primary');
background-color: get-theme-for($background, 'primary');

box-shadow: 0px 0px 15px rgba(17, 17, 17, 0.02);
border: 0.5px solid rgba(0, 0, 0, 0.04);
}
}
}

.chart-date-select {
&__item {
border-radius: $--main-border-radius;
color: get-theme-for($text, 'primary') !important;
border: 1px solid get-theme-for($border-color, 'primary');
max-width: 49px;

&:focus-within {
.v-input__icon .v-icon {
color: get-theme-for($text, 'primary') !important;
}
}

.v-input__icon {
&--append {
width: 9px;
min-width: 9px;
height: 4px;
}

.v-icon {
font-size: 13px;
}
}

.v-select__selections {
min-width: unset;
line-height: unset;
}

.v-select__selection {
font-weight: $--font-weight-semi-bold;
font-size: 14px;

&--comma {
max-width: 21px;
margin-right: 0 !important;
}
}

.v-input__append-inner {
margin: 0 !important;
margin-left: auto;
padding-left: 0 !important;
align-self: unset !important;
}

.v-input__slot {
min-height: 28px !important;
padding: 0 8px !important;
background: get-theme-for($button, 'primary', 'enabled') !important;

&:hover {
background-color: get-theme-for($button, 'primary', 'hover') !important;
}

&:before,
&:after {
display: none;
}
}
}

&__select-menu {
max-width: 49px;
width: 49px;

.v-list {
background: get-theme-for($button, 'primary', 'enabled') !important;
border-radius: $--main-border-radius;
padding: 3px 0;
}

.v-list-item {
min-height: 27px;
text-align: center;
padding: 0 4px;
border-radius: $--main-border-radius;
margin: 0 1px;

&:hover {
&:not(.v-list-item--active) {
background-color: get-theme-for($button, 'primary', 'hover');
}
}

&__title {
font-weight: $--font-weight-semi-bold !important;
font-size: 14px !important;
}
}

.v-list-item--active {
background: get-theme-for($background, 'primary');
color: get-theme-for($text, 'primary') !important;
}
}
}
</style>
145 changes: 80 additions & 65 deletions src/components/Wallets/WalletInfo.vue
Original file line number Diff line number Diff line change
@@ -1,76 +1,73 @@
<template>
<match-media v-slot="{ phone }" tag="div">
<div class="wallet-info" :class="{ 'wallet-info--compressed': compressed }" @click="uncompressWallet">
<coin-logo v-show="!isChartView" class="wallet-info__background-icon" :path="logo" :name="coin" />

<header class="wallet-info__header " :class="[isChartView && 'wallet-info__header--coin-price-chart']">
<div v-if="!isChartView" class="wallet-info__crypto-value-wrapper">
<span class="wallet-info__crypto-value">
{{ value }} <span class="grey--text">{{ coin }}</span>
</span>
<span class="wallet-info__fiat-value">3000.04 USD</span>
</div>
<h3 v-else class="wallet-info__coin-price-chart-title">{{ coin }} Price Chart</h3>
<chart-date-filters
v-if="isChartView && !phone"
:date-range="chartDateRange"
:options="$options.TIME_PERIOD_CHART"
@change="changeChartDateRange"
/>
<div class="wallet-info__optional-buttons">
<div class="wallet-info__chart-switcher-wrapper">
<swap-switch v-model="isChartView" label="Price chart"></swap-switch>
</div>

<div class="wallet-info__dividing-line"></div>

<swap-button fab small class="wallet-info__optional-button" @click="openShareModal">
<v-icon class="wallet-info__icon">mdi-export-variant</v-icon>
</swap-button>
<swap-button fab small class="wallet-info__optional-button" @click="openSettingsModal">
<v-icon class="wallet-info__icon">mdi-tune</v-icon>
</swap-button>
</div>
</header>

<div v-if="!isChartView" class="wallet-info__main">
<div class="wallet-info__address-wrapper">
<swap-copy-wrapper>
<template #default="{ copy, tooltopOn }">
<button
v-ripple="{ center: true }"
class="wallet-info__button-copy"
tabindex="-1"
@click="mediaQueries.desktop ? copy(address) : openCopyMenu()"
v-on="tooltopOn"
>
<span class="wallet-info__address">{{ mediaQueries.desktop ? address : minifiedAddress }}</span>
<svg-icon class="wallet-info__icon-copy" name="copy" />
</button>
</template>
</swap-copy-wrapper>

<button class="wallet-info__button-qrcode" @click="openShareModal">
<svg-icon class="wallet-info__icon-qrcode" name="qrcode"></svg-icon>
</button>
<div class="wallet-info" :class="{ 'wallet-info--compressed': compressed }" @click="uncompressWallet">
<coin-logo v-show="!isChartView" class="wallet-info__background-icon" :path="logo" :name="coin" />

<header class="wallet-info__header " :class="[isChartView && 'wallet-info__header--coin-price-chart']">
<div v-if="!isChartView" class="wallet-info__crypto-value-wrapper">
<span class="wallet-info__crypto-value">
{{ value }} <span class="grey--text">{{ coin }}</span>
</span>
<span class="wallet-info__fiat-value">3000.04 USD</span>
</div>
<h3 v-else class="wallet-info__coin-price-chart-title">{{ chartTitle }}</h3>
<chart-date-filters
v-if="isChartView"
:date-range="chartDateRange"
:options="$options.TIME_PERIOD_CHART"
@change="changeChartDateRange"
/>
<div class="wallet-info__optional-buttons">
<div class="wallet-info__chart-switcher-wrapper">
<swap-switch v-model="isChartView" label="Price chart"></swap-switch>
</div>

<div class="wallet-info__buttons">
<swap-button class="wallet-info__button" @click="openInvoiceBlock">Invoice</swap-button>
<swap-button :to="{ name: 'Swap' }" class="wallet-info__button">Swap</swap-button>
<swap-button class="wallet-info__button" @click="openSendForm">Send</swap-button>
</div>
<div class="wallet-info__dividing-line"></div>

<swap-button fab small class="wallet-info__optional-button" @click="openShareModal">
<v-icon class="wallet-info__icon">mdi-export-variant</v-icon>
</swap-button>
<swap-button fab small class="wallet-info__optional-button" @click="openSettingsModal">
<v-icon class="wallet-info__icon">mdi-tune</v-icon>
</swap-button>
</div>
</header>

<div v-if="!isChartView" class="wallet-info__main">
<div class="wallet-info__address-wrapper">
<swap-copy-wrapper>
<template #default="{ copy, tooltopOn }">
<button
v-ripple="{ center: true }"
class="wallet-info__button-copy"
tabindex="-1"
@click="mediaQueries.desktop ? copy(address) : openCopyMenu()"
v-on="tooltopOn"
>
<span class="wallet-info__address">{{ mediaQueries.desktop ? address : minifiedAddress }}</span>
<svg-icon class="wallet-info__icon-copy" name="copy" />
</button>
</template>
</swap-copy-wrapper>

<button class="wallet-info__button-qrcode" @click="openShareModal">
<svg-icon class="wallet-info__icon-qrcode" name="qrcode"></svg-icon>
</button>
</div>

<div v-else class="wallet-info__coin-price-chart-container">
<wallet-chart v-bind="{ datasets }"></wallet-chart>
<div class="wallet-info__buttons">
<swap-button class="wallet-info__button" @click="openInvoiceBlock">Invoice</swap-button>
<swap-button :to="{ name: 'Swap' }" class="wallet-info__button">Swap</swap-button>
<swap-button class="wallet-info__button" @click="openSendForm">Send</swap-button>
</div>
</div>
</match-media>

<div v-else class="wallet-info__coin-price-chart-container">
<wallet-chart v-bind="{ datasets }"></wallet-chart>
</div>
</div>
</template>

<script>
import { MatchMedia } from 'vue-component-media-queries'
import { mapMutations } from 'vuex'
import { ADD_MODAL } from '@/store/modules/Modals'
import { COPY_MENU, INVOICE_FORM, SEND_FORM, SHARE_MODAL, WALLET_SETTINGS } from '@/store/modules/Modals/names'
Expand All @@ -97,7 +94,7 @@ const CHART_DATE_RANGE_MAP = {
export default {
TIME_PERIOD_CHART,
name: 'WalletInfo',
components: { MatchMedia, CoinLogo, WalletChart, ChartDateFilters },
components: { CoinLogo, WalletChart, ChartDateFilters },
inject: ['mediaQueries'],
props: {
compressed: { type: Boolean, default: false },
Expand All @@ -119,10 +116,20 @@ export default {
minifiedAddress() {
return minifyAddress(this.address)
},
chartTitle() {
return this.mediaQueries.phone ? this.coin : `${this.coin} Price Chart`
},
walletId() {
return `${this.coin}-${this.networkId}-${this.address}`
}
},
watch: {
compressed(value) {
if (value && this.isChartView) {
this.isChartView = false
}
}
},
methods: {
...mapMutations({
mutationAddModal: ADD_MODAL
Expand Down Expand Up @@ -223,7 +230,11 @@ export default {
padding: 6px 10px;
background-color: get-theme-for($button, 'primary', 'enabled');
border-radius: 22px;
z-index: 100;
z-index: 1;

@include phone {
z-index: unset;
}

&:hover {
background-color: get-theme-for($button, 'primary', 'hover');
Expand All @@ -243,6 +254,10 @@ export default {

@include phone {
font-size: 14px;
margin-right: 18px;
}

@include small-phone {
margin-right: 5px;
}
}
Expand Down
Loading