Skip to content

Commit

Permalink
implement mobile filters
Browse files Browse the repository at this point in the history
  • Loading branch information
chienleng committed Dec 4, 2023
1 parent 3222d91 commit 661a4ba
Show file tree
Hide file tree
Showing 10 changed files with 716 additions and 193 deletions.
4 changes: 4 additions & 0 deletions assets/scss/drop-down.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,7 @@
}
}
}

.dropdown-menu {
z-index: 9999;
}
145 changes: 93 additions & 52 deletions components/Energy/DataOptionsBar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div
class="button-group"
:class="{ mobile: mobile }"
class="button-group"
style="gap: 8px;">
<div
v-if="use12MthRollingToggle"
Expand All @@ -13,62 +14,75 @@
</button>
</div>

<div
v-else
class="range-buttons buttons has-addons">
<button
v-on-clickaway="handleClickAway"
v-for="(r, i) in ranges"
:key="i"
:class="{ 'is-selected': isRangeSelected(r) }"
class="button is-rounded"
@click.stop="handleRangeClick(r)"
>
<span>
<div v-if="isString(r)">{{ r }}</div>
<div v-if="!isString(r)">
{{ getSelectedRangeLabel(r) }}
</div>
<!-- <i
<div>
<label
v-if="mobile"
style="margin-top: 8px;">Range:</label>
<div
v-if="!use12MthRollingToggle"
:class="{ mobile: mobile }"
class="range-buttons buttons has-addons">
<button
v-on-clickaway="handleClickAway"
v-for="(r, i) in ranges"
:key="i"
:class="{ 'is-selected': isRangeSelected(r) }"
class="button is-rounded"
@click.stop="handleRangeClick(r)"
>
<span>
<div v-if="isString(r)">{{ r }}</div>
<div v-if="!isString(r)">
{{ getSelectedRangeLabel(r) }}
</div>
<!-- <i
v-if="hasRangeFilter(r)"
class="filter-caret dropdown-trigger-icon fal fa-chevron-down" /> -->
<i
v-if="hasRangeFilter(r)"
:class="[
'fal dropdown-trigger-icon',
showRangeOptions(r) ? 'fa-chevron-up' : 'fa-chevron-down'
]"
/>
<div
v-show="showRangeOptions(r)"
class="filter-menu dropdown-menu">
<div class="dropdown-content">
<button
v-for="(range, rIndex) in r"
:key="`rangeOption${rIndex}`"
:class="{ 'is-selected': range === selectedRange }"
@click="handleRangeOptionClick(range)"
>
{{ range }}
</button>
<i
v-if="hasRangeFilter(r)"
:class="[
'fal dropdown-trigger-icon',
showRangeOptions(r) ? 'fa-chevron-up' : 'fa-chevron-down'
]"
/>
<div
v-show="showRangeOptions(r)"
class="filter-menu dropdown-menu">
<div class="dropdown-content">
<button
v-for="(range, rIndex) in r"
:key="`rangeOption${rIndex}`"
:class="{ 'is-selected': range === selectedRange }"
@click="handleRangeOptionClick(range)"
>
{{ range }}
</button>
</div>
</div>
</div>
</span>
</button>
</span>
</button>
</div>
</div>

<div class="interval-dropdowns">
<IntervalDropdown
:show-caret="selectedRangeIntervals && selectedRangeIntervals.length > 1"
:selected="selectedInterval"
:options="selectedRangeIntervals"
@option-change="handleIntervalChange" />

<IntervalDropdown
v-if="filters.length > 0"
:selected="selectedFilter"
:options="filters"
@option-change="handleFilterPeriodClick" />
<div>
<label
v-if="mobile"
style="margin-top: 16px;">Time Interval:</label>
<div class="interval-dropdowns">
<IntervalDropdown
:show-caret="selectedRangeIntervals && selectedRangeIntervals.length > 1"
:selected="selectedInterval"
:options="selectedRangeIntervals"
:mobile="mobile"
@option-change="handleIntervalChange" />

