Skip to content
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

docs: ensure ToastManager is layered above PortalManager to enable adding toast notifications within a portal #936

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions packages/react-docs/pages/_app.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,31 +133,31 @@ const App = (props) => {
theme={customTheme}
useCSSBaseline
>
<PortalManager>
<ToastManager
TransitionProps={{
sx: {
'[data-toast-placement^="top"] > &:first-of-type': {
mt: '4x', // the space to the top edge of the screen
},
'[data-toast-placement^="bottom"] > &:last-of-type': {
mb: '4x', // the space to the bottom edge of the screen
},
'[data-toast-placement$="left"] > &': {
ml: '4x', // the space to the left edge of the screen
},
'[data-toast-placement$="right"] > &': {
mr: '4x', // the space to the right edge of the screen
},
<ToastManager
TransitionProps={{
sx: {
'[data-toast-placement^="top"] > &:first-of-type': {
mt: '4x', // the space to the top edge of the screen
},
}}
>
'[data-toast-placement^="bottom"] > &:last-of-type': {
mb: '4x', // the space to the bottom edge of the screen
},
'[data-toast-placement$="left"] > &': {
ml: '4x', // the space to the left edge of the screen
},
'[data-toast-placement$="right"] > &': {
mr: '4x', // the space to the right edge of the screen
},
},
}}
>
<PortalManager>
<MDXProvider components={MDXComponents}>
<Page {...props} />
<GlobalStyles />
</MDXProvider>
</ToastManager>
</PortalManager>
</PortalManager>
</ToastManager>
</TonicProvider>
</EmotionCacheProvider>
</InstantSearch>
Expand Down
24 changes: 12 additions & 12 deletions packages/react-docs/pages/components/portal-manager/index.page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

## Setup

To incorporate with `PortalManager`, wrap your root component with the `PortalManager` component. This provides a context that the `usePortalManager` Hook can access.
First, import the necessary components:

```jsx disabled
import { TonicProvider, PortalManager } from '@tonic-ui/react';
```js
import {
PortalManager,
} from '@tonic-ui/react';
```

function App() {
return (
<TonicProvider>
<PortalManager>
{/* Your app goes here */}
</PortalManager>
</TonicProvider>
);
}
Next, wrap your application with `PortalManager`:

```jsx disabled
<PortalManager>
<App />
</PortalManager>
```

Once `PortalManager` is set up, any component can use the `usePortalManager` Hook to create and manage portals.
Expand Down
58 changes: 28 additions & 30 deletions packages/react-docs/pages/components/toast-manager/index.page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,36 @@

## Setup

To use `ToastManager`, you should wrap your root component with it, along with the `TonicProvider` component, as shown in the example below:
First, import the `ToastManager` component:

```jsx disabled
import { TonicProvider, ToastManager } from '@tonic-ui/react';
```jsx
import { ToastManager } from '@tonic-ui/react';
```

function App() {
return (
<TonicProvider>
<ToastManager
TransitionProps={{
sx: {
'[data-toast-placement^="top"] > &:first-of-type': {
mt: '4x', // the space to the top edge of the screen
},
'[data-toast-placement^="bottom"] > &:last-of-type': {
mb: '4x', // the space to the bottom edge of the screen
},
'[data-toast-placement$="left"] > &': {
ml: '4x', // the space to the left edge of the screen
},
'[data-toast-placement$="right"] > &': {
mr: '4x', // the space to the right edge of the screen
},
},
}}
placement="bottom-right"
>
{/* Your app goes here */}
</ToastManager>
</TonicProvider>
);
}
Next, wrap your application with `ToastManager`:

```jsx disabled
<ToastManager
TransitionProps={{
sx: {
'[data-toast-placement^="top"] > &:first-of-type': {
mt: '4x', // the space to the top edge of the screen
},
'[data-toast-placement^="bottom"] > &:last-of-type': {
mb: '4x', // the space to the bottom edge of the screen
},
'[data-toast-placement$="left"] > &': {
ml: '4x', // the space to the left edge of the screen
},
'[data-toast-placement$="right"] > &': {
mr: '4x', // the space to the right edge of the screen
},
},
}}
placement="bottom-right"
>
<App />
</ToastManager>
```

Once `ToastManager` is set up, you can use the `useToastManager` Hook to create and manage toasts from any component:
Expand Down
42 changes: 21 additions & 21 deletions packages/react-docs/pages/getting-started/usage/index.page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ import { Global, css } from '@emotion/react';
import React from 'react';
import {
Box,
TonicProvider,
PortalManager, // allows you to create and manage portals in the application
ToastManager, // allows you to create and manage toasts in the application
TonicProvider,
colorStyle,
theme,
useColorMode,
Expand All @@ -69,30 +69,30 @@ function App(props) {
theme={theme}
useCSSBaseline={true} // If `true`, apply CSS reset and base styles
>
<PortalManager>
<ToastManager
TransitionProps={{
sx: {
'[data-toast-placement^="top"] > &:first-of-type': {
mt: '4x', // the space to the top edge of the screen
},
'[data-toast-placement^="bottom"] > &:last-of-type': {
mb: '4x', // the space to the bottom edge of the screen
},
'[data-toast-placement$="left"] > &': {
ml: '4x', // the space to the left edge of the screen
},
'[data-toast-placement$="right"] > &': {
mr: '4x', // the space to the right edge of the screen
},
<ToastManager
TransitionProps={{
sx: {
'[data-toast-placement^="top"] > &:first-of-type': {
mt: '4x', // the space to the top edge of the screen
},
'[data-toast-placement^="bottom"] > &:last-of-type': {
mb: '4x', // the space to the bottom edge of the screen
},
'[data-toast-placement$="left"] > &': {
ml: '4x', // the space to the left edge of the screen
},
'[data-toast-placement$="right"] > &': {
mr: '4x', // the space to the right edge of the screen
},
}}
>
},
}}
>
<PortalManager>
<Layout>
<Box {...props} />
</Layout>
</ToastManager>
</PortalManager>
</PortalManager>
</ToastManager>
</TonicProvider>
);
}
Expand Down
Loading