Skip to content

Commit

Permalink
Merge pull request #83 from earthrise-media/add-mobile-layout
Browse files Browse the repository at this point in the history
Add mobile layout
  • Loading branch information
Martin Bernard authored Nov 29, 2023
2 parents edc4468 + 3870483 commit 2f4f1d3
Show file tree
Hide file tree
Showing 14 changed files with 299 additions and 10 deletions.
2 changes: 2 additions & 0 deletions vacs-map-app/src/LandingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ button:hover {
.callout {
padding: 1rem;
max-width: 90%;
width: 95%;
}
.callout-header {
Expand Down
24 changes: 19 additions & 5 deletions vacs-map-app/src/MapExplorer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<RegionPicker :map="map" :map-ready="mapReady" />
</template>
</component>
<div class="map-overlay">
<div class="map-overlay desktop">
<div class="overlay-left">
<ExploreSidebar class="interactive" ref="overlayLeftRef" />
<ExploreSidebar class="interactive" ref="overlayLeftRef"/>
<MapLegend />
</div>
<div class="overlay-right">
Expand All @@ -19,6 +19,7 @@
<span class="layer-selector-message"> Add layer </span>
</div>
</div>
<MobileExploreMapControls />
</div>
</div>
<MapTooltip />
Expand All @@ -40,9 +41,10 @@ import MapContainerColorSoil from '@/components/MapContainerColorSoil.vue'
import MapContainerColorSand from '@/components/MapContainerColorSand.vue'
import MapContainerColorPopulation from '@/components/MapContainerColorPopulation.vue'
import { useMapExploreStore } from '@/stores/mapExplore'
import LayoutOverview from '@/components/layouts/LayoutOverview.vue'
import ExploreSidebar from '@/components/ExploreSidebar.vue'
import RegionPicker from '@/components/RegionPicker.vue'
import LayoutOverview from './components/layouts/LayoutOverview.vue'
import ExploreSidebar from './components/ExploreSidebar.vue'
import RegionPicker from './components/RegionPicker.vue'
import MobileExploreMapControls from './components/MobileExploreMapControls.vue'
import MapTooltip from '@/components/MapTooltip.vue'
import MapLegend from '@/components/MapLegend.vue'
Expand Down Expand Up @@ -221,6 +223,12 @@ select:hover {
select:hover + .layer-selector-message {
opacity: 1;
}
@media only screen and (max-width: 720px) {
.desktop {
display: none;
}
}
</style>

<style>
Expand All @@ -233,4 +241,10 @@ select:hover + .layer-selector-message {
height: 12rem;
padding: 1.5rem;
}
@media only screen and (max-width: 720px) {
.region-picker {
display: none;
}
}
</style>
1 change: 1 addition & 0 deletions vacs-map-app/src/assets/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
--black: #17191b;
--black-90: rgba(25, 27, 30, 0.9);
--black-80: rgba(25, 27, 30, 0.8);
--black-70: rgba(25, 27, 30, 0.7);
--white: #e1dcd5;
--white-hover: #a8a39c;
--white-80: rgba(225, 220, 213, 0.8);
Expand Down
3 changes: 3 additions & 0 deletions vacs-map-app/src/assets/img/back-arrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions vacs-map-app/src/assets/img/show-filters.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions vacs-map-app/src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@

--page-horizontal-margin: 3.5rem;
}

@media only screen and (max-width: 720px) {
#app {
--page-horizontal-margin: 1rem;
}
}
7 changes: 7 additions & 0 deletions vacs-map-app/src/components/ContentModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ onClickOutside(contentInnerRef, () => emit('close'))
border-radius: 4px;
overflow-y: auto;
max-width: 50%;
max-height: 70%;
padding: 2.5rem;
white-space: pre-line;
Expand All @@ -78,4 +79,10 @@ onClickOutside(contentInnerRef, () => emit('close'))
cursor: pointer;
height: 20px;
}
@media only screen and (max-width: 720px) {
.content-modal-inner {
max-width: 95%;
}
}
</style>
74 changes: 73 additions & 1 deletion vacs-map-app/src/components/CropFilters.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<template>
<div class="crop-filters">
<div class="filters-header mobile">
<span class="header"> Filter crops </span>
<img src="@/assets/img/close.svg" alt="" @click="$emit('closeFilters')" />
</div>

<div class="left-side">
<span class="mobile category-header"> climate scenario </span>
<RadioSwitch v-model="selectedModel" :options="scenarioOptions" name="selected-scenario" />

<span class="mobile category-header"> food groups </span>
<div class="crop-groups">
<div
class="crop-group-label"
Expand All @@ -27,6 +34,7 @@
</div>
</div>

<span class="mobile category-header"> order by </span>
<div class="sort-by">
<RadioList v-model="cropSortOrder" :options="sortOrderOptions" name="sort-order" />

Expand All @@ -40,7 +48,7 @@
</template>

