Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | 37x 265x | import { LayoutGrid, List } from "lucide-react";
import React from "react";
export type ViewMode = "grid" | "list";
interface ViewToggleProps {
view: ViewMode;
onViewChange: (view: ViewMode) => void;
}
const ViewToggle: React.FC<ViewToggleProps> = ({ view, onViewChange }) => (
<div className="flex items-center rounded-lg border border-gray-200 dark:border-gray-600 overflow-hidden">
<button
onClick={() => onViewChange("grid")}
aria-label="Grid view"
className={`p-1.5 transition-colors ${
view === "grid"
? "bg-gray-900 dark:bg-gray-100 text-white dark:text-gray-900"
: "text-gray-400 dark:text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700"
}`}
>
<LayoutGrid className="size-3.5" />
</button>
<button
onClick={() => onViewChange("list")}
aria-label="List view"
className={`p-1.5 transition-colors ${
view === "list"
? "bg-gray-900 dark:bg-gray-100 text-white dark:text-gray-900"
: "text-gray-400 dark:text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700"
}`}
>
<List className="size-3.5" />
</button>
</div>
);
export default ViewToggle;
|