-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add toaster and menu components
- Loading branch information
1 parent
f62c3d6
commit e9fec88
Showing
7 changed files
with
56 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@saas-ui/react': minor | ||
--- | ||
|
||
Added toaster and menu components |
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
packages/saas-ui-react/src/components/snackbar/snackbar.context.ts
This file was deleted.
Oops, something went wrong.
61 changes: 0 additions & 61 deletions
61
packages/saas-ui-react/src/components/snackbar/snackbar.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './toaster.tsx' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use client' | ||
|
||
import { | ||
Toaster as ChakraToaster, | ||
CreateToasterReturn, | ||
Portal, | ||
Spinner, | ||
Stack, | ||
Toast, | ||
createToaster, | ||
} from '@chakra-ui/react' | ||
|
||
export const toast = createToaster({ | ||
placement: 'bottom-end', | ||
pauseOnPageIdle: true, | ||
}) | ||
|
||
export interface ToasterProps extends CreateToasterReturn { | ||
children: React.ReactNode | ||
} | ||
|
||
export const Toaster = () => { | ||
return ( | ||
<Portal> | ||
<ChakraToaster toaster={toast} insetInline={{ mdDown: '4' }}> | ||
{(toast) => ( | ||
<Toast.Root width={{ md: 'sm' }}> | ||
{toast.type === 'loading' ? ( | ||
<Spinner size="sm" color="colorPalette.solid" /> | ||
) : ( | ||
<Toast.Indicator /> | ||
)} | ||
<Stack gap="1" flex="1" maxWidth="100%"> | ||
{toast.title && <Toast.Title>{toast.title}</Toast.Title>} | ||
{toast.description && ( | ||
<Toast.Description>{toast.description}</Toast.Description> | ||
)} | ||
</Stack> | ||
{toast.action && ( | ||
<Toast.ActionTrigger>{toast.action.label}</Toast.ActionTrigger> | ||
)} | ||
{toast.meta?.closable && <Toast.CloseTrigger />} | ||
</Toast.Root> | ||
)} | ||
</ChakraToaster> | ||
</Portal> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters