@@ -109,39 +109,8 @@ function AttributeValue({ value }: { value: unknown }) {
109109 ) ;
110110}
111111
112- function IdRow ( { label, value } : { label : string ; value : string } ) {
113- const [ copied , setCopied ] = useState ( false ) ;
114- const copy = useCallback ( ( ) => {
115- navigator . clipboard . writeText ( value ) . then ( ( ) => {
116- setCopied ( true ) ;
117- setTimeout ( ( ) => setCopied ( false ) , 1500 ) ;
118- } ) ;
119- } , [ value ] ) ;
120-
121- return (
122- < div className = "flex items-center gap-2 group" >
123- < span className = "text-[10px] uppercase font-semibold shrink-0 w-12" style = { { color : "var(--text-muted)" } } >
124- { label }
125- </ span >
126- < span
127- className = "text-[11px] font-mono truncate flex-1"
128- style = { { color : "var(--text-secondary)" } }
129- title = { value }
130- >
131- { value }
132- </ span >
133- < button
134- onClick = { copy }
135- className = "opacity-0 group-hover:opacity-100 text-[10px] cursor-pointer shrink-0"
136- style = { { color : copied ? "var(--success)" : "var(--text-muted)" } }
137- >
138- { copied ? "copied" : "copy" }
139- </ button >
140- </ div >
141- ) ;
142- }
143-
144112export default function SpanDetails ( { span } : Props ) {
113+ const [ attrsOpen , setAttrsOpen ] = useState ( true ) ;
145114 const [ idsOpen , setIdsOpen ] = useState ( false ) ;
146115 const status = STATUS_CONFIG [ span . status . toLowerCase ( ) ] ?? { ...DEFAULT_STATUS , label : span . status } ;
147116
@@ -188,16 +157,20 @@ export default function SpanDetails({ span }: Props) {
188157 </ span >
189158 </ div >
190159
191- { /* Attributes — flat rows */ }
160+ { /* Attributes — collapsible */ }
192161 { attrEntries . length > 0 && (
193162 < >
194163 < div
195- className = "px-2 py-1 text-[10px] uppercase font-bold tracking-wider border-b"
164+ className = "px-2 py-1 text-[10px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center "
196165 style = { { color : "var(--accent)" , borderColor : "var(--border)" , background : "var(--bg-secondary)" } }
166+ onClick = { ( ) => setAttrsOpen ( ( o ) => ! o ) }
197167 >
198- Attributes ({ attrEntries . length } )
168+ < span className = "flex-1" > Attributes ({ attrEntries . length } )</ span >
169+ < span style = { { color : "var(--text-muted)" , transform : attrsOpen ? "rotate(0deg)" : "rotate(-90deg)" } } >
170+ ▾
171+ </ span >
199172 </ div >
200- { attrEntries . map ( ( [ key , value ] , idx ) => (
173+ { attrsOpen && attrEntries . map ( ( [ key , value ] , idx ) => (
201174 < div
202175 key = { key }
203176 className = "flex gap-2 px-2 py-1 items-start border-b"
@@ -224,21 +197,37 @@ export default function SpanDetails({ span }: Props) {
224197 { /* Identifiers — collapsible */ }
225198 < div
226199 className = "px-2 py-1 text-[10px] uppercase font-bold tracking-wider border-b cursor-pointer flex items-center"
227- style = { { color : "var(--info )" , borderColor : "var(--border)" , background : "var(--bg-secondary)" } }
200+ style = { { color : "var(--accent )" , borderColor : "var(--border)" , background : "var(--bg-secondary)" } }
228201 onClick = { ( ) => setIdsOpen ( ( o ) => ! o ) }
229202 >
230- < span className = "flex-1" > Identifiers</ span >
203+ < span className = "flex-1" > Identifiers ( { ids . length } ) </ span >
231204 < span style = { { color : "var(--text-muted)" , transform : idsOpen ? "rotate(0deg)" : "rotate(-90deg)" } } >
232205 ▾
233206 </ span >
234207 </ div >
235- { idsOpen && (
236- < div className = "px-2 py-1 space-y-0.5" style = { { background : "var(--bg-primary)" } } >
237- { ids . map ( ( id ) => (
238- < IdRow key = { id . label } label = { id . label } value = { id . value } />
239- ) ) }
208+ { idsOpen && ids . map ( ( id , idx ) => (
209+ < div
210+ key = { id . label }
211+ className = "flex gap-2 px-2 py-1 items-start border-b"
212+ style = { {
213+ borderColor : "var(--border)" ,
214+ background : idx % 2 === 0 ? "var(--bg-primary)" : "var(--bg-secondary)" ,
215+ } }
216+ >
217+ < span
218+ className = "font-mono font-semibold shrink-0 pt-px truncate text-[11px]"
219+ style = { { color : "var(--info)" , width : "35%" } }
220+ title = { id . label }
221+ >
222+ { id . label }
223+ </ span >
224+ < span className = "flex-1 min-w-0" >
225+ < span className = "font-mono text-[11px] break-all" style = { { color : "var(--text-primary)" } } >
226+ { id . value }
227+ </ span >
228+ </ span >
240229 </ div >
241- ) }
230+ ) ) }
242231 </ div >
243232 ) ;
244233}
0 commit comments