11<script setup lang="ts">
22import { computed } from " vue" ;
33
4+ import { useUniqueId } from " ../../composables/useUniqueId" ;
5+
46const props = defineProps <{
57 value: number ;
68 label: string ;
79 size: number ; // value in px
810 inline? : boolean ;
11+ tooltipLabel? : string ;
912}>();
1013
14+ const uniqueId = useUniqueId ();
15+
1116const progressPercentage = computed (() => {
1217 const percentage = props .value * 100 ;
1318 const rounded = Math .round (percentage );
@@ -24,13 +29,39 @@ const progressBarSize = computed(() => `${props.size / 16}rem`);
2429 </script >
2530
2631<template >
27- <div :class =" ['audit-progress', { 'audit-progress--inline': inline }]" >
32+ <div
33+ :class =" [
34+ 'audit-progress',
35+ {
36+ 'audit-progress--inline': inline,
37+ 'audit-progress--with-tooltip':
38+ tooltipLabel && $slots['tooltip-content']
39+ }
40+ ]"
41+ >
2842 <span :class =" ['audit-progress-label', { 'fr-sr-only': inline }]" >
2943 {{ label }}
3044 </span >
45+ <template v-if =" tooltipLabel && $slots [' tooltip-content' ]" >
46+ <button
47+ class =" fr-btn--tooltip fr-btn"
48+ type =" button"
49+ :aria-describedby =" `progress-bar-tooltip-${uniqueId}`"
50+ >
51+ {{ tooltipLabel }}
52+ </button >
53+ <span
54+ :id =" `progress-bar-tooltip-${uniqueId}`"
55+ class =" fr-tooltip fr-placement fr-text--sm"
56+ role =" tooltip"
57+ aria-hidden =" true"
58+ >
59+ <slot name =" tooltip-content" />
60+ </span >
61+ </template >
3162 <span
3263 :class =" [
33- ' fr-text--action-high-grey fr-m -0 audit-progress-percentage',
64+ ' fr-text--action-high-grey fr-mb -0 audit-progress-percentage',
3465 {
3566 'fr-text--xs': !inline
3667 }
@@ -43,34 +74,38 @@ const progressBarSize = computed(() => `${props.size / 16}rem`);
4374</template >
4475
4576<style scoped>
46- .audit-progress-bar {
47- background-color : var (--background-contrast-grey );
48- position : relative ;
49- grid-column : 1 / -1 ;
50- }
51-
5277.audit-progress {
5378 background : none ;
54- display : grid ;
55- gap : v-bind(progressBarSize) 1rem ;
56- grid-template-columns : 1fr 4ch ;
57- grid-template-rows : auto v-bind(progressBarSize);
79+ display : flex ;
80+ flex-wrap : wrap ;
81+ align-items : center ;
82+ justify-content : start ;
83+ gap : v-bind(progressBarSize) 0.125rem ;
5884}
5985
6086.audit-progress--inline {
61- grid-template-rows : v-bind(progressBarSize);
62- gap : 0 0.5rem ;
87+ gap : 0.5rem ;
88+ flex-direction : row-reverse ;
89+ flex-wrap : nowrap ;
6390
6491 .audit-progress-bar {
6592 height : v-bind(progressBarSize);
66- grid-column : 1 / span 1 ;
6793 }
94+ }
95+ .audit-progress-label {
96+ font-weight : 500 ;
97+ }
6898
69- .audit-progress-percentage {
70- grid-column : 2 ;
71- grid-row : 1 ;
72- align-self : center ;
73- }
99+ .audit-progress-percentage {
100+ color : var (--text-mention-grey );
101+ margin-inline-start : auto ;
102+ }
103+
104+ .audit-progress-bar {
105+ background-color : var (--background-contrast-grey );
106+ position : relative ;
107+ height : v-bind(progressBarSize);
108+ flex-basis : 100% ;
74109}
75110
76111.audit-progress-bar ::after {
@@ -83,14 +118,4 @@ const progressBarSize = computed(() => `${props.size / 16}rem`);
83118 transition : width 1s ease ;
84119 width : v-bind(progressBarValue);
85120}
86-
87- .audit-progress-label {
88- font-weight : 500 ;
89- }
90-
91- .audit-progress-percentage {
92- color : var (--text-mention-grey );
93- align-self : end ;
94- text-align : end ;
95- }
96121 </style >
0 commit comments