-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathindex.tsx
41 lines (36 loc) · 1009 Bytes
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import clsx from "clsx";
import type { ComponentProps } from "react";
import styles from "./index.module.scss";
type StructuredListProps = {
items: StructureListItemProps[];
} & ComponentProps<"div">;
type StructureListItemProps = {
label: React.ReactNode;
value: React.ReactNode;
} & ComponentProps<"div">;
export const StructuredList = ({ items, ...props }: StructuredListProps) => {
return (
items.length > 0 && (
<div className={clsx(styles.structuredList, props.className)} {...props}>
{items.map((item, index) => (
<StructuredListItem key={index} {...item} />
))}
</div>
)
);
};
export const StructuredListItem = ({
label,
value,
...props
}: StructureListItemProps) => {
return (
<div
className={clsx(styles.structuredListItem, props.className)}
{...props}
>
<div className={styles.structuredListItemLabel}>{label}</div>
<div className={styles.structuredListItemValue}>{value}</div>
</div>
);
};