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 7 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 package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@radix-ui/react-tooltip": "^1.1.0",
"color": "^4.2.3",
"dayjs": "^1.11.11",
"react-data-grid": "^7.0.0-beta.44",
"slugify": "^1.6.6"
},
"devDependencies": {
Expand Down
268 changes: 268 additions & 0 deletions packages/lib/src/data-grid/DataGrid.stories.tsx
Jialecl marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
import Title from "../../.storybook/components/Title";
import ExampleContainer from "../../.storybook/components/ExampleContainer";
import DxcDataGrid from "./DataGrid";
import DxcContainer from "../container/Container";
import { GridColumn, HierarchyGridRow } from "./types";
import { useState } from "react";

export default {
title: "Datagrid",
component: DxcDataGrid,
};

const columns: GridColumn[] = [
{
key: "id",
name: "ID",
resizable: true,
sortable: true,
draggable: false,
alignment: "left",
},
{
key: "task",
name: "Title",
resizable: true,
sortable: true,
draggable: true,
textEditable: true,
alignment: "left",
},
{
key: "complete",
name: " % Complete",
resizable: true,
sortable: true,
draggable: true,
alignment: "right",
summaryKeyToRender: "label",
},
{
key: "priority",
name: "Priority",
resizable: true,
draggable: true,
alignment: "center",
summaryKeyToRender: "total",
},
];

const expandableRows = [
{
id: 1,
task: "Task 1",
complete: 46,
priority: "High",
issueType: "Bug",
expandedContent: <DxcContainer> Custom content 1</DxcContainer>,
expandedContentHeight: 470,
},
{
id: 2,
task: "Task 2",
complete: 51,
priority: "High",
issueType: "Epic",
expandedContent: <DxcContainer> Custom content 1</DxcContainer>,
},
{
id: 3,
task: "Task 3",
complete: 40,
priority: "High",
issueType: "Improvement",
expandedContent: <DxcContainer> Custom content 1</DxcContainer>,
},
{
id: 4,
task: "Task 4",
complete: 10,
priority: "High",
issueType: "Improvement",
expandedContent: <DxcContainer> Custom content 1</DxcContainer>,
},
{
id: 5,
task: "Task 5",
complete: 68,
priority: "High",
issueType: "Improvement",
expandedContent: <DxcContainer> Custom content 1</DxcContainer>,
},
{
id: 6,
task: "Task 6",
complete: 37,
priority: "High",
issueType: "Improvement",
expandedContent: <DxcContainer> Custom content 1</DxcContainer>,
},
{
id: 7,
task: "Task 7",
complete: 73,
priority: "Medium",
issueType: "Story",
expandedContent: <DxcContainer> Custom content 1</DxcContainer>,
},
{
id: 8,
task: "Task 8",
complete: 27,
priority: "Medium",
issueType: "Story",
expandedContent: <DxcContainer> Custom content 1</DxcContainer>,
},
{
id: 9,
task: "Task 9",
complete: 36,
priority: "Critical",
issueType: "Epic",
expandedContent: <DxcContainer> Custom content 1</DxcContainer>,
},
];

const childcolumns: GridColumn[] = [
{
key: "name",
name: "Name",
resizable: true,
sortable: true,
alignment: "center",
},
{
key: "value",
name: "Value",
resizable: true,
sortable: true,
draggable: true,
textEditable: true,
alignment: "right",
},
];

const childRows: HierarchyGridRow[] = [
{
name: "Root Node 1",
value: "1",
id: "a",
childRows: [
{
name: "Child Node 1.1",
value: "1.1",
id: "aa",
childRows: [
{
name: "Grandchild Node 1.1.1",
value: "1.1.1",
id: "aaa",
},
{
name: "Grandchild Node 1.1.2",
value: "1.1.2",
id: "aab",
},
],
},
{
name: "Child Node 1.2",
value: "1.2",
id: "ab",
},
],
},
{
name: "Root Node 2",
value: "2",
id: "b",
childRows: [
{
name: "Child Node 2.1",
value: "2.1",
id: "ba",
childRows: [
{
name: "Grandchild Node 2.1.1",
value: "2.1.1",
id: "baa",
},
],
},
{
name: "Child Node 2.2",
value: "2.2",
id: "bb",
},
{
name: "Child Node 2.3",
value: "2.3",
id: "bc",
},
],
},
];

export const Chromatic = () => {
const [selectedRows, setSelectedRows] = useState((): Set<number | string> => new Set());
const [selectedChildRows, setSelectedChildRows] = useState((): Set<number | string> => new Set());
return (
<>
<ExampleContainer>
<Title title="Default" theme="light" level={4} />
<DxcDataGrid columns={columns} rows={expandableRows} uniqueRowId="id" />
</ExampleContainer>
<ExampleContainer>
<Title title="Expandable" theme="light" level={4} />
<DxcDataGrid columns={columns} rows={expandableRows} uniqueRowId="id" expandable />
</ExampleContainer>
<ExampleContainer>
<Title title="Selectable" theme="light" level={4} />
<DxcDataGrid
columns={columns}
rows={expandableRows}
uniqueRowId="task"
selectable
selectedRows={selectedRows}
onSelectRows={setSelectedRows}
/>
</ExampleContainer>
<ExampleContainer>
<Title title="Selectable & expandable" theme="light" level={4} />
<DxcDataGrid
columns={columns}
rows={expandableRows}
uniqueRowId="task"
expandable
selectable
selectedRows={selectedRows}
onSelectRows={setSelectedRows}
/>
</ExampleContainer>
<ExampleContainer>
<Title title="DataGrid with children" theme="light" level={4} />
<DxcDataGrid columns={childcolumns} rows={childRows} uniqueRowId="id" />
</ExampleContainer>
<ExampleContainer>
<Title title="DataGrid with children" theme="light" level={4} />
<DxcDataGrid
columns={childcolumns}
rows={childRows}
uniqueRowId="value"
selectable
selectedRows={selectedChildRows}
onSelectRows={setSelectedChildRows}
/>
</ExampleContainer>
<ExampleContainer>
<Title title="Summary row" theme="light" level={4} />
<DxcDataGrid
columns={columns}
rows={expandableRows}
summaryRow={{ label: "Total", total: 100 }}
uniqueRowId="id"
/>
</ExampleContainer>
</>
);
};
Loading
Loading