MCPcopy Create free account
hub / github.com/Surfer-Org/Protocol / CodePanel

Function CodePanel

docs/src/components/Code.jsx:128–152  ·  view source on GitHub ↗
({ children, tag, label, code })

Source from the content-addressed store, hash-verified

126}
127
128function CodePanel({ children, tag, label, code }) {
129 let child = Children.only(children)
130
131 if (isValidElement(child)) {
132 tag = child.props.tag ?? tag
133 label = child.props.label ?? label
134 code = child.props.code ?? code
135 }
136
137 if (!code) {
138 throw new Error(
139 '`CodePanel` requires a `code` prop, or a child with a `code` prop.',
140 )
141 }
142
143 return (
144 <div className="group dark:bg-white/2.5">
145 <CodePanelHeader tag={tag} label={label} />
146 <div className="relative">
147 <pre className="overflow-x-auto p-4 text-xs text-white">{children}</pre>
148 <CopyButton code={code} />
149 </div>
150 </div>
151 )
152}
153
154function CodeGroupHeader({ title, children, selectedIndex }) {
155 let hasTabs = Children.count(children) > 1

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected