From f67eb5d2083605af45d279a22d3a7cdb8942c5ce Mon Sep 17 00:00:00 2001 From: Emmanuel-Develops Date: Mon, 25 Nov 2024 16:39:03 +0100 Subject: [PATCH] feat: add banner component --- src/components/banner/Banner.stories.tsx | 33 +++++++ src/components/banner/Banner.tsx | 112 +++++++++++++++++++++++ src/components/banner/index.tsx | 1 + src/index.ts | 1 + tailwind.config.js | 3 + 5 files changed, 150 insertions(+) create mode 100644 src/components/banner/Banner.stories.tsx create mode 100644 src/components/banner/Banner.tsx create mode 100644 src/components/banner/index.tsx diff --git a/src/components/banner/Banner.stories.tsx b/src/components/banner/Banner.stories.tsx new file mode 100644 index 0000000..bbac791 --- /dev/null +++ b/src/components/banner/Banner.stories.tsx @@ -0,0 +1,33 @@ +import React from "react"; +import { Meta } from "@storybook/react"; + +import { Banner } from "./Banner"; + +export default { + title: "Components/Banner", + argTypes: { + colorMode: { + control: { type: "radio" }, + options: ["light", "dark"], + defaultValue: "light", + }, + }, +} as Meta; + +export const UnmodifiedBanner = (args: { colorMode: "light" | "dark" }) => { + const { colorMode } = args; + const isDark = colorMode === "dark"; + + return ( +
+ +
+ ); +}; diff --git a/src/components/banner/Banner.tsx b/src/components/banner/Banner.tsx new file mode 100644 index 0000000..eea5a35 --- /dev/null +++ b/src/components/banner/Banner.tsx @@ -0,0 +1,112 @@ +"use client"; +import React from "react"; +import { useState } from "react"; +import { cn } from "../../utils/cn"; + +type StyleConfig = { + container?: string; + bannerInfoContainer?: string; + bodyText?: string; + headingText?: string; + link?: string; + icon?: string; + boss?: string; +}; +type Links = { + linkText: string; + linkTo: string; +}; +type Props = Links & { + bodyText?: string; + headingText: string; + styles?: StyleConfig; + hasBoss?: boolean; +}; + +const defaultStyles = { + container: + "dark:text-bdp-white dark:shadow-dark-light gap-2 flex items-center justify-between w-full px-2 sm:px-4 shadow-md transition-all duration-200 ease-in-out text-center", + bannerInfoContainer: `flex flex-col flex-[1_1_auto]`, + headingText: "font-semibold text-sm md:text-lg", + bodyText: "text-sm md:text-base", + link: "text-bdp-accent underline font-semibold text-xs md:text-sm", + icon: "text-bdp-lightGrey hover:text-red-500 transition-all duration-200 ease-in-out", + boss: "text-bdp-accent text-base md:text-lg", +} as const; + +export function Banner({ + bodyText, + headingText, + styles = {}, + hasBoss, + ...rest +}: Props) { + const [showBanner, setShowBanner] = useState(true); + + return ( +
+
+ {!!headingText && ( +

+ {headingText} + {hasBoss && ( + ₿OSS + )} +

+ )} + {!!bodyText && ( +

+ {bodyText} +

+ )} + {!!rest.linkText && ( + + {rest.linkText} + + )} +
+ +
+ ); +} diff --git a/src/components/banner/index.tsx b/src/components/banner/index.tsx new file mode 100644 index 0000000..630d3e3 --- /dev/null +++ b/src/components/banner/index.tsx @@ -0,0 +1 @@ +export * from "./Banner"; diff --git a/src/index.ts b/src/index.ts index 7cdf8c5..20e69ed 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,3 +2,4 @@ export * from "./components/button"; export * from "./components/footer"; export * from "./components/carousel"; export * from "./components/select"; +export * from "./components/banner"; diff --git a/tailwind.config.js b/tailwind.config.js index d312c1c..1fcda69 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -4,6 +4,9 @@ module.exports = { content: ['./src/**/*.{js,jsx,ts,tsx}'], theme: { extend: { + boxShadowColor: { + "dark-light": "rgba(255, 255, 255, 0.05)" + }, colors: { bdp: { background: "var(--background)",