"use client" import React, { useMemo } from "react" import clsx from "clsx" import { CodeBlockStyle } from ".." import { useColorMode } from "@/providers" import { Badge, BadgeVariant } from "@/components" import { CodeBlockActions, CodeBlockActionsProps } from "../Actions" export type CodeBlockHeaderMeta = { badgeLabel?: string badgeColor?: BadgeVariant } type CodeBlockHeaderProps = { title?: string blockStyle?: CodeBlockStyle actionsProps: CodeBlockActionsProps } & CodeBlockHeaderMeta export const CodeBlockHeader = ({ title, blockStyle = "loud", badgeLabel, actionsProps, badgeColor, }: CodeBlockHeaderProps) => { const { colorMode } = useColorMode() const bgColor = useMemo( () => clsx( blockStyle === "loud" && "bg-medusa-contrast-bg-base", blockStyle === "subtle" && [ colorMode === "light" && "bg-medusa-bg-component", colorMode === "dark" && "bg-medusa-code-bg-header", ] ), [blockStyle, colorMode] ) const titleColor = useMemo( () => clsx( blockStyle === "loud" && "text-medusa-contrast-fg-secondary", blockStyle === "subtle" && [ colorMode === "light" && "text-medusa-fg-subtle", colorMode === "dark" && "text-medusa-contrast-fg-secondary", ] ), [blockStyle, colorMode] ) return (
{badgeLabel && ( {badgeLabel} )} {title && (
{title}
)}
) }