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

Add colorblind friendly mode #125

Merged
merged 10 commits into from
Dec 14, 2023
Prev Previous commit
Next Next commit
Fix indicator label text color so readable
  • Loading branch information
mwbernard committed Dec 13, 2023
commit 9cfa7f2af8b65ca5344c247b13d36994b1ba9dc8
19 changes: 17 additions & 2 deletions vacs-map-app/src/components/CardWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
<div class="title" :class="{ bold: boldTitle }">{{ title }}</div>
<div v-if="indicator" class="indicator">
<span class="indicator-category"> {{ indicator.key }} </span>
<span class="indicator-level" :style="{ background: indicatorColor }">
<span
class="indicator-level"
:class="{ 'dark-text': useDarkIndicatorText }"
:style="{ background: indicatorColor }"
>
{{ indicatorLevel }}
</span>
</div>
Expand Down Expand Up @@ -65,7 +69,7 @@ const props = defineProps({
const { title, description, handleClick, indicator } = toRefs(props)

const colorStore = useColorStore()
const { stopLight: stopLightScheme } = storeToRefs(colorStore)
const { stopLight: stopLightScheme, colorblindFriendly } = storeToRefs(colorStore)

const indicatorLevel = computed(() => {
if (indicator?.value.val === null) return 'no data'
Expand All @@ -78,6 +82,13 @@ const indicatorColor = computed(() => {
if (indicatorLevel.value === 'no data') return stopLightScheme.value.default
return stopLightScheme.value[indicatorLevel.value]
})

const useDarkIndicatorText = computed(() => {
return (
(indicatorLevel.value === 'low' && colorblindFriendly.value) ||
(indicatorLevel.value === 'medium' && !colorblindFriendly.value)
)
})
</script>

<style scoped>
Expand Down Expand Up @@ -156,6 +167,10 @@ const indicatorColor = computed(() => {
font-weight: 600;
}

.dark-text {
color: var(--gray);
}

.active {
border-color: var(--ui-blue);
}
Expand Down