forked from deriv-com/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
62 lines (58 loc) · 2.14 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import {
ComponentProps,
MouseEventHandler,
PropsWithChildren,
ReactNode,
} from "react";
import clsx from "clsx";
import { ChevronRightIcon } from "./ChevronRightIcon";
import { Text } from "../Text";
import "./SideNote.scss";
type SideNoteProps = Omit<ComponentProps<"div">, "className"> & {
title?: ReactNode;
titleSize?: ComponentProps<typeof Text>["size"];
className?: HTMLDivElement["className"];
actionClick?: MouseEventHandler<HTMLButtonElement>;
actionClassName?: HTMLDivElement["className"];
actionLabel?: ReactNode;
};
/**
* This component is a design feature that displays extra information next to the main text, providing additional details or comments.
* @param {SideNoteProps.title} title - Display the title content.
* @param {SideNoteProps.titleSize} titleSize - Set the font-size for the title. (default: "sm")
* @param {SideNoteProps.className} className - Add an extra className to the container.
* @param {SideNoteProps.actionClick} actionClick - An onclick handler for the action button.
* @param {SideNoteProps.actionClassName} actionClassName - Add an extra className to the action button.
* @param {SideNoteProps.actionLabel} actionLabel - Display the label of the action. (default: "Learn more")
* @returns {React.JSX.Element} - Returns the SideNote component.
*/
export const SideNote = ({
children,
title,
titleSize = "sm",
className,
actionClick,
actionClassName,
actionLabel = "Learn more",
...props
}: PropsWithChildren<SideNoteProps>) => (
<div className={clsx("deriv-side-note", className)} {...props}>
{title && (
<Text data-testid="dt_deriv-side-note-title" size={titleSize} align="left" weight="bold">
{title}
</Text>
)}
<div>{children}</div>
{actionClick && (
<button
className={clsx("deriv-side-note__action", actionClassName)}
onClick={actionClick}
>
<Text color="red" size="xs">
{actionLabel}
</Text>
<ChevronRightIcon />
</button>
)}
</div>
);