|
1
|
import { Text, clx } from "@medusajs/ui" |
|
2
|
import { ReactNode } from "react" |
|
3
|
|
|
4
|
export type SectionRowProps = { |
|
5
|
title: string |
|
6
|
value?: ReactNode | string | null |
|
7
|
actions?: ReactNode |
|
8
|
} |
|
9
|
|
|
10
|
export const SectionRow = ({ title, value, actions }: SectionRowProps) => { |
|
11
|
const isValueString = typeof value === "string" || !value |
|
12
|
|
|
13
|
return ( |
|
14
|
<div |
|
15
|
className={clx( |
|
16
|
`text-ui-fg-subtle grid w-full grid-cols-2 items-center gap-4 px-6 py-4`, |
|
17
|
{ |
|
18
|
"grid-cols-[1fr_1fr_28px]": !!actions, |
|
19
|
} |
|
20
|
)} |
|
21
|
> |
|
22
|
<Text size="small" weight="plus" leading="compact"> |
|
23
|
{title} |
|
24
|
</Text> |
|
25
|
|
|
26
|
{isValueString ? ( |
|
27
|
<Text |
|
28
|
size="small" |
|
29
|
leading="compact" |
|
30
|
className="whitespace-pre-line text-pretty" |
|
31
|
> |
|
32
|
{value ?? "-"} |
|
33
|
</Text> |
|
34
|
) : ( |
|
35
|
<div className="txt-compact-small flex min-w-0 flex-wrap gap-1"> |
|
36
|
{value} |
|
37
|
</div> |
|
38
|
)} |
|
39
|
|
|
40
|
{actions && <div>{actions}</div>} |
|
41
|
</div> |
|
42
|
) |
|
43
|
} |