Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@ import * as _ from 'lodash';
import * as React from 'react';
import { NavLink } from 'react-router-dom';

import { CodeSandboxExporter, CodeSandboxState, CopyToClipboard } from '@fluentui/docs-components';
import {
AcceptIcon,
CircleIcon,
EditIcon,
IndentIcon,
LinkIcon,
OpenOutsideIcon,
} from '@fluentui/react-icons-northstar';
import { Loader, Menu, menuAsToolbarBehavior, MenuItem, MenuProps, Tooltip } from '@fluentui/react-northstar';
import { CopyToClipboard } from '@fluentui/docs-components';
import { CircleIcon, EditIcon, IndentIcon, LinkIcon, OpenOutsideIcon } from '@fluentui/react-icons-northstar';
import { Menu, menuAsToolbarBehavior, MenuItem, MenuProps, Tooltip } from '@fluentui/react-northstar';

import { CodeSandboxIcon } from '../../Icons/CodeSandboxIcon';
import { imports } from '../../Playground/renderConfig';
import { ComponentSourceManagerLanguage } from '../ComponentSourceManager';
import CodeSnippetIcon from './CodeSnippetIcon';

Expand Down Expand Up @@ -54,126 +45,92 @@ const ComponentControls: React.FC<ComponentControlsProps> = props => {
...rest
} = props;

return (
<CodeSandboxExporter
exampleCode={exampleCode}
exampleLanguage={exampleLanguage}
exampleName={examplePath}
imports={imports}
>
{(state, onCodeSandboxClick) => {
const codeSandboxTooltip =
state === CodeSandboxState.Default
? 'CodeSandbox'
: state === CodeSandboxState.Loading
? 'Exporting...'
: 'Click to open';

const codeSandboxIcon =
state === CodeSandboxState.Default ? (
<CodeSandboxIcon />
) : state === CodeSandboxState.Loading ? (
<Loader size="small" />
) : (
<AcceptIcon />
);
const items: MenuProps['items'] = [
{
icon: <CodeSnippetIcon />,
onClick: onShowCode,
active: showCode,
children: (Component: typeof MenuItem, props) => (
<Tooltip content="Try it" key="show-code" trigger={<Component {...props} />} />
),
},

const items: MenuProps['items'] = [
{
icon: <CodeSnippetIcon />,
onClick: onShowCode,
active: showCode,
children: (Component: typeof MenuItem, props) => (
<Tooltip content="Try it" key="show-code" trigger={<Component {...props} />} />
),
},
{
icon: <EditIcon />,
onClick: onShowVariables,
active: showVariables,
children: (Component: typeof MenuItem, props) => (
<Tooltip content="Theme it" key="show-variables" trigger={<Component {...props} />} />
),
},
{
key: 'divider-1',
style: { margin: '0 5px' },
kind: 'divider',
},
{
icon: <CircleIcon outline />,
onClick: onShowTransparent,
active: showTransparent,
children: (Component: typeof MenuItem, props) => (
<Tooltip content="Transparent" key="show-transparent" trigger={<Component {...props} />} />
),
},
{
icon: <IndentIcon rotate={180} />,
onClick: onShowRtl,
active: showRtl,
children: (Component: typeof MenuItem, props) => (
<Tooltip content="RTL" key="show-rtl" trigger={<Component {...props} />} />
),
},

{
icon: <EditIcon />,
onClick: onShowVariables,
active: showVariables,
children: (Component: typeof MenuItem, props) => (
<Tooltip content="Theme it" key="show-variables" trigger={<Component {...props} />} />
),
},
{
key: 'divider-1',
style: { margin: '0 5px' },
kind: 'divider',
},
{
icon: <CircleIcon outline />,
onClick: onShowTransparent,
active: showTransparent,
children: (Component: typeof MenuItem, props) => (
<Tooltip content="Transparent" key="show-transparent" trigger={<Component {...props} />} />
),
},
{
icon: <IndentIcon rotate={180} />,
onClick: onShowRtl,
active: showRtl,
children: (Component: typeof MenuItem, props) => (
<Tooltip content="RTL" key="show-rtl" trigger={<Component {...props} />} />
),
},
{
icon: <OpenOutsideIcon />,
children: (Component: typeof MenuItem, props) => (
<Tooltip content="Popout" key="maximize" trigger={<Component {...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',
},
{
icon: <LinkIcon />,
children: (Component: typeof MenuItem, props) => (
<CopyToClipboard key="copy-link" value={anchorName}>
{(active, onClick) => (
<Tooltip
content={active ? 'Copied!' : 'Permalink'}
trigger={
<Component
{...props}
onClick={(e: React.SyntheticEvent) => {
onClick();
onCopyLink(e);
}}
/>
}
/>
)}
</CopyToClipboard>
),
},
];

{
icon: <OpenOutsideIcon />,
children: (Component: typeof MenuItem, props) => (
<Tooltip content="Popout" key="maximize" trigger={<Component {...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) => (
<Tooltip content={codeSandboxTooltip} key="show-codesandbox" trigger={<Component {...props} />} />
),
},
{
icon: <LinkIcon />,
children: (Component: typeof MenuItem, props) => (
<CopyToClipboard key="copy-link" value={anchorName}>
{(active, onClick) => (
<Tooltip
content={active ? 'Copied!' : 'Permalink'}
trigger={
<Component
{...props}
onClick={(e: React.SyntheticEvent) => {
onClick();
onCopyLink(e);
}}
/>
}
/>
)}
</CopyToClipboard>
),
},
];

return (
<Menu
{...rest}
iconOnly
accessibility={menuAsToolbarBehavior}
aria-label={`Actions for ${titleForAriaLabel || 'untitled'} example`}
items={items}
/>
);
}}
</CodeSandboxExporter>
return (
<Menu
{...rest}
iconOnly
accessibility={menuAsToolbarBehavior}
aria-label={`Actions for ${titleForAriaLabel || 'untitled'} example`}
items={items}
/>
);
};

Expand Down

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion packages/fluentui/react-component-ref/src/Ref.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class Ref extends React.Component<RefProps, RefState> {
return { kind: 'self' };
}

if (ReactIs.isForwardRef(child)) {
if (ReactIs.isForwardRef(child) || typeof (child as React.ReactElement).type === 'string') {
return { kind: 'forward' };
}

Expand Down
Loading
Loading