diff --git a/frontend/src/components/v2/Alert/Alert.stories.tsx b/frontend/src/components/v2/Alert/Alert.stories.tsx new file mode 100644 index 000000000..ef42a9af4 --- /dev/null +++ b/frontend/src/components/v2/Alert/Alert.stories.tsx @@ -0,0 +1,54 @@ +import { faTriangleExclamation } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import type { Meta, StoryObj } from "@storybook/react"; + +import { Alert, AlertDescription, AlertTitle } from "./Alert"; + +const meta: Meta = { + title: "Components/Alert", + component: Alert, + tags: ["v2"] +}; + +export default meta; + +type Story = StoryObj; + +const ExampleComponent = () => ( + <> + this is a title + this is a description + +); + +export const Default: Story = { + args: { + children: + } +}; + +export const Warning: Story = { + args: { + children: , + variant: "warning" + } +}; + +export const Destructive: Story = { + args: { + children: , + variant: "destructive" + } +}; + +export const WithIcon: Story = { + args: { + children: ( + <> + + + + ), + variant: "warning" + } +}; diff --git a/frontend/src/components/v2/Alert/Alert.tsx b/frontend/src/components/v2/Alert/Alert.tsx new file mode 100644 index 000000000..d28fc059a --- /dev/null +++ b/frontend/src/components/v2/Alert/Alert.tsx @@ -0,0 +1,51 @@ +import * as React from "react"; +import { type VariantProps, cva } from "cva"; + +import { cn } from "@app/helpers/classNames"; + +const alertVariants = cva( + "relative w-full bg-mineshaft-800 rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7", + { + variants: { + variant: { + default: "", + destructive: "text-red border-red", + warning: "text-yellow border-yellow" + } + }, + defaultVariants: { + variant: "default" + } + } +); + +const Alert = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes & VariantProps +>(({ className, variant, ...props }, ref) => ( +
+)); +Alert.displayName = "Alert"; + +const AlertTitle = React.forwardRef>( + ({ className, children, ...props }, ref) => ( +
+ {children} +
+ ) +); +AlertTitle.displayName = "AlertTitle"; + +const AlertDescription = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
+)); +AlertDescription.displayName = "AlertDescription"; + +export { Alert, AlertDescription, AlertTitle }; diff --git a/frontend/src/components/v2/Alert/index.tsx b/frontend/src/components/v2/Alert/index.tsx new file mode 100644 index 000000000..1b2cdda51 --- /dev/null +++ b/frontend/src/components/v2/Alert/index.tsx @@ -0,0 +1 @@ +export { Alert, AlertDescription, AlertTitle } from "./Alert"; diff --git a/frontend/src/components/v2/index.tsx b/frontend/src/components/v2/index.tsx index eb49f0d88..ea4263c90 100644 --- a/frontend/src/components/v2/index.tsx +++ b/frontend/src/components/v2/index.tsx @@ -1,4 +1,5 @@ export * from "./Accordion"; +export * from "./Alert"; export * from "./Button"; export * from "./Card"; export * from "./Checkbox";