From 04d723d4058cc9dad85ba7329b884242005512c1 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Sun, 28 Apr 2024 19:42:41 +0200 Subject: [PATCH] Fixed colors of AG Grid --- .../src/components/tableComponent/index.tsx | 51 +++++++++++++------ src/frontend/src/style/ag-theme-shadcn.css | 22 ++++++++ 2 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 src/frontend/src/style/ag-theme-shadcn.css diff --git a/src/frontend/src/components/tableComponent/index.tsx b/src/frontend/src/components/tableComponent/index.tsx index 754cc4dda..12688845f 100644 --- a/src/frontend/src/components/tableComponent/index.tsx +++ b/src/frontend/src/components/tableComponent/index.tsx @@ -1,20 +1,18 @@ +import { ColDef, ColGroupDef } from "ag-grid-community"; import "ag-grid-community/styles/ag-grid.css"; // Mandatory CSS required by the grid import "ag-grid-community/styles/ag-theme-quartz.css"; // Optional Theme applied to the grid import { AgGridReact } from "ag-grid-react"; -import { ColDef,ColGroupDef } from 'ag-grid-community'; import { useState } from "react"; -import { Card, CardContent, CardFooter } from "../ui/card"; +import { useDarkStore } from "../../stores/darkStore"; +import "../../style/ag-theme-shadcn.css"; // Custom CSS applied to the grid +import { cn } from "../../utils/utils"; +import { Button } from "../ui/button"; export default function TableComponent() { // Column Definitions: Defines the columns to be displayed. const [colDefs, setColDefs] = useState<(ColDef | ColGroupDef)[]>([ - { headerName: "Variable Name", - field: "name", - flex: 1, - editable: true - }, //This column will be twice as wide as the others + { headerName: "Variable Name", field: "name", flex: 1, editable: true }, //This column will be twice as wide as the others { - field: "type", cellEditor: "agSelectCellEditor", cellEditorParams: { @@ -72,20 +70,41 @@ export default function TableComponent() { }, ]); + const dark = useDarkStore((state) => state.dark); + return ( - - +
- - -
+
+
Showing 1-3 of 3 products
- - +
+ + +
+
+
); } diff --git a/src/frontend/src/style/ag-theme-shadcn.css b/src/frontend/src/style/ag-theme-shadcn.css new file mode 100644 index 000000000..dfe61f229 --- /dev/null +++ b/src/frontend/src/style/ag-theme-shadcn.css @@ -0,0 +1,22 @@ +/* set the background color of many elements across the grid */ +.ag-theme-quartz { + --ag-foreground-color: hsl(222 47% 11%); + --ag-background-color: hsl(0 0% 100%); + --ag-secondary-foreground-color: hsl(215 16% 46%); + --ag-data-color: hsl(222 47% 11%); + --ag-header-foreground-color: hsl(222 47% 11%); + --ag-header-background-color: hsl(210 40% 98%); + --ag-tooltip-background-color: hsl(210 40% 98%); + --ag-disabled-foreground-color: hsl(214 32% 91%); + + /* Add more color variables based on the ShadCN color palette */ + + --ag-border-color: hsl(214 32% 91%); + --ag-selected-row-background-color: hsl(210 40% 98%); + --ag-menu-background-color: hsl(210 40% 98%); + --ag-panel-background-color: hsl(210 40% 98%); + --ag-row-hover-color: hsl(210 40% 98%); + /* Set more color variables as per the ShadCN color scheme */ + +} +