@@ -45,19 +45,55 @@ const SidebarMenu: React.FC<SidebarMenuProps> = ({
45
45
)
46
46
) ?. id || "Information" ;
47
47
48
- const theme = basePath . includes ( "swapi" ) ? "swapi" : "pokemon" ;
48
+ const theme = basePath . includes ( "swapi" )
49
+ ? "swapi"
50
+ : basePath . includes ( "things" )
51
+ ? "things"
52
+ : basePath . includes ( "rickandmorty" )
53
+ ? "rickandmorty"
54
+ : "pokemon" ;
55
+
56
+ const getThemeColors = ( theme : string ) => {
57
+ switch ( theme ) {
58
+ case "swapi" :
59
+ return {
60
+ bg : "bg-black" ,
61
+ hover : "bg-sw-yellow" ,
62
+ decoration : "sw-yellow" ,
63
+ text : "text-white" ,
64
+ } ;
65
+
66
+ default :
67
+ return {
68
+ bg : "bg-gray-100" ,
69
+ hover : "bg-pokemon-yellow" ,
70
+ decoration : "pokemon-blue" ,
71
+ text : "" ,
72
+ } ;
73
+ }
74
+ } ;
75
+
76
+ const themeColors = getThemeColors ( theme ) ;
49
77
50
78
return (
51
- < div
52
- className = { `w-fit min-w-48 max-w-80 p-2 text-sm ${ theme === "swapi" ? "bg-black" : "bg-gray-100" } ` }
53
- >
79
+ < div className = { `w-fit min-w-48 max-w-80 p-2 text-sm ${ themeColors . bg } ` } >
54
80
{ categories . map ( ( category ) => (
55
81
< div key = { category . id } className = "mb-1" >
56
82
< Link
57
- href = { `/${ basePath } /documentation/${ category . endpoints ? formatEndpointId ( category . endpoints [ 0 ] . id ) : "" } ` }
83
+ href = { `/${ basePath } /documentation/${
84
+ category . endpoints
85
+ ? formatEndpointId ( category . endpoints [ 0 ] . id )
86
+ : ""
87
+ } `}
58
88
>
59
89
< div
60
- className = { `cursor-pointer px-2 py-1 mb-1 rounded-lg hover:bg-${ theme === "swapi" ? "sw-yellow" : "pokemon-yellow" } ${ selectedCategory === category . id ? `underline decoration-2 underline-offset-2 decoration-${ theme === "swapi" ? "sw-yellow" : "pokemon-blue" } ` : "" } ${ theme === "swapi" ? "text-white" : "" } ` }
90
+ className = { `cursor-pointer px-2 py-1 mb-1 rounded-lg hover:${
91
+ themeColors . hover
92
+ } ${
93
+ selectedCategory === category . id
94
+ ? `underline decoration-2 underline-offset-2 decoration-${ themeColors . decoration } `
95
+ : ""
96
+ } ${ themeColors . text } `}
61
97
>
62
98
{ category . id }
63
99
</ div >
@@ -66,11 +102,19 @@ const SidebarMenu: React.FC<SidebarMenuProps> = ({
66
102
< div className = "pl-2" >
67
103
{ category . endpoints . map ( ( endpoint ) => (
68
104
< Link
69
- href = { `/${ basePath } /documentation/${ formatEndpointId ( endpoint . id ) } ` }
105
+ href = { `/${ basePath } /documentation/${ formatEndpointId (
106
+ endpoint . id
107
+ ) } `}
70
108
key = { `link-${ endpoint . id } ` }
71
109
>
72
110
< div
73
- className = { `cursor-pointer px-2 py-1 mb-1 rounded-lg hover:bg-${ theme === "swapi" ? "sw-yellow" : "pokemon-yellow" } ${ selectedEndpoint === formatEndpointId ( endpoint . id ) ? `underline decoration-2 underline-offset-2 decoration-${ theme === "swapi" ? "sw-yellow" : "pokemon-blue" } ` : "" } ${ theme === "swapi" ? "text-white" : "" } ` }
111
+ className = { `cursor-pointer px-2 py-1 mb-1 rounded-lg hover:${
112
+ themeColors . hover
113
+ } ${
114
+ selectedEndpoint === formatEndpointId ( endpoint . id )
115
+ ? `underline decoration-2 underline-offset-2 decoration-${ themeColors . decoration } `
116
+ : ""
117
+ } ${ themeColors . text } `}
74
118
>
75
119
{ endpoint . id }
76
120
</ div >
0 commit comments