|
7 | 7 | */ |
8 | 8 |
|
9 | 9 | import * as React from 'react'; |
10 | | -import { cn, ToggleGroup, ToggleGroupItem } from '@object-ui/components'; |
| 10 | +import { cn } from '@object-ui/components'; |
11 | 11 | import { |
12 | 12 | Grid, |
13 | 13 | LayoutGrid, |
@@ -61,26 +61,32 @@ export const ViewSwitcher: React.FC<ViewSwitcherProps> = ({ |
61 | 61 | className, |
62 | 62 | }) => { |
63 | 63 | return ( |
64 | | - <ToggleGroup |
65 | | - type="single" |
66 | | - value={currentView} |
67 | | - onValueChange={(value) => value && onViewChange(value as ViewType)} |
68 | | - className={cn("bg-transparent gap-1", className)} |
69 | | - > |
70 | | - {availableViews.map((view) => ( |
71 | | - <ToggleGroupItem |
72 | | - key={view} |
73 | | - value={view} |
74 | | - aria-label={VIEW_LABELS[view]} |
75 | | - title={VIEW_LABELS[view]} |
76 | | - className="gap-2 px-3 data-[state=on]:bg-background data-[state=on]:shadow-sm border-transparent border data-[state=on]:border-border/50" |
77 | | - > |
78 | | - {VIEW_ICONS[view]} |
79 | | - <span className="hidden sm:inline-block text-xs font-medium"> |
80 | | - {VIEW_LABELS[view]} |
81 | | - </span> |
82 | | - </ToggleGroupItem> |
83 | | - ))} |
84 | | - </ToggleGroup> |
| 64 | + <div className={cn("flex items-center gap-1 bg-transparent", className)}> |
| 65 | + {availableViews.map((view) => { |
| 66 | + const isActive = currentView === view; |
| 67 | + return ( |
| 68 | + <button |
| 69 | + key={view} |
| 70 | + type="button" |
| 71 | + onClick={() => onViewChange(view)} |
| 72 | + aria-label={VIEW_LABELS[view]} |
| 73 | + title={VIEW_LABELS[view]} |
| 74 | + aria-pressed={isActive} |
| 75 | + data-state={isActive ? 'on' : 'off'} |
| 76 | + className={cn( |
| 77 | + "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", |
| 78 | + "hover:bg-muted hover:text-muted-foreground", |
| 79 | + "gap-2 px-3 py-2", |
| 80 | + "data-[state=on]:bg-background data-[state=on]:text-foreground data-[state=on]:shadow-sm border-transparent border data-[state=on]:border-border/50", |
| 81 | + )} |
| 82 | + > |
| 83 | + {VIEW_ICONS[view]} |
| 84 | + <span className="hidden sm:inline-block text-xs font-medium"> |
| 85 | + {VIEW_LABELS[view]} |
| 86 | + </span> |
| 87 | + </button> |
| 88 | + ); |
| 89 | + })} |
| 90 | + </div> |
85 | 91 | ); |
86 | 92 | }; |
0 commit comments