Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Grid component #2056

Merged
merged 27 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
64ac4e0
Data grid added
Jialecl Jul 24, 2024
92309b2
Merge branch 'master' of https://github.com/dxc-technology/halstack-r…
Jialecl Jul 25, 2024
25d498a
Added icons + visual test cases
Jialecl Jul 25, 2024
a098e90
Corrected files names
Jialecl Jul 25, 2024
200bf98
fixed export name
Jialecl Jul 25, 2024
9b005cc
Merge branch 'master' of https://github.com/dxc-technology/halstack-r…
Jialecl Jul 29, 2024
4c7f5eb
Fixed build and added summary row visual test
Jialecl Jul 30, 2024
99a44c7
Added accessibility exception for data-grid
Mil4n0r Jul 30, 2024
dfc99a4
Merge branch 'master' of https://github.com/dxc-technology/halstack-r…
Jialecl Aug 1, 2024
5b7dd69
Added more test cases
Jialecl Aug 1, 2024
9bf7579
expandable trigger moved into utils
Jialecl Aug 1, 2024
44b8aab
Merge branch 'master' of https://github.com/dxc-technology/halstack-r…
Jialecl Aug 1, 2024
98eabe1
Merge branch 'jialecl/Datagrid' of https://github.com/dxc-technology/…
Jialecl Aug 1, 2024
02eec58
added selectable to sorting test
Jialecl Aug 2, 2024
5d7d492
Documentation pages added to website
Jialecl Aug 2, 2024
fc32ba4
Summary row added back to test
Jialecl Aug 2, 2024
664e4b7
fixed typos and added WAI-ARIA link
Jialecl Aug 5, 2024
46423a6
Added reduced and onGridRowChange, improved styles and typing
Jialecl Aug 6, 2024
89b4edc
tokens added to the dataGrid + themeGenerator previews
Jialecl Aug 7, 2024
bb0d8fc
Merge branch 'master' of https://github.com/dxc-technology/halstack-r…
Jialecl Aug 7, 2024
885a67c
fixed type error in theme generator preview
Jialecl Aug 7, 2024
dbe675e
Improved typing based on feedback to make it more readable
Jialecl Aug 8, 2024
0fe3118
removed unused flex
Jialecl Aug 8, 2024
a8bfa40
removed usage and specifications for now and added component description
Jialecl Aug 9, 2024
b1ef60c
tokens and theme previews updated + mode removed
Jialecl Aug 13, 2024
3f5834b
Removed unused import and debug class
Jialecl Aug 13, 2024
475df1b
Merge branch 'master' into jialecl/datagrid
Mil4n0r Aug 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions apps/website/pages/components/data-grid/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Head from "next/head";
import type { ReactElement } from "react";
import DataGridCodePage from "screens/components/data-grid/code/DataGridCodePage";
import DataGridPageLayout from "screens/components/data-grid/DatagridPageLayout";

const Usage = () => {
return (
<>
<Head>
<title>Data Grid — Halstack Design System</title>
</Head>
<DataGridCodePage />
</>
);
};

Usage.getLayout = function getLayout(page: ReactElement) {
return <DataGridPageLayout>{page}</DataGridPageLayout>;
};

export default Usage;
21 changes: 21 additions & 0 deletions apps/website/pages/components/data-grid/specifications.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Head from "next/head";
import type { ReactElement } from "react";
import DataGridSpecsPage from "screens/components/data-grid/specs/DataGridSpecsPage";
import DataGridPageLayout from "screens/components/data-grid/DatagridPageLayout";

const Specifications = () => {
return (
<>
<Head>
<title>Data Grid Specs — Halstack Design System</title>
</Head>
<DataGridSpecsPage />
</>
);
};

Specifications.getLayout = function getLayout(page: ReactElement) {
return <DataGridPageLayout>{page}</DataGridPageLayout>;
};

export default Specifications;
21 changes: 21 additions & 0 deletions apps/website/pages/components/data-grid/usage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Head from "next/head";
import type { ReactElement } from "react";
import DataGridUsagePage from "screens/components/data-grid/usage/DataGridUsagePage";
import DataGridPageLayout from "../../../screens/components/data-grid/DatagridPageLayout";

const Usage = () => {
return (
<>
<Head>
<title>Data Grid Usage — Halstack Design System</title>
</Head>
<DataGridUsagePage />
</>
);
};

Usage.getLayout = function getLayout(page: ReactElement) {
return <DataGridPageLayout>{page}</DataGridPageLayout>;
};

