UNPKG

swingset

Version:

drop-in component library and documentation pages for next.js

26 lines (23 loc) 756 B
import createLiveComponent from '../components/live-component' import createKnobsComponent from '../components/knobs-component' import PropsTable from '../components/props-table' import { SwingsetOptions } from '../types' import React from 'react' export default function createScope( scope: Record<string, JSX.Element>, swingsetOptions: SwingsetOptions, peerComponents: Record<string, React.ElementType> = {} ) { const scopeWithCustomComponents = Object.assign( {}, scope, swingsetOptions.components || {}, peerComponents ) return { ...scopeWithCustomComponents, LiveComponent: createLiveComponent(scopeWithCustomComponents), KnobsComponent: createKnobsComponent(scopeWithCustomComponents), PropsTable, } }