@@ -75,8 +75,7 @@ function parseTimeComplexity(description: string): Entry[] {
7575 if ( ! blockMatch ) return entries
7676 const block = blockMatch [ 0 ]
7777
78- const oRe = ( prefix : string ) =>
79- new RegExp ( `${ prefix } :\\s*(O\\((?:[^()]+|\\([^)]*\\))*\\))` , 'i' )
78+ const oRe = ( prefix : string ) => new RegExp ( `${ prefix } :\\s*(O\\((?:[^()]+|\\([^)]*\\))*\\))` , 'i' )
8079
8180 const best = block . match ( oRe ( isSpanish ? 'Mejor' : 'Best' ) )
8281 const avg = block . match ( oRe ( isSpanish ? 'Promedio' : 'Average' ) )
@@ -85,15 +84,28 @@ function parseTimeComplexity(description: string): Entry[] {
8584 if ( best || avg || worst ) {
8685 if ( best ) {
8786 const k = normalizeToKey ( best [ 1 ] )
88- if ( k ) entries . push ( { label : isSpanish ? 'Mejor' : 'Best' , raw : best [ 1 ] , key : k , color : '#34d399' } )
87+ if ( k )
88+ entries . push ( {
89+ label : isSpanish ? 'Mejor' : 'Best' ,
90+ raw : best [ 1 ] ,
91+ key : k ,
92+ color : '#34d399' ,
93+ } )
8994 }
9095 if ( avg ) {
9196 const k = normalizeToKey ( avg [ 1 ] )
92- if ( k ) entries . push ( { label : isSpanish ? 'Prom' : 'Avg' , raw : avg [ 1 ] , key : k , color : '#fbbf24' } )
97+ if ( k )
98+ entries . push ( { label : isSpanish ? 'Prom' : 'Avg' , raw : avg [ 1 ] , key : k , color : '#fbbf24' } )
9399 }
94100 if ( worst ) {
95101 const k = normalizeToKey ( worst [ 1 ] )
96- if ( k ) entries . push ( { label : isSpanish ? 'Peor' : 'Worst' , raw : worst [ 1 ] , key : k , color : '#f87171' } )
102+ if ( k )
103+ entries . push ( {
104+ label : isSpanish ? 'Peor' : 'Worst' ,
105+ raw : worst [ 1 ] ,
106+ key : k ,
107+ color : '#f87171' ,
108+ } )
97109 }
98110 } else {
99111 const single = block . match ( O_RE )
@@ -162,7 +174,13 @@ function resolveOverlaps(
162174 return sorted
163175}
164176
165- export default function ComplexityChart ( { description, locale = 'en' } : { description : string ; locale ?: string } ) {
177+ export default function ComplexityChart ( {
178+ description,
179+ locale = 'en' ,
180+ } : {
181+ description : string
182+ locale ?: string
183+ } ) {
166184 const entries = useMemo ( ( ) => parseTimeComplexity ( description ) , [ description ] )
167185
168186 if ( entries . length === 0 ) return null
@@ -179,7 +197,12 @@ export default function ComplexityChart({ description, locale = 'en' }: { descri
179197 const labels : { y : number ; text : string ; color : string ; opacity : number } [ ] = [ ]
180198 for ( const key of REFERENCE_KEYS ) {
181199 if ( ! highlightedKeys . has ( key ) ) {
182- labels . push ( { y : endY ( COMPLEXITY_FNS [ key ] ) , text : key , color : '#fff' , opacity : 0.18 } )
200+ labels . push ( {
201+ y : endY ( COMPLEXITY_FNS [ key ] ) ,
202+ text : key ,
203+ color : 'var(--foreground)' ,
204+ opacity : 0.18 ,
205+ } )
183206 }
184207 }
185208 for ( const [ key , group ] of grouped ) {
@@ -300,10 +323,7 @@ export default function ComplexityChart({ description, locale = 'en' }: { descri
300323 < div className = "flex flex-wrap gap-x-4 gap-y-1 mt-2" >
301324 { entries . map ( ( e , i ) => (
302325 < div key = { i } className = "flex items-center gap-1.5" >
303- < div
304- className = "w-3 h-0.5 rounded-full shrink-0"
305- style = { { backgroundColor : e . color } }
306- />
326+ < div className = "w-3 h-0.5 rounded-full shrink-0" style = { { backgroundColor : e . color } } />
307327 < span className = "text-[10px] text-neutral-500" >
308328 { e . label ? `${ e . label } : ` : '' }
309329 < span className = "font-mono text-neutral-400" > { e . raw } </ span >
0 commit comments