export default Usage;
5 changes: 5 additions & 0 deletions apps/website/screens/common/componentsList.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
"path": "/components/contextual-menu",
"status": "new"
},
{
"label": "Data Grid",
"path": "/components/data-grid",
"status": "experimental"
},
{
"label": "Date Input",
"path": "/components/date-input",
Expand Down
30 changes: 30 additions & 0 deletions apps/website/screens/common/themes/advanced-theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,36 @@
"iconColor": "#333333",
"iconSize": "16px"
},
"dataGrid": {
"rowSeparatorThickness": "1px",
"rowSeparatorStyle": "solid",
"rowSeparatorColor": "#cccccc",
"dataBackgroundColor": "#ffffff",
"dataFontFamily": "Open Sans, sans-serif",
"dataFontSize": "0.875rem",
"dataFontStyle": "normal",
"dataFontWeight": "400",
"dataFontColor": "#000000",
"dataFontTextTransform": "none",
"dataPaddingRight": "1.5rem",
"dataPaddingLeft": "1.5rem",
"dataPaddingRightReduced": "1rem",
"dataPaddingLeftReduced": "1rem",
"dataTextLineHeight": "normal",
"headerBackgroundColor": "#5f249f",
"headerBorderRadius": "4px",
"headerFontFamily": "Open Sans, sans-serif",
"headerFontSize": "0.875rem",
"headerFontStyle": "normal",
"headerFontWeight": "400",
"headerFontColor": "#ffffff",
"headerFontTextTransform": "none",
"headerPaddingRight": "1.4rem",
"headerPaddingLeft": "1.5rem",
"headerPaddingRightReduced": "1rem",
"headerPaddingLeftReduced": "1rem",
"headerTextLineHeight": "normal"
},
"dateInput": {
"pickerBackgroundColor": "#ffffff",
"pickerFontColor": "#000000",
Expand Down
5 changes: 5 additions & 0 deletions apps/website/screens/common/themes/opinionated-theme.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
"fontColor": "#333333",
"iconColor": "#333333"
},
"dataGrid": {
"baseColor": "#5f249f",
"headerFontColor": "#ffffff",
"cellFontColor": "#000000"
},
"dateInput": {
"baseColor": "#5f249f",
"selectedFontColor": "#ffffff"
Expand Down
27 changes: 27 additions & 0 deletions apps/website/screens/components/data-grid/DatagridPageLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { DxcParagraph, DxcFlex } from "@dxc-technology/halstack-react";
import PageHeading from "@/common/PageHeading";
import TabsPageHeading from "@/common/TabsPageLayout";
import ComponentHeading from "@/common/ComponentHeading";

const DataGridPageHeading = ({ children }: { children: React.ReactNode }) => {
const tabs = [
{ label: "Code", path: "/components/data-grid" },
{ label: "Usage", path: "/components/data-grid/usage" },
{ label: "Specifications", path: "/components/data-grid/specifications" },
];

return (
<DxcFlex direction="column" gap="3rem">
<PageHeading>
<DxcFlex direction="column" gap="2rem">
<ComponentHeading name="Data Grid" />
<DxcParagraph>A data grid is ... (TODO).</DxcParagraph>
Mil4n0r marked this conversation as resolved.
Show resolved Hide resolved
<TabsPageHeading tabs={tabs}></TabsPageHeading>
</DxcFlex>
</PageHeading>
{children}
</DxcFlex>
);
};

export default DataGridPageHeading;
220 changes: 220 additions & 0 deletions apps/website/screens/components/data-grid/code/DataGridCodePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
import { DxcFlex, DxcTable } from "@dxc-technology/halstack-react";
import QuickNavContainer from "@/common/QuickNavContainer";
import QuickNavContainerLayout from "@/common/QuickNavContainerLayout";
import DocFooter from "@/common/DocFooter";
import Code from "@/common/Code";
import Example from "@/common/example/Example";
import TableCode, { ExtendedTableCode } from "@/common/TableCode";
import StatusBadge from "@/common/StatusBadge";
import basicUsage from "./examples/basicUsage";
import selectable from "./examples/selectable";
import expandable from "./examples/expandable";
import hierarchical from "./examples/hierarchical";
import hierarchicalSelectable from "./examples/hierarchicalSelectable";

const columnsTypeString = `{
key: string;
label: string;
resizable?: boolean;
sortable?: boolean;
draggable?: boolean;
textEditable?: boolean;
summaryKey?: string;
alignment?: "left" | "right" | "center";
}`;

const GridRowTypeString = `{
[key: string]: React.ReactNode | undefined;
}`;

const HierarchyGridRowTypeString = `GridRow & {
childRows?: HierarchyGridRow[] | GridRow[];
}`;

const ExpandableGridRowTypeString = `GridRow & {
expandedContent?: React.ReactNode;
expandedContentHeight?: number;
}`;

const sections = [
{
title: "Props",
content: (
<DxcTable>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<StatusBadge status="required" />
columns
</td>
<td>
<p>
<Code>GridColumn[]</Code>
being <Code>GridColumn</Code>:
</p>
<ExtendedTableCode>{columnsTypeString}</ExtendedTableCode>
</td>
<td>
Each <Code>GridColumn</Code> object has the following properties:
<ul>
<li>
<b>key</b>: Key that will be rendered from each row in <TableCode>rows</TableCode>.
</li>
<li>
<b>label</b>: Label that will be used for the column header.
</li>
<li>
<b>resizable</b>: Whether the column is resizable or not.
</li>
<li>
<b>sortable</b>: Whether the column is sortable or not.
</li>
<li>
<b>draggable</b>: Whether the column can be dragged or not to another position or not.
</li>
<li>
<b>textEditable</b>: Whether the column cells are editable or not.
</li>
<li>
<b>summaryKey</b>: Value that will be rendered from the <TableCode>summaryRow</TableCode>
</li>
<li>
<b>alignment</b>: St sets the alignment inside the cells.
</li>
</ul>
</td>
<td>-</td>
</tr>
<tr>
<td>
<StatusBadge status="required" />
rows
</td>
<td>
<TableCode>GridRow[] | HierarchyGridRow[] | ExpandableGridRow[]</TableCode>
<p>Each one of them being in order:</p>
<p>
<ExtendedTableCode>{GridRowTypeString}</ExtendedTableCode>
</p>
<p>
<ExtendedTableCode>{HierarchyGridRowTypeString}</ExtendedTableCode>
</p>
<p>
<ExtendedTableCode>{ExpandableGridRowTypeString}</ExtendedTableCode>
</p>
</td>
<td>
List of rows that will be rendered in each cell based on the <Code>key</Code> in each column.
</td>
<td>-</td>
</tr>
<tr>
<td>expandable</td>
<td>
<TableCode>boolean</TableCode>
</td>
<td>Whether the rows can expand or not.</td>
<td>-</td>
</tr>
<tr>
<td>summaryRow</td>
<td>
<TableCode>GridRow</TableCode>
</td>
<td>Extra row that will be always visible.</td>
<td>-</td>
</tr>
<tr>
<td>selectable</td>
<td>
<TableCode>boolean</TableCode>
</td>
<td>Whether the rows are selectable or not.</td>
<td>-</td>
</tr>
<tr>
<td>selectedRows</td>
<td>
<TableCode>{`Set<string | number>`}</TableCode>
</td>
<td>
Set of selected rows. This prop is mandatory if <Code>selectable</Code> is set to true. The{" "}
<Code>uniqueRowId</Code> key will be used to identify the each row.
</td>
<td>-</td>
</tr>
<tr>
<td>onSelectRows</td>
<td>
<TableCode>{`(selectedRows: Set<number | string>) => void`}</TableCode>
</td>
<td>
Function called whenever the selected values changes. This prop is mandatory if <Code>selectable</Code> is
set to true.The <Code>uniqueRowId</Code> key will be used to identify the rows.
</td>
<td>-</td>
</tr>
<tr>
<td>uniqueRowId</td>
<td>
<TableCode>string</TableCode>
</td>
<td>
This prop indicates the unique key that can be used to identify each row. This prop is mandatory if{" "}
<Code>selectable</Code> is set to true, <Code>expandable</Code> is set to true or <Code>rows</Code> is of
type <Code>HierarchyGridRow[]</Code>.
</td>
<td>-</td>
</tr>
</tbody>
</DxcTable>
),
},

{
title: "Examples",
subSections: [
{
title: "Basic usage",
content: <Example example={basicUsage} defaultIsVisible />,
},
{
title: "Selectable data grid",
content: <Example example={selectable} defaultIsVisible />,
},
{
title: "Expandable data grid",
content: <Example example={expandable} defaultIsVisible />,
},
{
title: "Hierarchical data grid",
content: <Example example={hierarchical} defaultIsVisible />,
},
{
title: "Hierarchical and selectable data grid",
content: <Example example={hierarchicalSelectable} defaultIsVisible />,
},
],
},
];

const DataGridCodePage = () => {
return (
<DxcFlex direction="column" gap="4rem">
<QuickNavContainerLayout>
<QuickNavContainer sections={sections} startHeadingLevel={2}></QuickNavContainer>
</QuickNavContainerLayout>
<DocFooter githubLink="https://github.com/dxc-technology/halstack-react/blob/master/website/screens/components/data-grid/code/DataGridCodePage.tsx" />
</DxcFlex>
);
};

export default DataGridCodePage;
Loading
Loading