-
-
Notifications
You must be signed in to change notification settings - Fork 32.6k
[docs] Improve Toolpad Core docs #43796
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
cc061e5
bbdff62
6d30b3e
31932f9
3c41def
655ea3e
e55719c
eb195e8
0b7fe3f
92ba569
a111ee1
bf03532
46dcc36
794c4be
6936458
2faedd3
2e2052c
54cc265
79f374a
f19f2b6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -35,10 +35,10 @@ The max-width matches the min-width of the current breakpoint. | |||
<Container fixed> | ||||
``` | ||||
|
||||
## Experimental APIs | ||||
## Toolpad | ||||
|
||||
### Page Container | ||||
|
||||
The [PageContainer](https://mui.com/toolpad/core/react-page-container/) component in `@toolpad/core` is the ideal wrapper for the content of your dashboard. It makes the Material UI Container navigation aware and extends it with page title, breadcrumbs, actions, and more. | ||||
The [PageContainer](https://mui.com/toolpad/core/react-page-container/) component in `@toolpad/core` is the ideal wrapper for the content of your dashboard. It makes the Material UI Container navigation-aware and extends it with page title, breadcrumbs, actions, and more. | ||||
|
||||
{{"demo": "../breadcrumbs/PageContainerBasic.js", "height": 400, "hideToolbar": true}} | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The dark/light mode is broken on all those demos. As far as I understand things, At minimum, MUI System should support theme nesting where you can inherit the light/dark mode and use different values for the other values. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
to be clear. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import * as React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { DialogsProvider, useDialogs } from '@toolpad/core/useDialogs'; | ||
import Button from '@mui/material/Button'; | ||
import Dialog from '@mui/material/Dialog'; | ||
import DialogTitle from '@mui/material/DialogTitle'; | ||
import DialogContent from '@mui/material/DialogContent'; | ||
import DialogActions from '@mui/material/DialogActions'; | ||
|
||
function MyCustomDialog({ open, onClose }) { | ||
return ( | ||
<Dialog | ||
fullWidth | ||
open={open} | ||
onClose={(event) => onClose?.(event, 'escapeKeyDown')} | ||
> | ||
<DialogTitle>Custom dialog</DialogTitle> | ||
<DialogContent>I am a custom dialog</DialogContent> | ||
<DialogActions> | ||
<Button onClick={(event) => onClose?.(event, 'escapeKeyDown')}> | ||
Close me | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
} | ||
|
||
MyCustomDialog.propTypes = { | ||
/** | ||
* Callback fired when the component requests to be closed. | ||
* | ||
* @param {object} event The event source of the callback. | ||
* @param {string} reason Can be: `"escapeKeyDown"`, `"backdropClick"`. | ||
*/ | ||
onClose: PropTypes.func, | ||
/** | ||
* If `true`, the component is shown. | ||
*/ | ||
open: PropTypes.bool.isRequired, | ||
}; | ||
|
||
function DemoContent() { | ||
const dialogs = useDialogs(); | ||
return ( | ||
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}> | ||
<Button | ||
onClick={async () => { | ||
await dialogs.open(MyCustomDialog); | ||
}} | ||
> | ||
Open a custom dialog! | ||
</Button> | ||
<div style={{ display: 'flex', gap: 16 }}> | ||
<Button | ||
onClick={async () => { | ||
await dialogs.alert('This is an alert dialog'); | ||
}} | ||
> | ||
Alert | ||
</Button> | ||
<Button | ||
onClick={async () => { | ||
const confirmed = await dialogs.confirm( | ||
'Are you sure you want to delete this?', | ||
{ | ||
okText: 'Confirm', | ||
cancelText: 'Cancel', | ||
}, | ||
); | ||
if (confirmed) { | ||
dialogs.alert('Deleted!'); | ||
} | ||
}} | ||
> | ||
Confirm | ||
</Button> | ||
<Button | ||
onClick={async () => { | ||
const name = await dialogs.prompt('Enter your name', { | ||
okText: 'Confirm', | ||
cancelText: 'Cancel', | ||
}); | ||
dialogs.alert(`Hello, ${name}!`); | ||
}} | ||
> | ||
Prompt | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default function ToolpadDialogs() { | ||
return ( | ||
<DialogsProvider> | ||
<DemoContent /> | ||
</DialogsProvider> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import * as React from 'react'; | ||
import { DialogsProvider, useDialogs } from '@toolpad/core/useDialogs'; | ||
import Button from '@mui/material/Button'; | ||
import Dialog, { DialogProps } from '@mui/material/Dialog'; | ||
import DialogTitle from '@mui/material/DialogTitle'; | ||
import DialogContent from '@mui/material/DialogContent'; | ||
import DialogActions from '@mui/material/DialogActions'; | ||
|
||
function MyCustomDialog({ open, onClose }: Pick<DialogProps, 'open' | 'onClose'>) { | ||
return ( | ||
<Dialog | ||
fullWidth | ||
open={open} | ||
onClose={(event: React.SyntheticEvent) => onClose?.(event, 'escapeKeyDown')} | ||
> | ||
<DialogTitle>Custom dialog</DialogTitle> | ||
<DialogContent>I am a custom dialog</DialogContent> | ||
<DialogActions> | ||
<Button | ||
onClick={(event: React.SyntheticEvent) => | ||
onClose?.(event, 'escapeKeyDown') | ||
} | ||
> | ||
Close me | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
} | ||
|
||
function DemoContent() { | ||
const dialogs = useDialogs(); | ||
return ( | ||
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}> | ||
<Button | ||
onClick={async () => { | ||
await dialogs.open(MyCustomDialog); | ||
}} | ||
> | ||
Open a custom dialog! | ||
</Button> | ||
<div style={{ display: 'flex', gap: 16 }}> | ||
<Button | ||
onClick={async () => { | ||
await dialogs.alert('This is an alert dialog'); | ||
}} | ||
> | ||
Alert | ||
</Button> | ||
<Button | ||
onClick={async () => { | ||
const confirmed = await dialogs.confirm( | ||
'Are you sure you want to delete this?', | ||
{ | ||
okText: 'Confirm', | ||
cancelText: 'Cancel', | ||
}, | ||
); | ||
if (confirmed) { | ||
dialogs.alert('Deleted!'); | ||
} | ||
}} | ||
> | ||
Confirm | ||
</Button> | ||
<Button | ||
onClick={async () => { | ||
const name = await dialogs.prompt('Enter your name', { | ||
okText: 'Confirm', | ||
cancelText: 'Cancel', | ||
}); | ||
dialogs.alert(`Hello, ${name}!`); | ||
}} | ||
> | ||
Prompt | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default function ToolpadDialogs() { | ||
oliviertassinari marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
<DialogsProvider> | ||
<DemoContent /> | ||
</DialogsProvider> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<DialogsProvider> | ||
<DemoContent /> | ||
</DialogsProvider> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import * as React from 'react'; | ||
import { | ||
useNotifications, | ||
NotificationsProvider, | ||
} from '@toolpad/core/useNotifications'; | ||
import Button from '@mui/material/Button'; | ||
|
||
export default function ToolpadNotifications() { | ||
const notifications = useNotifications(); | ||
return ( | ||
<NotificationsProvider> | ||
<div> | ||
<Button | ||
onClick={() => { | ||
// preview-start | ||
notifications.show('Consider yourself notified!', { | ||
autoHideDuration: 3000, | ||
}); | ||
// preview-end | ||
}} | ||
> | ||
Notify me | ||
</Button> | ||
</div> | ||
</NotificationsProvider> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as React from 'react'; | ||
import { | ||
useNotifications, | ||
NotificationsProvider, | ||
} from '@toolpad/core/useNotifications'; | ||
import Button from '@mui/material/Button'; | ||
|
||
function NotifyButton() { | ||
const notifications = useNotifications(); | ||
return ( | ||
<Button | ||
onClick={() => { | ||
notifications.show('Consider yourself notified!', { | ||
autoHideDuration: 3000, | ||
}); | ||
}} | ||
> | ||
Notify me | ||
</Button> | ||
); | ||
} | ||
|
||
export default function ToolpadNotifications() { | ||
oliviertassinari marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
<NotificationsProvider> | ||
<NotifyButton /> | ||
</NotificationsProvider> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<NotificationsProvider> | ||
<div> | ||
<Button | ||
onClick={() => { | ||
// preview-start | ||
notifications.show('Consider yourself notified!', { | ||
autoHideDuration: 3000, | ||
}); | ||
// preview-end | ||
}} | ||
> | ||
Notify me | ||
</Button> | ||
</div> | ||
</NotificationsProvider> |
Uh oh!
There was an error while loading. Please reload this page.