Presidentlin commited on
Commit
f911da5
·
1 Parent(s): 6f8c125
src/components/BenchmarkComparisonSelector.tsx CHANGED
@@ -1,6 +1,6 @@
1
- // components/BenchmarkComparisonSelector.tsx
2
  import React from "react";
3
  import { Checkbox } from "@/components/ui/checkbox";
 
4
 
5
  interface Props {
6
  allMetrics: string[];
@@ -13,20 +13,38 @@ export const BenchmarkComparisonSelector: React.FC<Props> = ({
13
  selected,
14
  onChange,
15
  }) => {
 
 
 
 
 
 
 
 
 
16
  return (
17
- <div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2 mb-4">
18
- {allMetrics.map((metric) => (
19
- <div key={metric} className="flex items-center space-x-2">
20
- <Checkbox
21
- id={metric}
22
- checked={selected.includes(metric)}
23
- onCheckedChange={(checked) => onChange(metric, !!checked)}
24
- />
25
- <label htmlFor={metric} className="text-sm">
26
- {metric.replace(/_/g, " ").toUpperCase()}
27
- </label>
28
- </div>
29
- ))}
30
- </div>
 
 
 
 
 
 
 
 
 
31
  );
32
  };
 
 
1
  import React from "react";
2
  import { Checkbox } from "@/components/ui/checkbox";
3
+ import { Button } from "@/components/ui/button"; // Assuming you have a Button component
4
 
5
  interface Props {
6
  allMetrics: string[];
 
13
  selected,
14
  onChange,
15
  }) => {
16
+ const allSelected = allMetrics.every((metric) => selected.includes(metric));
17
+
18
+ const toggleAll = () => {
19
+ allMetrics.forEach((metric) => {
20
+ const shouldCheck = !allSelected;
21
+ onChange(metric, shouldCheck);
22
+ });
23
+ };
24
+
25
  return (
26
+ <>
27
+
28
+ <div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2 mb-4">
29
+ {allMetrics.map((metric) => (
30
+ <div key={metric} className="flex items-center space-x-2">
31
+ <Checkbox
32
+ id={metric}
33
+ checked={selected.includes(metric)}
34
+ onCheckedChange={(checked) => onChange(metric, !!checked)}
35
+ />
36
+ <label htmlFor={metric} className="text-sm">
37
+ {metric.replace(/_/g, " ").toUpperCase()}
38
+ </label>
39
+ </div>
40
+ ))}
41
+ </div>
42
+
43
+ <div className="flex justify-start py-4">
44
+ <Button size="sm" variant="ghost" onClick={toggleAll}>
45
+ {allSelected ? "Uncheck All" : "Check All"}
46
+ </Button>
47
+ </div>
48
+ </>
49
  );
50
  };