Fixed colors of AG Grid
This commit is contained in:
parent
2dd0b2bf16
commit
04d723d405
2 changed files with 57 additions and 16 deletions
|
|
@ -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-grid.css"; // Mandatory CSS required by the grid
|
||||||
import "ag-grid-community/styles/ag-theme-quartz.css"; // Optional Theme applied to the grid
|
import "ag-grid-community/styles/ag-theme-quartz.css"; // Optional Theme applied to the grid
|
||||||
import { AgGridReact } from "ag-grid-react";
|
import { AgGridReact } from "ag-grid-react";
|
||||||
import { ColDef,ColGroupDef } from 'ag-grid-community';
|
|
||||||
import { useState } from "react";
|
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() {
|
export default function TableComponent() {
|
||||||
// Column Definitions: Defines the columns to be displayed.
|
// Column Definitions: Defines the columns to be displayed.
|
||||||
const [colDefs, setColDefs] = useState<(ColDef<any> | ColGroupDef<any>)[]>([
|
const [colDefs, setColDefs] = useState<(ColDef<any> | ColGroupDef<any>)[]>([
|
||||||
{ headerName: "Variable Name",
|
{ headerName: "Variable Name", field: "name", flex: 1, editable: true }, //This column will be twice as wide as the others
|
||||||
field: "name",
|
|
||||||
flex: 1,
|
|
||||||
editable: true
|
|
||||||
}, //This column will be twice as wide as the others
|
|
||||||
{
|
{
|
||||||
|
|
||||||
field: "type",
|
field: "type",
|
||||||
cellEditor: "agSelectCellEditor",
|
cellEditor: "agSelectCellEditor",
|
||||||
cellEditorParams: {
|
cellEditorParams: {
|
||||||
|
|
@ -72,20 +70,41 @@ export default function TableComponent() {
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const dark = useDarkStore((state) => state.dark);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className="mb-12 h-full">
|
<div className="flex h-full flex-col">
|
||||||
<CardContent className="flex h-full flex-col pt-4">
|
|
||||||
<div
|
<div
|
||||||
className="ag-theme-quartz h-full" // applying the grid theme
|
className={cn(
|
||||||
|
dark ? "ag-theme-quartz-dark" : "ag-theme-quartz",
|
||||||
|
"ag-theme-shadcn flex h-full flex-col"
|
||||||
|
)} // applying the grid theme
|
||||||
>
|
>
|
||||||
<AgGridReact columnDefs={colDefs} rowData={rowData} />
|
<AgGridReact columnDefs={colDefs} rowData={rowData} />
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
<div className="flex items-center justify-between w-full">
|
||||||
<CardFooter>
|
<div className="text-xs text-muted-foreground py-4">
|
||||||
<div className="text-xs text-muted-foreground">
|
|
||||||
Showing <strong>1-3</strong> of <strong>3</strong> products
|
Showing <strong>1-3</strong> of <strong>3</strong> products
|
||||||
</div>
|
</div>
|
||||||
</CardFooter>
|
<div className="flex items-center justify-end space-x-2 py-4">
|
||||||
</Card>
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => {}}
|
||||||
|
disabled={true}
|
||||||
|
>
|
||||||
|
Previous
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={() => {}}
|
||||||
|
disabled={false}
|
||||||
|
>
|
||||||
|
Next
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
22
src/frontend/src/style/ag-theme-shadcn.css
Normal file
22
src/frontend/src/style/ag-theme-shadcn.css
Normal file
|
|
@ -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 */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue