1
1
import React from 'react' ;
2
2
3
+ import cn from 'classnames' ;
3
4
import upperCase from 'lodash/upperCase' ;
4
5
import { useSelector } from 'react-redux' ;
5
6
@@ -19,8 +20,8 @@ const renderPlayerId = (id, verticalAlign) => (
19
20
< span style = { { marginLeft : '-0.2em' , verticalAlign } } > { id } </ span >
20
21
) ;
21
22
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 = "И" /> : < > < />
24
25
) ;
25
26
26
27
function StreamFullPanel ( {
@@ -34,6 +35,11 @@ function StreamFullPanel({
34
35
outputDataFontSize,
35
36
nameLineHeight,
36
37
headerVerticalAlign,
38
+ testBarMarginBottom,
39
+ testBarFontSize,
40
+ testBarHeight,
41
+ testBarWinGifTop,
42
+ testBarProgressGifTop,
37
43
} ) {
38
44
const leftEditor = useSelector ( leftEditorSelector ( roomMachineState ) ) ;
39
45
const rightEditor = useSelector ( rightEditorSelector ( roomMachineState ) ) ;
@@ -95,14 +101,17 @@ function StreamFullPanel({
95
101
const args = assert ? JSON . stringify ( assert . arguments ) : '' ;
96
102
const expected = assert ? JSON . stringify ( assert . expected ) : '' ;
97
103
98
- console . log ( leftOutput , rightOutput ) ;
104
+ const isWinnerLeft = leftOutput ?. status === 'ok' ;
105
+ const isWinnerRight = rightOutput ?. status === 'ok' ;
99
106
100
107
return (
101
108
< div className = "d-flexflex-column w-100 h-100 cb-stream-full-info" >
102
109
< div className = "d-flex w-100 justify-content-between py-3 px-4" style = { { height : '25%' , minHeight : '25%' , maxHeight : '25%' } } >
103
110
< div >
104
111
< 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 >
106
115
</ div >
107
116
</ div >
108
117
< div style = { { fontSize : descriptionFontSize } } className = "cb-stream-task-description h-100 w-100 px-4" >
@@ -114,7 +123,7 @@ function StreamFullPanel({
114
123
< span > Входные</ span >
115
124
< span > данные</ span >
116
125
</ 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 } } >
118
127
{ args }
119
128
</ div >
120
129
</ div >
@@ -123,31 +132,46 @@ function StreamFullPanel({
123
132
< span > Ожидаемые</ span >
124
133
< span > данные</ span >
125
134
</ 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 } } >
127
136
{ expected }
128
137
</ div >
129
138
</ div >
130
139
</ div >
131
140
</ 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
+ >
134
151
< div className = "d-flex align-items-center p-2" style = { { fontSize : taskHeaderFontSize } } >
135
152
< 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
+ }
137
159
style = { imgStyle }
138
160
>
139
161
{ renderPlayerId ( leftEditor ?. playerId , headerVerticalAlign ) }
140
162
</ div >
141
163
< div className = "cb-stream-player-clan h-100 position-relative mr-3" >
142
164
{ /* {player?.clanId && ( */ }
143
- { renderImg ( leftPlayer ?. clanId , imgStyle ) }
165
+ { renderImg ( leftPlayer ?. clanId , imgStyle , isWinnerLeft ) }
144
166
{ /* )} */ }
145
167
</ div >
146
168
< 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
+ ) }
148
172
style = { { verticalAlign : headerVerticalAlign } }
149
173
>
150
- { ( 'Фамилия Имя' ) . split ( ' ' ) . map ( str => (
174
+ { ( leftPlayer ?. name || 'Фамилия Имя' ) . split ( ' ' ) . map ( str => (
151
175
< div
152
176
key = { str }
153
177
style = { { lineHeight : nameLineHeight } }
@@ -161,38 +185,63 @@ function StreamFullPanel({
161
185
< ExtendedEditor { ...editorLeftParams } />
162
186
</ div >
163
187
{ 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 >
172
200
</ 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
+ />
173
207
</ div >
174
208
</ div >
175
209
) }
176
210
</ div >
177
211
< 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
+ >
179
219
< div className = "d-flex align-items-center p-2" style = { { fontSize : taskHeaderFontSize } } >
180
220
< 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
+ }
182
227
style = { imgStyle }
183
228
>
184
229
{ renderPlayerId ( rightEditor ?. playerId , headerVerticalAlign ) }
185
230
</ div >
186
231
< div className = "cb-stream-player-clan h-100 position-relative mr-3" >
187
232
{ /* {player?.clanId && ( */ }
188
- { renderImg ( rightPlayer ?. clanId , imgStyle ) }
233
+ { renderImg ( rightPlayer ?. clanId , imgStyle , isWinnerRight ) }
189
234
{ /* )} */ }
190
235
</ div >
191
236
< 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
+ }
193
242
style = { { verticalAlign : headerVerticalAlign } }
194
243
>
195
- { ( 'Фамилия Имя' ) . split ( ' ' ) . map ( str => (
244
+ { ( rightPlayer ?. name || 'Фамилия Имя' ) . split ( ' ' ) . map ( str => (
196
245
< div
197
246
key = { str }
198
247
style = { { lineHeight : nameLineHeight } }
@@ -206,15 +255,25 @@ function StreamFullPanel({
206
255
< ExtendedEditor { ...editorRightParams } />
207
256
</ div >
208
257
{ 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 >
217
270
</ 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
+ />
218
277
</ div >
219
278
</ div >
220
279
) }
0 commit comments