-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add banner component, add missing Storybook stories (#103)
- Loading branch information
Showing
20 changed files
with
377 additions
and
15 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,5 @@ | ||
--- | ||
"namesake": patch | ||
--- | ||
|
||
Add banner component, display banners for login error and success messages |
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,5 @@ | ||
--- | ||
"namesake": patch | ||
--- | ||
|
||
Fix login screen sizing and padding |
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,45 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { Badge } from "./Badge"; | ||
|
||
const meta = { | ||
component: Badge, | ||
} satisfies Meta<typeof Badge>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: "Default", | ||
}, | ||
}; | ||
|
||
export const Info: Story = { | ||
args: { | ||
children: "Info", | ||
variant: "info", | ||
}, | ||
}; | ||
|
||
export const Success: Story = { | ||
args: { | ||
children: "Success", | ||
variant: "success", | ||
}, | ||
}; | ||
|
||
export const Warning: Story = { | ||
args: { | ||
children: "Warning", | ||
variant: "warning", | ||
}, | ||
}; | ||
|
||
export const Danger: Story = { | ||
args: { | ||
children: "Error", | ||
variant: "danger", | ||
}, | ||
}; |
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,45 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { Banner } from "./Banner"; | ||
|
||
const meta = { | ||
component: Banner, | ||
} satisfies Meta<typeof Banner>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: "Basic information", | ||
}, | ||
}; | ||
|
||
export const Info: Story = { | ||
args: { | ||
children: "Here's some handy information", | ||
variant: "info", | ||
}, | ||
}; | ||
|
||
export const Success: Story = { | ||
args: { | ||
children: "Something successful happened", | ||
variant: "success", | ||
}, | ||
}; | ||
|
||
export const Danger: Story = { | ||
args: { | ||
children: "Something went wrong", | ||
variant: "danger", | ||
}, | ||
}; | ||
|
||
export const Warning: Story = { | ||
args: { | ||
children: "Be careful!", | ||
variant: "warning", | ||
}, | ||
}; |
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,68 @@ | ||
import { | ||
type RemixiconComponentType, | ||
RiAlertLine, | ||
RiCheckLine, | ||
RiErrorWarningLine, | ||
RiInformationLine, | ||
} from "@remixicon/react"; | ||
import { tv } from "tailwind-variants"; | ||
|
||
export interface BannerProps { | ||
children: React.ReactNode; | ||
icon?: RemixiconComponentType; | ||
variant?: "info" | "success" | "danger" | "warning"; | ||
} | ||
|
||
const bannerStyles = tv({ | ||
base: "flex gap-2 p-3 pr-4 items-start w-full text-sm rounded-lg bg-gray-3 dark:bg-graydark-3 text-gray-dim", | ||
variants: { | ||
variant: { | ||
info: "bg-blue-3 dark:bg-bluedark-3 text-blue-normal", | ||
success: "bg-green-3 dark:bg-greendark-3 text-green-normal", | ||
danger: "bg-red-3 dark:bg-reddark-3 text-red-normal", | ||
warning: "bg-amber-3 dark:bg-amberdark-3 text-amber-normal", | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: undefined, | ||
}, | ||
}); | ||
|
||
const iconStyles = tv({ | ||
base: "text-gray-9 dark:text-graydark-9 shrink-0", | ||
variants: { | ||
variant: { | ||
info: "text-blue-10 dark:text-bluedark-10", | ||
success: "text-green-10 dark:text-greendark-10", | ||
danger: "text-red-10 dark:text-reddark-10", | ||
warning: "text-amber-10 dark:text-amberdark-10", | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: undefined, | ||
}, | ||
}); | ||
|
||
export function Banner({ children, icon: Icon, variant }: BannerProps) { | ||
const DefaultIcon = () => { | ||
switch (variant) { | ||
case "success": | ||
return RiCheckLine; | ||
case "danger": | ||
return RiErrorWarningLine; | ||
case "warning": | ||
return RiAlertLine; | ||
default: | ||
return RiInformationLine; | ||
} | ||
}; | ||
|
||
Icon = Icon ?? DefaultIcon(); | ||
|
||
return ( | ||
<div className={bannerStyles({ variant })}> | ||
<Icon size={20} className={iconStyles({ variant })} /> | ||
{children} | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Banner"; |
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,17 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { Card } from "./Card"; | ||
|
||
const meta = { | ||
component: Card, | ||
} satisfies Meta<typeof Card>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
children: "Default", | ||
}, | ||
}; |
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,38 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { RiQuestionLine } from "@remixicon/react"; | ||
import { Empty } from "./Empty"; | ||
|
||
const meta = { | ||
component: Empty, | ||
} satisfies Meta<typeof Empty>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
icon: RiQuestionLine, | ||
title: "Page not found", | ||
}, | ||
}; | ||
|
||
export const Subtitle: Story = { | ||
args: { | ||
icon: RiQuestionLine, | ||
title: "Page not found", | ||
subtitle: "We couldn't find that page.", | ||
}, | ||
}; | ||
|
||
export const Button: Story = { | ||
args: { | ||
icon: RiQuestionLine, | ||
title: "Page not found", | ||
subtitle: "We couldn't find that page.", | ||
button: { | ||
children: "Return home", | ||
}, | ||
}, | ||
}; |
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,16 @@ | ||
import type { Meta } from "@storybook/react"; | ||
|
||
import { Button } from "../Button"; | ||
import { FileTrigger } from "./FileTrigger"; | ||
|
||
const meta = { | ||
component: FileTrigger, | ||
} satisfies Meta<typeof FileTrigger>; | ||
|
||
export default meta; | ||
|
||
export const Default = (args: any) => ( | ||
<FileTrigger {...args}> | ||
<Button>Upload file</Button> | ||
</FileTrigger> | ||
); |
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,13 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { Logo } from "./Logo"; | ||
|
||
const meta = { | ||
component: Logo, | ||
} satisfies Meta<typeof Logo>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = {}; |
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,46 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { Badge } from "../Badge"; | ||
import { Button } from "../Button"; | ||
import { PageHeader } from "./PageHeader"; | ||
|
||
const meta = { | ||
component: PageHeader, | ||
parameters: { | ||
layout: "padded", | ||
}, | ||
} satisfies Meta<typeof PageHeader>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
title: "Court Order", | ||
}, | ||
}; | ||
|
||
export const Badged: Story = { | ||
args: { | ||
title: "Court Order", | ||
badge: <Badge>MA</Badge>, | ||
}, | ||
}; | ||
|
||
export const Subtitle: Story = { | ||
args: { | ||
title: "Court Order", | ||
badge: <Badge>MA</Badge>, | ||
subtitle: "Case #123456", | ||
}, | ||
}; | ||
|
||
export const Actions: Story = { | ||
args: { | ||
title: "Court Order", | ||
badge: <Badge>MA</Badge>, | ||
subtitle: "Case #123456", | ||
children: <Button>Mark complete</Button>, | ||
}, | ||
}; |
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,20 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
|
||
import { RichTextEditor } from "./RichTextEditor"; | ||
|
||
const meta = { | ||
component: RichTextEditor, | ||
parameters: { | ||
layout: "padded", | ||
}, | ||
} satisfies Meta<typeof RichTextEditor>; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
markdown: "hello", | ||
}, | ||
}; |
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
Oops, something went wrong.