<IntervalDropdown
v-if="filters.length > 0"
:selected="selectedFilter"
:options="filters"
:mobile="mobile"
@option-change="handleFilterPeriodClick" />
</div>
</div>
</div>
</template>
Expand Down Expand Up @@ -148,6 +162,10 @@ export default {
use12MthRollingToggle: {
type: Boolean,
default: false
},
mobile: {
type: Boolean,
default: false
}
},
Expand Down Expand Up @@ -534,6 +552,29 @@ export default {
</script>

<style lang="scss" scoped>
.button-group.mobile {
display: block;
}
label {
text-transform: uppercase;
font-size: 12px;
font-weight: 500;
display: block;
color: #353535;
margin-bottom: 4px;
}
.range-buttons.mobile {
width: 100%;
flex-wrap: nowrap;
button {
min-width: auto;
width: 100%;
}
}
.interval-dropdowns {
display: flex;
align-items: center;
Expand Down
31 changes: 30 additions & 1 deletion components/Energy/IntervalDropdown.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div
:class="{ 'is-active': dropdownActive }"
:class="{ 'is-active': dropdownActive, 'mobile': mobile }"
class="dropdown">
<button
v-on-clickaway="handleClickAway"
Expand Down Expand Up @@ -55,6 +55,10 @@ export default {
showCaret: {
type: Boolean,
default: true
},
mobile: {
type: Boolean,
default: false
}
},
Expand Down Expand Up @@ -93,4 +97,29 @@ export default {
button.button.is-selected {
box-shadow: none;
}
.mobile {
&.dropdown {
width: 100%;
display: block;
}
button.dropdown-trigger {
display: block;
min-width: auto;
width: 100%;
border: 1px solid #6A6A6A;
color: #353535;
&:focus:not(:active) {
box-shadow: none;
}
span {
display: flex;
justify-content: space-between;
align-items: center;
}
}
}
</style>
91 changes: 68 additions & 23 deletions components/Toolbar/EnergyDataOptions.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
<template>
<div class="data-view-options">
<div class="button-group has-addons">
<div class="buttons">
<button
class="button is-small"
v-tooltip="dashboardView === 'discrete-time' ? '' : 'Switch to discrete time view'"
:class="{ 'is-selected': dashboardView === 'discrete-time' }"
@click="() => handleViewChange('discrete-time')">
<span class="icon">
<IconDiscreteTime />
</span>
</button>

<button
class="button is-small"
v-tooltip="dashboardView === 'time-of-day' ? '' : 'Switch to time of day view'"
:class="{ 'is-selected': dashboardView === 'time-of-day' }"
@click="() => handleViewChange('time-of-day')">
<span class="icon">
<IconTimeOfDay />
</span>
</button>
<div
:class="{ mobile: mobile }"
class="data-view-options">

<div>
<label v-if="mobile">View:</label>
<div class="button-group has-addons">
<div class="buttons">
<button
class="button"
v-tooltip="dashboardView === 'discrete-time' ? '' : 'Switch to discrete time view'"
:class="{ 'is-selected': dashboardView === 'discrete-time' }"
@click="() => handleViewChange('discrete-time')">
<span class="icon">
<IconDiscreteTime />
</span>
<span v-if="mobile">Discrete</span>
</button>

<button
class="button"
v-tooltip="dashboardView === 'time-of-day' ? '' : 'Switch to time of day view'"
:class="{ 'is-selected': dashboardView === 'time-of-day' }"
@click="() => handleViewChange('time-of-day')">
<span class="icon">
<IconTimeOfDay />
</span>
<span v-if="mobile">Time of Day</span>
</button>
</div>
</div>
</div>

Expand All @@ -32,6 +40,7 @@
:interval="interval"
:filter-period="filterPeriod"
:view="dashboardView"
:mobile="mobile"
@queryChange="handleQueryChange"
@rangeChange="handleRangeChange"
@intervalChange="handleIntervalChange"
Expand Down Expand Up @@ -68,6 +77,13 @@ export default {
IconDiscreteTime
},
props: {
mobile: {
type: Boolean,
default: false
}
},
data() {
return {
ranges: RANGES,
Expand Down Expand Up @@ -174,7 +190,36 @@ $breakpoint: 769px;
.data-view-options {
display: flex;
gap: 8px;
align-items: center;
align-content: center;
&.mobile {
flex-direction: column;
label {
text-transform: uppercase;
font-size: 12px;
font-weight: 500;
display: block;
color: #353535;
margin-bottom: 4px;
}
.buttons {
display: flex;
width: 100%;
justify-content: center;
}
button {
display: flex;
min-width: auto;
width: 50%;
height: auto;
padding: 8px;
gap: 8px;
align-items: center;
}
}
}
.button-group .buttons {
Expand Down
Loading

0 comments on commit 661a4ba

Please sign in to comment.