<script setup>
import { computed } from 'vue'
import { computed, ref } from 'vue'
import { storeToRefs } from 'pinia'
import { useFiltersStore } from '@/stores/filters'
import { useContentStore } from '@/stores/siteContent'
Expand All @@ -50,6 +58,7 @@ import RadioSwitch from '@/components/RadioSwitch.vue'
const contentStore = useContentStore()
const { copy } = storeToRefs(contentStore)
defineEmits(['closeFilters'])
const filtersStore = useFiltersStore()
const {
availableModels,
Expand Down Expand Up @@ -159,4 +168,67 @@ const scenarioOptions = computed(() => {
.sort-by select:hover {
color: var(--ui-blue-hover);
}
.mobile {
display: none;
}
@media only screen and (max-width: 720px) {
.mobile {
display: flex;
justify-content: flex-start;
}
.filters-header {
width: 100%;
display: flex;
}
.filters-header img {
margin-left: auto;
margin-right: 1rem;
width: 1rem;
cursor: pointer;
}
.header {
font-family: var(--font-family-h2);
font-size: 1.25rem;
}
.category-header {
text-transform: uppercase;
font-size: 0.875rem;
}
.crop-filters {
z-index: 500;
width: 100%;
position: fixed;
bottom: 0;
left: 0;
padding: 2rem var(--page-horizontal-margin);
flex-direction: column;
gap: 0.5rem;
align-items: flex-start;
background: var(--black);
border-radius: 1.875rem 1.875rem 0rem 0rem;
}
.left-side {
flex-direction: column;
align-items: flex-start;
gap: 0.5rem;
}
.crop-groups {
gap: 0.5rem;
}
.sort-by {
width: 100%;
margin: 0;
flex-direction: column-reverse;
gap: 0.5rem;
}
}
</style>
108 changes: 108 additions & 0 deletions vacs-map-app/src/components/MobileExploreMapControls.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<template>
<div class="wrapper">
<div class="top-row">
<div class="row-item">
<span class="item-label"> Crop </span>
<select v-model="selectedCrop" class="crop-picker">
<optgroup v-for="group in availableCropGroups" :key="group" :label="group">
<option v-for="crop in getCropsByGroup(group)" :key="crop.id" :value="crop.id">
{{ crop.label }}
</option>
</optgroup>
</select>
</div>

<div class="row-item">
<span class="item-label"> Emissions </span>
<RadioSwitch v-model="selectedModel" :options="scenarioOptions" name="selected-scenario" />
</div>
</div>

<!-- TODO: add map color legend -->
</div>
</template>

<script setup>
import { storeToRefs } from 'pinia'
import { computed } from 'vue'
import { useFiltersStore } from '@/stores/filters'
import { useCropInformationStore } from '@/stores/cropInformation'
import RadioSwitch from '@/components/RadioSwitch.vue'
const cropInformationStore = useCropInformationStore()
const filtersStore = useFiltersStore()
const { selectedCrop, availableModels, selectedModel, availableCropGroups } =
storeToRefs(filtersStore)
const { data: cropInformation } = storeToRefs(cropInformationStore)
const getCropsByGroup = (group) => {
return cropInformation?.value?.filter((crop) => crop.crop_group === group)
}
const futureScenarios = computed(() => {
return availableModels?.value?.filter((d) => d.startsWith('future'))
})
const scenarioOptions = computed(() => {
return futureScenarios?.value?.map((s, i) => {
return {
value: s,
label: i ? 'High' : 'Low'
}
})
})
</script>
<style scoped>
.wrapper {
position: absolute;
top: 0;
left: 0;
display: none;
flex-direction: column;
padding: 0 1rem;
width: 100%;
}
.top-row {
display: flex;
width: 100%;
gap: 1rem;
}
.row-item {
flex-grow: 1;
gap: 0.25rem;
display: flex;
flex-direction: column;
}
.item-label {
font-size: 0.75rem;
font-weight: 500;
}
select {
font-family: var(--font-family-header);
font-size: 0.75rem;
appearance: none;
cursor: pointer;
border-radius: 0.25rem;
border: 1px solid var(--gray);
background: var(--dark-gray);
text-transform: uppercase;
color: var(--ui-blue);
padding: 0.5rem;
padding-right: 2rem;
background-image: url('../assets/img/select-arrow-blue.svg');
background-position: 95% center;
background-repeat: no-repeat;
}
@media only screen and (max-width: 720px) {
.wrapper {
display: flex;
}
}
</style>
10 changes: 9 additions & 1 deletion vacs-map-app/src/components/NavigationButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ const props = defineProps({
color: var(--white);
background: var(--dark-gray);
font-size: 1rem;
padding: 0.5rem;
padding: 0.625rem 0.75rem;
text-decoration: none;
display: flex;
justify-content: center;
}
.navigation-button:hover {
background: var(--dark-gray-hover);
}
@media only screen and (max-width: 720px) {
.navigation-button {
background: var(--ui-blue);
aspect-ratio: 1/1;
}
}
</style>
22 changes: 21 additions & 1 deletion vacs-map-app/src/components/OverviewTop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
<button @click="copyLink" title="Copy URL">
<img src="@/assets/img/copy-link.svg" alt="copy-link" />
</button>
<NavigationButton :to="backRoute">Back</NavigationButton>
<NavigationButton :to="backRoute" class="desktop">Back</NavigationButton>
<NavigationButton :to="backRoute" class="mobile">
<img src="@/assets/img/back-arrow.svg" alt="" />
</NavigationButton>
</div>
</div>
</div>
Expand Down Expand Up @@ -75,4 +78,21 @@ button {
button:hover {
background: var(--dark-gray-hover);
}
.mobile {
display: none;
}
@media only screen and (max-width: 720px) {
.desktop {
display: none;
}
.mobile {
display: flex;
}
.overview-top {
font-size: 1rem;
}
}
</style>
1 change: 0 additions & 1 deletion vacs-map-app/src/components/RadioList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const { name, options, modelValue } = toRefs(props)
padding: 0.25rem 0;
}
.option-wrapper {
width: 100%;
display: flex;
}
Expand Down
Loading

0 comments on commit 2f4f1d3

Please sign in to comment.