From bb7e3e36a9d6864e32b77a3588feea6293a08ea2 Mon Sep 17 00:00:00 2001 From: Skylar Date: Fri, 23 Aug 2024 14:00:42 -0700 Subject: [PATCH] feat: add build mode banner (#25) * feat: add build mode banner * fix: ts import --- .../src/components/Banner/Banner.stories.tsx | 14 ++++ .../src/components/Banner/index.tsx | 68 +++++++++++++++++++ .../src/components/Layout/index.tsx | 41 ++++++----- .../src/contexts/NavigationContext.tsx | 16 +++-- kontrol-frontend/src/pages/FlowsCreate.tsx | 2 +- kontrol-frontend/src/theme.ts | 1 + 6 files changed, 118 insertions(+), 24 deletions(-) create mode 100644 kontrol-frontend/src/components/Banner/Banner.stories.tsx create mode 100644 kontrol-frontend/src/components/Banner/index.tsx diff --git a/kontrol-frontend/src/components/Banner/Banner.stories.tsx b/kontrol-frontend/src/components/Banner/Banner.stories.tsx new file mode 100644 index 0000000..7488154 --- /dev/null +++ b/kontrol-frontend/src/components/Banner/Banner.stories.tsx @@ -0,0 +1,14 @@ +import type { Meta, StoryObj } from "@storybook/react"; + +import Banner from "."; + +const meta: Meta = { + component: Banner, +}; + +export default meta; +type Story = StoryObj; + +export const Example: Story = { + args: {}, +}; diff --git a/kontrol-frontend/src/components/Banner/index.tsx b/kontrol-frontend/src/components/Banner/index.tsx new file mode 100644 index 0000000..b509952 --- /dev/null +++ b/kontrol-frontend/src/components/Banner/index.tsx @@ -0,0 +1,68 @@ +import { useNavigationContext } from "@/contexts/NavigationContext"; +import { Box, Flex, Text, CloseButton } from "@chakra-ui/react"; + +const Banner = () => { + const { isBannerVisible, setIsBannerVisible } = useNavigationContext(); + + if (!isBannerVisible) { + return null; + } + + return ( + + + + + 🚧 + + + + WELCOME! KARDINAL IS STILL IN BUILD MODE + + + The features you see in the UI might differ from the CLI, we're + currently working towards feature parity.
If you have + comments or suggestions, please{" "} + + open a github issue + {" "} + or{" "} + + reach out via email + {" "} + and help us shape the product! +
+
+
+ { + setIsBannerVisible(false); + }} + color="orange.500" + /> +
+
+ ); +}; + +export default Banner; diff --git a/kontrol-frontend/src/components/Layout/index.tsx b/kontrol-frontend/src/components/Layout/index.tsx index c1e8728..5c72707 100644 --- a/kontrol-frontend/src/components/Layout/index.tsx +++ b/kontrol-frontend/src/components/Layout/index.tsx @@ -1,35 +1,40 @@ import { GridItem, Grid } from "@chakra-ui/react"; import { ReactNode } from "react"; +import Banner from "@/components/Banner"; interface Props { children: ReactNode[]; + showBanner?: boolean; } -const Layout = ({ children }: Props) => { +const Layout = ({ children, showBanner }: Props) => { return ( - + {showBanner && } + - {["title", "a", "b", "c", "d", "footer"].map((area, i) => ( - - {children[i]} - - ))} - + gridTemplateRows={"64px auto auto auto 40px"} + gridTemplateColumns={"1fr 1fr"} + h="100%" + rowGap={8} + columnGap={4} + color="blackAlpha.700" + fontWeight="bold" + > + {["title", "a", "b", "c", "d", "footer"].map((area, i) => ( + + {children[i]} + + ))} + + ); }; diff --git a/kontrol-frontend/src/contexts/NavigationContext.tsx b/kontrol-frontend/src/contexts/NavigationContext.tsx index 43964a9..d69e08e 100644 --- a/kontrol-frontend/src/contexts/NavigationContext.tsx +++ b/kontrol-frontend/src/contexts/NavigationContext.tsx @@ -1,16 +1,19 @@ import { createContext, useContext, useState, ReactNode } from "react"; -// Define the shape of your context interface NavigationContextType { - // Add your context properties here isSidebarCollapsed: boolean; setIsSidebarCollapsed: (c: boolean) => void; + isBannerVisible: boolean; + setIsBannerVisible: (c: boolean) => void; } // Create the context with a default value -const NavigationContext = createContext( - undefined, -); +const NavigationContext = createContext({ + isSidebarCollapsed: false, + setIsSidebarCollapsed: () => {}, + isBannerVisible: true, + setIsBannerVisible: () => {}, +}); // Create a provider component interface NavigationContextProviderProps { @@ -21,12 +24,15 @@ export const NavigationContextProvider = ({ children, }: NavigationContextProviderProps) => { const [isSidebarCollapsed, setIsSidebarCollapsed] = useState(false); + const [isBannerVisible, setIsBannerVisible] = useState(true); return ( {children} diff --git a/kontrol-frontend/src/pages/FlowsCreate.tsx b/kontrol-frontend/src/pages/FlowsCreate.tsx index 026195a..4f0983d 100644 --- a/kontrol-frontend/src/pages/FlowsCreate.tsx +++ b/kontrol-frontend/src/pages/FlowsCreate.tsx @@ -125,7 +125,7 @@ const Page = () => { const formIsValid = formState.name.length > 0 && formState.service.length > 0; return ( - + Update traffic control and data isolation details below diff --git a/kontrol-frontend/src/theme.ts b/kontrol-frontend/src/theme.ts index 9a0db8c..3e37a5b 100644 --- a/kontrol-frontend/src/theme.ts +++ b/kontrol-frontend/src/theme.ts @@ -23,6 +23,7 @@ export const colorOverrides: Record> = { }, orange: { "500": "#FF602C", + "100": "#FCA0610D", }, blue: { "50": "#F6FAFF",