Repository navigation
Expand file tree
/
Copy pathMainSortingCanvas.js
More file actions
78 lines (72 loc) · 2.57 KB
/
Copy pathMainSortingCanvas.js
File metadata and controls
78 lines (72 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React, { Component } from "react";
import { CONSTANTS } from "../../Utility/config";
import { InputHandler } from "../InputHandler/InputHandler";
import Navigation from "../Page/partial/Navbar/Navigation";
import { Canvas } from "./Canvas";
import { InputField } from "./InputField";
import "./main-canvas.css";
class MainCanvas extends Component {
constructor(props) {
super(props);
this.InputHandler = new InputHandler();
this.state = {
generatedArray: InputHandler.getGeneratedArray,
inputArrayLength: InputHandler.getGeneratedArray.length,
options: {
// SG 07/11/2022 12:36 load config from localStorage if exists
delay:
JSON.parse(localStorage.getItem("options"))?.delay || CONSTANTS.DELAY,
skipJ: JSON.parse(localStorage.getItem("options"))?.skipJ || false,
processingColor:
JSON.parse(localStorage.getItem("options"))?.processingColor ||
CONSTANTS.PROCESSING[0],
defaultBarColor:
JSON.parse(localStorage.getItem("options"))?.defaultBarColor ||
CONSTANTS.DEFAULT[0],
sortedBarColor:
JSON.parse(localStorage.getItem("options"))?.sortedBarColor ||
CONSTANTS.SORTED[0],
currentMinBarColor:
JSON.parse(localStorage.getItem("options"))?.currentMinBarColor ||
CONSTANTS.CURRENT_MIN[0],
showHeight:
JSON.parse(localStorage.getItem("options"))?.showHeight || false,
},
};
}
componentDidMount() {
const darkTheme = localStorage.getItem("theme") === "dark";
const options = JSON.parse(localStorage.getItem("options"));
// SG 07/16/2022 20:03 if option not provided and theme is dark, set default bar colro to white
if (darkTheme && !options?.defaultBarColor) {
this.setState({
options: { ...this.state.options, defaultBarColor: "white" },
});
}
window.addEventListener("resize", () => {
this.forceUpdate();
});
}
render() {
const { options, generatedArray } = this.state;
return (
<>
<Navigation themeToggle={true} />
<InputField
name={["generic-input", "instructions"]}
InputHandler={this}
generatedArray={generatedArray}
inputArray={generatedArray}
/>
<Canvas
defaultBarColor={this.state.options.defaultBarColor}
showHeight={this.state.options.showHeight}
generatedArray={this.state.generatedArray}
barColor={options.defaultBarColor}
InputHandler={this}
/>
</>
);
}
}
export default MainCanvas;