@@ -5,10 +5,11 @@ import React from "react"
5
5
import { type Docs , docs } from "#site/content"
6
6
import { goodTitle , sortDocs } from "@/resources/lib/utils"
7
7
import { LayoutGroup , motion } from "framer-motion"
8
- import { IconChevronLeft , IconCircleHalf , IconCube , IconHighlight , IconLayers } from "justd-icons"
8
+ import { IconChevronRight , IconCircleHalf , IconCube , IconHighlight , IconLayers } from "justd-icons"
9
9
import { Link as NextLink } from "next-view-transitions"
10
10
import type { LinkProps as NextLinkProps } from "next/link"
11
11
import { usePathname } from "next/navigation"
12
+ import { twJoin } from "tailwind-merge"
12
13
import { tv } from "tailwind-variants"
13
14
import { Badge , cn , Disclosure , DisclosureGroup } from "ui"
14
15
@@ -56,11 +57,11 @@ const renderHierarchy = (node: HierarchyNode, defaultValues: string[]) => {
56
57
hideIndicator
57
58
allowsMultipleExpanded
58
59
defaultExpandedKeys = { [ "getting-started" , "components" ] }
59
- className = "w-full [&_.dk32xd]:p-0 [&_.zwx3ai]:p-0 [&_.zwx3ai]:border-none"
60
+ className = "w-full [&_.dk32xd]:p-0 flex flex-col gap-y-0.5 [&_.zwx3ai]:p-0 [&_.zwx3ai]:border-none"
60
61
>
61
62
{ filteredNodeEntries . map ( ( [ key , value ] ) => (
62
- < Disclosure key = { key } id = { key } >
63
- < Trigger className = "[&_.jr131]:size-4 py-1 .5 text-fg groud-data-[open]:text-muted-fg [&_.jr131]:text-primary [&_.jr131]:fill-primary /10 dark:[&_.jr131]:fill-primary /30" >
63
+ < Disclosure className = { ( { isExpanded } ) => twJoin ( isExpanded && "pb-0" ) } key = { key } id = { key } >
64
+ < Trigger className = "[&_.jr131]:size-4 pl-2 .5 pr-1 text-fg groud-data-[open]:text-muted-fg [&_.jr131]:text-muted-fg [&_.jr131]:fill-muted-fg /10 dark:[&_.jr131]:fill-muted-fg /30" >
64
65
{ key === "getting-started" ? (
65
66
< IconLayers className = "jr131" />
66
67
) : key === "prologue" ? (
@@ -73,97 +74,98 @@ const renderHierarchy = (node: HierarchyNode, defaultValues: string[]) => {
73
74
{ goodTitle ( key ) }
74
75
</ Trigger >
75
76
< Disclosure . Panel >
76
- { typeof value === "object" && "title" in value ? (
77
- < AsideLink href = { `/${ ( value as Doc ) . slug } ` } >
78
- { goodTitle ( ( value as Doc ) . title ) }
79
- </ AsideLink >
80
- ) : (
81
- < DisclosureGroup
82
- allowsMultipleExpanded
83
- hideBorder
84
- hideIndicator
85
- defaultExpandedKeys = { defaultValues }
86
- className = "w-full relative"
87
- >
88
- < div className = "h-full absolute left-0 bg-zinc-200 dark:bg-zinc-800 w-px ml-4" />
89
- { Object . entries ( value as HierarchyNode ) . map ( ( [ subKey , subValue ] ) =>
90
- typeof subValue === "object" && "title" in subValue ? (
91
- < AsideLink
92
- className = "pl-[2rem] flex justify-between items-center"
93
- key = { subKey }
94
- href = { `/${ subValue . slug } ` }
95
- >
96
- { ( subValue as Doc ) . title }
97
- { subValue . status && (
98
- < Badge
99
- intent = {
100
- subValue ?. status === "wip"
101
- ? "warning"
102
- : subValue ?. status === "alpha"
103
- ? "danger"
104
- : subValue . status === "beta"
77
+ < DisclosureGroup
78
+ allowsMultipleExpanded
79
+ hideBorder
80
+ hideIndicator
81
+ defaultExpandedKeys = { defaultValues }
82
+ className = "w-full relative"
83
+ >
84
+ < div className = "h-full absolute left-0 bg-zinc-200 dark:bg-zinc-800 w-px ml-4" />
85
+ { Object . entries ( value as HierarchyNode ) . map ( ( [ subKey , subValue ] ) =>
86
+ typeof subValue === "object" && "title" in subValue ? (
87
+ < AsideLink
88
+ className = "pl-[2.1rem] flex justify-between items-center"
89
+ key = { subKey }
90
+ href = { `/${ subValue . slug } ` }
91
+ >
92
+ { ( subValue as Doc ) . title }
93
+ { subValue . status && (
94
+ < Badge
95
+ intent = {
96
+ subValue ?. status === "wip"
97
+ ? "warning"
98
+ : subValue ?. status === "alpha"
99
+ ? "danger"
100
+ : subValue . status === "beta"
101
+ ? "warning"
102
+ : subValue . status === "help"
105
103
? "warning"
106
- : subValue . status === "help"
107
- ? "warning"
108
- : subValue . status === "primitive"
109
- ? "secondary"
110
- : "info"
111
- }
112
- className = "uppercase h-5 text-[0.5rem]"
113
- >
114
- { subValue ?. status as Doc [ "status" ] }
115
- </ Badge >
104
+ : subValue . status === "primitive"
105
+ ? "secondary"
106
+ : "info"
107
+ }
108
+ className = "uppercase h-5 text-[0.5rem]"
109
+ >
110
+ { subValue ?. status as Doc [ "status" ] }
111
+ </ Badge >
112
+ ) }
113
+ </ AsideLink >
114
+ ) : (
115
+ < Disclosure
116
+ className = { ( { isExpanded } ) => twJoin ( isExpanded && "pb-0" ) }
117
+ key = { subKey }
118
+ id = { subKey }
119
+ >
120
+ { /* Trigger components: buttons, controls, etc. */ }
121
+ < Trigger className = "[--trigger-padding-left:2.2rem] pl-[--trigger-padding-left] pr-1" >
122
+ { goodTitle ( subKey ) }
123
+ </ Trigger >
124
+ < Disclosure . Panel >
125
+ { Object . entries ( subValue as HierarchyNode ) . map ( ( [ childKey , childValue ] ) =>
126
+ typeof childValue === "object" && "title" in childValue ? (
127
+ < AsideLink
128
+ className = { cn (
129
+ "ml-[-0rem] flex justify-between h-9 items-center pl-[2.2rem] pr-2" ,
130
+ defaultValues . length > 0 && "jf320s"
131
+ ) }
132
+ key = { childKey }
133
+ href = { `/${ childValue . slug } ` }
134
+ indicatorClassName = ""
135
+ >
136
+ { ( childValue as Doc ) . title === "Disclosure Group aka Accordion"
137
+ ? "Disclosure Group"
138
+ : ( childValue as Doc ) . title === "Disclosure aka Collapsible"
139
+ ? "Disclosure"
140
+ : goodTitle ( ( childValue as Doc ) . title ) }
141
+ { childValue . status && (
142
+ < Badge
143
+ intent = {
144
+ childValue ?. status === "wip"
145
+ ? "primary"
146
+ : childValue . status === "beta"
147
+ ? "warning"
148
+ : childValue . status === "alpha"
149
+ ? "primary"
150
+ : childValue . status === "help"
151
+ ? "warning"
152
+ : childValue . status === "primitive"
153
+ ? "secondary"
154
+ : "info"
155
+ }
156
+ className = "capitalize h-5 text-[0.65rem]"
157
+ >
158
+ { childValue ?. status as Doc [ "status" ] }
159
+ </ Badge >
160
+ ) }
161
+ </ AsideLink >
162
+ ) : null
116
163
) }
117
- </ AsideLink >
118
- ) : (
119
- < Disclosure key = { subKey } id = { subKey } >
120
- < Trigger className = "pl-[2rem]" > { goodTitle ( subKey ) } </ Trigger >
121
- < Disclosure . Panel >
122
- { Object . entries ( subValue as HierarchyNode ) . map ( ( [ childKey , childValue ] ) =>
123
- typeof childValue === "object" && "title" in childValue ? (
124
- < AsideLink
125
- className = { cn (
126
- "ml-[-0rem] flex justify-between items-center pl-[3rem]" ,
127
- defaultValues . length > 0 && "jf320s"
128
- ) }
129
- key = { childKey }
130
- href = { `/${ childValue . slug } ` }
131
- indicatorClassName = ""
132
- >
133
- { ( childValue as Doc ) . title === "Disclosure Group aka Accordion"
134
- ? "Disclosure Group"
135
- : ( childValue as Doc ) . title === "Disclosure aka Collapsible"
136
- ? "Disclosure"
137
- : goodTitle ( ( childValue as Doc ) . title ) }
138
- { childValue . status && (
139
- < Badge
140
- intent = {
141
- childValue ?. status === "wip"
142
- ? "primary"
143
- : childValue . status === "beta"
144
- ? "warning"
145
- : childValue . status === "alpha"
146
- ? "primary"
147
- : childValue . status === "help"
148
- ? "warning"
149
- : childValue . status === "primitive"
150
- ? "secondary"
151
- : "info"
152
- }
153
- className = "capitalize h-5 text-[0.65rem]"
154
- >
155
- { childValue ?. status as Doc [ "status" ] }
156
- </ Badge >
157
- ) }
158
- </ AsideLink >
159
- ) : null
160
- ) }
161
- </ Disclosure . Panel >
162
- </ Disclosure >
163
- )
164
- ) }
165
- </ DisclosureGroup >
166
- ) }
164
+ </ Disclosure . Panel >
165
+ </ Disclosure >
166
+ )
167
+ ) }
168
+ </ DisclosureGroup >
167
169
</ Disclosure . Panel >
168
170
</ Disclosure >
169
171
) ) }
@@ -208,12 +210,12 @@ const Trigger = ({ children, className }: { children: React.ReactNode; className
208
210
return (
209
211
< Disclosure . Trigger
210
212
className = { cn (
211
- "group py-2 hover:text-fg pressed:text-fg aria-expanded:text-fg text-muted -fg" ,
213
+ "group hover:text-fg hover:bg-muted/60 py-1.5 pressed:text-fg aria-expanded:text-fg" ,
212
214
className
213
215
) }
214
216
>
215
217
{ children }
216
- < IconChevronLeft className = "ml-auto group-aria-expanded:- rotate-90 transition shrink-0 duration-300" />
218
+ < IconChevronRight className = "ml-auto group-aria-expanded:rotate-90 transition shrink-0 duration-300" />
217
219
</ Disclosure . Trigger >
218
220
)
219
221
}
@@ -226,7 +228,7 @@ interface AsideLinkProps extends NextLinkProps {
226
228
}
227
229
228
230
const asideLinkStyles = tv ( {
229
- base : "relative block focus:outline-none focus-visible:bg-secondary/70 focus-visible:ring-inset focus-visible:ring-1 focus-visible:ring-primary rounded-md px -2.5 py-2 text-base transition-colors hover:bg-secondary/70 hover:text-fg lg:text-sm" ,
231
+ base : "relative block group focus:outline-none focus-visible:bg-muted/50 focus-visible:ring-inset focus-visible:ring-1 focus-visible:ring-primary rounded-lg pl -2.5 h-9 text-base transition-colors hover:bg-muted/60 hover:text-fg lg:text-sm" ,
230
232
variants : {
231
233
isActive : {
232
234
true : "font-medium text-fg" ,
0 commit comments