1- import { definePlugin , ToolbarItem , AppHeader , AppSidebar , AppDashboard , StyleProvider } from 'example-sdk' ;
1+ import { definePlugin , ToolbarItem , AppHeader , AppSidebar , AppDashboard , StyleProvider , useAppLayout } from 'example-sdk' ;
22import { useAppContext } from 'example-sdk/react' ;
3- import type { PluginRoute } from 'example-sdk' ;
43
54/**
65 * DarkThemePlugin
@@ -64,7 +63,9 @@ export default darkThemePlugin;
6463/**
6564 * Dark-themed Header component
6665 */
67- function DarkHeader ( { toolbar } : { toolbar : React . ReactNode [ ] } ) {
66+ function DarkHeader ( ) {
67+ const layout = useAppLayout ( ) ;
68+
6869 return (
6970 < StyleProvider
7071 variables = { {
@@ -91,7 +92,7 @@ function DarkHeader({ toolbar }: { toolbar: React.ReactNode[] }) {
9192 < strong style = { { marginRight : 'auto' , color : '#e4e4e7' , fontSize : 16 } } >
9293 🌙 My App
9394 </ strong >
94- { toolbar }
95+ { layout . toolbar }
9596 </ header >
9697 </ StyleProvider >
9798 ) ;
@@ -100,15 +101,16 @@ function DarkHeader({ toolbar }: { toolbar: React.ReactNode[] }) {
100101/**
101102 * Dark-themed Sidebar component
102103 */
103- function DarkSidebar ( {
104- pluginRoutes,
105- sidebarItems,
106- Link,
107- } : {
108- pluginRoutes : Map < string , PluginRoute > ;
109- sidebarItems : React . ReactNode [ ] ;
110- Link : any ;
111- } ) {
104+ function DarkSidebar ( ) {
105+ const context = useAppContext ( ) ;
106+ const layout = useAppLayout ( ) ;
107+ const pluginRoutes = context . router . getRoutes ( ) ;
108+
109+ const handleNavigate = ( path : string ) => ( e : React . MouseEvent ) => {
110+ e . preventDefault ( ) ;
111+ context . router . navigate ( path ) ;
112+ } ;
113+
112114 return (
113115 < StyleProvider
114116 variables = { {
@@ -145,15 +147,17 @@ function DarkSidebar({
145147 Navigation
146148 </ p >
147149 < nav style = { { display : 'flex' , flexDirection : 'column' , gap : 4 } } >
148- < Link
149- to = "/"
150+ < a
151+ href = "/"
152+ onClick = { handleNavigate ( '/' ) }
150153 style = { {
151154 fontSize : 13 ,
152155 color : '#60a5fa' ,
153156 textDecoration : 'none' ,
154157 padding : '6px 12px' ,
155158 borderRadius : 4 ,
156159 transition : 'background 0.2s' ,
160+ cursor : 'pointer' ,
157161 } }
158162 onMouseEnter = { ( e : any ) => {
159163 e . currentTarget . style . background = '#3f3f46' ;
@@ -163,16 +167,18 @@ function DarkSidebar({
163167 } }
164168 >
165169 🏠 Home
166- </ Link >
167- < Link
168- to = "/settings"
170+ </ a >
171+ < a
172+ href = "/settings"
173+ onClick = { handleNavigate ( '/settings' ) }
169174 style = { {
170175 fontSize : 13 ,
171176 color : '#60a5fa' ,
172177 textDecoration : 'none' ,
173178 padding : '6px 12px' ,
174179 borderRadius : 4 ,
175180 transition : 'background 0.2s' ,
181+ cursor : 'pointer' ,
176182 } }
177183 onMouseEnter = { ( e : any ) => {
178184 e . currentTarget . style . background = '#3f3f46' ;
@@ -182,21 +188,23 @@ function DarkSidebar({
182188 } }
183189 >
184190 ⚙ Settings
185- </ Link >
191+ </ a >
186192 { /* Plugin routes */ }
187193 { Array . from ( pluginRoutes . values ( ) )
188194 . filter ( ( r ) => r . label )
189195 . map ( ( route ) => (
190- < Link
196+ < a
191197 key = { route . path }
192- to = { route . path }
198+ href = { route . path }
199+ onClick = { handleNavigate ( route . path ) }
193200 style = { {
194201 fontSize : 13 ,
195202 color : '#60a5fa' ,
196203 textDecoration : 'none' ,
197204 padding : '6px 12px' ,
198205 borderRadius : 4 ,
199206 transition : 'background 0.2s' ,
207+ cursor : 'pointer' ,
200208 } }
201209 onMouseEnter = { ( e : any ) => {
202210 e . currentTarget . style . background = '#3f3f46' ;
@@ -206,7 +214,7 @@ function DarkSidebar({
206214 } }
207215 >
208216 { route . label }
209- </ Link >
217+ </ a >
210218 ) ) }
211219 </ nav >
212220 < hr
@@ -228,10 +236,10 @@ function DarkSidebar({
228236 >
229237 Sidebar Plugins
230238 </ p >
231- { sidebarItems . length === 0 ? (
239+ { layout . sidebar . length === 0 ? (
232240 < p style = { { fontSize : 12 , color : '#71717a' } } > No sidebar plugins.</ p >
233241 ) : (
234- sidebarItems
242+ layout . sidebar
235243 ) }
236244 </ aside >
237245 </ StyleProvider >
@@ -241,7 +249,9 @@ function DarkSidebar({
241249/**
242250 * Dark-themed Dashboard component
243251 */
244- function DarkDashboard ( { dashboardItems } : { dashboardItems : React . ReactNode [ ] } ) {
252+ function DarkDashboard ( ) {
253+ const layout = useAppLayout ( ) ;
254+
245255 return (
246256 < StyleProvider
247257 variables = { {
@@ -261,7 +271,7 @@ function DarkDashboard({ dashboardItems }: { dashboardItems: React.ReactNode[] }
261271 gridTemplateColumns : 'repeat(auto-fill, minmax(240px, 1fr))' ,
262272 } }
263273 >
264- { dashboardItems . length === 0 ? (
274+ { layout . dashboard . length === 0 ? (
265275 < div
266276 style = { {
267277 padding : 32 ,
@@ -278,7 +288,7 @@ function DarkDashboard({ dashboardItems }: { dashboardItems: React.ReactNode[] }
278288 </ p >
279289 </ div >
280290 ) : (
281- dashboardItems
291+ layout . dashboard
282292 ) }
283293 </ div >
284294 </ StyleProvider >
0 commit comments