|
1 | 1 | import { CustomSelect } from '@/components/custom-select'; |
2 | 2 | import { Button } from '@/components/ui/button'; |
3 | 3 | import { Play, Grid3X3, Eraser, Trash2 } from 'lucide-react'; |
4 | | -import { Component } from 'react'; |
5 | 4 |
|
6 | | -class Menu extends Component { |
7 | | - render() { |
8 | | - const disabled = this.props.disable; |
9 | | - return ( |
10 | | - <div className="w-64 bg-gray-100 p-4 space-y-6"> |
11 | | - <h2 className="text-lg font-semibold">Pathfinder</h2> |
| 5 | +export default function Menu({ onAlgoChanged, onVisualize, algorithms, mazes, onMazeChanged, onCreateMaze, onClearBoard, onClearPath, disabled }) { |
| 6 | + return ( |
| 7 | + <div className="w-64 bg-gray-100 p-4 space-y-6"> |
| 8 | + <h2 className="text-lg font-semibold">Pathfinder</h2> |
12 | 9 |
|
| 10 | + <CustomSelect |
| 11 | + title="Algorithm" |
| 12 | + options={algorithms} |
| 13 | + onChange={onAlgoChanged} |
| 14 | + disabled={disabled} |
| 15 | + /> |
| 16 | + |
| 17 | + <div className="space-y-3"> |
| 18 | + <div className="flex items-center gap-2"> |
| 19 | + <div className="h-px flex-1 bg-gray-300" /> |
| 20 | + <span className="text-xs font-medium text-gray-500 uppercase tracking-wider">Maze</span> |
| 21 | + <div className="h-px flex-1 bg-gray-300" /> |
| 22 | + </div> |
13 | 23 | <CustomSelect |
14 | | - title="Algorithm" |
15 | | - options={this.props.algorithms} |
16 | | - onChange={this.props.onAlgoChanged} |
| 24 | + title="Division Type" |
| 25 | + options={mazes} |
| 26 | + onChange={onMazeChanged} |
17 | 27 | disabled={disabled} |
18 | 28 | /> |
| 29 | + <Button |
| 30 | + className="w-full" |
| 31 | + variant="outline" |
| 32 | + onClick={onCreateMaze} |
| 33 | + disabled={disabled} |
| 34 | + > |
| 35 | + <Grid3X3 /> Generate Maze |
| 36 | + </Button> |
| 37 | + </div> |
19 | 38 |
|
20 | | - <div className="space-y-3"> |
21 | | - <div className="flex items-center gap-2"> |
22 | | - <div className="h-px flex-1 bg-gray-300" /> |
23 | | - <span className="text-xs font-medium text-gray-500 uppercase tracking-wider">Maze</span> |
24 | | - <div className="h-px flex-1 bg-gray-300" /> |
25 | | - </div> |
26 | | - <CustomSelect |
27 | | - title="Division Type" |
28 | | - options={this.props.mazes} |
29 | | - onChange={this.props.onMazeChanged} |
30 | | - disabled={disabled} |
31 | | - /> |
| 39 | + <div className="space-y-3"> |
| 40 | + <div className="flex items-center gap-2"> |
| 41 | + <div className="h-px flex-1 bg-gray-300" /> |
| 42 | + <span className="text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</span> |
| 43 | + <div className="h-px flex-1 bg-gray-300" /> |
| 44 | + </div> |
| 45 | + <Button |
| 46 | + className="w-full" |
| 47 | + onClick={onVisualize} |
| 48 | + disabled={disabled} |
| 49 | + > |
| 50 | + <Play /> Visualize |
| 51 | + </Button> |
| 52 | + <div className="flex gap-2"> |
32 | 53 | <Button |
33 | | - className="w-full" |
34 | | - variant="outline" |
35 | | - onClick={this.props.onCreateMaze} |
| 54 | + className="flex-1" |
| 55 | + variant="secondary" |
| 56 | + size="sm" |
| 57 | + onClick={onClearPath} |
36 | 58 | disabled={disabled} |
37 | 59 | > |
38 | | - <Grid3X3 /> Generate Maze |
| 60 | + <Eraser /> Path |
39 | 61 | </Button> |
40 | | - </div> |
41 | | - |
42 | | - <div className="space-y-3"> |
43 | | - <div className="flex items-center gap-2"> |
44 | | - <div className="h-px flex-1 bg-gray-300" /> |
45 | | - <span className="text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</span> |
46 | | - <div className="h-px flex-1 bg-gray-300" /> |
47 | | - </div> |
48 | 62 | <Button |
49 | | - className="w-full" |
50 | | - onClick={this.props.onVisualize} |
| 63 | + className="flex-1" |
| 64 | + variant="secondary" |
| 65 | + size="sm" |
| 66 | + onClick={onClearBoard} |
51 | 67 | disabled={disabled} |
52 | 68 | > |
53 | | - <Play /> Visualize |
| 69 | + <Trash2 /> Board |
54 | 70 | </Button> |
55 | | - <div className="flex gap-2"> |
56 | | - <Button |
57 | | - className="flex-1" |
58 | | - variant="secondary" |
59 | | - size="sm" |
60 | | - onClick={this.props.onClearPath} |
61 | | - disabled={disabled} |
62 | | - > |
63 | | - <Eraser /> Path |
64 | | - </Button> |
65 | | - <Button |
66 | | - className="flex-1" |
67 | | - variant="secondary" |
68 | | - size="sm" |
69 | | - onClick={this.props.onClearBoard} |
70 | | - disabled={disabled} |
71 | | - > |
72 | | - <Trash2 /> Board |
73 | | - </Button> |
74 | | - </div> |
75 | 71 | </div> |
76 | 72 | </div> |
77 | | - ); |
78 | | - } |
| 73 | + </div> |
| 74 | + ); |
79 | 75 | } |
80 | | - |
81 | | -export default Menu; |
0 commit comments