From 1dd3b7d30184d7541ea6cf7829d99a31d1036fe7 Mon Sep 17 00:00:00 2001 From: codytseng Date: Wed, 22 Oct 2025 22:11:33 +0800 Subject: [PATCH] feat: layout switcher --- src/components/Sidebar/LayoutSwitcher.tsx | 53 +++++++++++++++++++++++ src/components/Sidebar/index.tsx | 6 ++- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/components/Sidebar/LayoutSwitcher.tsx diff --git a/src/components/Sidebar/LayoutSwitcher.tsx b/src/components/Sidebar/LayoutSwitcher.tsx new file mode 100644 index 0000000..1e7e6b6 --- /dev/null +++ b/src/components/Sidebar/LayoutSwitcher.tsx @@ -0,0 +1,53 @@ +import { Button } from '@/components/ui/button' +import { cn } from '@/lib/utils' +import { useUserPreferences } from '@/providers/UserPreferencesProvider' +import { Columns2, PanelLeft } from 'lucide-react' + +export default function LayoutSwitcher({ collapse }: { collapse: boolean }) { + const { enableSingleColumnLayout, updateEnableSingleColumnLayout } = useUserPreferences() + + if (collapse) { + return ( + + ) + } + + return ( +
+
+
updateEnableSingleColumnLayout(false)} + > + +
+
updateEnableSingleColumnLayout(true)} + > + +
+
+
+
+ ) +} diff --git a/src/components/Sidebar/index.tsx b/src/components/Sidebar/index.tsx index 68a70ce..ed89a76 100644 --- a/src/components/Sidebar/index.tsx +++ b/src/components/Sidebar/index.tsx @@ -10,6 +10,7 @@ import AccountButton from './AccountButton' import BookmarkButton from './BookmarkButton' import RelaysButton from './ExploreButton' import HomeButton from './HomeButton' +import LayoutSwitcher from './LayoutSwitcher' import NotificationsButton from './NotificationButton' import PostButton from './PostButton' import ProfileButton from './ProfileButton' @@ -50,7 +51,10 @@ export default function PrimaryPageSidebar() {
- +
+ + +