|
1
|
import clsx from "clsx" |
|
2
|
import React from "react" |
|
3
|
import { CollapsibleReturn } from "../../../../hooks/use-collapsible" |
|
4
|
|
|
5
|
export type CodeBlockCollapsibleFadeProps = { |
|
6
|
type: "start" | "end" |
|
7
|
hasHeader?: boolean |
|
8
|
} & Pick<CollapsibleReturn, "collapsed"> |
|
9
|
|
|
10
|
export const CodeBlockCollapsibleFade = ({ |
|
11
|
type, |
|
12
|
hasHeader = false, |
|
13
|
collapsed, |
|
14
|
}: CodeBlockCollapsibleFadeProps) => { |
|
15
|
if (!collapsed) { |
|
16
|
return <></> |
|
17
|
} |
|
18
|
|
|
19
|
return ( |
|
20
|
<span |
|
21
|
className={clsx( |
|
22
|
"absolute flex flex-col z-10", |
|
23
|
hasHeader && "left-[6px] w-[calc(100%-12px)]", |
|
24
|
!hasHeader && "w-full left-0", |
|
25
|
type === "start" && [ |
|
26
|
hasHeader && "top-[44px]", |
|
27
|
!hasHeader && "top-[36px]", |
|
28
|
], |
|
29
|
type === "end" && [ |
|
30
|
hasHeader && "bottom-[44px]", |
|
31
|
!hasHeader && "bottom-[36px]", |
|
32
|
] |
|
33
|
)} |
|
34
|
> |
|
35
|
{type === "end" && ( |
|
36
|
<span |
|
37
|
className={clsx( |
|
38
|
"w-full h-[56px]", |
|
39
|
"bg-code-fade-bottom-to-top dark:bg-code-fade-bottom-to-top-dark" |
|
40
|
)} |
|
41
|
data-testid="collapsible-fade-end" |
|
42
|
/> |
|
43
|
)} |
|
44
|
{type === "start" && ( |
|
45
|
<span |
|
46
|
className={clsx( |
|
47
|
"w-full h-[56px]", |
|
48
|
"bg-code-fade-top-to-bottom dark:bg-code-fade-top-to-bottom-dark" |
|
49
|
)} |
|
50
|
data-testid="collapsible-fade-start" |
|
51
|
/> |
|
52
|
)} |
|
53
|
</span> |
|
54
|
) |
|
55
|
} |