Skip to content

Commit

Permalink
Merge pull request #143 from deriv-com/shayan/feq-1987/fix-side-note-…
Browse files Browse the repository at this point in the history
…component-style-issue

style: added gap between sideNote sections
  • Loading branch information
shayan-deriv authored Mar 29, 2024
2 parents fff2a67 + 1520f2c commit b4c276a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/components/SideNote/SideNote.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
color: #333333;
padding: 16px 24px;
border-radius: 8px;
display: flex;
flex-direction: column;

&__title {
margin-bottom: 8px;
}

&:hover > &__action {
text-decoration: underline;
Expand All @@ -14,5 +20,6 @@
align-items: center;
gap: 8px;
cursor: pointer;
margin-top: 16px;
}
}
7 changes: 5 additions & 2 deletions src/components/SideNote/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type SideNoteProps = Omit<ComponentProps<"div">, "className"> & {
className?: HTMLDivElement["className"];
actionClick?: MouseEventHandler<HTMLButtonElement>;
actionClassName?: HTMLDivElement["className"];
titleClassName?: HTMLDivElement["className"];
actionLabel?: ReactNode;
};

Expand All @@ -25,6 +26,7 @@ type SideNoteProps = Omit<ComponentProps<"div">, "className"> & {
* @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.titleClassName} titleClassName - Add an extra className to the title.
* @param {SideNoteProps.actionLabel} actionLabel - Display the label of the action. (default: "Learn more")
* @returns {React.JSX.Element} - Returns the SideNote component.
*/
Expand All @@ -35,17 +37,18 @@ export const SideNote = ({
className,
actionClick,
actionClassName,
titleClassName,
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">
<Text data-testid="dt_deriv-side-note-title" className={clsx("deriv-side-note__title", titleClassName)} size={titleSize} align="left" weight="bold">
{title}
</Text>
)}

<div>{children}</div>
{children}

{actionClick && (
<button
Expand Down
7 changes: 6 additions & 1 deletion stories/SideNote.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const meta = {
actionLabel: "Learn more",
actionClick: () => console.log("Test action"),
actionClassName: "",
titleClassName: "",
},
argTypes: {
title: { control: false, description: "Display the title content." },
Expand All @@ -31,6 +32,10 @@ const meta = {
control: false,
description: "Add an extra className to the action button.",
},
titleClassName: {
control: false,
description: "Add an extra className to the title wrapper.",
},
},
parameters: { layout: "centered" },
tags: ["autodocs"],
Expand All @@ -48,7 +53,7 @@ export const Default: Story = {
actionLabel="Learn more"
actionClick={() => console.log("test click!")}
>
<p style={{ margin: "10px 0" }}>This is a test note</p>
This is a test note
</SideNote>
</div>
),
Expand Down

0 comments on commit b4c276a

Please sign in to comment.