@@ -56,13 +56,13 @@ export function CodeGroup({ children, className }: CodeGroupProps) {
5656 return (
5757 < div
5858 className = { cn (
59- "code-group group my-4 rounded-md border pt-2 " ,
59+ "code-group group my-4 rounded-md border" ,
6060 className ,
6161 ) }
6262 data-code-group
6363 >
64- < Tabs defaultValue = { getChildIdx ( children [ 0 ] ) } >
65- < div className = "flex gap-1 border-b pr-2" >
64+ < Tabs defaultValue = { getChildIdx ( children [ 0 ] ) } >
65+ < div className = "flex gap-1 border-b pr-2" >
6666 < ScrollArea
6767 className = "w-full"
6868 viewportProps = { { className : "[&>div]:!table" } }
@@ -71,7 +71,11 @@ export function CodeGroup({ children, className }: CodeGroupProps) {
7171 { Children . map ( children , ( child ) => {
7272 const idx = getChildIdx ( child ) ;
7373 return (
74- < TabsTrigger key = { idx } value = { idx } >
74+ < TabsTrigger
75+ key = { idx }
76+ value = { idx }
77+ className = "data-[state=active]:!text-white"
78+ >
7579 { child . props . title ||
7680 child . props . meta ||
7781 languageNames [
@@ -83,20 +87,6 @@ export function CodeGroup({ children, className }: CodeGroupProps) {
8387 } ) }
8488 </ TabsList >
8589 </ ScrollArea >
86- < WithTooltip
87- trigger = {
88- < CopyCodeTrigger >
89- < Button
90- size = "icon-sm"
91- className = "text-foreground"
92- variant = "ghost"
93- >
94- < Icon icon = { faCopy } />
95- </ Button >
96- </ CopyCodeTrigger >
97- }
98- content = "Copy code"
99- />
10090 </ div >
10191 { Children . map ( children , ( child ) => {
10292 const idx = getChildIdx ( child ) ;
@@ -128,12 +118,14 @@ export const pre = ({
128118 title,
129119 isInGroup,
130120} : PreProps ) => {
121+ const showHeader = ! isInGroup || ! ! file ;
122+ const showCopyButton = ! isInGroup ;
131123 return (
132124 < div
133125 className = "not-prose my-4 rounded-md border group-[.code-group]:my-0 group-[.code-group]:-mt-2 group-[.code-group]:border-none"
134126 data-code-group
135127 >
136- { ! file && isInGroup ? null : (
128+ { showHeader && (
137129 < div className = "text-foreground flex items-center justify-between gap-2 border-b p-2 text-xs" >
138130 < div className = "text-muted-foreground flex items-center gap-1" >
139131 { file ? (
@@ -147,16 +139,18 @@ export const pre = ({
147139 </ Badge >
148140 ) }
149141 </ div >
150- < WithTooltip
151- trigger = {
152- < CopyCodeTrigger >
153- < Button size = "icon-sm" variant = "ghost" >
154- < Icon icon = { faCopy } />
155- </ Button >
156- </ CopyCodeTrigger >
157- }
158- content = "Copy code"
159- />
142+ { showCopyButton ? (
143+ < WithTooltip
144+ trigger = {
145+ < CopyCodeTrigger >
146+ < Button size = "icon-sm" variant = "ghost" >
147+ < Icon icon = { faCopy } />
148+ </ Button >
149+ </ CopyCodeTrigger >
150+ }
151+ content = "Copy code"
152+ />
153+ ) : null }
160154 </ div >
161155 ) }
162156 < div className = "bg-background text-wrap p-2 text-sm" >
0 commit comments