{props.description && (
)}
{asDropdown ? (
<$LanguageDropdown
highlighted={highlighted}
value={props.value}
onValueChange={props.onValueChange}
label={(lang, meta) => label(lang, meta, true)}
/>
) : (
{highlighted?.map(({ meta, lang }, i) => {
if (isSingle) {
return null;
}
return (
{label(lang, meta)}
);
})}
)}
{highlighted?.map((codeblock, i) => (
))}
{/* Extra toolbar action(s) after copy — e.g. Atlas's run-request play. */}
{codeActions}
);
}
interface LanguageDropdownProps {
highlighted: HighlightedCode[];
value?: string;
onValueChange?: (value: string) => void;
label: (lang: string, meta?: string) => React.ReactNode;
}
// The language switcher rendered as a dropdown. Drives the same active value as
// the tab row (the enclosing Tabs.Root is controlled), so the code panes swap
// exactly as they do for tabs — analytics included (via `onValueChange`).
function $LanguageDropdown(props: LanguageDropdownProps) {
const current =
props.highlighted.find((h) => (h.meta || h.lang) === props.value) ||
props.highlighted[0];
return (