1- import React , { useCallback } from "react" ;
1+ import React from "react" ;
22import Sidebar from "./sidebar" ;
33import {
44 LucideBell ,
@@ -8,17 +8,14 @@ import {
88 LucideClipboard ,
99 LucideLink ,
1010 LucideMail ,
11- LucideMoon ,
1211 LucidePhone ,
1312 LucideSettings ,
1413 LucideUser ,
1514 LucideUserCheck ,
1615 LucideUsers ,
1716} from "lucide-react" ;
1817import { MemoryRouter } from "react-router" ;
19- import { Meta , StoryObj } from "@storybook/react-vite/*" ;
20- import { useDarkMode } from "storybook-dark-mode" ;
21- import { noop } from "../../utils" ;
18+ import type { Meta , StoryObj } from "@storybook/react-vite" ;
2219
2320const meta : Meta < typeof Sidebar > = {
2421 title : "Components/Sidebar" ,
@@ -65,11 +62,6 @@ const crmSidebar = {
6562 subtitle : "Jane Doe" ,
6663 logo : "https://raw.githubusercontent.com/frappe/crm/develop/.github/logo.svg" ,
6764 menuItems : [
68- {
69- label : "Toggle Theme" ,
70- icon : < LucideMoon size = { 16 } className = "text-ink-gray-6 mr-2" /> ,
71- onClick : noop ,
72- } ,
7365 {
7466 label : "Help" ,
7567 to : "/help" ,
@@ -171,42 +163,6 @@ const crmSidebar = {
171163
172164export const SidebarExample : Story = {
173165 render : ( ) => {
174- const mode = useDarkMode ( ) ? "dark" : "light" ;
175-
176- const toggleTheme = useCallback ( ( ) => {
177- const container = document . getElementById ( "sidebar-container" ) ;
178- if ( ! container ) return ;
179-
180- const bodyHasDark = mode === "dark" ;
181- const containerHasDark = container . classList . contains ( "dark" ) ;
182-
183- // Sync container's dark class with body
184- if ( bodyHasDark !== containerHasDark ) {
185- if ( bodyHasDark ) {
186- container . classList . add ( "dark" ) ;
187- } else {
188- container . classList . remove ( "dark" ) ;
189- }
190- }
191-
192- // Toggle theme
193- if ( bodyHasDark ) {
194- const button = parent . document . querySelector (
195- '[title="Change theme to light mode"]'
196- ) as HTMLButtonElement ;
197- if ( button ) button . click ( ) ;
198-
199- container . classList . remove ( "dark" ) ;
200- } else {
201- const button = parent . document . querySelector (
202- '[title="Change theme to dark mode"]'
203- ) as HTMLButtonElement ;
204- if ( button ) button . click ( ) ;
205-
206- container . classList . add ( "dark" ) ;
207- }
208- } , [ mode ] ) ;
209-
210166 return (
211167 < div
212168 className = "flex h-screen w-full flex-col bg-surface-white shadow"
@@ -216,11 +172,6 @@ export const SidebarExample: Story = {
216172 < Sidebar
217173 header = { {
218174 ...crmSidebar . header ,
219- menuItems : crmSidebar . header . menuItems . map ( ( item ) =>
220- item . label === "Toggle Theme"
221- ? { ...item , onClick : toggleTheme }
222- : item
223- ) ,
224175 } }
225176 sections = { crmSidebar . sections }
226177 />
0 commit comments