Skip to content

Commit b4c276a

Browse files
authored
Merge pull request #143 from deriv-com/shayan/feq-1987/fix-side-note-component-style-issue
style: added gap between sideNote sections
2 parents fff2a67 + 1520f2c commit b4c276a

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/components/SideNote/SideNote.scss

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
color: #333333;
44
padding: 16px 24px;
55
border-radius: 8px;
6+
display: flex;
7+
flex-direction: column;
8+
9+
&__title {
10+
margin-bottom: 8px;
11+
}
612

713
&:hover > &__action {
814
text-decoration: underline;
@@ -14,5 +20,6 @@
1420
align-items: center;
1521
gap: 8px;
1622
cursor: pointer;
23+
margin-top: 16px;
1724
}
1825
}

src/components/SideNote/index.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ type SideNoteProps = Omit<ComponentProps<"div">, "className"> & {
1515
className?: HTMLDivElement["className"];
1616
actionClick?: MouseEventHandler<HTMLButtonElement>;
1717
actionClassName?: HTMLDivElement["className"];
18+
titleClassName?: HTMLDivElement["className"];
1819
actionLabel?: ReactNode;
1920
};
2021

@@ -25,6 +26,7 @@ type SideNoteProps = Omit<ComponentProps<"div">, "className"> & {
2526
* @param {SideNoteProps.className} className - Add an extra className to the container.
2627
* @param {SideNoteProps.actionClick} actionClick - An onclick handler for the action button.
2728
* @param {SideNoteProps.actionClassName} actionClassName - Add an extra className to the action button.
29+
* @param {SideNoteProps.titleClassName} titleClassName - Add an extra className to the title.
2830
* @param {SideNoteProps.actionLabel} actionLabel - Display the label of the action. (default: "Learn more")
2931
* @returns {React.JSX.Element} - Returns the SideNote component.
3032
*/
@@ -35,17 +37,18 @@ export const SideNote = ({
3537
className,
3638
actionClick,
3739
actionClassName,
40+
titleClassName,
3841
actionLabel = "Learn more",
3942
...props
4043
}: PropsWithChildren<SideNoteProps>) => (
4144
<div className={clsx("deriv-side-note", className)} {...props}>
4245
{title && (
43-
<Text data-testid="dt_deriv-side-note-title" size={titleSize} align="left" weight="bold">
46+
<Text data-testid="dt_deriv-side-note-title" className={clsx("deriv-side-note__title", titleClassName)} size={titleSize} align="left" weight="bold">
4447
{title}
4548
</Text>
4649
)}
4750

48-
<div>{children}</div>
51+
{children}
4952

5053
{actionClick && (
5154
<button

stories/SideNote.stories.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const meta = {
1111
actionLabel: "Learn more",
1212
actionClick: () => console.log("Test action"),
1313
actionClassName: "",
14+
titleClassName: "",
1415
},
1516
argTypes: {
1617
title: { control: false, description: "Display the title content." },
@@ -31,6 +32,10 @@ const meta = {
3132
control: false,
3233
description: "Add an extra className to the action button.",
3334
},
35+
titleClassName: {
36+
control: false,
37+
description: "Add an extra className to the title wrapper.",
38+
},
3439
},
3540
parameters: { layout: "centered" },
3641
tags: ["autodocs"],
@@ -48,7 +53,7 @@ export const Default: Story = {
4853
actionLabel="Learn more"
4954
actionClick={() => console.log("test click!")}
5055
>
51-
<p style={{ margin: "10px 0" }}>This is a test note</p>
56+
This is a test note
5257
</SideNote>
5358
</div>
5459
),

0 commit comments

Comments
 (0)