MCPcopy Create free account
hub / github.com/adobe/react-spectrum / CodeProps

Function CodeProps

packages/dev/s2-docs/src/VisualExampleClient.tsx:304–332  ·  view source on GitHub ↗
({indent = ''})

Source from the content-addressed store, hash-verified

302}
303
304export function CodeProps({indent = ''}) {
305 let {props, controls, propsObject} = useContext(Context);
306 if (propsObject) {
307 props = {[propsObject]: props};
308 }
309
310 let renderedProps: ReactNode[] = Object.keys(props)
311 .filter(prop => prop !== 'children')
312 .map(prop => renderProp(prop, props[prop], controls[prop], indent))
313 .filter(Boolean);
314 let newlines = indent.length > 0 || countChars(renderedProps) > 40;
315 let separator = newlines ? indent || ' ' : ' ';
316 renderedProps = renderedProps.map((p, i) => {
317 let sep = separator;
318 if (newlines) {
319 sep = (indent && i === 0 ? '' : '\n') + separator;
320 }
321 return (
322 <Fragment key={i}>
323 {sep}
324 {p}
325 </Fragment>
326 );
327 });
328 if (newlines && indent && renderedProps.length) {
329 renderedProps.push('\n');
330 }
331 return renderedProps;
332}
333
334function renderElement(name: string, props: Props, controls?: Controls, indent = '') {
335 let start = (

Callers

nothing calls this directly

Calls 4

renderPropFunction · 0.85
countCharsFunction · 0.85
pushMethod · 0.80
filterMethod · 0.65

Tested by

no test coverage detected