From 857d4dfc1690764676720fc8a80449e12c7cb691 Mon Sep 17 00:00:00 2001 From: MananTank Date: Wed, 13 Aug 2025 23:35:36 +0000 Subject: [PATCH] Playground: Fix theme toggle UI when sidebar is collapsed (#7853) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR focuses on refining the sidebar component in the application by adjusting styles, modifying the theme toggle functionality, and enhancing the UI elements for better user experience. ### Detailed summary - Updated `SIDEBAR_WIDTH` and `SIDEBAR_WIDTH_MOBILE` from `"19rem"` to `"18rem"`. - Removed `ChevronDownIcon` and replaced it with `ChevronRightIcon` in `RenderSidebarSubmenu`. - Added `` in `FullWidthSidebarLayoutInner`. - Replaced `Button` with `SidebarMenu`, `SidebarMenuButton`, and `SidebarMenuItem` in `ThemeToggle`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` ## Summary by CodeRabbit - New Features - Theme toggle now appears as a sidebar menu item with improved loading placeholders for icon and label. - UI/UX - Sidebar width reduced from 19rem to 18rem for a more compact layout. - Chevron indicators updated: right-chevron rotates 90° when open for clearer state. - Added a visual separator in the sidebar footer for better grouping. - Bug Fixes - Prevented rendering of empty sidebar menus/submenus. - Refactor - Streamlined imports and removed unused variants; maintained existing toggle behavior. --- .../src/components/ThemeToggle.tsx | 38 ++++++++++--------- .../blocks/full-width-sidebar-layout.tsx | 9 +++-- .../src/components/ui/sidebar.tsx | 4 +- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/apps/playground-web/src/components/ThemeToggle.tsx b/apps/playground-web/src/components/ThemeToggle.tsx index 24e9a4b3263..1e4711298de 100644 --- a/apps/playground-web/src/components/ThemeToggle.tsx +++ b/apps/playground-web/src/components/ThemeToggle.tsx @@ -3,35 +3,39 @@ import { MoonIcon, SunIcon } from "lucide-react"; import { useTheme } from "next-themes"; import { ClientOnly } from "@/components/ClientOnly"; -import { Button } from "@/components/ui/button"; +import { + SidebarMenu, + SidebarMenuButton, + SidebarMenuItem, +} from "@/components/ui/sidebar"; import { Skeleton } from "@/components/ui/skeleton"; export function ThemeToggle() { const { setTheme, theme } = useTheme(); return ( -
- } - > - - -
+ }> + {theme} + + + + ); } diff --git a/apps/playground-web/src/components/blocks/full-width-sidebar-layout.tsx b/apps/playground-web/src/components/blocks/full-width-sidebar-layout.tsx index 749a2cdd2ef..5a62bdf0244 100644 --- a/apps/playground-web/src/components/blocks/full-width-sidebar-layout.tsx +++ b/apps/playground-web/src/components/blocks/full-width-sidebar-layout.tsx @@ -1,6 +1,6 @@ "use client"; -import { ChevronDownIcon, ChevronRightIcon } from "lucide-react"; +import { ChevronRightIcon } from "lucide-react"; import Link from "next/link"; import { useMemo, useState } from "react"; import { @@ -126,6 +126,7 @@ function FullWidthSidebarLayoutInner(props: FullWidthSidebarLayoutProps) { links={footerSidebarLinks} fullPath={props.fullPath} /> + )} @@ -289,7 +290,7 @@ function RenderSidebarSubmenu(props: { {props.subMenu.label} {sidebar.open && ( - )} diff --git a/apps/playground-web/src/components/ui/sidebar.tsx b/apps/playground-web/src/components/ui/sidebar.tsx index 5e4fd468313..f8c07cbbdb9 100644 --- a/apps/playground-web/src/components/ui/sidebar.tsx +++ b/apps/playground-web/src/components/ui/sidebar.tsx @@ -27,8 +27,8 @@ import { cn } from "@/lib/utils"; const SIDEBAR_COOKIE_NAME = "sidebar_state"; const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7; -const SIDEBAR_WIDTH = "19rem"; -const SIDEBAR_WIDTH_MOBILE = "19rem"; +const SIDEBAR_WIDTH = "18rem"; +const SIDEBAR_WIDTH_MOBILE = "18rem"; const SIDEBAR_WIDTH_ICON = "3rem"; const SIDEBAR_KEYBOARD_SHORTCUT = "b";