@@ -53,66 +53,69 @@ const QuizSimulator = () => {
5353 }
5454 } , [ config ] )
5555
56+ const Header = (
57+ < div className = { styles . header } ref = { ref } tabIndex = { - 1 } >
58+ { question > 0 && config && (
59+ < button
60+ data-testid = 'quiz-previous-button'
61+ type = 'button'
62+ className = { styles . previousButton }
63+ onClick = { ( ) => {
64+ setAnswer ( undefined )
65+ setQuestion ( question - 1 )
66+ setDisplayMore ( false )
67+ track ( 'Quiz' , 'Previous' , question . toString ( ) )
68+ } } >
69+ < FullArrowLeftIcon />
70+ { t ( 'previous' ) }
71+ </ button >
72+ ) }
73+ < p className = { styles . question } data-testid = 'quiz-header' >
74+ { config ? (
75+ < >
76+ { t ( 'question' ) } { question + 1 } / 10
77+ </ >
78+ ) : (
79+ t ( 'finished' )
80+ ) }
81+ </ p >
82+ < legend className = { styles . title } data-testid = 'quiz-title' >
83+ { config
84+ ? t . rich ( 'title' , { important : ( chunks ) => < b > { chunks } </ b > } )
85+ : t . rich ( 'score' , {
86+ score : score . current . reduce ( ( acc , current ) => acc + current , 0 ) ,
87+ important : ( chunks ) => < b > { chunks } </ b > ,
88+ } ) }
89+ </ legend >
90+ { config && (
91+ < p
92+ className = { classNames ( styles . tag , {
93+ [ styles . correct ] : answer === config . answer ,
94+ [ styles . missed ] : answer && answer !== config . answer ,
95+ } ) }
96+ data-testid = 'quiz-question-result'
97+ role = 'status' >
98+ { answer ? (
99+ answer === config . answer ? (
100+ t . rich ( 'correct' , { important : ( chunks ) => < b > { chunks } </ b > } )
101+ ) : (
102+ < >
103+ { t . rich ( 'missed' , { important : ( chunks ) => < b > { chunks } </ b > } ) } { config . answer } !
104+ </ >
105+ )
106+ ) : (
107+ t ( 'tag' )
108+ ) }
109+ </ p >
110+ ) }
111+ </ div >
112+ )
56113 return (
57114 < >
58- < form >
59- < fieldset >
60- < div className = { styles . header } ref = { ref } tabIndex = { - 1 } >
61- { question > 0 && config && (
62- < button
63- data-testid = 'quiz-previous-button'
64- type = 'button'
65- className = { styles . previousButton }
66- onClick = { ( ) => {
67- setAnswer ( undefined )
68- setQuestion ( question - 1 )
69- setDisplayMore ( false )
70- track ( 'Quiz' , 'Previous' , question . toString ( ) )
71- } } >
72- < FullArrowLeftIcon />
73- { t ( 'previous' ) }
74- </ button >
75- ) }
76- < p className = { styles . question } data-testid = 'quiz-header' >
77- { config ? (
78- < >
79- { t ( 'question' ) } { question + 1 } / 10
80- </ >
81- ) : (
82- t ( 'finished' )
83- ) }
84- </ p >
85- < legend className = { styles . title } data-testid = 'quiz-title' >
86- { config
87- ? t . rich ( 'title' , { important : ( chunks ) => < b > { chunks } </ b > } )
88- : t . rich ( 'score' , {
89- score : score . current . reduce ( ( acc , current ) => acc + current , 0 ) ,
90- important : ( chunks ) => < b > { chunks } </ b > ,
91- } ) }
92- </ legend >
93- { config && (
94- < p
95- className = { classNames ( styles . tag , {
96- [ styles . correct ] : answer === config . answer ,
97- [ styles . missed ] : answer && answer !== config . answer ,
98- } ) }
99- data-testid = 'quiz-question-result'
100- role = 'status' >
101- { answer ? (
102- answer === config . answer ? (
103- t . rich ( 'correct' , { important : ( chunks ) => < b > { chunks } </ b > } )
104- ) : (
105- < >
106- { t . rich ( 'missed' , { important : ( chunks ) => < b > { chunks } </ b > } ) } { config . answer } !
107- </ >
108- )
109- ) : (
110- t ( 'tag' )
111- ) }
112- </ p >
113- ) }
114- </ div >
115- { config ? (
115+ { config ? (
116+ < form >
117+ < fieldset >
118+ { Header }
116119 < div className = { answer && ! displayMore ? styles . reduced : undefined } >
117120 < Question
118121 question = { config }
@@ -129,65 +132,66 @@ const QuizSimulator = () => {
129132 displayMore = { displayMore }
130133 />
131134 </ div >
132- ) : (
133- < >
134- < div className = { styles . result } >
135- < Image src = '/images/tools-quiz-end.svg' alt = '' width = { 220 } height = { 180 } data-testid = 'quiz-success' />
136- < Button
137- data-testid = 'quiz-restart-button'
138- priority = 'outline'
139- onClick = { ( ) => {
140- setAnswer ( undefined )
141- setQuestion ( 0 )
142- track ( 'Quiz' , 'Restart' , 'quiz_restart_button' )
143- } } >
144- { t ( 'restart' ) }
145- </ Button >
146- </ div >
147- < QuizInfography />
148- < div className = { styles . ressources } >
149- < p > { t ( 'read-more' ) } </ p >
150- < Resource
151- image = '/images/fiches.png'
152- text = 'fiches'
153- href = '/kit/fiches.zip'
154- withLink = 'Télécharger les 20 fiches'
155- tracking = 'Quiz'
156- />
157- < Resource
158- image = '/images/tools-transport.svg'
159- text = 'ico2-transport'
160- href = 'https://impactco2.fr/outils/transport'
161- withLink = 'Simulateur Transports'
162- tracking = 'Quiz'
163- />
164- < Resource
165- image = '/images/tools-fruitsetlegumes.svg'
166- text = 'ico2-fruitsetlegumes'
167- href = 'https://impactco2.fr/outils/fruitsetlegumes'
168- withLink = 'Fruits et légumes de saison'
169- tracking = 'Quiz'
170- />
171- < Resource
172- image = '/images/lvao.png'
173- text = 'lvao'
174- href = 'https://quefairedemesobjets.ademe.fr/?mtm_campaign=impactCO2'
175- withLink = 'Longue Vie Aux Objets'
176- tracking = 'Quiz'
177- />
178- < Resource
179- image = '/images/ngc.png'
180- text = 'ngc'
181- href = 'https://nosgestesclimat.fr/'
182- withLink = 'Nos Gestes Climat'
183- tracking = 'Quiz'
184- />
185- </ div >
186- < div className = { shareableStyles . separator } />
187- </ >
188- ) } { ' ' }
189- </ fieldset >
190- </ form >
135+ </ fieldset >
136+ </ form >
137+ ) : (
138+ < >
139+ { Header }
140+ < div className = { styles . result } >
141+ < Image src = '/images/tools-quiz-end.svg' alt = '' width = { 220 } height = { 180 } data-testid = 'quiz-success' />
142+ < Button
143+ data-testid = 'quiz-restart-button'
144+ priority = 'outline'
145+ onClick = { ( ) => {
146+ setAnswer ( undefined )
147+ setQuestion ( 0 )
148+ track ( 'Quiz' , 'Restart' , 'quiz_restart_button' )
149+ } } >
150+ { t ( 'restart' ) }
151+ </ Button >
152+ </ div >
153+ < QuizInfography />
154+ < div className = { styles . ressources } >
155+ < p > { t ( 'read-more' ) } </ p >
156+ < Resource
157+ image = '/images/fiches.png'
158+ text = 'fiches'
159+ href = '/kit/fiches.zip'
160+ withLink = 'Télécharger les 20 fiches'
161+ tracking = 'Quiz'
162+ />
163+ < Resource
164+ image = '/images/tools-transport.svg'
165+ text = 'ico2-transport'
166+ href = 'https://impactco2.fr/outils/transport'
167+ withLink = 'Simulateur Transports'
168+ tracking = 'Quiz'
169+ />
170+ < Resource
171+ image = '/images/tools-fruitsetlegumes.svg'
172+ text = 'ico2-fruitsetlegumes'
173+ href = 'https://impactco2.fr/outils/fruitsetlegumes'
174+ withLink = 'Fruits et légumes de saison'
175+ tracking = 'Quiz'
176+ />
177+ < Resource
178+ image = '/images/lvao.png'
179+ text = 'lvao'
180+ href = 'https://quefairedemesobjets.ademe.fr/?mtm_campaign=impactCO2'
181+ withLink = 'Longue Vie Aux Objets'
182+ tracking = 'Quiz'
183+ />
184+ < Resource
185+ image = '/images/ngc.png'
186+ text = 'ngc'
187+ href = 'https://nosgestesclimat.fr/'
188+ withLink = 'Nos Gestes Climat'
189+ tracking = 'Quiz'
190+ />
191+ </ div >
192+ < div className = { shareableStyles . separator } />
193+ </ >
194+ ) }
191195 { answer && (
192196 < div role = 'alert' aria-live = 'polite' >
193197 < button
0 commit comments