1 "use client"
2
3 import clsx from "clsx"
4 import React from "react"
5 import { CollapsibleReturn } from "../../../../hooks/use-collapsible"
6 import { Button } from "@medusajs/ui"
7
8 export type CodeBlockCollapsibleButtonProps = {
9 type: "start" | "end"
10 expandButtonLabel?: string
11 className?: string
12 } & Omit<CollapsibleReturn, "getCollapsibleElms">
13
14 export const CodeBlockCollapsibleButton = ({
15 type,
16 expandButtonLabel = "Show more",
17 collapsed,
18 setCollapsed,
19 className,
20 }: CodeBlockCollapsibleButtonProps) => {
21 if (!collapsed) {
22 return <></>
23 }
24
25 return (
26 <>
27 {type === "start" && (
28 <Button
29 className={clsx(
30 "font-base w-full !p-docs_0.5 !shadow-none z-10",
31 "bg-medusa-contrast-button hover:bg-medusa-contrast-button-hover",
32 "txt-compact-xsmall text-medusa-contrast-fg-secondary",
33 type === "start" && "rounded-t-docs_DEFAULT rounded-b-none",
34 className
35 )}
36 data-testid="collapsible-button-start"
37 onClick={() => setCollapsed(false)}
38 >
39 {expandButtonLabel}
40 </Button>
41 )}
42 {type === "end" && (
43 <Button
44 className={clsx(
45 "font-base w-full !p-docs_0.5 !shadow-none z-10",
46 "bg-medusa-contrast-button hover:bg-medusa-contrast-button-hover",
47 "txt-compact-xsmall text-medusa-contrast-fg-secondary",
48 "rounded-t-none rounded-b-docs_DEFAULT",
49 className
50 )}
51 data-testid="collapsible-button-end"
52 onClick={() => setCollapsed(false)}
53 >
54 {expandButtonLabel}
55 </Button>
56 )}
57 </>
58 )
59 }