@@ -10,6 +10,44 @@ const SORT_OPTIONS = [
1010 { value : "name-asc" , label : "Nazwa (A-Z)" } ,
1111] ;
1212
13+ const RATING_COLORS = {
14+ 800 : "#919191" ,
15+ 1600 : "#5bcfa2" ,
16+ 2600 : "#6de2e8" ,
17+ 3200 : "#775cd1" ,
18+ 4000 : "#ffd56b" ,
19+ 5000 : "#fcae65" ,
20+ 6000 : "#ed9a93" ,
21+ 8001 : "#ffffff"
22+ } ;
23+
24+ function getRatingInfo ( rating ) {
25+ const thresholds = Object . keys ( RATING_COLORS )
26+ . map ( Number )
27+ . sort ( ( a , b ) => a - b ) ;
28+
29+ let current = thresholds [ 0 ] ;
30+ let next = null ;
31+
32+ for ( let i = 0 ; i < thresholds . length ; i ++ ) {
33+ if ( rating >= thresholds [ i ] ) {
34+ current = thresholds [ i ] ;
35+ next = thresholds [ i + 1 ] ?? null ;
36+ } else {
37+ break ;
38+ }
39+ }
40+
41+ const progress = next
42+ ? ( rating - current ) / ( next - current )
43+ : 1 ;
44+
45+ return {
46+ color : RATING_COLORS [ current ] ,
47+ progress : Math . max ( 0 , Math . min ( progress , 1 ) ) ,
48+ } ;
49+ }
50+
1351const getText = ( value ) => {
1452 if ( typeof value === "string" ) {
1553 return value ;
@@ -192,14 +230,29 @@ const ListWidget = ({ dataUrl = DEFAULT_RESULTS_URL, embedded = false }) => {
192230 { ! loading && ! error ? (
193231 < div className = "oi-list-results" >
194232 { visibleProblems . map ( ( problem ) => {
233+ const { color, progress } = getRatingInfo ( problem . rating ) ;
234+
195235 const content = (
196236 < >
197- < span className = "oi-list-item__name" > { problem . name } </ span >
237+ < div className = "oi-list-item__header" >
238+ < span className = "oi-list-item__name" > { problem . name } </ span >
239+ < div className = "oi-list-item__rating" >
240+ < span style = { { color : color } } > { problem . rating } </ span >
241+ < div
242+ className = "oi-list-rating-circle"
243+ style = { {
244+ "--fill" : `${ progress * 100 } %` ,
245+ "--color" : color ,
246+ } }
247+ >
248+ < div className = "oi-list-rating-circle__fill" />
249+ </ div >
250+ </ div >
251+ </ div >
198252 < span className = "oi-list-item__tags" >
199253 < code > { problem . code || "N/A" } </ code >
200254 < span > etap { problem . stage || "?" } </ span >
201255 < span > edycja { problem . year || "?" } </ span >
202- < span > rating { problem . rating || 0 } </ span >
203256 </ span >
204257 { problem . url ? (
205258 < svg
0 commit comments