-
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.
feat(shared-ui-feat-notifications): Added notifications banner and gr…
…oup components
- Loading branch information
1 parent
e0b5875
commit 17e7946
Showing
48 changed files
with
815 additions
and
432 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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
"theunderscorer", | ||
"typesense", | ||
"unoptimized", | ||
"uuidv", | ||
"webp" | ||
], | ||
"enableFiletypes": [ | ||
|
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
54 changes: 54 additions & 0 deletions
54
design-system/components/src/message-bar/MessageBar.stories.tsx
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,54 @@ | ||
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
import type { ComponentStory } from "@storybook/react"; | ||
import { MessageBar } from "./MessageBar"; | ||
import { MessageBarVariants } from "./MessageBar.types"; | ||
|
||
export default { | ||
title: "Containers/MessageBar", | ||
component: MessageBar, | ||
}; | ||
|
||
const Template: ComponentStory<typeof MessageBar> = args => ( | ||
<MessageBar {...args} onClose={() => {}} /> | ||
); | ||
|
||
export const Primary = Template.bind({}); | ||
Primary.args = { | ||
message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", | ||
}; | ||
|
||
export const Warning = Template.bind({}); | ||
Warning.args = { | ||
message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", | ||
variant: MessageBarVariants.WARNING, | ||
}; | ||
|
||
export const Error = Template.bind({}); | ||
Error.args = { | ||
message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", | ||
variant: MessageBarVariants.ERROR, | ||
}; | ||
|
||
export const Info = Template.bind({}); | ||
Info.args = { | ||
message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", | ||
variant: MessageBarVariants.INFO, | ||
}; | ||
|
||
export const Success = Template.bind({}); | ||
Success.args = { | ||
message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", | ||
variant: MessageBarVariants.SUCCESS, | ||
}; | ||
|
||
export const LongMessage = Template.bind({}); | ||
LongMessage.args = { | ||
message: | ||
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.", | ||
}; | ||
|
||
export const CloseIconDisplayed = Template.bind({}); | ||
CloseIconDisplayed.args = { | ||
showCloseIcon: true, | ||
message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", | ||
}; |
109 changes: 109 additions & 0 deletions
109
design-system/components/src/message-bar/MessageBar.tsx
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,109 @@ | ||
"use client"; | ||
|
||
import { XMarkIcon } from "@heroicons/react/24/outline"; | ||
import clsx from "clsx"; | ||
import { Heading } from "../heading"; | ||
import { ModalVariants } from "../modal/Modal.types"; | ||
import { PropsWithBase } from "../types"; | ||
import { getSvgFillStyle } from "../utilities/svg-style-utils"; | ||
import { MessageBarVariants } from "./MessageBar.types"; | ||
import { | ||
getBackgroundStyle, | ||
getBorderStyle, | ||
getCloseButtonStyle, | ||
getDefaultTitle, | ||
getTextStyle, | ||
} from "./MessageBar.utils"; | ||
|
||
export type MessageBarProps = PropsWithBase<{ | ||
/** | ||
* The variant style of the modal | ||
*/ | ||
variant?: MessageBarVariants; | ||
|
||
/** | ||
* The text message displayed at the top of the modal | ||
*/ | ||
message: string; | ||
|
||
/** | ||
* An indicator specifying if the "close icon" is displayed (allowing the user to manually close the message bar) | ||
*/ | ||
showCloseIcon?: boolean; | ||
|
||
/** | ||
* An event handler called when the "close icon" is clicked by the user | ||
* | ||
* @remarks Please note: If no `onClose` prop is provided, the "close icon" will not be displayed | ||
*/ | ||
onClose?: () => void; | ||
}>; | ||
|
||
/** | ||
* The base MessageBar component used by the Open System repository | ||
*/ | ||
export const MessageBar = ({ | ||
className, | ||
onClose, | ||
message, | ||
showCloseIcon = true, | ||
variant = MessageBarVariants.INFO, | ||
}: MessageBarProps) => { | ||
return ( | ||
<div className="h-fit w-fit bg-black/80"> | ||
<div | ||
className={clsx( | ||
"relative h-fit w-[50rem] min-w-fit border-4 p-4 backdrop-blur-xl backdrop-brightness-0", | ||
getTextStyle(variant), | ||
getBorderStyle(variant), | ||
getBackgroundStyle(variant), | ||
className | ||
)}> | ||
<div className="flex h-full flex-row items-center gap-5"> | ||
<span className="inline-block h-fit"> | ||
<svg | ||
width="45" | ||
height="45" | ||
viewBox="0 0 25 25" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg"> | ||
<path | ||
fillRule="evenodd" | ||
clipRule="evenodd" | ||
d="M12.5 0C5.59644 0 0 5.59644 0 12.5C0 19.4035 5.59644 25 12.5 25C19.4035 25 25 19.4035 25 12.5C25 5.59644 19.4035 0 12.5 0ZM13.6364 6.81818C13.6364 6.19059 13.1276 5.68182 12.5 5.68182C11.8724 5.68182 11.3636 6.19059 11.3636 6.81818V13.6364C11.3636 14.264 11.8724 14.7727 12.5 14.7727C13.1276 14.7727 13.6364 14.264 13.6364 13.6364V6.81818ZM13.6364 17.6136C13.6364 16.986 13.1276 16.4773 12.5 16.4773C11.8724 16.4773 11.3636 16.986 11.3636 17.6136V18.1818C11.3636 18.8094 11.8724 19.3182 12.5 19.3182C13.1276 19.3182 13.6364 18.8094 13.6364 18.1818V17.6136Z" | ||
className={getSvgFillStyle( | ||
variant === ModalVariants.ERROR, | ||
variant === ModalVariants.WARNING, | ||
variant === ModalVariants.INFO, | ||
variant === ModalVariants.SUCCESS | ||
)} | ||
/> | ||
</svg> | ||
</span> | ||
<div className="flex h-full flex-1 flex-row items-center"> | ||
<div className="flex h-fit flex-row items-end gap-2 leading-none"> | ||
<Heading | ||
level={6} | ||
className={clsx(getTextStyle(variant), "text-2xl")}> | ||
{`${getDefaultTitle(variant)}:`} | ||
</Heading> | ||
<label className="flex-1 font-header-6 text-lg font-bold text-primary"> | ||
{message} | ||
</label> | ||
</div> | ||
</div> | ||
{showCloseIcon && onClose && ( | ||
<div | ||
onClick={onClose} | ||
className={clsx( | ||
"cursor-pointer rounded-full border-2 p-3 font-semibold transition-colors", | ||
getCloseButtonStyle(variant) | ||
)}> | ||
<XMarkIcon className="h-6 w-6 cursor-pointer" /> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
</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,7 @@ | ||
export type MessageBarVariants = "warning" | "error" | "info" | "success"; | ||
export const MessageBarVariants = { | ||
WARNING: "warning" as MessageBarVariants, | ||
ERROR: "error" as MessageBarVariants, | ||
INFO: "info" as MessageBarVariants, | ||
SUCCESS: "success" as MessageBarVariants, | ||
}; |
51 changes: 51 additions & 0 deletions
51
design-system/components/src/message-bar/MessageBar.utils.ts
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,51 @@ | ||
import { MessageBarVariants } from "./MessageBar.types"; | ||
|
||
export function getBorderStyle(variant: MessageBarVariants) { | ||
return variant === MessageBarVariants.ERROR | ||
? "border-error" | ||
: variant === MessageBarVariants.WARNING | ||
? "border-warning" | ||
: variant === MessageBarVariants.SUCCESS | ||
? "border-success" | ||
: "border-info"; | ||
} | ||
|
||
export function getBackgroundStyle(variant: MessageBarVariants) { | ||
return variant === MessageBarVariants.ERROR | ||
? "bg-error/60" | ||
: variant === MessageBarVariants.WARNING | ||
? "bg-warning/60" | ||
: variant === MessageBarVariants.SUCCESS | ||
? "bg-success/60" | ||
: "bg-info/60"; | ||
} | ||
|
||
export function getTextStyle(variant: MessageBarVariants) { | ||
return variant === MessageBarVariants.ERROR | ||
? "text-error font-bold" | ||
: variant === MessageBarVariants.WARNING | ||
? "text-warning font-bold" | ||
: variant === MessageBarVariants.SUCCESS | ||
? "text-success font-bold" | ||
: "text-info font-bold"; | ||
} | ||
|
||
export function getDefaultTitle(variant: MessageBarVariants) { | ||
return variant === MessageBarVariants.ERROR | ||
? "Error" | ||
: variant === MessageBarVariants.WARNING | ||
? "Warning" | ||
: variant === MessageBarVariants.SUCCESS | ||
? "Success" | ||
: "Attention"; | ||
} | ||
|
||
export function getCloseButtonStyle(variant: MessageBarVariants) { | ||
return variant === MessageBarVariants.ERROR | ||
? "border-error text-error hover:border-primary hover:text-primary font-extrabold" | ||
: variant === MessageBarVariants.WARNING | ||
? "border-warning text-warning hover:border-primary hover:text-primary font-extrabold" | ||
: variant === MessageBarVariants.SUCCESS | ||
? "border-success text-success hover:border-primary hover:text-primary font-extrabold" | ||
: "border-info text-info hover:border-primary hover:text-primary font-extrabold"; | ||
} |
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,2 @@ | ||
export * from "./MessageBar"; | ||
export * from "./MessageBar.types"; |
Oops, something went wrong.