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
88import styles from './layouts.module.css' ;
99
1010const BaseLayout : FC < PropsWithChildren > = ( { children } ) => (
11- < NotificationProvider viewportClassName = "fixed bottom-0 right-0 list-none" >
11+ < NotificationProvider >
1212 < NavigationStateProvider >
1313 < div className = { styles . baseLayout } > { children } </ div >
1414 </ NavigationStateProvider >
Original file line number Diff line number Diff line change 1- import * as Toast from '@radix-ui/react-toast' ;
21import { withThemeByDataAttribute } from '@storybook/addon-themes' ;
32import type { Preview , ReactRenderer } from '@storybook/react' ;
43
4+ import { NotificationProvider } from '#ui/Providers/NotificationProvider' ;
5+
56import { STORYBOOK_MODES , STORYBOOK_SIZES } from './constants' ;
67
78import '#ui/styles/index.css' ;
@@ -13,10 +14,9 @@ const preview: Preview = {
1314 } ,
1415 decorators : [
1516 Story => (
16- < Toast . Provider >
17+ < NotificationProvider >
1718 < Story />
18- < Toast . Viewport />
19- </ Toast . Provider >
19+ </ NotificationProvider >
2020 ) ,
2121 withThemeByDataAttribute < ReactRenderer > ( {
2222 themes : { light : '' , dark : 'dark' } ,
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { render } from '@testing-library/react';
33import { describe , it } from 'node:test' ;
44import assert from 'node:assert/strict' ;
55
6- import { NotificationProvider , useNotification } from '../NotificationProvider ' ;
6+ import { NotificationProvider , useNotification } from '..' ;
77
88describe ( 'useNotification' , ( ) => {
99 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 {
1010
1111import Notification from '#ui/Common/Notification' ;
1212
13+ import styles from './index.module.css' ;
14+
1315type NotificationContextType = {
1416 message : string | ReactNode ;
1517 duration : number ;
1618} | null ;
1719
18- type NotificationProps = { viewportClassName ?: string } ;
19-
2020const NotificationContext = createContext < NotificationContextType > ( null ) ;
2121
2222export const NotificationDispatch = createContext <
@@ -25,10 +25,7 @@ export const NotificationDispatch = createContext<
2525
2626export const useNotification = ( ) => useContext ( NotificationDispatch ) ;
2727
28- export const NotificationProvider : FC < PropsWithChildren < NotificationProps > > = ( {
29- viewportClassName,
30- children,
31- } ) => {
28+ export const NotificationProvider : FC < PropsWithChildren > = ( { children } ) => {
3229 const [ notification , dispatch ] = useState < NotificationContextType > ( null ) ;
3330
3431 useEffect ( ( ) => {
@@ -43,13 +40,13 @@ export const NotificationProvider: FC<PropsWithChildren<NotificationProps>> = ({
4340 < Toast . Provider >
4441 { children }
4542
46- < Toast . Viewport className = { viewportClassName } />
47-
4843 { notification && (
4944 < Notification duration = { notification . duration } >
5045 { notification . message }
5146 </ Notification >
5247 ) }
48+
49+ < Toast . Viewport className = { styles . viewport } />
5350 </ Toast . Provider >
5451 </ NotificationDispatch . Provider >
5552 </ NotificationContext . Provider >
You can’t perform that action at this time.
0 commit comments