import * as React from 'react'; import { useCopyToClipboard } from '../CopyToClipboard'; import { CodeSnippetProps } from './types'; type CopySnippetLabelProps = Pick & { value: string; }; const checkIcon = ( ); const copyIcon = ( ); export const CodeSnippetLabel: React.FunctionComponent = props => { const { copyable, label, mode, value } = props; const hasLabel = label !== false; const [active, onCopy] = useCopyToClipboard(value); return ( hasLabel && (
{label || mode}
{copyable &&
{active ? checkIcon : copyIcon}
}
) ); };