From b0ec7a2a82909dd502ccbce227bea4f74740f33c Mon Sep 17 00:00:00 2001 From: Pablo Lara Date: Fri, 16 Aug 2024 12:43:02 +0200 Subject: [PATCH] fix: temporary rename to resolve casing conflict --- .eslintrc.cjs | 1 + app/(prowler)/page.tsx | 30 ++- components/charts/StatusChart.tsx | 107 +++++++++ components/charts/index.ts | 1 + components/ui/chart/tempChart.tsx | 370 +++++++++++++++++++++++++++++ components/ui/custom/CustomBox.tsx | 7 +- components/ui/index.ts | 1 + styles/globals.css | 19 ++ 8 files changed, 531 insertions(+), 5 deletions(-) create mode 100644 components/charts/StatusChart.tsx create mode 100644 components/charts/index.ts create mode 100644 components/ui/chart/tempChart.tsx diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 230bd6691f..c9f6d992bf 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -37,5 +37,6 @@ module.exports = { "simple-import-sort/exports": "error", "jsx-a11y/anchor-is-valid": "error", "jsx-a11y/alt-text": "error", + "@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }], }, }; diff --git a/app/(prowler)/page.tsx b/app/(prowler)/page.tsx index 3882fd7071..7cf4e2273f 100644 --- a/app/(prowler)/page.tsx +++ b/app/(prowler)/page.tsx @@ -1,11 +1,37 @@ +import { Spacer } from "@nextui-org/react"; + +import { StatusChart } from "@/components/charts"; +import { FilterControls } from "@/components/filters"; import { Header } from "@/components/ui"; +import { CustomBox } from "@/components/ui/custom"; export default function Home() { return ( <>
- -

Hi hi from Overview page

+ + + +
+ + + + +

hi hi

+
+ +

hi hi

+
+
); } diff --git a/components/charts/StatusChart.tsx b/components/charts/StatusChart.tsx new file mode 100644 index 0000000000..7f68ae2842 --- /dev/null +++ b/components/charts/StatusChart.tsx @@ -0,0 +1,107 @@ +"use client"; + +import { TrendingUp } from "lucide-react"; +import * as React from "react"; +import { Label, Pie, PieChart } from "recharts"; + +import { + ChartConfig, + ChartContainer, + ChartTooltip, + ChartTooltipContent, +} from "../ui"; + +const chartData = [ + { findings: "Success", number: 436, fill: "var(--color-success)" }, + { findings: "Fail", number: 293, fill: "var(--color-fail)" }, +]; + +const chartConfig = { + number: { + label: "Findings", + }, + chrome: { + label: "Chrome", + color: "hsl(var(--chart-1))", + }, + success: { + label: "Success", + color: "hsl(var(--chart-success))", + }, + firefox: { + label: "Firefox", + color: "hsl(var(--chart-3))", + }, + edge: { + label: "Edge", + color: "hsl(var(--chart-4))", + }, + fail: { + label: "Fail", + color: "hsl(var(--chart-fail))", + }, +} satisfies ChartConfig; + +export function StatusChart() { + const totalVisitors = React.useMemo(() => { + return chartData.reduce((acc, curr) => acc + curr.number, 0); + }, []); + + return ( +
+ + + } /> + + + + +
+
+ No change from last scan +
+
+ +2 findings from last scan +
+
+
+ ); +} diff --git a/components/charts/index.ts b/components/charts/index.ts new file mode 100644 index 0000000000..6883b502b9 --- /dev/null +++ b/components/charts/index.ts @@ -0,0 +1 @@ +export * from "./StatusChart"; diff --git a/components/ui/chart/tempChart.tsx b/components/ui/chart/tempChart.tsx new file mode 100644 index 0000000000..a83d876ec4 --- /dev/null +++ b/components/ui/chart/tempChart.tsx @@ -0,0 +1,370 @@ +"use client"; + +import * as React from "react"; +import * as RechartsPrimitive from "recharts"; + +// import { +// NameType, +// Payload, +// ValueType, +// } from "recharts/types/component/DefaultTooltipContent"; +import { cn } from "@/lib/utils"; + +// Format: { THEME_NAME: CSS_SELECTOR } +const THEMES = { light: "", dark: ".dark" } as const; + +export type ChartConfig = { + [k in string]: { + label?: React.ReactNode; + icon?: React.ComponentType; + } & ( + | { color?: string; theme?: never } + | { color?: never; theme: Record } + ); +}; + +type ChartContextProps = { + config: ChartConfig; +}; + +const ChartContext = React.createContext(null); + +function useChart() { + const context = React.useContext(ChartContext); + + if (!context) { + throw new Error("useChart must be used within a "); + } + + return context; +} + +const ChartContainer = React.forwardRef< + HTMLDivElement, + React.ComponentProps<"div"> & { + config: ChartConfig; + children: React.ComponentProps< + typeof RechartsPrimitive.ResponsiveContainer + >["children"]; + } +>(({ id, className, children, config, ...props }, ref) => { + const uniqueId = React.useId(); + const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`; + + return ( + +
+ + + {children} + +
+
+ ); +}); +ChartContainer.displayName = "Chart"; + +const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => { + const colorConfig = Object.entries(config).filter( + ([_, config]) => config.theme || config.color, + ); + + if (!colorConfig.length) { + return null; + } + + return ( +