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

Function TruncatedCode

packages/dev/s2-docs/src/CodeBlock.tsx:196–218  ·  view source on GitHub ↗
({children, maxLines = 6, ...props}: TruncatedCodeProps)

Source from the content-addressed store, hash-verified

194}
195
196function TruncatedCode({children, maxLines = 6, ...props}: TruncatedCodeProps) {
197 let lines = children.split('\n');
198 return lines.length > maxLines ? (
199 <ExpandableCode hasHighlightedLine={/- begin (highlight|focus)/.test(children)}>
200 <Pre>
201 <Code {...props}>{children}</Code>
202 </Pre>
203 </ExpandableCode>
204 ) : (
205 <div
206 className={style({
207 overflow: 'auto',
208 '--code-padding-end': {
209 type: 'paddingEnd',
210 value: 64 // Extra space for the toolbar
211 }
212 })}>
213 <Pre>
214 <Code {...props}>{children}</Code>
215 </Pre>
216 </div>
217 );
218}
219
220interface FilesProps {
221 children?: ReactNode;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected