-
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.
- Loading branch information
1 parent
f0cf1b1
commit f39ebab
Showing
4 changed files
with
76 additions
and
0 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,6 @@ | ||
.deriv-side-note { | ||
background-color: #f2f3f4; | ||
padding: 1rem 1.5rem; | ||
color: #333333; | ||
border-radius: 0.5rem; | ||
} |
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,34 @@ | ||
import { ComponentProps, PropsWithChildren } from "react"; | ||
import { Text } from "../Text"; | ||
import "./SideNote.scss"; | ||
|
||
interface SideNoteProps extends ComponentProps<"div"> { | ||
title?: string; | ||
titleSize?: ComponentProps<typeof Text>["size"]; | ||
sideNoteFooter?: JSX.Element; | ||
} | ||
|
||
/** | ||
* 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 | ||
*/ | ||
export const SideNote = ({ | ||
children, | ||
title, | ||
titleSize = "sm", | ||
sideNoteFooter, | ||
...props | ||
}: PropsWithChildren<SideNoteProps>): React.JSX.Element => ( | ||
<div className="deriv-side-note" {...props}> | ||
{title && ( | ||
<Text size={titleSize} align="center" weight="bold"> | ||
{title} | ||
</Text> | ||
)} | ||
<div>{children}</div> | ||
{sideNoteFooter} | ||
</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
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,35 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { SideNote, Text } from "../../lib/main"; | ||
|
||
const meta = { | ||
title: "Components/SideNote", | ||
component: SideNote, | ||
args: { | ||
title: "This is a test title", | ||
titleSize: "md", | ||
sideNoteFooter: <a href="/">Learn more</a>, | ||
children: <Text>This is test note!</Text>, | ||
}, | ||
argTypes: { | ||
title: { | ||
control: false, | ||
description: "Contains the title to be shown.", | ||
}, | ||
titleSize: { | ||
description: "Sets the title text size.", | ||
}, | ||
sideNoteFooter: { | ||
control: false, | ||
description: "A prop which can be passed with a single HTML Element", | ||
}, | ||
}, | ||
parameters: { layout: "centered" }, | ||
tags: ["autodocs"], | ||
} satisfies Meta<typeof SideNote>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
name: "SideNote", | ||
}; |