@@ -18,6 +18,16 @@ interface CodeExamplePanelProps {
1818 supportingText ?: string
1919}
2020
21+ const colors = {
22+ cream : '#FAF7F2' ,
23+ creamDark : '#F0EBE3' ,
24+ ink : '#1a1816' ,
25+ inkLight : '#3d3835' ,
26+ inkMuted : '#6b6460' ,
27+ coral : '#E85D4C' ,
28+ sage : '#7D9F8E'
29+ }
30+
2131export default function CodeExamplePanel ( {
2232 title = 'Example Code' ,
2333 defaultOpen = false ,
@@ -33,13 +43,11 @@ export default function CodeExamplePanel({
3343
3444 const activeCode = tabs . find ( ( tab ) => tab . value === activeTab ) ?. code || ''
3545
36- // Handle when content refs update
3746 const updateTabHeight = (
3847 tabValue : string ,
3948 element : HTMLDivElement | null
4049 ) => {
4150 if ( element ) {
42- // Small delay to ensure content has fully rendered
4351 setTimeout ( ( ) => {
4452 const height = element . scrollHeight
4553 setTabHeights ( ( prev ) => ( {
@@ -50,7 +58,6 @@ export default function CodeExamplePanel({
5058 }
5159 }
5260
53- // Update heights when tab changes or content loads
5461 useEffect ( ( ) => {
5562 const currentRef = contentRefs . current [ activeTab ]
5663 if ( currentRef && highlighterLoadedRef . current [ activeTab ] ) {
@@ -67,43 +74,89 @@ export default function CodeExamplePanel({
6774 return (
6875 < div className = "w-full" >
6976 < Collapsible . Root open onOpenChange = { setOpen } className = "w-full" >
70- < Collapsible . Trigger className = "flex w-full items-center justify-between p-3 rounded-t-lg bg-zinc-900/80 hover:bg-zinc-900 border border-zinc-800/80 transition-colors" >
77+ < Collapsible . Trigger
78+ className = "flex w-full items-center justify-between p-3 rounded-t-sm transition-colors"
79+ style = { {
80+ backgroundColor : colors . ink ,
81+ border : `1px solid ${ colors . ink } `
82+ } }
83+ >
7184 < div className = "flex items-center gap-2" >
72- < Code className = "h-4 w-4 text-zinc-400" />
73- < span className = "text-sm font-medium text-zinc-300" > { title } </ span >
85+ < Code
86+ className = "h-4 w-4"
87+ style = { { color : 'rgba(255,255,255,0.6)' } }
88+ />
89+ < span
90+ className = "text-sm font-medium"
91+ style = { { color : 'rgba(255,255,255,0.9)' } }
92+ >
93+ { title }
94+ </ span >
7495 </ div >
7596 < div
7697 className = { `transition-transform duration-200 ${ open ? 'rotate-90' : '' } ` }
7798 >
78- < ChevronRight className = "h-4 w-4 text-zinc-400" />
99+ < ChevronRight
100+ className = "h-4 w-4"
101+ style = { { color : 'rgba(255,255,255,0.6)' } }
102+ />
79103 </ div >
80104 </ Collapsible . Trigger >
81105
82106 < Collapsible . Content className = "overflow-hidden data-[state=open]:animate-collapsible-down data-[state=closed]:animate-collapsible-up" >
83- < div className = "border-x border-b border-zinc-800/80 rounded-b-lg overflow-hidden" >
107+ < div
108+ className = "rounded-b-sm overflow-hidden"
109+ style = { { border : `1px solid ${ colors . ink } 25` , borderTop : 'none' } }
110+ >
84111 < Tabs . Root value = { activeTab } onValueChange = { setActiveTab } >
85- < Tabs . List className = "flex border-b border-zinc-800/80 bg-black/20" >
112+ < Tabs . List
113+ className = "flex"
114+ style = { {
115+ borderBottom : `1px solid ${ colors . ink } 20` ,
116+ backgroundColor : `${ colors . inkLight } 40`
117+ } }
118+ >
86119 { tabs . map ( ( tab ) => (
87120 < Tabs . Trigger
88121 key = { tab . value }
89122 value = { tab . value }
90- className = "px-4 py-2 text-sm transition-colors data-[state=active]:text-violet-400 data-[state=active]:border-b-2 data-[state=active]:border-violet-500 data-[state=active]:-mb-px text-zinc-500 hover:text-zinc-400 font-medium"
123+ className = "px-4 py-2 text-sm transition-colors font-medium data-[state=active]:-mb-px"
124+ style = { {
125+ color :
126+ activeTab === tab . value
127+ ? colors . coral
128+ : colors . inkMuted ,
129+ borderBottom :
130+ activeTab === tab . value
131+ ? `2px solid ${ colors . coral } `
132+ : 'none'
133+ } }
91134 >
92135 { tab . label }
93136 </ Tabs . Trigger >
94137 ) ) }
95138 </ Tabs . List >
96139
97- < div className = "relative bg-black/30" >
140+ < div className = "relative" style = { { backgroundColor : colors . ink } } >
98141 < button
99142 onClick = { handleCopy }
100- className = "absolute top-3 right-3 text-xs flex items-center gap-1.5 text-zinc-500 px-2.5 py-1 rounded-md bg-zinc-800/80 hover:bg-zinc-800 hover:text-zinc-300 transition-colors border border-zinc-700/50 z-10"
143+ className = "absolute top-3 right-3 text-xs flex items-center gap-1.5 px-2.5 py-1 rounded-sm transition-colors z-10"
144+ style = { {
145+ color : 'rgba(255,255,255,0.4)' ,
146+ backgroundColor : 'rgba(255,255,255,0.05)' ,
147+ border : '1px solid rgba(255,255,255,0.1)'
148+ } }
101149 aria-label = "Copy code to clipboard"
102150 >
103151 { copied ? (
104152 < span className = "flex items-center gap-1.5" >
105- < Check className = "h-3 w-3 text-emerald-400" />
106- < span > Copied</ span >
153+ < Check
154+ className = "h-3 w-3"
155+ style = { { color : colors . sage } }
156+ />
157+ < span style = { { color : 'rgba(255,255,255,0.7)' } } >
158+ Copied
159+ </ span >
107160 </ span >
108161 ) : (
109162 < span className = "flex items-center gap-1.5" >
@@ -132,7 +185,6 @@ export default function CodeExamplePanel({
132185 load = { ( ) =>
133186 import ( '../components/shiki-highlighter' ) . then (
134187 ( m ) => {
135- // Mark this highlighter as loaded
136188 highlighterLoadedRef . current [ tab . value ] = true
137189 return m . default
138190 }
@@ -141,12 +193,12 @@ export default function CodeExamplePanel({
141193 fallback = {
142194 < div className = "flex items-start p-5" >
143195 < div className = "w-full animate-pulse" >
144- { /* Generate lines based on code length */ }
145196 { tab . code . split ( '\n' ) . map ( ( _ , i ) => (
146197 < div
147198 key = { i }
148- className = "h-[21px] bg-zinc-800/50 rounded mb-1.5"
199+ className = "h-[21px] rounded mb-1.5"
149200 style = { {
201+ backgroundColor : 'rgba(255,255,255,0.1)' ,
150202 width : `${ Math . min ( 100 , 30 + Math . random ( ) * 70 ) } %`
151203 } }
152204 > </ div >
@@ -170,7 +222,14 @@ export default function CodeExamplePanel({
170222 </ Tabs . Root >
171223
172224 { supportingText && (
173- < div className = "p-3 text-xs text-zinc-400 border-t border-zinc-800/50 bg-black/20" >
225+ < div
226+ className = "p-3 text-xs"
227+ style = { {
228+ color : colors . inkMuted ,
229+ borderTop : `1px solid ${ colors . ink } 15` ,
230+ backgroundColor : colors . creamDark
231+ } }
232+ >
174233 { supportingText }
175234 </ div >
176235 ) }
0 commit comments