Skip to content

Commit 9fab713

Browse files
authored
fix: update docs for glide-data-grid-cells (#1056)
1 parent c961675 commit 9fab713

File tree

2 files changed

+4
-51
lines changed

2 files changed

+4
-51
lines changed

packages/cells/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@ Current cells
2424

2525
# Usage
2626

27-
Step 1: Add the extra cells to your grid.
27+
Step 1: Import the cell renderers you want to use and pass them to the grid.
2828

2929
```tsx
30-
import { useExtraCells } from "@glideapps/glide-data-grid-cells";
30+
import { allCells } from "@glideapps/glide-data-grid-cells";
3131

3232
const Grid = () => {
33-
const { customRenderers } = useExtraCells();
34-
return <DataEditor customRenderers={customRenderers} {...rest} />;
33+
return <DataEditor customRenderers={allCells} {...rest} />;
3534
};
3635
```
3736

packages/core/API.md

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,50 +1315,4 @@ If `isDraggable` is set, the whole Grid is draggable, and `onDragStart` will be
13151315

13161316
Behavior not defined or officially supported. Feel free to check out what this does in github but anything in here is up for grabs to be changed at any time.
13171317

1318-
---
1319-
1320-
# Hooks
1321-
1322-
## useCustomCells
1323-
1324-
```ts
1325-
// arguments passed to the draw callback
1326-
interface DrawArgs {
1327-
ctx: CanvasRenderingContext2D;
1328-
theme: Theme;
1329-
rect: Rectangle;
1330-
hoverAmount: number;
1331-
hoverX: number | undefined;
1332-
hoverY: number | undefined;
1333-
col: number;
1334-
row: number;
1335-
highlighted: boolean;
1336-
imageLoader: ImageWindowLoader;
1337-
}
1338-
1339-
// a standardized cell renderer consumed by the hook
1340-
type CustomCellRenderer<T extends CustomCell> = {
1341-
isMatch: (cell: CustomCell) => cell is T;
1342-
draw: (args: DrawArgs, cell: T) => boolean;
1343-
provideEditor: ProvideEditorCallback<T>;
1344-
};
1345-
1346-
// the hook itself
1347-
declare function useCustomCells(cells: readonly CustomCellRenderer<any>[]): {
1348-
drawCell: DrawCustomCellCallback;
1349-
provideEditor: ProvideEditorCallback<GridCell>;
1350-
};
1351-
```
1352-
1353-
The useCustomCells hook provides a standardized method of integrating custom cells into the Glide Data Grid. All cells in the `@glideapps/glide-data-grid-source` package are already in this format and can be used individually by passing them to this hook as so. The result of the hook is an object which can be spread on the DataEditor to implement the cells.
1354-
1355-
```tsx
1356-
import StarCell from "@glideapps/glide-data-grid-cells/cells/star-cell";
1357-
import DropdownCell from "@glideapps/glide-data-grid-cells/cells/dropdown-cell";
1358-
1359-
const MyGrid = () => {
1360-
const args = useCustomCells([StarCell, DropdownCell]);
1361-
1362-
return <DataEditor {...args} />;
1363-
};
1364-
```
1318+
---

0 commit comments

Comments
 (0)