|
1
|
"use client" |
|
2
|
|
|
3
|
import React, { useMemo } from "react" |
|
4
|
import clsx from "clsx" |
|
5
|
import { ArrowUturnLeft } from "@medusajs/icons" |
|
6
|
import { useSidebar } from "@/providers/Sidebar" |
|
7
|
|
|
8
|
export const SidebarChild = () => { |
|
9
|
const { goBack, shownSidebar } = useSidebar() |
|
10
|
|
|
11
|
const title = useMemo(() => { |
|
12
|
if (!shownSidebar) { |
|
13
|
return "" |
|
14
|
} |
|
15
|
|
|
16
|
return "childSidebarTitle" in shownSidebar |
|
17
|
? shownSidebar.childSidebarTitle || shownSidebar.title |
|
18
|
: shownSidebar.title |
|
19
|
}, [shownSidebar]) |
|
20
|
|
|
21
|
if (!shownSidebar) { |
|
22
|
return <></> |
|
23
|
} |
|
24
|
|
|
25
|
return ( |
|
26
|
<div className="px-docs_0.75" data-testid="sidebar-child"> |
|
27
|
<div |
|
28
|
onClick={goBack} |
|
29
|
className={clsx( |
|
30
|
"flex items-center justify-start my-docs_0.75 gap-[10px]", |
|
31
|
"border border-transparent cursor-pointer mx-docs_0.5", |
|
32
|
"!text-medusa-fg-base !text-compact-small-plus" |
|
33
|
)} |
|
34
|
tabIndex={-1} |
|
35
|
data-testid="sidebar-child-back-button" |
|
36
|
> |
|
37
|
<ArrowUturnLeft /> |
|
38
|
<span |
|
39
|
className="truncate flex-1 overscroll-y-auto" |
|
40
|
data-testid="sidebar-child-title" |
|
41
|
> |
|
42
|
{title} |
|
43
|
</span> |
|
44
|
</div> |
|
45
|
</div> |
|
46
|
) |
|
47
|
} |