File tree Expand file tree Collapse file tree 5 files changed +19
-14
lines changed
src/Providers/NotificationProvider Expand file tree Collapse file tree 5 files changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { NavigationStateProvider } from '#site/providers/navigationStateProvider
8
8
import styles from './layouts.module.css' ;
9
9
10
10
const BaseLayout : FC < PropsWithChildren > = ( { children } ) => (
11
- < NotificationProvider viewportClassName = "fixed bottom-0 right-0 list-none" >
11
+ < NotificationProvider >
12
12
< NavigationStateProvider >
13
13
< div className = { styles . baseLayout } > { children } </ div >
14
14
</ NavigationStateProvider >
Original file line number Diff line number Diff line change 1
- import * as Toast from '@radix-ui/react-toast' ;
2
1
import { withThemeByDataAttribute } from '@storybook/addon-themes' ;
3
2
import type { Preview , ReactRenderer } from '@storybook/react' ;
4
3
4
+ import { NotificationProvider } from '#ui/Providers/NotificationProvider' ;
5
+
5
6
import { STORYBOOK_MODES , STORYBOOK_SIZES } from './constants' ;
6
7
7
8
import '#ui/styles/index.css' ;
@@ -13,10 +14,9 @@ const preview: Preview = {
13
14
} ,
14
15
decorators : [
15
16
Story => (
16
- < Toast . Provider >
17
+ < NotificationProvider >
17
18
< Story />
18
- < Toast . Viewport />
19
- </ Toast . Provider >
19
+ </ NotificationProvider >
20
20
) ,
21
21
withThemeByDataAttribute < ReactRenderer > ( {
22
22
themes : { light : '' , dark : 'dark' } ,
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { render } from '@testing-library/react';
3
3
import { describe , it } from 'node:test' ;
4
4
import assert from 'node:assert/strict' ;
5
5
6
- import { NotificationProvider , useNotification } from '../NotificationProvider ' ;
6
+ import { NotificationProvider , useNotification } from '..' ;
7
7
8
8
describe ( 'useNotification' , ( ) => {
9
9
it ( 'should return the notification dispatch function' , ( ) => {
Original file line number Diff line number Diff line change
1
+ @reference "../../styles/index.css" ;
2
+
3
+ .viewport {
4
+ @apply fixed
5
+ bottom-0
6
+ right-0
7
+ list-none;
8
+ }
Original file line number Diff line number Diff line change @@ -10,13 +10,13 @@ import type {
10
10
11
11
import Notification from '#ui/Common/Notification' ;
12
12
13
+ import styles from './index.module.css' ;
14
+
13
15
type NotificationContextType = {
14
16
message : string | ReactNode ;
15
17
duration : number ;
16
18
} | null ;
17
19
18
- type NotificationProps = { viewportClassName ?: string } ;
19
-
20
20
const NotificationContext = createContext < NotificationContextType > ( null ) ;
21
21
22
22
export const NotificationDispatch = createContext <
@@ -25,10 +25,7 @@ export const NotificationDispatch = createContext<
25
25
26
26
export const useNotification = ( ) => useContext ( NotificationDispatch ) ;
27
27
28
- export const NotificationProvider : FC < PropsWithChildren < NotificationProps > > = ( {
29
- viewportClassName,
30
- children,
31
- } ) => {
28
+ export const NotificationProvider : FC < PropsWithChildren > = ( { children } ) => {
32
29
const [ notification , dispatch ] = useState < NotificationContextType > ( null ) ;
33
30
34
31
useEffect ( ( ) => {
@@ -43,13 +40,13 @@ export const NotificationProvider: FC<PropsWithChildren<NotificationProps>> = ({
43
40
< Toast . Provider >
44
41
{ children }
45
42
46
- < Toast . Viewport className = { viewportClassName } />
47
-
48
43
{ notification && (
49
44
< Notification duration = { notification . duration } >
50
45
{ notification . message }
51
46
</ Notification >
52
47
) }
48
+
49
+ < Toast . Viewport className = { styles . viewport } />
53
50
</ Toast . Provider >
54
51
</ NotificationDispatch . Provider >
55
52
</ NotificationContext . Provider >
You can’t perform that action at this time.
0 commit comments