Skip to content

Commit 4bd43b6

Browse files
committed
styling adjusted
1 parent c57695e commit 4bd43b6

6 files changed

Lines changed: 33 additions & 29 deletions

File tree

‎src/Utility/config.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ const PINK = '#ff595e';
88
const CONSTANTS = {
99
margin: 2,
1010
DEFAULT: [YELLOW, PINK, LIGHT_GREEN, PURPLE],
11-
SORTED: [LIGHT_GREEN, 'red', YELLOW, PURPLE],
12-
PROCESSING: [DARK_BLUE, 'red', LIGHT_GREEN, PURPLE],
13-
CURRENT_MIN: [LIGHT_GREEN, YELLOW, DARK_BLUE, PURPLE, 'red'],
11+
SORTED: [LIGHT_GREEN, RED, YELLOW, PURPLE],
12+
PROCESSING: [DARK_BLUE, RED, LIGHT_GREEN, PURPLE],
13+
CURRENT_MIN: [RED, YELLOW, DARK_BLUE, PURPLE, LIGHT_GREEN],
1414
DELAY: 4, // SG 07/09/2022 13:54 4ms
1515
}
1616

‎src/components/Animation/Animation.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Animation {
1111
}
1212

1313

14-
// SG 07/07/2022 22:00 define differnet animaiton here and call it in sorting algorithms
14+
// SG 07/07/2022 22:00 define differnet animaitons here and call it in sorting algorithms
1515

1616

1717
/**

‎src/components/Canvas/InputField.js‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

‎src/components/Canvas/options/Options.js‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Options extends Component {
3434

3535
<div className="w-fit flex space-x-5">
3636

37-
<div className="flex flex-col items-center relative space-y-2">
37+
<div className="flex flex-col items-center relative space-y-2 cursor-pointer">
3838
<div className="p-2 hover:bg-gray-200 rounded-md peer" onClick={() => this.setState({showDefaultBarColor: !showDefaultBarColor})}>
3939
<UnsortedBars className="scale-[1.2]"/>
4040
</div>
@@ -55,7 +55,7 @@ class Options extends Component {
5555
<p className={`bg-white z-10 inline absolute top-[100%] border-2 p-1 rounded-md hidden peer-hover:block tool-tip-options text-gray-600`}><span className="font-bold">Unsorted</span> bars color</p>
5656
</div>
5757

58-
<div className="flex flex-col items-center relative space-y-2">
58+
<div className="flex flex-col items-center relative space-y-2 cursor-pointer">
5959
<div className="p-2 hover:bg-gray-200 peer rounded-md" onClick={() => this.setState({showSortedBarColor: !showSortedBarColor})}>
6060
<SortedBars className="scale-[1.2]"/>
6161
</div>
@@ -77,7 +77,7 @@ class Options extends Component {
7777
</div>
7878

7979

80-
<div className="flex flex-col items-center relative space-y-2">
80+
<div className="flex flex-col items-center relative space-y-2 cursor-pointer">
8181
<div className="p-2 hover:bg-gray-200 peer rounded-md" onClick={() => this.setState({showProcessingColor: !showProcessingColor})}>
8282
<CPU className="scale-[1.2]"/>
8383
</div>
@@ -99,7 +99,7 @@ class Options extends Component {
9999
</div>
100100

101101

102-
<div className="flex flex-col items-center relative space-y-2">
102+
<div className="flex flex-col items-center relative space-y-2 cursor-pointer">
103103
<div className="p-2 hover:bg-gray-200 peer rounded-md" onClick={() => this.setState({showMinBarColor: !showMinBarColor})}>
104104
<Key className="scale-[1.2]"/>
105105
</div>
@@ -121,7 +121,7 @@ class Options extends Component {
121121
</div>
122122

123123

124-
<div className="flex flex-col items-center relative space-y-2">
124+
<div className="flex flex-col items-center relative space-y-2 cursor-pointer">
125125
<div className="p-2 hover:bg-gray-200 peer rounded-md" onClick={() => this.setState({showDelay: !showDelay})}>
126126
<Speed className="scale-[1.2]"/>
127127
</div>
@@ -137,7 +137,7 @@ class Options extends Component {
137137

138138

139139

140-
<div className="flex flex-col items-center relative space-y-2">
140+
<div className="flex flex-col items-center relative space-y-2 cursor-pointer">
141141
<div className={`p-2 hover:bg-gray-200 peer rounded-md`} onClick={() => {
142142
this.props.options.setState(prev => ({options: {...prev.options, skipJ: !this.props.options.state.options.skipJ}}))
143143

‎src/components/Strategy/Algorithms/SelectionSort.js‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,9 @@ export default class SelectionSort {
1111
this._delay = 4;
1212
}
1313

14-
/**
15-
* @param {{}} options
16-
*/
17-
set setOptions(options) {
18-
this._delay = options?.delay || 4;
19-
}
20-
14+
2115
async perform(options) {
16+
console.log(options);
2217
console.log(options)
2318
const DEFAULT = options.defaultBarColor;
2419
const PROCESSING = options.processingColor;
@@ -30,7 +25,7 @@ export default class SelectionSort {
3025

3126
for(var i = 0; i < unSortedBars.length; i++) {
3227
// SG 07/08/2022 15:01 animation for i iterationå
33-
await Animation.getAnimation(this._delay);
28+
await Animation.getAnimation(options.delay);
3429

3530
minBarIndex = i;
3631
for(var j = i + 1; j < unSortedBars.length; j++) {
@@ -41,7 +36,7 @@ export default class SelectionSort {
4136

4237
// SG 07/08/2022 15:01 animation for j iteration - can be removed for faster animation
4338
if(!options.skipJ) {
44-
await Animation.getAnimation(this._delay);
39+
await Animation.getAnimation(options.delay);
4540
}
4641

4742
var currentMinBar = parseInt(unSortedBars[minBarIndex].id);

‎src/components/Strategy/Strategy.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ class Strategy {
1818
return this._strategy;
1919
}
2020

21+
/**
22+
* @param {{}} options
23+
*/
24+
set setOption(options) {
25+
this._strategy.setOptions = options;
26+
}
2127

2228
/**
2329
* @param {any} newArray

0 commit comments

Comments
 (0)