From 9da305d0297047b913d26c03185df96cae54446b Mon Sep 17 00:00:00 2001 From: BrickheadJohnny Date: Thu, 28 Nov 2024 09:14:14 +0100 Subject: [PATCH] feat: DataBlock component --- src/components/requirements/DataBlock.tsx | 42 +++++++++++++++++++ .../requirements/DataBlock.stories.tsx | 37 ++++++++++++++++ src/styles/globals.css | 13 ++++++ tailwind.config.ts | 23 +++++++--- 4 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 src/components/requirements/DataBlock.tsx create mode 100644 src/stories/requirements/DataBlock.stories.tsx diff --git a/src/components/requirements/DataBlock.tsx b/src/components/requirements/DataBlock.tsx new file mode 100644 index 0000000000..a752611585 --- /dev/null +++ b/src/components/requirements/DataBlock.tsx @@ -0,0 +1,42 @@ +import { Skeleton } from "@/components/ui/Skeleton"; +import { + Tooltip, + TooltipContent, + TooltipTrigger, +} from "@/components/ui/Tooltip"; +import { Warning } from "@phosphor-icons/react/dist/ssr"; +import type { PropsWithChildren } from "react"; + +type Props = { + isLoading?: boolean; + error?: string; +}; + +const DataBlock = ({ + isLoading, + error, + children, +}: PropsWithChildren): JSX.Element => { + if (isLoading) return ; + + return ( + + + + {error && ( + + )} + {children} + + + +

{error}

+
+
+ ); +}; + +export { DataBlock }; diff --git a/src/stories/requirements/DataBlock.stories.tsx b/src/stories/requirements/DataBlock.stories.tsx new file mode 100644 index 0000000000..825d267e97 --- /dev/null +++ b/src/stories/requirements/DataBlock.stories.tsx @@ -0,0 +1,37 @@ +import { DataBlock } from "@/components/requirements/DataBlock"; +import { Card } from "@/components/ui/Card"; +import { TooltipProvider } from "@/components/ui/Tooltip"; +import type { Meta, StoryObj } from "@storybook/react"; + +const meta: Meta = { + title: "Requirement building blocks/DataBlock", + component: DataBlock, + decorators: (Story) => ( + + + {"This is a "} + + {" example"} + + + ), +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + args: { + children: "DataBlock", + error: "", + }, +}; + +export const ErrorState: Story = { + name: "Error state", + args: { + ...Default.args, + error: "An error occurred", + }, +}; diff --git a/src/styles/globals.css b/src/styles/globals.css index a618b6a950..e74452b9e7 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -63,6 +63,17 @@ html { --blue-800: #1e40af; --blue-900: #1e3a8a; + --orange-50: #fff7ed; + --orange-100: #ffedd5; + --orange-200: #fed7aa; + --orange-300: #fdba74; + --orange-400: #fb923c; + --orange-500: #f97316; + --orange-600: #ea580c; + --orange-700: #c2410c; + --orange-800: #9a3412; + --orange-900: #7c2d12; + --red-50: #fef2f2; --red-100: #fee2e2; --red-200: #fecaca; @@ -156,6 +167,7 @@ html { --icon-success: var(--green-500); --icon-error: var(--red-500); + --icon-warning: var(--orange-500); } .dark { @@ -213,6 +225,7 @@ html { --icon-success: var(--green-400); --icon-error: var(--red-400); + --icon-warning: var(--orange-300); } body { diff --git a/tailwind.config.ts b/tailwind.config.ts index d35465e192..85b633f1da 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -12,11 +12,11 @@ const config = { ], prefix: "", theme: { - fontFamily: { - sans: ["var(--font-inter,sans-serif)"], - display: ["var(--font-dystopian,sans-serif)"], - }, extend: { + fontFamily: { + sans: ["var(--font-inter,sans-serif)"], + display: ["var(--font-dystopian,sans-serif)"], + }, colors: { background: "var(--background)", foreground: { @@ -71,8 +71,19 @@ const config = { "scroll-thumb": "var(--scroll-thumb)", icon: { success: "var(--icon-success)", - error: "var(--icon-error)" - } + error: "var(--icon-error)", + warning: "var(--icon-warning)", + }, + blackAlpha: { + DEFAULT: "var(--blackAlpha)", + medium: "var(--blackAlpha-medium)", + hard: "var(--blackAlpha-hard)", + }, + whiteAlpha: { + DEFAULT: "var(--whiteAlpha)", + medium: "var(--whiteAlpha-medium)", + hard: "var(--whiteAlpha-hard)", + }, }, keyframes: { "collapse-open": {