@@ -29,7 +29,7 @@ class InputField extends Component {
2929 < div className = "flex flex-col" >
3030
3131 < div className = { `flex items-center justify-around p-3 w-sreen gap-4 flex-wrap ${ this . name [ 0 ] + ' ' } ` } >
32- < div className = "flex flex-col justify-center items-center h-full sm:mb-0" >
32+ < div className = "flex flex-col justify-center items-center h-full sm:mb-0 cursor-pointer " >
3333 < div className = "flex" >
3434 < input placeholder = { `Array size (MAX ${ InputHandler . getAllowedMaxInputSize ( ) } )` } value = { inputArrayLength === 0 ? '' : inputArrayLength } onChange = { ( e ) => {
3535 // SG 07/07/2022 21:03 Input validation, only accepts a number that is less than the allowed array size
@@ -51,40 +51,40 @@ class InputField extends Component {
5151 < div className = "w-[41em] overflow-auto flex gap-3 p-1" >
5252 < div onClick = { ( ) => {
5353 this . Strategy . setStrategy = this . selectionSort ;
54- this . selectionSort . setOptions = options ;
54+
5555 this . setState ( { algorithm : 'selection' } ) ;
5656 } }
57- className = { `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` } >
57+ 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` } >
5858
5959 < p className = "font-semibold" > Selection Sort</ p >
6060 </ div >
6161
6262 < div onClick = { ( ) => {
6363 this . Strategy . setStrategy = this . selectionSort ;
64- this . selectionSort . setOptions = options ;
64+
6565 this . setState ( { algorithm : 'merge' } ) ;
6666 } }
67- className = { `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` } >
67+ 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` } >
6868
6969 < p className = "font-semibold" > Merge Sort</ p >
7070 </ div >
7171
7272 < div onClick = { ( ) => {
7373 this . Strategy . setStrategy = this . selectionSort ;
74- this . selectionSort . setOptions = options ;
74+
7575 this . setState ( { algorithm : 'quick' } ) ;
7676 } }
77- className = { `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` } >
77+ 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` } >
7878
7979 < p className = "font-semibold" > Quick Sort</ p >
8080 </ div >
8181
8282 < div onClick = { ( ) => {
8383 this . Strategy . setStrategy = this . selectionSort ;
84- this . selectionSort . setOptions = options ;
84+
8585 this . setState ( { algorithm : 'bubble' } ) ;
8686 } }
87- className = { `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` } >
87+ 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` } >
8888 < p className = "font-semibold" > Bubble Sort</ p >
8989 </ div >
9090
@@ -94,7 +94,10 @@ class InputField extends Component {
9494 </ div >
9595
9696 < div className = "flex self-center group gap-3" >
97- < div onClick = { ( ) => this . Strategy . perform ( options ) } className = { `p-3 rounded-lg flex ${ this . state . algorithm ? "bg-green-600 cursor-pointer hover:bg-green-700" : "bg-gray-600" } ` } >
97+ < div onClick = { async ( ) => {
98+ this . Strategy . setOptions = options ;
99+ await this . Strategy . perform ( options ) }
100+ } className = { `p-3 rounded-lg flex ${ this . state . algorithm ? "bg-green-600 cursor-pointer hover:bg-green-700" : "bg-gray-600" } ` } >
98101 < p className = "text-white font-semibold mr-2" > Sort</ p > < Play className = { `${ this . state . algorithm && "group-hover:scale-[1.15] transition-all duration-200 ease-in-out" } ` } />
99102 </ div >
100103
0 commit comments