From 7d5bdb4b6bdb48cd9287a68383b4880c2f2e1813 Mon Sep 17 00:00:00 2001 From: mwbernard Date: Fri, 12 Jan 2024 10:47:22 -0800 Subject: [PATCH] Add hover states and fix color assignment --- .../src/assets/img/negative-yield.svg | 3 + .../src/assets/img/positive-yield.svg | 3 + .../src/assets/img/reference-crop.svg | 3 + vacs-map-app/src/components/CardWrapper.vue | 57 +++++++-- vacs-map-app/src/components/ContentModal.vue | 2 +- vacs-map-app/src/components/CropCards.vue | 2 + .../components/CropGroupStackedBarChart.vue | 14 ++- .../src/components/ExploreSidebar.vue | 16 ++- vacs-map-app/src/components/GridOverlay.vue | 22 +++- .../src/components/MapLegendCropGroups.vue | 115 ++++++++++++++++-- vacs-map-app/src/components/MapTooltip.vue | 78 ++++++++++-- .../src/components/TooltipWrapper.vue | 2 + vacs-map-app/src/stores/colors.js | 40 +++++- vacs-map-app/src/stores/mapExplore.js | 7 +- vacs-map-app/src/stores/siteContent.js | 2 +- vacs-map-app/src/utils/colors.js | 11 +- 16 files changed, 321 insertions(+), 56 deletions(-) create mode 100644 vacs-map-app/src/assets/img/negative-yield.svg create mode 100644 vacs-map-app/src/assets/img/positive-yield.svg create mode 100644 vacs-map-app/src/assets/img/reference-crop.svg diff --git a/vacs-map-app/src/assets/img/negative-yield.svg b/vacs-map-app/src/assets/img/negative-yield.svg new file mode 100644 index 0000000..2394f35 --- /dev/null +++ b/vacs-map-app/src/assets/img/negative-yield.svg @@ -0,0 +1,3 @@ + + + diff --git a/vacs-map-app/src/assets/img/positive-yield.svg b/vacs-map-app/src/assets/img/positive-yield.svg new file mode 100644 index 0000000..fed3b27 --- /dev/null +++ b/vacs-map-app/src/assets/img/positive-yield.svg @@ -0,0 +1,3 @@ + + + diff --git a/vacs-map-app/src/assets/img/reference-crop.svg b/vacs-map-app/src/assets/img/reference-crop.svg new file mode 100644 index 0000000..10b6f8b --- /dev/null +++ b/vacs-map-app/src/assets/img/reference-crop.svg @@ -0,0 +1,3 @@ + + + diff --git a/vacs-map-app/src/components/CardWrapper.vue b/vacs-map-app/src/components/CardWrapper.vue index f67d330..b4088b4 100644 --- a/vacs-map-app/src/components/CardWrapper.vue +++ b/vacs-map-app/src/components/CardWrapper.vue @@ -7,11 +7,17 @@
-
- {{ title }} +
+ + {{ title }} + + {{ subtitle }}
+
+ {{ cropGroup }} reference crop +
{{ indicator.key }} {} @@ -84,8 +100,18 @@ const props = defineProps({ default: () => {} } }) -const { title, description, handleClick, indicator, isActive, isDynamic, showMoreInfo, boldTitle } = - toRefs(props) +const { + title, + description, + handleClick, + indicator, + isActive, + isDynamic, + showMoreInfo, + boldTitle, + referenceCrop, + cropGroup +} = toRefs(props) const colorStore = useColorStore() const { stopLight: stopLightScheme, colorblindFriendly } = storeToRefs(colorStore) @@ -170,30 +196,41 @@ const useDarkIndicatorText = computed(() => { padding-top: 0; } -.title { +.title-row { font-family: var(--font-family-h2); height: var(--title-height); font-size: 1.125rem; display: flex; gap: 0.5rem; - align-items: center; + align-items: baseline; overflow-x: hidden; text-overflow: ellipsis; white-space: nowrap; } -.title img { +.title-row img { margin-left: auto; } +.title-row.bold { + font-family: var(--font-family-header); + font-size: 1.375rem; +} + +.title { + height: 100%; + display: flex; + align-items: center; + gap: 0.5rem; +} + .subtitle { font-size: 0.875rem; font-family: var(--font-family-h3); } -.title.bold { - font-family: var(--font-family-header); - font-size: 1.375rem; +.reference-crop-message { + color: var(--dark-gray); } .indicator { diff --git a/vacs-map-app/src/components/ContentModal.vue b/vacs-map-app/src/components/ContentModal.vue index 3673ff8..10be85c 100644 --- a/vacs-map-app/src/components/ContentModal.vue +++ b/vacs-map-app/src/components/ContentModal.vue @@ -80,7 +80,7 @@ onClickOutside(contentInnerRef, () => emit('close')) .header { font-family: var(--font-family-h2); font-size: 1.875rem; - padding-bottom: 0.25rem; + padding-bottom: 0.75rem; line-height: 110%; } diff --git a/vacs-map-app/src/components/CropCards.vue b/vacs-map-app/src/components/CropCards.vue index 5dfe564..901d18c 100644 --- a/vacs-map-app/src/components/CropCards.vue +++ b/vacs-map-app/src/components/CropCards.vue @@ -7,6 +7,8 @@ :title="crop.label" :bold-title="true" :description="crop.description" + :reference-crop="!!crop.benchmark" + :crop-group="crop.crop_group" :handle-click="() => navigate(crop.id)" :indicator="{ key: cropSortBy, diff --git a/vacs-map-app/src/components/CropGroupStackedBarChart.vue b/vacs-map-app/src/components/CropGroupStackedBarChart.vue index 3d3937b..5dd4698 100644 --- a/vacs-map-app/src/components/CropGroupStackedBarChart.vue +++ b/vacs-map-app/src/components/CropGroupStackedBarChart.vue @@ -4,6 +4,10 @@ v-for="bar in bars" :key="bar.id" class="crop-bar" + :class="{ + highlighted: hoveredCrop === bar.id, + unhighlighted: hoveredCrop && hoveredCrop !== bar.id + }" :style="{ width: `${bar.gridShare}%`, background: bar.fill @@ -29,9 +33,9 @@ const mapExploreStore = useMapExploreStore() const { selectedCrop, selectedModel } = storeToRefs(filtersStore) const { data: cropInformation } = storeToRefs(cropInformationStore) -const { ordinal: ordinalScheme, noData: noDataFill } = storeToRefs(colorStore) +const { ordinal: ordinalScheme, noData: noDataFill, getCropColor } = storeToRefs(colorStore) const { data: cropYieldsData } = storeToRefs(cropYieldsStore) -const { showCropGroupMap, cropGroupMetric } = storeToRefs(mapExploreStore) +const { showCropGroupMap, cropGroupMetric, hoveredCrop } = storeToRefs(mapExploreStore) const selectedCropInfo = computed(() => { return cropInformation?.value?.find((d) => d.id === selectedCrop.value) @@ -65,7 +69,7 @@ const bars = computed(() => { return { id: crop.id, label: crop.label, - fill: ordinalScheme.value[i], + fill: colorStore.getCropColor(crop.id), gridShare } }) @@ -98,4 +102,8 @@ const bars = computed(() => { .crop-bar { height: 100%; } + +.unhighlighted { + opacity: 20%; +} diff --git a/vacs-map-app/src/components/ExploreSidebar.vue b/vacs-map-app/src/components/ExploreSidebar.vue index ed84d9e..815ff25 100644 --- a/vacs-map-app/src/components/ExploreSidebar.vue +++ b/vacs-map-app/src/components/ExploreSidebar.vue @@ -29,15 +29,7 @@