import { KnobProvider } from '@fluentui/docs-components'; import * as _ from 'lodash'; import * as React from 'react'; import { examplePlaygroundContext } from '../../utils'; import ComponentPlaygroundTemplate from './ComponentPlaygroundTemplate'; import usePlaygroundComponent from './usePlaygroundComponent'; type ComponentPlaygroundProps = { componentName: string; }; const unsupportedComponents = [ 'Accordion', 'Animation', 'Box', 'Carousel', 'Chat', 'Dropdown', 'Flex', 'Form', 'Grid', 'HierarchicalTree', 'ItemLayout', 'Layout', 'List', 'MenuButton', 'Portal', 'Provider', 'RadioGroup', 'SplitButton', 'Table', 'Toolbar', 'Ref', ]; const ComponentPlayground: React.FunctionComponent = props => { if (unsupportedComponents.indexOf(props.componentName) !== -1) { return null; } const playgroundPaths = examplePlaygroundContext.keys(); const playgroundPath = _.find(playgroundPaths, playgroundPath => _.includes(playgroundPath, `/${props.componentName}/`), ); if (playgroundPath) { const component: React.FC = examplePlaygroundContext(playgroundPath).default; return ; } // This is intentional, `playgroundPath` will not change during execution // eslint-disable-next-line react-hooks/rules-of-hooks const [element, unsupportedProps] = usePlaygroundComponent(props.componentName); return ( /* TODO: remove "fluid" prop after Divider's refactor */ {process.env.NODE_ENV === 'production' ? null : (
Props not supported in playground {unsupportedProps.join(' | ')}
)}
); }; export default props => ( /* KnobProvider should be defined outside otherwise hooks will not properly register */ );