Skip to content

Commit c88ecf7

Browse files
Add documentation to all DataGrid components
1 parent 93de35e commit c88ecf7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

extensions/ql-vscode/src/view/common/DataGrid.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ interface DataGridProps {
2424
children: ReactNode;
2525
}
2626

27+
/**
28+
* The top level for a grid systemm that will contain `DataGridRow` and `DataGridCell` components.
29+
*
30+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns for how to use `gridTemplateColumns`.
31+
*/
2732
export function DataGrid({ gridTemplateColumns, children }: DataGridProps) {
2833
return (
2934
<StyledDataGrid $gridTemplateColumns={gridTemplateColumns}>
@@ -54,6 +59,14 @@ interface DataGridRowProps {
5459
"data-testid"?: string;
5560
}
5661

62+
/**
63+
* Optional component for encompasing a single row in a `DataGrid`.
64+
* Implements hover and focus states that highlight all cells in the row.
65+
*
66+
* Note that using this component is not mandatory. Cells can be placed directly
67+
* inside a `DataGrid`. Feel free to skip this component if your cells do not
68+
* line up into neat rows, or you do not need the hover and focus states.
69+
*/
5770
export const DataGridRow = forwardRef(
5871
(
5972
{ focused, children, "data-testid": testId }: DataGridRowProps,
@@ -85,6 +98,15 @@ interface DataGridCellProps {
8598
children: ReactNode;
8699
}
87100

101+
/**
102+
* A cell in a `DataGrid`.
103+
*
104+
* By default, the position of cells in the grid is determined by the order in which
105+
* they appear in the DOM. Cells will fill up the current row and then move on to the
106+
* next row. This can be overridden using the `gridRow` and `gridColumn` to place
107+
* cells anywhere within the grid. You can also configure cells to span multiple rows
108+
* or columns. See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column.
109+
*/
88110
export function DataGridCell({
89111
rowType = "default",
90112
gridRow,

0 commit comments

Comments
 (0)