@@ -31,72 +31,79 @@ class InputField extends Component {
3131
3232
3333 return (
34- < div className = "flex flex-col border-[1px]" >
34+ < div className = "flex flex-col border-[1px] bg-gray-100 " >
3535
36- < div className = { `flex items-center justify-around p-3 w-sreen gap-4 flex-wrap ${ this . name [ 0 ] + ' ' } ` } >
37- < div className = "flex flex-col justify-center items-center h-full sm:mb-0 cursor-pointer" >
38- < div className = "flex" >
39- < input placeholder = { `Array size (MAX ${ InputHandler . getAllowedMaxInputSize ( ) } )` } value = { inputArrayLength === 0 ? '' : inputArrayLength } onChange = { ( e ) => {
40- // SG 07/07/2022 21:03 Input validation, only accepts a number that is less than the allowed array size
41- ( Number ( e . target . value ) || ! e . target . value )
42- && ( e . target . value <= InputHandler . getAllowedMaxInputSize ( ) )
43- ? this . props . InputHandler . setState ( { inputArrayLength : e . target . value . replace ( / \D / g, '' ) } )
44- : this . props . InputHandler . setState ( { inputArrayLength : InputHandler . getAllowedMaxInputSize ( ) } )
45- } }
46- className = " bg-gray-200 rounded-md text-center p-[.5em] font-medium w-[57%] sm:w-100"
47- maximum = { InputHandler . getAllowedMaxInputSize ( ) }
48- />
49- < button onClick = { ( ) => {
50- this . props . InputHandler . setState ( { generatedArray : InputHandler . handleInputRequest ( inputArrayLength ) } ) ;
51- } } className = "bg-blue-300 p-2 ml-3 rounded-md text-white font-medium hover:scale-[1.02] hover:bg-blue-400 transition duration-200 ease-in-out" > Generate Array</ button >
52- </ div >
53- </ div >
36+ < div className = { `flex items-center justify-center p-3 w-sreen gap-4 flex-wrap ${ this . name [ 0 ] + ' ' } ` } >
5437
55- < div className = "w-[41em] overflow-auto flex gap-3 p-1 " >
38+ < div className = "w-[41em] overflow-auto flex gap-3 p-2 " >
5639 < div onClick = { ( ) => {
5740 this . Strategy . setStrategy = this . selectionSort ;
5841 this . setState ( { algorithm : 'Selection' } ) ;
5942 } }
60- className = { `cursor-pointer hover:scale-[1.02 ] transition-all duration-200 ease-in-out border-2 ${ algorithm === 'Selection' ? "bg-blue-100 border-blue-300" : "border-gray-300" } min-w-[150px] rounded-xl text-gray-600 flex flex-col p-3 items-center` } >
43+ className = { `cursor-pointer hover:scale-[1.05 ] transition-all duration-200 ease-in-out border-2 hover:bg-blue-200 hover:border-blue-300 ${ algorithm === 'Selection' ? "bg-blue-100 border-blue-300" : "border-gray-300 bg-white " } min-w-[150px] rounded-xl text-gray-600 flex flex-col p-3 items-center` } >
6144 < p className = "font-semibold" > Selection Sort</ p >
6245 </ div >
6346
6447 < div onClick = { ( ) => {
6548 this . Strategy . setStrategy = this . mergeSort ;
6649 this . setState ( { algorithm : 'Merge' } ) ;
6750 } }
68- className = { `cursor-pointer hover:scale-[1.02 ] transition-all duration-200 ease-in-out border-2 ${ algorithm === 'Merge' ? "bg-blue-100 border-blue-300" : "border-gray-300" } min-w-[150px] rounded-xl text-gray-600 flex flex-col p-3 items-center` } >
51+ className = { `cursor-pointer hover:scale-[1.05 ] transition-all duration-200 ease-in-out border-2 hover:bg-blue-200 hover:border-blue-300 ${ algorithm === 'Merge' ? "bg-blue-100 border-blue-300" : "border-gray-300 bg-white " } min-w-[150px] rounded-xl text-gray-600 flex flex-col p-3 items-center` } >
6952 < p className = "font-semibold" > Merge Sort</ p >
7053 </ div >
7154
7255 < div onClick = { ( ) => {
7356 this . Strategy . setStrategy = this . selectionSort ;
7457 this . setState ( { algorithm : 'Quick' } ) ;
7558 } }
76- className = { `cursor-pointer hover:scale-[1.02 ] transition-all duration-200 ease-in-out border-2 ${ algorithm === 'Quick' ? "bg-blue-100 border-blue-300" : "border-gray-300" } min-w-[150px] rounded-xl text-gray-600 flex flex-col p-3 items-center` } >
59+ className = { `cursor-pointer hover:scale-[1.05 ] transition-all duration-200 ease-in-out border-2 hover:bg-blue-200 hover:border-blue-300 ${ algorithm === 'Quick' ? "bg-blue-100 border-blue-300" : "border-gray-300 bg-white " } min-w-[150px] rounded-xl text-gray-600 flex flex-col p-3 items-center` } >
7760 < p className = "font-semibold" > Quick Sort</ p >
7861 </ div >
7962
8063 < div onClick = { ( ) => {
8164 this . Strategy . setStrategy = this . selectionSort ;
8265 this . setState ( { algorithm : 'Bubble' } ) ;
8366 } }
84- className = { `cursor-pointer hover:scale-[1.02 ] transition-all duration-200 ease-in-out border-2 ${ algorithm === 'Bubble' ? "bg-blue-100 border-blue-300" : "border-gray-300" } min-w-[150px] rounded-xl text-gray-600 flex flex-col p-3 items-center` } >
67+ className = { `cursor-pointer hover:scale-[1.05 ] transition-all duration-200 ease-in-out border-2 hover:bg-blue-200 hover:border-blue-300 ${ algorithm === 'Bubble' ? "bg-blue-100 border-blue-300" : "border-gray-300 bg-white " } min-w-[150px] rounded-xl text-gray-600 flex flex-col p-3 items-center` } >
8568 < p className = "font-semibold" > Bubble Sort</ p >
8669 </ div >
8770
88- </ div >
71+ </ div >
72+
73+ < div className = "flex flex-col justify-center items-center h-full sm:mb-0 cursor-pointer" >
74+ < div className = "flex" >
75+ < input placeholder = { `Array size (MAX ${ InputHandler . getAllowedMaxInputSize ( ) } )` } value = { inputArrayLength === 0 ? '' : inputArrayLength } onChange = { ( e ) => {
76+ // SG 07/07/2022 21:03 Input validation, only accepts a number that is less than the allowed array size
77+ ( Number ( e . target . value ) || ! e . target . value )
78+ && ( e . target . value <= InputHandler . getAllowedMaxInputSize ( ) )
79+ ? this . props . InputHandler . setState ( { inputArrayLength : e . target . value . replace ( / \D / g, '' ) } )
80+ : this . props . InputHandler . setState ( { inputArrayLength : InputHandler . getAllowedMaxInputSize ( ) } )
81+ } }
82+ className = " bg-gray-200 rounded-lg text-center p-[.7em] font-medium w-[57%] sm:w-100"
83+ maximum = { InputHandler . getAllowedMaxInputSize ( ) }
84+ />
85+ < button onClick = { ( ) => {
86+ this . props . InputHandler . setState ( { generatedArray : InputHandler . handleInputRequest ( inputArrayLength ) } ) ;
87+ } } className = "bg-blue-300 p-2 ml-3 rounded-lg text-white font-medium hover:scale-[1.02] hover:bg-blue-400 transition duration-200 ease-in-out" > Generate Array</ button >
88+ </ div >
89+ </ div >
8990
9091 < div className = "flex gap-10 flex-wrap justify-center" >
9192 < Options options = { this . props . InputHandler } algorithm = { algorithm } />
9293 < div className = "flex self-center gap-3" >
9394 < div onClick = { ( ) => {
94- this . Strategy . setOptions = options ;
95- this . Strategy . perform ( options , inputArray )
95+ if ( this . state . algorithm && inputArrayLength ) {
96+ window . scroll ( { // SG 07/10/2022 18:55 for mobile devices
97+ top : 1000 ,
98+ behavior : 'smooth'
99+ } ) ;
100+ this . Strategy . setOptions = options ;
101+ this . Strategy . perform ( options , inputArray )
102+ }
96103 }
97104 } className = { `relative min-w-[3.5em] p-3 group rounded-lg flex ${ this . state . algorithm && inputArrayLength ? "bg-green-600 cursor-pointer hover:shadow-custom-md-green transition-all duration-200 ease-in-out" : "bg-gray-600 cursor-not-allowed" } ` } >
98105 < p className = { `text-white font-semibold group-hover:opacity-0 ${ this . state . algorithm && "mr-9" } ` } > { this . state . algorithm && this . state . algorithm + " sort" } </ p >
99- < Play className = { `absolute right-[1em] transition-all duration-200 ease-in-out ${ this . state . algorithm && "group-hover:scale-[1.15] group-hover:right-[39 %]" } ` } />
106+ < Play className = { `absolute right-[1em] transition-all duration-200 ease-in-out ${ this . state . algorithm && "group-hover:scale-[1.15] group-hover:right-[40 %]" } ` } />
100107 </ div >
101108
102109 < div className = "self-center group" >
0 commit comments