11import React from 'react' ;
22
3+ import cn from 'classnames' ;
34import upperCase from 'lodash/upperCase' ;
45import { useSelector } from 'react-redux' ;
56
@@ -19,8 +20,8 @@ const renderPlayerId = (id, verticalAlign) => (
1920 < span style = { { marginLeft : '-0.2em' , verticalAlign } } > { id } </ span >
2021) ;
2122
22- const renderImg = ( _id , imgStyle ) => (
23- < img style = { imgStyle } src = " /assets/images/clans/1 .png" alt = "И" />
23+ const renderImg = ( id , imgStyle ) => (
24+ id ? < img style = { imgStyle } src = { ` /assets/images/clans/${ id || 1 } .png` } alt = "И" /> : < > < />
2425) ;
2526
2627function StreamFullPanel ( {
@@ -34,6 +35,11 @@ function StreamFullPanel({
3435 outputDataFontSize,
3536 nameLineHeight,
3637 headerVerticalAlign,
38+ testBarMarginBottom,
39+ testBarFontSize,
40+ testBarHeight,
41+ testBarWinGifTop,
42+ testBarProgressGifTop,
3743} ) {
3844 const leftEditor = useSelector ( leftEditorSelector ( roomMachineState ) ) ;
3945 const rightEditor = useSelector ( rightEditorSelector ( roomMachineState ) ) ;
@@ -95,14 +101,17 @@ function StreamFullPanel({
95101 const args = assert ? JSON . stringify ( assert . arguments ) : '' ;
96102 const expected = assert ? JSON . stringify ( assert . expected ) : '' ;
97103
98- console . log ( leftOutput , rightOutput ) ;
104+ const isWinnerLeft = leftOutput ?. status === 'ok' ;
105+ const isWinnerRight = rightOutput ?. status === 'ok' ;
99106
100107 return (
101108 < div className = "d-flexflex-column w-100 h-100 cb-stream-full-info" >
102109 < div className = "d-flex w-100 justify-content-between py-3 px-4" style = { { height : '25%' , minHeight : '25%' , maxHeight : '25%' } } >
103110 < div >
104111 < div className = "cb-stream-tasks-stats cb-stream-full-task-stats cb-stream-widget-text italic" >
105- < span style = { { verticalAlign : headerVerticalAlign , fontSize : taskHeaderFontSize } } > 3/8 Задача</ span >
112+ < span style = { { verticalAlign : headerVerticalAlign , fontSize : taskHeaderFontSize } } >
113+ { `${ ( game ?. task ?. id || 1 ) % 21 } /21 ЗАДАЧ` }
114+ </ span >
106115 </ div >
107116 </ div >
108117 < div style = { { fontSize : descriptionFontSize } } className = "cb-stream-task-description h-100 w-100 px-4" >
@@ -114,7 +123,7 @@ function StreamFullPanel({
114123 < span > Входные</ span >
115124 < span > данные</ span >
116125 </ div >
117- < div className = "d-flex align-items-center pl-2 cb-stream-output-data" style = { { fontSize : outputDataFontSize } } >
126+ < div className = "d-flex align-items-center pl-3 cb-stream-output-data" style = { { fontSize : outputDataFontSize } } >
118127 { args }
119128 </ div >
120129 </ div >
@@ -123,31 +132,46 @@ function StreamFullPanel({
123132 < span > Ожидаемые</ span >
124133 < span > данные</ span >
125134 </ div >
126- < div className = "d-flex align-items-center pl-2 cb-stream-output-data" style = { { fontSize : outputDataFontSize } } >
135+ < div className = "d-flex align-items-center pl-3 cb-stream-output-data" style = { { fontSize : outputDataFontSize } } >
127136 { expected }
128137 </ div >
129138 </ div >
130139 </ div >
131140 </ div >
132- < div className = "d-flex w-100 h-100 cb-stream-full-editors" >
133- < div className = "cb-stream-full-editor position-relative editor-left p-2" style = { { width : '35%' } } >
141+ < div className = "d-flex w-100 cb-stream-full-editors" style = { { height : '75%' , minHeight : '75%' , maxHeight : '75%' } } >
142+ < div
143+ className = {
144+ cn (
145+ 'cb-stream-full-editor position-relative editor-left p-2' ,
146+ { winner : isWinnerLeft } ,
147+ )
148+ }
149+ style = { { width : '35%' } }
150+ >
134151 < div className = "d-flex align-items-center p-2" style = { { fontSize : taskHeaderFontSize } } >
135152 < div
136- className = "d-flex position-relative align-items-center justify-content-center cb-stream-player-number cb-stream-widget-text italic"
153+ className = {
154+ cn (
155+ 'd-flex position-relative align-items-center justify-content-center' ,
156+ 'cb-stream-player-number cb-stream-widget-text italic' ,
157+ )
158+ }
137159 style = { imgStyle }
138160 >
139161 { renderPlayerId ( leftEditor ?. playerId , headerVerticalAlign ) }
140162 </ div >
141163 < div className = "cb-stream-player-clan h-100 position-relative mr-3" >
142164 { /* {player?.clanId && ( */ }
143- { renderImg ( leftPlayer ?. clanId , imgStyle ) }
165+ { renderImg ( leftPlayer ?. clanId , imgStyle , isWinnerLeft ) }
144166 { /* )} */ }
145167 </ div >
146168 < div
147- className = "d-flex flex-column cb-stream-name cb-stream-widget-text"
169+ className = { cn (
170+ 'd-flex flex-column cb-stream-name cb-stream-widget-text' ,
171+ ) }
148172 style = { { verticalAlign : headerVerticalAlign } }
149173 >
150- { ( 'Фамилия Имя' ) . split ( ' ' ) . map ( str => (
174+ { ( leftPlayer ?. name || 'Фамилия Имя' ) . split ( ' ' ) . map ( str => (
151175 < div
152176 key = { str }
153177 style = { { lineHeight : nameLineHeight } }
@@ -161,38 +185,63 @@ function StreamFullPanel({
161185 < ExtendedEditor { ...editorLeftParams } />
162186 </ div >
163187 { leftOutput && (
164- < div style = { { marginRight : '-10px' } } className = "d-flex cb-stream-full-solution-bar position-absolute" >
165- < div className = "d-flex w-100 justify-content-between" >
166- < div />
167- < div
168- style = { { fontSize : taskHeaderFontSize } }
169- className = "d-flex align-items-center cb-stream-widget-text italic mr-2"
170- >
171- { `${ leftOutput . successCount } /${ leftOutput . assertsCount || 100 } ` }
188+ < div
189+ style = { { bottom : '12%' , marginLeft : '-0.3em' , height : testBarHeight } }
190+ className = { cn ( 'd-flex cb-stream-full-solution-bar position-absolute' ) }
191+ >
192+ < div className = "d-flex w-100 position-relative" >
193+ < div className = "d-flex w-100 justify-content-end" >
194+ < div
195+ style = { { fontSize : testBarFontSize } }
196+ className = "d-flex align-items-center cb-stream-widget-text italic mr-2 inverted-bar"
197+ >
198+ { `${ Math . round ( ( leftOutput . successCount || 0 ) / ( leftOutput . assertsCount / 1 ) ) } /100` }
199+ </ div >
172200 </ div >
201+ < img
202+ alt = "И"
203+ src = { isWinnerLeft ? '/assets/images/stream/win_bv.png' : '/assets/images/stream/progress.png' }
204+ className = "position-absolute"
205+ style = { { top : ( isWinnerLeft ? testBarWinGifTop : testBarProgressGifTop ) , left : '-30px' } }
206+ />
173207 </ div >
174208 </ div >
175209 ) }
176210 </ div >
177211 < div className = "px-2" style = { { width : '30%' } } />
178- < div className = "cb-stream-full-editor position-relative editor-right p-2" style = { { width : '35%' } } >
212+ < div
213+ className = { cn (
214+ 'cb-stream-full-editor position-relative editor-right p-2' ,
215+ { winner : isWinnerRight } ,
216+ ) }
217+ style = { { width : '35%' } }
218+ >
179219 < div className = "d-flex align-items-center p-2" style = { { fontSize : taskHeaderFontSize } } >
180220 < div
181- className = "d-flex position-relative align-items-center justify-content-center cb-stream-player-number cb-stream-widget-text italic"
221+ className = {
222+ cn (
223+ 'd-flex position-relative align-items-center justify-content-center' ,
224+ 'cb-stream-player-number cb-stream-widget-text italic' ,
225+ )
226+ }
182227 style = { imgStyle }
183228 >
184229 { renderPlayerId ( rightEditor ?. playerId , headerVerticalAlign ) }
185230 </ div >
186231 < div className = "cb-stream-player-clan h-100 position-relative mr-3" >
187232 { /* {player?.clanId && ( */ }
188- { renderImg ( rightPlayer ?. clanId , imgStyle ) }
233+ { renderImg ( rightPlayer ?. clanId , imgStyle , isWinnerRight ) }
189234 { /* )} */ }
190235 </ div >
191236 < div
192- className = "d-flex flex-column cb-stream-name cb-stream-widget-text"
237+ className = {
238+ cn (
239+ 'd-flex flex-column cb-stream-name cb-stream-widget-text' ,
240+ )
241+ }
193242 style = { { verticalAlign : headerVerticalAlign } }
194243 >
195- { ( 'Фамилия Имя' ) . split ( ' ' ) . map ( str => (
244+ { ( rightPlayer ?. name || 'Фамилия Имя' ) . split ( ' ' ) . map ( str => (
196245 < div
197246 key = { str }
198247 style = { { lineHeight : nameLineHeight } }
@@ -206,15 +255,25 @@ function StreamFullPanel({
206255 < ExtendedEditor { ...editorRightParams } />
207256 </ div >
208257 { rightOutput && (
209- < div style = { { marginLeft : '-10px' } } className = "d-flex cb-stream-full-solution-bar position-absolute" >
210- < div className = "d-flex w-100 justify-content-between" >
211- < div />
212- < div
213- style = { { fontSize : taskHeaderFontSize } }
214- className = "d-flex align-items-center cb-stream-widget-text italic mr-2"
215- >
216- { `${ rightOutput . successCount } /${ rightOutput . assertsCount || 100 } ` }
258+ < div
259+ style = { { bottom : '12%' , marginLeft : '-0.7em' , height : testBarHeight } }
260+ className = { cn ( 'd-flex cb-stream-full-solution-bar position-absolute' ) }
261+ >
262+ < div className = "d-flex w-100 position-relative" >
263+ < div className = "d-flex w-100 justify-content-end" >
264+ < div
265+ style = { { fontSize : testBarFontSize } }
266+ className = "d-flex align-items-center cb-stream-widget-text italic inverted-bar mr-2"
267+ >
268+ { `${ Math . round ( ( rightOutput . successCount || 0 ) / ( rightOutput . assertsCount || 1 ) ) } /100` }
269+ </ div >
217270 </ div >
271+ < img
272+ alt = "И"
273+ src = { isWinnerRight ? '/assets/images/stream/win_bv.png' : '/assets/images/stream/progress.png' }
274+ className = "position-absolute"
275+ style = { { top : ( isWinnerRight ? testBarWinGifTop : testBarProgressGifTop ) , left : '-30px' } }
276+ />
218277 </ div >
219278 </ div >
220279 ) }
0 commit comments