Demos
Introductionβ
More info on demos. Each demo should have a live code block for you to tinker with.
How To Add Demoβ
General Infoβ
- Your demo should be placed in a folder under
~/demos.- For example,
~/demos/override/row
- For example,
- You have the ability to use React inside of markdown
- Make sure your file ends in
.mdx - Refer to an existing demo file for a better understanding
- Make sure your file ends in
- Each
.mdxor.mdfile has to have a header- See here for an example
- The
idis required and needs to be unique per folder - See here for more on markdown headers
- Highly recommend reading more on markdown features here
Sidebarβ
- To show your demo in the sidebar you need to edit
~/sidebar.demos.js- If I wanted to add a demo to the URL
/demo/override/rowI would- Create a file at
~/demos/override/row.mdcould also use.mdxextension - Update sidebar.demos.js
- *The
idneeds to be the same as the ending of the path you put into~/sidebar.demos.js
- Create a file at
- If I wanted to add a demo to the URL
row.mdxβ
---
id: row
// ...
---
sidebar.demos.jsβ
module.exports = {
sidebar: [
// ...
{
type: "category",
label: "Override Components",
items: [
"override/toolbar"
+ "override/row"
],
},
// ...
]
}
Demo Environmentβ
In order to keep our demos succinct, we take advantage of "global variables". Global variables will be in all caps snake case.
<MaterialTable
data={DEMO_DATA}
columns={DEMO_COLS}
// ...
/>
Environmental Variablesβ
The values for our global environmental variables can be found below.
Important Noteβ
PLEASE NOTE
The list below may not be up to date! Please see here for more
DEMO_DATAβ
This data is passed into <MaterialTable data={...} />
const DEMO_DATA = [
{ id: 2, name: "Joe" },
{ id: 1, name: "Mary" },
];
DEMO_COLSβ
This data is passed into <MaterialTable columns={...} />
const DEMO_COLS = [
{ field: "id", title: "Id" },
{ field: "name", title: "Name" },
];
TABLE_ICONSβ
This data is passed into <MaterialTable icons={...} />
The base icons are supplied out of the box.
const TABLE_ICONS = {
Add: forwardRef((props, ref) => <AddBox {...props} ref={ref} />),
Check: forwardRef((props, ref) => <Check {...props} ref={ref} />),
Clear: forwardRef((props, ref) => <Clear {...props} ref={ref} />),
Delete: forwardRef((props, ref) => <DeleteOutline {...props} ref={ref} />),
DetailPanel: forwardRef((props & { level?: number; row?: RowData }, ref) => (
<ChevronRight {...props} ref={ref} />
)),
Edit: forwardRef((props, ref) => <Edit {...props} ref={ref} />),
Export: forwardRef((props, ref) => <SaveAlt {...props} ref={ref} />),
Filter: forwardRef((props, ref) => <FilterList {...props} ref={ref} />),
FirstPage: forwardRef((props, ref) => <FirstPage {...props} ref={ref} />),
LastPage: forwardRef((props, ref) => <LastPage {...props} ref={ref} />),
NextPage: forwardRef((props, ref) => <ChevronRight {...props} ref={ref} />),
PreviousPage: forwardRef((props, ref) => (
<ChevronLeft {...props} ref={ref} />
)),
ResetSearch: forwardRef((props, ref) => <Clear {...props} ref={ref} />),
Search: forwardRef((props, ref) => <Search {...props} ref={ref} />),
SortArrow: forwardRef((props, ref) => <ArrowUpward {...props} ref={ref} />),
ThirdStateCheck: forwardRef((props, ref) => <Remove {...props} ref={ref} />),
ViewColumn: forwardRef((props, ref) => <ViewColumn {...props} ref={ref} />),
};