import { CopyToClipboard } from '@fluentui/docs-components'; import { Menu, menuAsToolbarBehavior, Tooltip, Loader, MenuProps, MenuItem } from '@fluentui/react-northstar'; import * as _ from 'lodash'; import * as React from 'react'; import { NavLink } from 'react-router-dom'; import { ComponentSourceManagerLanguage } from '../ComponentSourceManager'; import ComponentControlsCodeSandbox, { CodeSandboxState, } from './ComponentControlsCodeSandbox/ComponentControlsCodeSandbox'; import { EditIcon, FilesCodeIcon, CircleIcon, LinkIcon, OpenOutsideIcon, AcceptIcon, IndentIcon, } from '@fluentui/react-icons-northstar'; import CodeSnippetIcon from './CodeSnippetIcon'; type ComponentControlsProps = { exampleCode: string; exampleLanguage: ComponentSourceManagerLanguage; examplePath: string; anchorName: string; onCopyLink: (e: React.SyntheticEvent) => void; onShowCode: (e: React.SyntheticEvent) => void; onShowRtl: (e: React.SyntheticEvent) => void; onShowTransparent: (e: React.SyntheticEvent) => void; onShowVariables: (e: React.SyntheticEvent) => void; showCode: boolean; showRtl: boolean; showVariables: boolean; showTransparent: boolean; titleForAriaLabel?: string; }; const ComponentControls: React.FC = props => { const { anchorName, exampleCode, exampleLanguage, examplePath, showCode, showRtl, showVariables, showTransparent, onCopyLink, onShowCode, onShowRtl, onShowTransparent, onShowVariables, titleForAriaLabel, ...rest } = props; return ( {(state, onCodeSandboxClick) => { const codeSandboxTooltip = state === CodeSandboxState.Default ? 'CodeSandbox' : state === CodeSandboxState.Loading ? 'Exporting...' : 'Click to open'; const codeSandboxIcon = state === CodeSandboxState.Default ? ( ) : state === CodeSandboxState.Loading ? ( ) : ( ); const items: MenuProps['items'] = [ { icon: , onClick: onShowCode, active: showCode, children: (Component: typeof MenuItem, props) => ( } /> ), }, { icon: , onClick: onShowVariables, active: showVariables, children: (Component: typeof MenuItem, props) => ( } /> ), }, { key: 'divider-1', style: { margin: '0 5px' }, kind: 'divider', }, { icon: , onClick: onShowTransparent, active: showTransparent, children: (Component: typeof MenuItem, props) => ( } /> ), }, { icon: , onClick: onShowRtl, active: showRtl, children: (Component: typeof MenuItem, props) => ( } /> ), }, { icon: , children: (Component: typeof MenuItem, props) => ( } /> ), as: NavLink, to: `/maximize/${_.kebabCase( examplePath .split('/') .slice(-1) .pop(), )}/${showRtl}`, target: '_blank', rel: 'noopener noreferrer', }, { key: 'divider-2', style: { margin: '0 5px' }, kind: 'divider', }, { onClick: onCodeSandboxClick, icon: codeSandboxIcon, children: (Component: typeof MenuItem, props) => ( } /> ), }, { icon: , children: (Component: typeof MenuItem, props) => ( {(active, onClick) => ( { onClick(); onCopyLink(e); }} /> } /> )} ), }, ]; return ( ); }} ); }; export default React.memo(ComponentControls);