-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #456 from AppQuality/update-stories
Update stories
- Loading branch information
Showing
5 changed files
with
93 additions
and
40 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
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,38 +1,56 @@ | ||
import { Meta as ComponentMeta, StoryFn as Story } from "@storybook/react"; | ||
import { | ||
GlobalAlert as UgGlobalAlert, | ||
GlobalAlertProps | ||
} from "."; | ||
import { Anchor } from "../../buttons/anchor"; | ||
|
||
const GlobalAlertTemplate: Story<GlobalAlertProps> = ({ ...props }) => ( | ||
<UgGlobalAlert {...props}> | ||
</UgGlobalAlert> | ||
); | ||
|
||
export const GlobalAlert = GlobalAlertTemplate.bind({}); | ||
GlobalAlert.args = { | ||
type: "info", | ||
title: "Account update", | ||
dismissable: true, | ||
onClose: () => {alert('dismissed')}, | ||
cta: { | ||
label: "Find out more", | ||
onClick: () => {alert('clicked')} | ||
}, | ||
message: <> | ||
Your account will automatically update in 5 days.{' '} | ||
<Anchor href="#" isExternal> | ||
Find out more | ||
</Anchor> | ||
</> | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { GlobalAlert } from "."; | ||
import { Placeholder } from "../../placeholder"; | ||
|
||
type Args = React.ComponentProps<typeof GlobalAlert> & { | ||
messageContent?: "accountupdate" | "placeholder"; | ||
}; | ||
|
||
export default { | ||
title: "Molecules/Notification", | ||
component: UgGlobalAlert, | ||
parameters: { | ||
// Sets a delay for the component's stories | ||
chromatic: { delay: 300 }, | ||
const meta = { | ||
title: "Molecules/Notification/GlobalAlert", | ||
component: GlobalAlert, | ||
|
||
render: ({ messageContent, ...args }) => { | ||
const message = | ||
messageContent === "accountupdate" ? ( | ||
<> | ||
Your account will automatically update in 5 days.{" "} | ||
<a href="#" target="_blank"> | ||
Find out more | ||
</a> | ||
</> | ||
) : ( | ||
<Placeholder /> | ||
); | ||
return <GlobalAlert {...args} message={message} />; | ||
}, | ||
|
||
args: { | ||
type: "info", | ||
title: "Account update", | ||
dismissable: true, | ||
onClose: () => { | ||
alert("dismissed"); | ||
}, | ||
cta: { | ||
label: "Find out more", | ||
onClick: () => { | ||
alert("clicked"); | ||
}, | ||
}, | ||
}, | ||
} as ComponentMeta<typeof UgGlobalAlert>; | ||
} satisfies Meta<Args>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const AccountUpdate: Story = { | ||
args: { | ||
messageContent: "accountupdate", | ||
}, | ||
}; | ||
|
||
export const Generic: Story = { | ||
args: {}, | ||
}; |
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,18 @@ | ||
import type { Meta } from "@storybook/react"; | ||
|
||
import { Placeholder } from "."; | ||
|
||
type Args = React.ComponentProps<typeof Placeholder> & {}; | ||
|
||
const meta = { | ||
title: "Utils/Placeholder", | ||
component: Placeholder, | ||
|
||
args: {}, | ||
} satisfies Meta<Args>; | ||
|
||
export default meta; | ||
|
||
export const Default = { | ||
args: {}, | ||
}; |
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,20 @@ | ||
import styled from "styled-components"; | ||
|
||
const Wrapper = styled.div` | ||
padding: 10px; | ||
background-color: #ccc; | ||
.content { | ||
padding: 10px; | ||
background-color: #fff; | ||
} | ||
`; | ||
|
||
const Placeholder = () => { | ||
return ( | ||
<Wrapper> | ||
<div className="content">PLACEHOLDER</div> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
export { Placeholder }; |
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