({ title, children, selectedIndex })
| 152 | } |
| 153 | |
| 154 | function CodeGroupHeader({ title, children, selectedIndex }) { |
| 155 | let hasTabs = Children.count(children) > 1 |
| 156 | |
| 157 | if (!title && !hasTabs) { |
| 158 | return null |
| 159 | } |
| 160 | |
| 161 | return ( |
| 162 | <div className="flex min-h-[calc(theme(spacing.12)+1px)] flex-wrap items-start gap-x-4 border-b border-zinc-700 bg-zinc-800 px-4 dark:border-zinc-800 dark:bg-transparent"> |
| 163 | {title && ( |
| 164 | <h3 className="mr-auto pt-3 text-xs font-semibold text-white"> |
| 165 | {title} |
| 166 | </h3> |
| 167 | )} |
| 168 | {hasTabs && ( |
| 169 | <TabList className="-mb-px flex gap-4 text-xs font-medium"> |
| 170 | {Children.map(children, (child, childIndex) => ( |
| 171 | <Tab |
| 172 | className={clsx( |
| 173 | 'border-b py-3 transition ui-not-focus-visible:outline-none', |
| 174 | childIndex === selectedIndex |
| 175 | ? 'border-blue-500 text-blue-400' |
| 176 | : 'border-transparent text-zinc-400 hover:text-zinc-300', |
| 177 | )} |
| 178 | > |
| 179 | {getPanelTitle(isValidElement(child) ? child.props : {})} |
| 180 | </Tab> |
| 181 | ))} |
| 182 | </TabList> |
| 183 | )} |
| 184 | </div> |
| 185 | ) |
| 186 | } |
| 187 | |
| 188 | function CodeGroupPanels({ children, ...props }) { |
| 189 | let hasTabs = Children.count(children) > 1 |
nothing calls this directly
no test coverage detected