@@ -2,62 +2,59 @@ import React, { useState } from 'react';
2
2
import timeComplexities from '../time_complexities.json' ;
3
3
4
4
const applyEquationClass = ( text , force ) => {
5
- const regex = / \$ ( .* ?) \$ / g;
6
- return text . split ( regex ) . map ( ( part , index ) =>
7
- index % 2 === 1 || force ? < span key = { index } className = "equation" > { part } </ span > : part
8
- ) ;
5
+ const regex = / \$ ( .* ?) \$ / g;
6
+ return text . split ( regex ) . map ( ( part , index ) =>
7
+ index % 2 === 1 || force ? (
8
+ < span key = { index } className = "equation" >
9
+ { part }
10
+ </ span >
11
+ ) : (
12
+ part
13
+ ) ,
14
+ ) ;
9
15
} ;
10
16
11
- const renderRows = ( data ) => {
17
+ const renderRows = data => {
12
18
if ( ! data ) {
13
19
return null ;
14
20
}
15
- return Object . keys ( data ) . map ( ( operation ) => {
16
- const operationData = data [ operation ] ;
17
- return (
18
- < ul key = { operation } >
19
- < h4 > { data [ operation ] . name } </ h4 >
21
+ return Object . keys ( data ) . map ( operation => {
22
+ const operationData = data [ operation ] ;
23
+ return (
24
+ < ul key = { operation } >
25
+ < h4 > { operation } </ h4 >
20
26
< table >
21
27
< tbody >
22
- {
23
- Object . keys ( operationData ) . map ( ( complexity ) => {
24
- if ( complexity === 'name' ) return null ;
25
- return (
26
- < tr key = { complexity } >
27
- < td > { complexity [ 0 ] . toUpperCase ( ) + complexity . slice ( 1 ) } </ td >
28
- < ToggleBlurCell text = { operationData [ complexity ] . big_o } />
29
- < td > { applyEquationClass ( operationData [ complexity ] . explanation ) } </ td >
30
- </ tr >
31
- )
32
- } )
33
- }
28
+ { Object . keys ( operationData ) . map ( complexity => (
29
+ < tr key = { complexity } >
30
+ < td style = { { width : '13%' } } > { complexity [ 0 ] . toUpperCase ( ) + complexity . slice ( 1 ) } </ td >
31
+ < ToggleBlurCell text = { operationData [ complexity ] . big_o } />
32
+ < td > { applyEquationClass ( operationData [ complexity ] . explanation ) } </ td >
33
+ </ tr >
34
+ ) ) }
34
35
</ tbody >
35
36
</ table >
36
- </ ul >
37
- ) ;
38
- } ) ;
37
+ </ ul >
38
+ ) ;
39
+ } ) ;
39
40
} ;
40
41
41
42
const ToggleBlurCell = ( { text } ) => {
42
- const [ isBlurred , setIsBlurred ] = useState ( true ) ;
43
+ const [ isBlurred , setIsBlurred ] = useState ( true ) ;
43
44
44
- const handleMouseEnter = ( ) => {
45
- setIsBlurred ( false ) ;
46
- } ;
45
+ const handleMouseEnter = ( ) => {
46
+ setIsBlurred ( false ) ;
47
+ } ;
47
48
48
- return (
49
- < td
50
- className = { isBlurred ? 'blur' : '' }
51
- onMouseEnter = { handleMouseEnter }
52
- >
53
- { applyEquationClass ( text , true ) }
54
- </ td >
55
- ) ;
49
+ return (
50
+ < td style = { { width : '10%' } } className = { isBlurred ? 'blur' : '' } onMouseEnter = { handleMouseEnter } >
51
+ { applyEquationClass ( text , true ) }
52
+ </ td >
53
+ ) ;
56
54
} ;
57
55
58
-
59
- const Modals = ( page ) => {
60
- return renderRows ( timeComplexities [ page ] ) ;
56
+ const Modals = page => {
57
+ return renderRows ( timeComplexities [ page ] ) ;
61
58
} ;
62
59
63
60
export default Modals ;
0 commit comments