Skip to content

Commit f0a59f6

Browse files
committed
Extend toolbar docs
1 parent 00b87fb commit f0a59f6

File tree

2 files changed

+43
-4
lines changed

2 files changed

+43
-4
lines changed

docs/src/pages/page-home.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ export const HomePage = () => {
102102
<Section title="Usage">
103103
<p>
104104
A <strong>Blueprint Datagrid</strong> is created with the <Code>Datagrid</Code> component and by passing it an
105-
array of objects as <Code>dataSource</Code>, which contain
105+
array of objects as <Code>dataSource</Code>, which contains
106106
the data to use as the contents of the table. The <Code>Datagrid</Code> is mainy configured by passing
107-
additional components to it's slot, like <Code>Column</Code>{" "}
108-
components or the <Code>Pager</Code>:
107+
additional components to it's slot, like <Code>Column</Code>s or the <Code>Toolbar</Code> component, which can
108+
hold additional controls like
109+
the <Code>Pager</Code>:
109110
</p>
110111
<Example code={usageExampleCode} showCode>
111112
<Datagrid dataSource={varieties}>

docs/src/pages/page-toolbars.tsx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ import { Page } from "../components/page";
44
import { Section } from "../components/section";
55
import { Variety } from "../data/pepper-varieties/pepper-varieties";
66
import { Example } from "../components/example";
7+
import { useAppSelector } from "../app/hooks";
8+
import React from "react";
9+
import { Link } from "react-router-dom";
710

811
const positioningDemoCode = `<Datagrid dataSource={[] as Variety[]}>
912
<Toolbar position={ToolbarPosition.TOP}>
@@ -23,13 +26,24 @@ const positioningDemoCode = `<Datagrid dataSource={[] as Variety[]}>
2326
</Toolbar>
2427
</Datagrid>`;
2528

29+
const pagerPositioningExampleCode = `<Datagrid dataSource={varieties}>
30+
<Column field="name" label="Name" />
31+
<Column field="shuUpperBound" label="Heat (SHU)" type={ColumnType.NUMBER} />
32+
<Column field="rare" label="Rare" type={ColumnType.BOOLEAN} />
33+
<Toolbar position={ToolbarPosition.BOTTOM}>
34+
<Pager elementsPerPage={5} align={Alignment.CENTER} />
35+
</Toolbar>
36+
</Datagrid>`;
37+
2638
const DemoBox = (props: { position: ToolbarPosition, align: Alignment }) => {
2739
return (
2840
<Tag intent={Intent.PRIMARY}>{props.position} {props.align}</Tag>
2941
);
3042
};
3143

3244
export const ToolbarsPage = () => {
45+
const { varieties } = useAppSelector(state => state.varieties);
46+
3347
return (
3448
<Page title="Toolbars">
3549
<Section>
@@ -56,6 +70,30 @@ export const ToolbarsPage = () => {
5670
</Datagrid>
5771
</Example>
5872
</Section>
73+
<Section title="Toolbar Components">
74+
<p>Three types of components can be placed inside toolbars:
75+
<ul>
76+
<li>Special <strong>Blueprint Datagrid</strong> controls</li>
77+
<li>Table-level actions</li>
78+
<li>Any custom component</li>
79+
</ul>
80+
</p>
81+
<p>Some <strong>Blueprint Datagrid</strong> controls can be placed in any of the toolbars with any alignment in
82+
order to activate a feature. The <Code>Pager</Code> component, for example, activates pagination (see <Link to={"/pagination"}>Pagination</Link> for more information):</p>
83+
<Example code={pagerPositioningExampleCode}>
84+
<Datagrid dataSource={varieties}>
85+
<Column field="name" label="Name" />
86+
<Column field="shuUpperBound" label="Heat (SHU)" type={ColumnType.NUMBER} />
87+
<Column field="rare" label="Rare" type={ColumnType.BOOLEAN} />
88+
<Toolbar position={ToolbarPosition.BOTTOM}>
89+
<Pager elementsPerPage={5} align={Alignment.CENTER} />
90+
</Toolbar>
91+
</Datagrid>
92+
</Example>
93+
<p>For table-level actions, check out the <Link to={"/pagination"}>Actions</Link> chapter.</p>
94+
<p>Finally, any custom component can be passed to a toolbar, provided that it has an <Code>align</Code> prop of type <Code>Alignment</Code>. See the first example on this page for an example!</p>
95+
</Section>
5996
</Page>
60-
);
97+
)
98+
;
6199
};

0 commit comments

Comments
 (0)