From 2610fb5a3d2fa22e9ec307b066759bb3b2baf7e2 Mon Sep 17 00:00:00 2001 From: Renato Pozzi Date: Sun, 25 Apr 2021 22:47:12 +0200 Subject: [PATCH] Updated alert component --- components/Alert.js | 37 ++++++++++++++++++++---------- components/__tests__/Alert.test.js | 4 ++-- pages/s/[seed]/index.js | 6 +++++ 3 files changed, 33 insertions(+), 14 deletions(-) diff --git a/components/Alert.js b/components/Alert.js index c25ec3f5..321be17d 100644 --- a/components/Alert.js +++ b/components/Alert.js @@ -1,21 +1,33 @@ -import { XCircleIcon } from "@heroicons/react/solid"; +import { XCircleIcon, ExclamationIcon } from "@heroicons/react/solid"; +import { Show } from "./Show"; + +export const Alert = ({ style, title, messages }) => { + const styles = { danger: "red", alert: "yellow" }; -export const Alert = ({ title, messages }) => { return ( -
+
-
-

{title}

-
-
    - {messages.map((message, key) => ( -
  • {message}
  • - ))} -
-
+

{title}

+ + 0}> +
+
    + {messages.map((message, key) => ( +
  • {message}
  • + ))} +
+
+
@@ -23,6 +35,7 @@ export const Alert = ({ title, messages }) => { }; Alert.defaultProps = { + style: "danger", title: "Please insert a title", messages: [], }; diff --git a/components/__tests__/Alert.test.js b/components/__tests__/Alert.test.js index 47b9fc41..603708f8 100644 --- a/components/__tests__/Alert.test.js +++ b/components/__tests__/Alert.test.js @@ -10,9 +10,9 @@ describe("Alert", () => { expect(screen.getByText("title")).toBeInTheDocument(); }); - it("should render an unordered list", () => { + it("should not have an unordered list", () => { const { container } = render(); - expect(container.querySelector("ul")).toBeInTheDocument(); + expect(container.querySelector("ul")).toBeNull(); }); it("should have zero messages", () => { diff --git a/pages/s/[seed]/index.js b/pages/s/[seed]/index.js index e7f88b53..aa88699c 100644 --- a/pages/s/[seed]/index.js +++ b/pages/s/[seed]/index.js @@ -11,6 +11,7 @@ import { CountryViews } from "../../../components/charts/CountryViews"; import { PageHeading } from "../../../components/PageHeading"; import { RealtimeVisitors } from "../../../components/RealtimeVisitors"; import { RangeSelector } from "../../../components/RangeSelector"; +import { Alert } from "../../../components/Alert"; export async function getServerSideProps(context) { const { seed } = context.query; @@ -35,6 +36,11 @@ const Website = ({ seed }) => { EXPERIMENTAL_IS_DARK={true} /> + +