Skip to content

Commit 737dc91

Browse files
committed
remove mui components from ShowBase, ListBase and EditBase docs
1 parent 8046b0e commit 737dc91

File tree

3 files changed

+38
-71
lines changed

3 files changed

+38
-71
lines changed

docs/EditBase.md

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,18 @@ Contrary to [`<Edit>`](./Edit.md), it does not render the page layout, so no tit
1717
Use `<EditBase>` to create a custom Edition view, with exactly the content you add as child and nothing else (no title, Card, or list of actions as in the `<Edit>` component).
1818

1919
```jsx
20-
import { EditBase, SelectInput, SimpleForm, TextInput, Title } from "react-admin";
21-
import { Card, CardContent, Container } from "@mui/material";
20+
import { EditBase, Form } from "react-admin";
2221

2322
export const BookEdit = () => (
2423
<EditBase>
25-
<Container>
26-
<Title title="Book Edition" />
27-
<Card>
28-
<CardContent>
29-
<SimpleForm>
30-
<TextInput source="title" />
31-
<TextInput source="author" />
32-
<SelectInput source="availability" choices={[
33-
{ id: "in_stock", name: "In stock" },
34-
{ id: "out_of_stock", name: "Out of stock" },
35-
{ id: "out_of_print", name: "Out of print" },
36-
]} />
37-
</SimpleForm>
38-
</CardContent>
39-
</Card>
40-
</Container>
24+
<div>
25+
<h1>Book Edition</h1>
26+
<div>
27+
<Form>
28+
...
29+
</Form>
30+
</div>
31+
</div>
4132
</EditBase>
4233
);
4334
```
@@ -66,18 +57,17 @@ If your `authProvider` implements [Access Control](./Permissions.md#access-contr
6657
For instance, for the `<PostEdit>`page below:
6758

6859
```tsx
69-
import { EditBase, SimpleForm, TextInput } from 'react-admin';
60+
import { EditBase, Form } from 'react-admin';
7061

7162
// Resource name is "posts"
7263
const PostEdit = () => (
7364
<EditBase>
74-
<SimpleForm>
75-
<TextInput source="title" />
76-
<TextInput source="author" />
77-
<TextInput source="published_at" />
78-
</SimpleForm>
65+
<Form>
66+
...
67+
</Form>
7968
</EditBase>
8069
);
70+
8171
```
8272

8373
`<EditBase>` will call `authProvider.canAccess()` using the following parameters:

docs/ListBase.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,28 @@ You can use `ListBase` to create your own custom reusable List component, like t
1919
```jsx
2020
import {
2121
ListBase,
22-
Title,
23-
ListToolbar,
24-
Pagination,
25-
DataTable,
22+
ListIterator,
2623
} from 'react-admin';
27-
import { Card } from '@mui/material';
2824

2925
const MyList = ({ children, actions, filters, title, ...props }) => (
3026
<ListBase {...props}>
31-
<Title title={title}/>
32-
<ListToolbar
27+
<h1>{title}</h1>
28+
<CustomToolbar
3329
filters={filters}
3430
actions={actions}
3531
/>
36-
<Card>
32+
<div>
3733
{children}
38-
</Card>
39-
<Pagination />
34+
</div>
35+
<CustomPagination />
4036
</ListBase>
4137
);
4238

4339
const PostList = () => (
4440
<MyList title="Post List">
45-
<DataTable>
41+
<ListIterator>
4642
...
47-
</DataTable>
43+
</ListIterator>
4844
</MyList>
4945
);
5046
```
@@ -78,16 +74,14 @@ If your `authProvider` implements [Access Control](./Permissions.md#access-contr
7874
For instance, for the `<PostList>` page below:
7975

8076
```tsx
81-
import { ListBase, DataTable } from 'react-admin';
77+
import { ListBase, ListIterator } from 'react-admin';
8278

8379
// Resource name is "posts"
8480
const PostList = () => (
8581
<ListBase>
86-
<DataTable>
87-
<DataTable.Col source="title" />
88-
<DataTable.Col source="author" />
89-
<DataTable.Col source="published_at" />
90-
</DataTable>
82+
<ListIterator>
83+
<CustomPostRenderer />
84+
</ListIterator>
9185
</ListBase>
9286
);
9387
```

docs/ShowBase.md

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -78,29 +78,18 @@ For instance, to display several fields in a single line, you can use Material U
7878

7979
{% raw %}
8080
```jsx
81-
import { ShowBase, TextField, DateField, ReferenceField, WithRecord } from 'react-admin';
82-
import { Grid } from '@mui/material';
81+
import { ShowBase, ReferenceFieldBase, WithRecord } from 'react-admin';
8382
import StarIcon from '@mui/icons-material/Star';
8483

8584
const BookShow = () => (
8685
<ShowBase>
87-
<Grid container spacing={2} sx={{ margin: 2 }}>
88-
<Grid item xs={12} sm={6}>
89-
<TextField label="Title" source="title" />
90-
</Grid>
91-
<Grid item xs={12} sm={6}>
92-
<ReferenceField label="Author" source="author_id" reference="authors">
93-
<TextField source="name" />
94-
</ReferenceField>
95-
</Grid>
96-
<Grid item xs={12} sm={6}>
97-
<DateField label="Publication Date" source="published_at" />
98-
</Grid>
99-
<Grid item xs={12} sm={6}>
100-
<WithRecord label="Rating" render={record => <>
101-
{[...Array(record.rating)].map((_, index) => <StarIcon key={index} />)}
102-
</>} />
103-
</Grid>
86+
<div>
87+
<ReferenceFieldBase source="author_id" reference="authors">
88+
...
89+
</ReferenceFieldBase>
90+
<WithRecord label="Rating" render={record => <>
91+
{[...Array(record.rating)].map((_, index) => <StarIcon key={index} />)}
92+
</>} />
10493
</Grid>
10594
</ShowBase>
10695
);
@@ -170,7 +159,7 @@ You can override this behavior and pass custom side effects by providing a custo
170159

171160
```jsx
172161
import * as React from 'react';
173-
import { useNotify, useRefresh, useRedirect, ShowBase, SimpleShowLayout } from 'react-admin';
162+
import { useNotify, useRefresh, useRedirect, ShowBase } from 'react-admin';
174163

175164
const PostShow = () => {
176165
const notify = useNotify();
@@ -185,9 +174,7 @@ const PostShow = () => {
185174

186175
return (
187176
<ShowBase queryOptions={{ onError }}>
188-
<SimpleShowLayout>
189-
...
190-
</SimpleShowLayout>
177+
...
191178
</ShowBase>
192179
);
193180
}
@@ -228,16 +215,12 @@ If your `authProvider` implements [Access Control](./Permissions.md#access-contr
228215
For instance, for the `<PostShow>`page below:
229216

230217
```tsx
231-
import { ShowBase, SimpleShowLayout, TextField } from 'react-admin';
218+
import { ShowBase } from 'react-admin';
232219

233220
// Resource name is "posts"
234221
const PostShow = () => (
235222
<ShowBase>
236-
<SimpleShowLayout>
237-
<TextField source="title" />
238-
<TextField source="author" />
239-
<TextField source="published_at" />
240-
</SimpleShowLayout>
223+
...
241224
</ShowBase>
242225
);
243226
```

0 commit comments

Comments
 (0)