Skip to content

Commit d6aea5a

Browse files
authored
fix: meter bar design in Chrome and improve tooltip button in card (#964)
1 parent 6386141 commit d6aea5a

File tree

10 files changed

+87
-79
lines changed

10 files changed

+87
-79
lines changed

datagouv-components/assets/main.css

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -188,34 +188,6 @@
188188
.code {
189189
@apply p-1! font-mono! bg-gray-lower! text-sm! text-gray-medium! rounded!;
190190
}
191-
meter.quality-score {
192-
background: none;
193-
border: 1px solid var(--color-gray-default);
194-
border-radius: 8px;
195-
height: 10px;
196-
vertical-align: baseline;
197-
}
198-
meter.quality-score::-webkit-meter-bar {
199-
height: 10px;
200-
background: whiteSmoke;
201-
border-radius: 8px;
202-
}
203-
meter.quality-score::-moz-meter-bar {
204-
background: whiteSmoke;
205-
border-radius: 8px;
206-
}
207-
meter.quality-score::-webkit-meter-suboptimum-value {
208-
background-color: var(--color-gray-low);
209-
}
210-
meter.quality-score:-moz-meter-sub-optimum::-moz-meter-bar {
211-
background-color: var(--color-gray-low);
212-
}
213-
meter.quality-score::-webkit-meter-optimum-value {
214-
background-color: #27A658;
215-
}
216-
meter.quality-score:-moz-meter-optimum::-moz-meter-bar {
217-
background-color: #27A658;
218-
}
219191

220192
/* Vue Sonner Toast custom colors */
221193
[data-sonner-toast][data-type="success"] {

datagouv-components/src/components/DatasetCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
</div>
6161
</div>
6262
<div class="mx-0 -mb-1 flex flex-wrap items-center text-sm text-gray-medium">
63-
<div class="hidden sm:flex text-gray-medium -ml-2.5">
63+
<div class="hidden sm:flex text-gray-medium">
6464
<DatasetQualityInline :quality="dataset.quality" />
6565
</div>
6666
<RiSubtractLine

datagouv-components/src/components/DatasetQuality.vue

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
<template>
2-
<div class="flex items-center">
3-
<Toggletip
4-
:button-props="{ class: '-ml-2 mt-px', title: t('Qualité des métadonnées') }"
5-
>
6-
<template #toggletip>
7-
<DatasetQualityTooltipContent :quality />
8-
</template>
9-
</Toggletip>
10-
<div class="text-sm text-gray-plain font-bold">
11-
{{ t('Qualité des métadonnées:') }}
12-
</div>
13-
</div>
14-
<DatasetQualityScore
15-
:score="quality.score"
16-
class="w-full"
17-
/>
2+
<Toggletip
3+
:styled-button="false"
4+
button-class="flex flex-col gap-1 rounded-sm p-1.5 -m-1.5 border-transparent -outline-offset-2 hover:bg-gray-some transition-colors w-full text-left"
5+
:button-props="{ title: t('Qualité des métadonnées') }"
6+
>
7+
<span class="flex items-center gap-1">
8+
<RiInformationLine
9+
class="size-5 shrink-0"
10+
aria-hidden="true"
11+
/>
12+
<span class="text-sm text-gray-plain font-bold">
13+
{{ t('Qualité des métadonnées:') }}
14+
</span>
15+
</span>
16+
<DatasetQualityScore
17+
:score="quality.score"
18+
class="w-full"
19+
/>
20+
<template #toggletip>
21+
<DatasetQualityTooltipContent :quality />
22+
</template>
23+
</Toggletip>
1824
<template v-if="!hideWarnings">
1925
<ul class="list-none pl-0">
2026
<DatasetQualityItemWarning
@@ -54,6 +60,7 @@
5460
</template>
5561

5662
<script setup lang="ts">
63+
import { RiInformationLine } from '@remixicon/vue'
5764
import type { Quality } from '../types/datasets'
5865
import DatasetQualityItemWarning from './DatasetQualityItemWarning.vue'
5966
import DatasetQualityScore from './DatasetQualityScore.vue'

datagouv-components/src/components/DatasetQualityInline.vue

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
<template>
2-
<div class="m-0 flex flex-wrap items-center text-sm text-gray-medium">
3-
<div class="fr-grid-row fr-grid-row--middle">
4-
<Toggletip
5-
:button-props="{ class: 'relative z-2 ml-0.5', title: t('Qualité des métadonnées') }"
6-
>
7-
<RiInformationLine class="size-4" />
8-
<template #toggletip>
9-
<DatasetQualityTooltipContent :quality />
10-
</template>
11-
</Toggletip>
12-
<p class="my-0 mr-1 text-gray-medium text-sm">
13-
{{ t('Métadonnées :') }}
14-
</p>
15-
<div class="fr-grid-row fr-grid-row--middle fr-mr-1v">
16-
<DatasetQualityScore :score="quality.score" />
17-
</div>
18-
</div>
2+
<div class="m-0 text-sm text-gray-medium">
3+
<Toggletip
4+
:styled-button="false"
5+
button-class="border-transparent -outline-offset-2 inline-flex items-center justify-center hover:bg-gray-lower transition-colors"
6+
:button-props="{ class: 'relative z-2 gap-1 rounded-sm px-1 -mx-1 group/quality', title: t('Qualité des métadonnées') }"
7+
>
8+
<RiInformationLine class="size-3.5 shrink-0" />
9+
<span class="text-gray-medium text-sm group-hover/quality:underline">{{ t('Métadonnées :') }}</span>
10+
<DatasetQualityScore :score="quality.score" />
11+
<template #toggletip>
12+
<DatasetQualityTooltipContent :quality />
13+
</template>
14+
</Toggletip>
1915
</div>
2016
</template>
2117

datagouv-components/src/components/DatasetQualityScore.vue

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
<template>
2-
<meter
3-
class="quality-score"
4-
:class="props.class"
5-
min="0"
6-
low="0"
7-
:high="high"
8-
:max="quality_max_score"
9-
:optimum="quality_max_score"
2+
<ProgressBar
103
:value="score"
4+
:max="quality_max_score"
5+
:aria-label="score >= high ? t('Bon') : t('À améliorer')"
6+
:bar-class="score >= high ? 'bg-success-dark' : 'bg-gray-low'"
7+
:class="props.class"
118
>
12-
<template v-if="score >= high">
13-
{{ t('Bon') }}
14-
</template>
15-
<template v-else>
16-
{{ t('À améliorer') }}
17-
</template>({{ calculatedScore }})
18-
</meter>
9+
<span class="sr-only">
10+
<template v-if="score >= high">{{ t('Bon') }}</template>
11+
<template v-else>{{ t('À améliorer') }}</template>
12+
({{ calculatedScore }})
13+
</span>
14+
</ProgressBar>
1915
</template>
2016

2117
<script setup lang="ts">
2218
import { computed } from 'vue'
2319
import { useTranslation } from '../composables/useTranslation'
20+
import ProgressBar from './ProgressBar.vue'
2421
2522
const props = withDefaults(defineProps<{
2623
score: number
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<template>
2+
<div
3+
role="meter"
4+
:aria-valuenow="value"
5+
aria-valuemin="0"
6+
:aria-valuemax="max"
7+
class="min-w-20 h-2.5 rounded-lg border border-gray-default bg-[#f5f5f5] overflow-hidden"
8+
>
9+
<div
10+
class="h-full rounded-lg"
11+
:class="barClass"
12+
:style="{ width: percentage + '%' }"
13+
/>
14+
<slot />
15+
</div>
16+
</template>
17+
18+
<script setup lang="ts">
19+
import { computed } from 'vue'
20+
21+
const props = withDefaults(defineProps<{
22+
value: number
23+
max?: number
24+
barClass?: string
25+
}>(), {
26+
max: 1,
27+
barClass: '',
28+
})
29+
30+
const percentage = computed(() => Math.min(100, Math.max(0, (props.value / props.max) * 100)))
31+
</script>

datagouv-components/src/components/Toggletip.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
/>
1414
<PopoverButton
1515
v-bind="buttonProps"
16-
class="border-transparent -outline-offset-2 inline-flex items-center justify-center hover:bg-gray-some"
17-
:class="{ 'w-8 h-8 rounded-full bg-transparent': styledButton }"
16+
:class="[
17+
buttonClass ?? 'border-transparent -outline-offset-2 inline-flex items-center justify-center hover:bg-gray-some',
18+
{ 'w-8 h-8 rounded-full bg-transparent': styledButton && !buttonClass },
19+
]"
1820
>
1921
<slot>
2022
<RiInformationLine
@@ -57,6 +59,7 @@ import ValueWatcher from './ValueWatcher.vue'
5759
5860
withDefaults(defineProps<{
5961
buttonProps?: object
62+
buttonClass?: string
6063
noMargin?: boolean
6164
styledButton?: boolean
6265
}>(), {

datagouv-components/src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import DatasetQuality from './components/DatasetQuality.vue'
4949
import DatasetQualityInline from './components/DatasetQualityInline.vue'
5050
import DatasetQualityItem from './components/DatasetQualityItem.vue'
5151
import DatasetQualityScore from './components/DatasetQualityScore.vue'
52+
import ProgressBar from './components/ProgressBar.vue'
5253
import DatasetQualityTooltipContent from './components/DatasetQualityTooltipContent.vue'
5354
import ExtraAccordion from './components/ExtraAccordion.vue'
5455
import LabelTag from './components/DatasetLabelTag.vue'
@@ -285,6 +286,7 @@ export {
285286
PaddedContainer,
286287
Pagination,
287288
Placeholder,
289+
ProgressBar,
288290
PostCard,
289291
RadioGroup,
290292
RadioInput,
-743 Bytes
Loading
-1.48 KB
Loading

0 commit comments

Comments
 (0)