-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added action button to side note component
- Loading branch information
1 parent
207f24b
commit dec8393
Showing
4 changed files
with
104 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export const ChevronRightIcon = () => ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="12" | ||
height="12" | ||
viewBox="0 0 12 12" | ||
fill="none" | ||
> | ||
<g id="icon"> | ||
<path | ||
id="icon_2" | ||
fill-rule="evenodd" | ||
clip-rule="evenodd" | ||
d="M3.85983 1.60983C4.00628 1.46339 4.24372 1.46339 4.39017 1.60983L8.51516 5.73484C8.66161 5.88128 8.66161 6.11872 8.51516 6.26516L4.39017 10.3902C4.24372 10.5366 4.00628 10.5366 3.85983 10.3902C3.71339 10.2437 3.71339 10.0063 3.85983 9.85983L7.71967 6L3.85983 2.14017C3.71339 1.99372 3.71339 1.75628 3.85983 1.60983Z" | ||
fill="#FF444F" | ||
/> | ||
</g> | ||
</svg> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,19 @@ | ||
.deriv-side-note { | ||
background-color: #f2f3f4; | ||
padding: 1rem 1.5rem; | ||
color: #333333; | ||
padding: 1rem 1.5rem; | ||
border-radius: 0.5rem; | ||
} | ||
|
||
&:hover > &__action { | ||
text-decoration: underline; | ||
text-decoration-color: red; | ||
} | ||
&__action { | ||
width: 100%; | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
gap: 0.5rem; | ||
cursor: pointer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,62 @@ | ||
import { ComponentProps, PropsWithChildren } from "react"; | ||
import { | ||
ComponentProps, | ||
MouseEventHandler, | ||
PropsWithChildren, | ||
ReactElement, | ||
} from "react"; | ||
import { ChevronRightIcon } from "./ChevronRightIcon"; | ||
import { Text } from "../Text"; | ||
import "./SideNote.scss"; | ||
import clsx from "clsx"; | ||
|
||
interface SideNoteProps extends ComponentProps<"div"> { | ||
title?: string; | ||
type SideNoteProps = Omit<ComponentProps<"div">, "className"> & { | ||
title?: string | ReactElement; | ||
titleSize?: ComponentProps<typeof Text>["size"]; | ||
sideNoteFooter?: JSX.Element; | ||
} | ||
className?: HTMLDivElement["className"]; | ||
actionClick?: MouseEventHandler<HTMLButtonElement>; | ||
actionClassName?: HTMLDivElement["className"]; | ||
actionLabel?: string | ReactElement; | ||
}; | ||
|
||
/** | ||
* This component is a design feature that displays extra information next to the main text, providing additional details or comments. | ||
* @param {SideNoteProps.title} title - Title content to be displayed. | ||
* @param {SideNoteProps.titleSize} titleSize - Defining title Font-size. | ||
* @param {SideNoteProps.sideNoteFooter} sideNoteFooter - Action buttons or links like learn more... | ||
* @returns {React.JSX.Element} - returns the SideNote component | ||
* @param {SideNoteProps.title} title - Display the title content. | ||
* @param {SideNoteProps.titleSize} titleSize - Set the font-size for the title. | ||
* @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. | ||
* @returns {React.JSX.Element} - Returns the SideNote component. | ||
*/ | ||
export const SideNote = ({ | ||
children, | ||
title, | ||
titleSize = "sm", | ||
sideNoteFooter, | ||
className, | ||
actionClick, | ||
actionClassName, | ||
actionLabel, | ||
...props | ||
}: PropsWithChildren<SideNoteProps>): React.JSX.Element => ( | ||
<div className="deriv-side-note" {...props}> | ||
<div className={clsx("deriv-side-note", className)} {...props}> | ||
{title && ( | ||
<Text size={titleSize} align="center" weight="bold"> | ||
{title} | ||
</Text> | ||
)} | ||
|
||
<div>{children}</div> | ||
{sideNoteFooter} | ||
|
||
{actionClick && ( | ||
<button | ||
className={clsx("deriv-side-note__action", actionClassName)} | ||
onClick={actionClick} | ||
> | ||
<Text color="red" size="xs"> | ||
{actionLabel} | ||
</Text> | ||
<ChevronRightIcon /> | ||
</button> | ||
)} | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters