|
1
|
import React from "react" |
|
2
|
import { CollapsibleReturn } from "../../../../hooks/use-collapsible" |
|
3
|
|
|
4
|
export type CodeBlockCollapsibleLinesProps = { |
|
5
|
children: React.ReactNode |
|
6
|
type: "start" | "end" |
|
7
|
} & Pick<CollapsibleReturn, "collapsed"> |
|
8
|
|
|
9
|
export const CodeBlockCollapsibleLines = ({ |
|
10
|
children, |
|
11
|
type, |
|
12
|
collapsed, |
|
13
|
}: CodeBlockCollapsibleLinesProps) => { |
|
14
|
const isStart = type === "start" |
|
15
|
return ( |
|
16
|
<> |
|
17
|
{collapsed && Array.isArray(children) |
|
18
|
? children.slice(isStart ? -2 : 0, isStart ? undefined : 2) |
|
19
|
: children} |
|
20
|
</> |
|
21
|
) |
|
22
|
} |