From f2b75fb69945e43f33c9f3a617b70aae52d0c70f Mon Sep 17 00:00:00 2001 From: bzzz-coding <86077274+bzzz-coding@users.noreply.github.com> Date: Mon, 26 Feb 2024 16:28:16 -0800 Subject: [PATCH 1/7] Created Loader component and added fallback loader for citation-data-insights --- packages/ui/src/components/loader/index.ts | 1 + packages/ui/src/components/loader/loader.tsx | 37 +++++++++++++++++++ .../citation/ui/citation-data-insights.tsx | 11 ++++-- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 packages/ui/src/components/loader/index.ts create mode 100644 packages/ui/src/components/loader/loader.tsx diff --git a/packages/ui/src/components/loader/index.ts b/packages/ui/src/components/loader/index.ts new file mode 100644 index 00000000..537ea6ba --- /dev/null +++ b/packages/ui/src/components/loader/index.ts @@ -0,0 +1 @@ +export { default } from "./loader"; diff --git a/packages/ui/src/components/loader/loader.tsx b/packages/ui/src/components/loader/loader.tsx new file mode 100644 index 00000000..d8d2e918 --- /dev/null +++ b/packages/ui/src/components/loader/loader.tsx @@ -0,0 +1,37 @@ +interface LoaderProps { + height?: string; + width?: string; + textColor?: string; + spinnerColor?: string; + spinnerSize?: string; + backgroundColor?: string; +} + +const Loader: React.FC = ({ + height = "16", + width = "16", + textColor = "blue-500", + spinnerColor = "#1d4ed8", + spinnerSize = "12", + backgroundColor = "gray-100", +}) => { + return ( +
+ + + + + +

Loading...

+
+ ); +}; + +export default Loader; diff --git a/packages/website/src/features/citation/ui/citation-data-insights.tsx b/packages/website/src/features/citation/ui/citation-data-insights.tsx index 7480ef69..ea102371 100644 --- a/packages/website/src/features/citation/ui/citation-data-insights.tsx +++ b/packages/website/src/features/citation/ui/citation-data-insights.tsx @@ -1,5 +1,6 @@ import OpenInNewIcon from "@mui/icons-material/OpenInNew"; -import { VisualizationStub } from "@/shared/ui/visualization"; +import React, { Suspense } from "react"; +import Loader from "@lucky-parking/ui/src/components/loader"; interface CitationDataset { name?: string; @@ -15,6 +16,8 @@ interface CitationDataInsightsProps { title: string; } +const LazyVisualizationStub = React.lazy(() => import("@/shared/ui/visualization/visualization-stub")); + export default function CitationDataInsights(props: CitationDataInsightsProps) { const { category, datasets, dates, onClick, stat, title } = props; @@ -35,8 +38,10 @@ export default function CitationDataInsights(props: CitationDataInsightsProps) { {datasets.map(({ name, data }, index) => (
{name &&

{name}

} - {/*// @ts-ignore*/} - + }> + {/*// @ts-ignore*/} + +
))} From c1de6a77d3ab0d145c5fd45413c2f57cd8904a6f Mon Sep 17 00:00:00 2001 From: bzzz-coding <86077274+bzzz-coding@users.noreply.github.com> Date: Mon, 26 Feb 2024 17:32:58 -0800 Subject: [PATCH 2/7] Added tests for the Loader component --- .../ui/src/components/loader/loader.test.tsx | 23 +++++++++++++++++++ packages/ui/src/components/loader/loader.tsx | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 packages/ui/src/components/loader/loader.test.tsx diff --git a/packages/ui/src/components/loader/loader.test.tsx b/packages/ui/src/components/loader/loader.test.tsx new file mode 100644 index 00000000..d328767c --- /dev/null +++ b/packages/ui/src/components/loader/loader.test.tsx @@ -0,0 +1,23 @@ +import { render, screen } from "@testing-library/react"; +import Loader from "./loader"; + +// Test case for basic rendering and text +test("Renders the Loader component correctly", () => { + render(); + const loader = screen.getByTestId("loader"); + expect(loader).toBeInTheDocument(); + expect(loader).toHaveTextContent("Loading..."); +}); + +// Test case for styling props +test("Renders loader with custom background color", () => { + render(); + const loader = screen.getByTestId("loader"); + expect(loader).toHaveStyle({ backgroundColor: "rgb(245 158 11)" }); +}); + +test("Renders loader with custom height", () => { + render(); + const loader = screen.getByTestId("loader"); + expect(loader).toHaveClass("h-40"); +}); diff --git a/packages/ui/src/components/loader/loader.tsx b/packages/ui/src/components/loader/loader.tsx index d8d2e918..5aad9ad0 100644 --- a/packages/ui/src/components/loader/loader.tsx +++ b/packages/ui/src/components/loader/loader.tsx @@ -16,7 +16,7 @@ const Loader: React.FC = ({ backgroundColor = "gray-100", }) => { return ( -
+
Date: Tue, 27 Feb 2024 10:11:08 -0800 Subject: [PATCH 3/7] Documented Loader component using JSDoc --- packages/ui/src/components/loader/loader.tsx | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/ui/src/components/loader/loader.tsx b/packages/ui/src/components/loader/loader.tsx index 5aad9ad0..ab820ac8 100644 --- a/packages/ui/src/components/loader/loader.tsx +++ b/packages/ui/src/components/loader/loader.tsx @@ -8,15 +8,38 @@ interface LoaderProps { } const Loader: React.FC = ({ + /** + * The height and width of the loader, using Tailwind CSS sizing classes. + * @default 'h-16' height: 4rem; (64px) + * @default 'w-16' width: 4rem; (64px) + */ height = "16", width = "16", + /** + * The color of the text within the loader, using a Tailwind CSS color class. + * @default 'text-blue-500' color: rgb(59 130 246); + */ textColor = "blue-500", + /** + * The color of the spinner within the loader. + * @default '#1d4ed8' branding color + */ spinnerColor = "#1d4ed8", + /** + * The size of the spinner, using Tailwind CSS sizing classes. + * @default 'h-12 w-12' height: 3rem; width: 3rem; (48px) + */ spinnerSize = "12", + /** + * The background color of the loader, using a Tailwind CSS color class. + * @default 'bg-gray-100' background-color: rgb(243 244 246); + */ backgroundColor = "gray-100", }) => { return ( -
+
Date: Mon, 26 Feb 2024 16:28:16 -0800 Subject: [PATCH 4/7] Created Loader component and added fallback loader for citation-data-insights --- packages/ui/src/components/loader/index.ts | 1 + packages/ui/src/components/loader/loader.tsx | 37 +++++++++++++++++++ .../citation/ui/citation-data-insights.tsx | 11 ++++-- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 packages/ui/src/components/loader/index.ts create mode 100644 packages/ui/src/components/loader/loader.tsx diff --git a/packages/ui/src/components/loader/index.ts b/packages/ui/src/components/loader/index.ts new file mode 100644 index 00000000..537ea6ba --- /dev/null +++ b/packages/ui/src/components/loader/index.ts @@ -0,0 +1 @@ +export { default } from "./loader"; diff --git a/packages/ui/src/components/loader/loader.tsx b/packages/ui/src/components/loader/loader.tsx new file mode 100644 index 00000000..d8d2e918 --- /dev/null +++ b/packages/ui/src/components/loader/loader.tsx @@ -0,0 +1,37 @@ +interface LoaderProps { + height?: string; + width?: string; + textColor?: string; + spinnerColor?: string; + spinnerSize?: string; + backgroundColor?: string; +} + +const Loader: React.FC = ({ + height = "16", + width = "16", + textColor = "blue-500", + spinnerColor = "#1d4ed8", + spinnerSize = "12", + backgroundColor = "gray-100", +}) => { + return ( +
+ + + + + +

Loading...

+
+ ); +}; + +export default Loader; diff --git a/packages/website/src/features/citation/ui/citation-data-insights.tsx b/packages/website/src/features/citation/ui/citation-data-insights.tsx index 8dab6026..c1b4b337 100644 --- a/packages/website/src/features/citation/ui/citation-data-insights.tsx +++ b/packages/website/src/features/citation/ui/citation-data-insights.tsx @@ -1,5 +1,6 @@ import OpenInNewIcon from "@mui/icons-material/OpenInNew"; -import { VisualizationStub } from "@/shared/ui/visualization"; +import React, { Suspense } from "react"; +import Loader from "@lucky-parking/ui/src/components/loader"; interface CitationDataset { name?: string; @@ -15,6 +16,8 @@ interface CitationDataInsightsProps { title: string; } +const LazyVisualizationStub = React.lazy(() => import("@/shared/ui/visualization/visualization-stub")); + export default function CitationDataInsights(props: CitationDataInsightsProps) { const { category, datasets, dates, onClick, stat, title } = props; @@ -35,8 +38,10 @@ export default function CitationDataInsights(props: CitationDataInsightsProps) { {datasets.map(({ name, data }, index) => (
{name &&

{name}

} - {/*// @ts-ignore*/} - + }> + {/*// @ts-ignore*/} + +
))} From c1f68164732b0eba73973a2fa681dea0719b7ec4 Mon Sep 17 00:00:00 2001 From: bzzz-coding <86077274+bzzz-coding@users.noreply.github.com> Date: Mon, 26 Feb 2024 17:32:58 -0800 Subject: [PATCH 5/7] Added tests for the Loader component --- .../ui/src/components/loader/loader.test.tsx | 23 +++++++++++++++++++ packages/ui/src/components/loader/loader.tsx | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 packages/ui/src/components/loader/loader.test.tsx diff --git a/packages/ui/src/components/loader/loader.test.tsx b/packages/ui/src/components/loader/loader.test.tsx new file mode 100644 index 00000000..d328767c --- /dev/null +++ b/packages/ui/src/components/loader/loader.test.tsx @@ -0,0 +1,23 @@ +import { render, screen } from "@testing-library/react"; +import Loader from "./loader"; + +// Test case for basic rendering and text +test("Renders the Loader component correctly", () => { + render(); + const loader = screen.getByTestId("loader"); + expect(loader).toBeInTheDocument(); + expect(loader).toHaveTextContent("Loading..."); +}); + +// Test case for styling props +test("Renders loader with custom background color", () => { + render(); + const loader = screen.getByTestId("loader"); + expect(loader).toHaveStyle({ backgroundColor: "rgb(245 158 11)" }); +}); + +test("Renders loader with custom height", () => { + render(); + const loader = screen.getByTestId("loader"); + expect(loader).toHaveClass("h-40"); +}); diff --git a/packages/ui/src/components/loader/loader.tsx b/packages/ui/src/components/loader/loader.tsx index d8d2e918..5aad9ad0 100644 --- a/packages/ui/src/components/loader/loader.tsx +++ b/packages/ui/src/components/loader/loader.tsx @@ -16,7 +16,7 @@ const Loader: React.FC = ({ backgroundColor = "gray-100", }) => { return ( -
+
Date: Tue, 27 Feb 2024 10:11:08 -0800 Subject: [PATCH 6/7] Documented Loader component using JSDoc --- packages/ui/src/components/loader/loader.tsx | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/packages/ui/src/components/loader/loader.tsx b/packages/ui/src/components/loader/loader.tsx index 5aad9ad0..ab820ac8 100644 --- a/packages/ui/src/components/loader/loader.tsx +++ b/packages/ui/src/components/loader/loader.tsx @@ -8,15 +8,38 @@ interface LoaderProps { } const Loader: React.FC = ({ + /** + * The height and width of the loader, using Tailwind CSS sizing classes. + * @default 'h-16' height: 4rem; (64px) + * @default 'w-16' width: 4rem; (64px) + */ height = "16", width = "16", + /** + * The color of the text within the loader, using a Tailwind CSS color class. + * @default 'text-blue-500' color: rgb(59 130 246); + */ textColor = "blue-500", + /** + * The color of the spinner within the loader. + * @default '#1d4ed8' branding color + */ spinnerColor = "#1d4ed8", + /** + * The size of the spinner, using Tailwind CSS sizing classes. + * @default 'h-12 w-12' height: 3rem; width: 3rem; (48px) + */ spinnerSize = "12", + /** + * The background color of the loader, using a Tailwind CSS color class. + * @default 'bg-gray-100' background-color: rgb(243 244 246); + */ backgroundColor = "gray-100", }) => { return ( -
+
Date: Wed, 20 Mar 2024 17:55:15 -0700 Subject: [PATCH 7/7] Added link to home page to Logo --- .../src/entities/branding/ui/logo.test.tsx | 17 +++++++++++++++++ .../website/src/entities/branding/ui/logo.tsx | 9 +++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 packages/website/src/entities/branding/ui/logo.test.tsx diff --git a/packages/website/src/entities/branding/ui/logo.test.tsx b/packages/website/src/entities/branding/ui/logo.test.tsx new file mode 100644 index 00000000..3968b707 --- /dev/null +++ b/packages/website/src/entities/branding/ui/logo.test.tsx @@ -0,0 +1,17 @@ +import { render, screen } from "@testing-library/react"; +import userEvent from "@testing-library/user-event"; +import { MemoryRouter } from "react-router-dom"; +import Logo from "./logo"; + +test("clicking on the logo redirects to the home page", async () => { + render( + + + , + ); + + const logo = screen.getByTestId("logo"); + userEvent.click(logo); + + expect(window.location.pathname).toBe("/"); +}); diff --git a/packages/website/src/entities/branding/ui/logo.tsx b/packages/website/src/entities/branding/ui/logo.tsx index 476f87a5..b1781061 100644 --- a/packages/website/src/entities/branding/ui/logo.tsx +++ b/packages/website/src/entities/branding/ui/logo.tsx @@ -1,14 +1,19 @@ import BrandMark from "./brandmark.svg"; +import { Link } from "react-router-dom"; export default function Logo() { return ( -
+ /** + * reloadDocument - A property used in the Link component from React Router to skip client side routing and let the browser handle the transition normally (as if it were an ). + * @typedef {boolean} reloadDocument + */ + Parking Insights brand mark

Parking

Insights

-
+ ); }