1- import ' ./main-canvas.css' ;
2- import React , { Component } from ' react'
3- import { InputHandler } from ' ../InputHandler/InputHandler' ;
4- import { Canvas } from ' ./Canvas' ;
5- import { InputField } from ' ./InputField' ;
6- import { CONSTANTS } from ' ../../Utility/config'
7- import Navigation from ' ../Page/partial/Navbar/Navigation' ;
8-
1+ import " ./main-canvas.css" ;
2+ import React , { Component } from " react" ;
3+ import { InputHandler } from " ../InputHandler/InputHandler" ;
4+ import { Canvas } from " ./Canvas" ;
5+ import { InputField } from " ./InputField" ;
6+ import { CONSTANTS } from " ../../Utility/config" ;
7+ import Navigation from " ../Page/partial/Navbar/Navigation" ;
8+ import { Animation } from "../Animation/Animation" ;
99
1010class MainCanvas extends Component {
1111 constructor ( props ) {
1212 super ( props ) ;
1313 this . InputHandler = new InputHandler ( ) ;
14- this . state = {
14+ this . state = {
1515 generatedArray : InputHandler . getGeneratedArray ,
1616 inputArrayLength : InputHandler . getGeneratedArray . length ,
17- options : { // SG 07/11/2022 12:36 load config from localStorage if exists
18- delay : JSON . parse ( localStorage . getItem ( 'options' ) ) ?. delay || CONSTANTS . DELAY ,
19- skipJ : JSON . parse ( localStorage . getItem ( 'options' ) ) ?. skipJ || false ,
20- processingColor : JSON . parse ( localStorage . getItem ( 'options' ) ) ?. processingColor || CONSTANTS . PROCESSING [ 0 ] ,
21- defaultBarColor : JSON . parse ( localStorage . getItem ( 'options' ) ) ?. defaultBarColor || CONSTANTS . DEFAULT [ 0 ] ,
22- sortedBarColor : JSON . parse ( localStorage . getItem ( 'options' ) ) ?. sortedBarColor || CONSTANTS . SORTED [ 0 ] ,
23- currentMinBarColor : JSON . parse ( localStorage . getItem ( 'options' ) ) ?. currentMinBarColor || CONSTANTS . CURRENT_MIN [ 0 ] ,
24- showHeight : JSON . parse ( localStorage . getItem ( 'options' ) ) ?. showHeight || false
25- }
17+ options : {
18+ // SG 07/11/2022 12:36 load config from localStorage if exists
19+ delay :
20+ JSON . parse ( localStorage . getItem ( "options" ) ) ?. delay || CONSTANTS . DELAY ,
21+ skipJ : JSON . parse ( localStorage . getItem ( "options" ) ) ?. skipJ || false ,
22+ processingColor :
23+ JSON . parse ( localStorage . getItem ( "options" ) ) ?. processingColor ||
24+ CONSTANTS . PROCESSING [ 0 ] ,
25+ defaultBarColor :
26+ JSON . parse ( localStorage . getItem ( "options" ) ) ?. defaultBarColor ||
27+ CONSTANTS . DEFAULT [ 0 ] ,
28+ sortedBarColor :
29+ JSON . parse ( localStorage . getItem ( "options" ) ) ?. sortedBarColor ||
30+ CONSTANTS . SORTED [ 0 ] ,
31+ currentMinBarColor :
32+ JSON . parse ( localStorage . getItem ( "options" ) ) ?. currentMinBarColor ||
33+ CONSTANTS . CURRENT_MIN [ 0 ] ,
34+ showHeight :
35+ JSON . parse ( localStorage . getItem ( "options" ) ) ?. showHeight || false ,
36+ } ,
2637 } ;
2738 }
2839
2940 componentDidMount ( ) {
30- const darkTheme = localStorage . getItem ( 'theme' ) === "dark" ;
31- const options = JSON . parse ( localStorage . getItem ( 'options' ) ) ;
32-
33- // SG 07/16/2022 20:03 if option not provided and theme is dark, set default bar colro to white
34- if ( darkTheme && ! options ?. defaultBarColor ) {
35- this . setState ( { options : { ...this . state . options , defaultBarColor : 'white' } } )
41+ const darkTheme = localStorage . getItem ( "theme" ) === "dark" ;
42+ const options = JSON . parse ( localStorage . getItem ( "options" ) ) ;
43+
44+ // SG 07/16/2022 20:03 if option not provided and theme is dark, set default bar colro to white
45+ if ( darkTheme && ! options ?. defaultBarColor ) {
46+ this . setState ( {
47+ options : { ...this . state . options , defaultBarColor : "white" } ,
48+ } ) ;
3649 }
3750 }
3851
39-
4052 render ( ) {
4153 const { options, generatedArray } = this . state ;
42-
54+
4355 return (
4456 < >
45- < Navigation themeToggle = { true } />
46- < InputField name = { [ 'generic-input' , 'instructions' ] } InputHandler = { this } generatedArray = { generatedArray } inputArray = { generatedArray } />
47- < Canvas defaultBarColor = { this . state . options . defaultBarColor } showHeight = { this . state . options . showHeight } generatedArray = { this . state . generatedArray } barColor = { options . defaultBarColor } InputHandler = { this } />
57+ < Navigation themeToggle = { true } />
58+ < InputField
59+ name = { [ "generic-input" , "instructions" ] }
60+ InputHandler = { this }
61+ generatedArray = { generatedArray }
62+ inputArray = { generatedArray }
63+ />
64+ < Canvas
65+ defaultBarColor = { this . state . options . defaultBarColor }
66+ showHeight = { this . state . options . showHeight }
67+ generatedArray = { this . state . generatedArray }
68+ barColor = { options . defaultBarColor }
69+ InputHandler = { this }
70+ />
4871 </ >
49- )
72+ ) ;
5073 }
5174}
5275
53-
54-
55- export default MainCanvas ;
76+ export default MainCanvas ;
0 commit comments