MCPcopy
hub / github.com/wandb/openui / htmlToJSX

Function htmlToJSX

frontend/src/components/CodeViewer.tsx:35–64  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

33}
34
35function htmlToJSX(text: string) {
36 const mapObj = {
37 'class=': 'className=',
38 'for=': 'htmlFor=',
39 '-rule': 'Rule',
40 'stroke-l': 'strokeL',
41 'stroke-w': 'strokeW',
42 '<!--': '{/*',
43 '-->': '*/}',
44 tabindex: 'tabIndex',
45 colspan: 'colSpan:',
46 rowspan: 'rowSpan:',
47 'aria-*': 'aria-*',
48 'data-*': 'data-*',
49 onclick: 'onClick',
50 onchange: 'onChange',
51 onblur: 'onBlur'
52 }
53
54 const render = replaceAll(text, mapObj)
55 // TODO: it would cool to generate a name for our component
56 return `export default function Widget() {
57 return (
58${render
59 .split('\n')
60 .map(line => ` ${line}`)
61 .join('\n')}
62 )
63}`
64}
65
66interface ViewerProps {
67 id: string

Callers 1

CodeViewerFunction · 0.85

Calls 1

replaceAllFunction · 0.85

Tested by

no test coverage detected