Skip to content

Commit 6d16e4f

Browse files
authored
Update BigOModals.js
1 parent e095cbe commit 6d16e4f

File tree

1 file changed

+37
-40
lines changed

1 file changed

+37
-40
lines changed

src/modals/BigOModals.js

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,59 @@ import React, { useState } from 'react';
22
import timeComplexities from '../time_complexities.json';
33

44
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+
);
915
};
1016

11-
const renderRows = (data) => {
17+
const renderRows = data => {
1218
if (!data) {
1319
return null;
1420
}
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>
2026
<table>
2127
<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+
))}
3435
</tbody>
3536
</table>
36-
</ul>
37-
);
38-
});
37+
</ul>
38+
);
39+
});
3940
};
4041

4142
const ToggleBlurCell = ({ text }) => {
42-
const [isBlurred, setIsBlurred] = useState(true);
43+
const [isBlurred, setIsBlurred] = useState(true);
4344

44-
const handleMouseEnter = () => {
45-
setIsBlurred(false);
46-
};
45+
const handleMouseEnter = () => {
46+
setIsBlurred(false);
47+
};
4748

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+
);
5654
};
5755

58-
59-
const Modals = (page) => {
60-
return renderRows(timeComplexities[page]);
56+
const Modals = page => {
57+
return renderRows(timeComplexities[page]);
6158
};
6259

6360
export default Modals;

0 commit comments

Comments
 (0)