11import { Route , HashRouter , useLocation } from '@solidjs/router' ;
22import type { Component , ParentComponent } from 'solid-js' ;
3- import { createSignal , createEffect } from 'solid-js' ;
3+ import { createSignal , createEffect , createMemo } from 'solid-js' ;
44import { routes } from './routes' ;
55import { Drawer } from './components/Drawer' ;
66import { StageNavigation } from './components/StageNavigation' ;
7+ import { menuGroups , isMenuGroup } from './config/menu' ;
8+ import Welcome from './stages/Welcome' ;
9+
710
811const Layout : ParentComponent = ( props ) => {
912 const location = useLocation ( ) ;
1013 const [ drawerOpen , setDrawerOpen ] = createSignal ( false ) ;
1114
1215 createEffect ( ( ) => {
13- location . pathname ;
1416 setDrawerOpen ( false ) ;
1517 } ) ;
1618
19+ const getCurrentLevel = createMemo ( ( ) => {
20+ const currentPath = location . pathname ;
21+
22+ for ( const group of menuGroups ) {
23+ console . log
24+ if ( isMenuGroup ( group ) ) {
25+ const foundLink = group . links . find ( link => link . href === currentPath ) ;
26+ if ( foundLink ) {
27+ return {
28+ title : group . title ,
29+ label : foundLink . label ,
30+ isLink : true
31+ } ;
32+ }
33+ } else {
34+ if ( group . href === currentPath ) {
35+ return {
36+ title : group . label ,
37+ label : null ,
38+ isLink : false
39+ } ;
40+ }
41+ }
42+ }
43+
44+ return null ;
45+ } ) ;
46+
47+ const currentLevel = getCurrentLevel ( ) ;
48+
49+ console . log ( 'currentLevel' , currentLevel )
50+
1751 return (
1852 < >
1953 < button
@@ -28,23 +62,33 @@ const Layout: ParentComponent = (props) => {
2862 </ svg >
2963 </ button >
3064
31- { /* Основной контент с минимальной высотой 100vh */ }
3265 < div class = "min-h-screen bg-[#f8faff]" >
3366 < div class = "mx-auto w-full max-w-[1024px] px-4 py-6" >
34- { /* Отступ для кнопки меню на мобильных */ }
3567 < div class = "lg:hidden h-14" />
36-
37- { /* Контент будет растягиваться */ }
3868 < div class = "min-h-[calc(100vh-3rem)] flex flex-col" >
3969 < div class = "flex-1" >
70+ < h1 class = "text-xl2 font-semibold text-[#1f2a44]" > 2.5D Render</ h1 >
71+
72+ { currentLevel && (
73+ < div class = "mb-6 pb-3 border-b border-[#d8deea]" >
74+ { currentLevel . isLink ? (
75+ < >
76+ < p class = "text-sm text-[#6b7a8f] mb-1" > { currentLevel . title } </ p >
77+ < h2 class = "text-xl font-semibold text-[#1f2a44]" > { currentLevel . label } </ h2 >
78+ </ >
79+ ) : (
80+ < h2 class = "text-xl font-semibold text-[#1f2a44]" > { currentLevel . title } </ h2 >
81+ ) }
82+ </ div >
83+ ) }
84+
4085 { props . children }
4186 </ div >
4287 < StageNavigation />
4388 </ div >
4489 </ div >
4590 </ div >
4691
47- { /* Drawer компонент */ }
4892 < Drawer isOpen = { drawerOpen ( ) } onClose = { ( ) => setDrawerOpen ( false ) } />
4993 </ >
5094 ) ;
@@ -53,6 +97,7 @@ const Layout: ParentComponent = (props) => {
5397const App : Component = ( ) => {
5498 return (
5599 < HashRouter root = { Layout } >
100+ < Route path = "/" component = { ( ) => < Welcome /> } />
56101 { routes }
57102 < Route path = "*" component = { ( ) => 'Not found' } />
58103 </ HashRouter >
0 commit comments