Skip to content

Commit

Permalink
feat: add toaster and menu components
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagebakers committed Nov 25, 2024
1 parent f62c3d6 commit e9fec88
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 74 deletions.
5 changes: 5 additions & 0 deletions .changeset/beige-fans-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@saas-ui/react': minor
---

Added toaster and menu components
2 changes: 0 additions & 2 deletions packages/saas-ui-react/src/components/snackbar/index.ts

This file was deleted.

10 changes: 0 additions & 10 deletions packages/saas-ui-react/src/components/snackbar/snackbar.context.ts

This file was deleted.

61 changes: 0 additions & 61 deletions packages/saas-ui-react/src/components/snackbar/snackbar.tsx

This file was deleted.

1 change: 1 addition & 0 deletions packages/saas-ui-react/src/components/toaster/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './toaster.tsx'
48 changes: 48 additions & 0 deletions packages/saas-ui-react/src/components/toaster/toaster.tsx
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>
)
}
3 changes: 2 additions & 1 deletion packages/saas-ui-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export * from './components/link/index.ts'
export * from './components/loading-overlay/index.ts'
export * from './components/navbar/index.ts'
export * from './components/number-input/index.ts'
export * from './components/menu/index.ts'
export * from './components/password-input/index.ts'
export * from './components/persona/index.ts'
export * from './components/pin-input/index.ts'
Expand All @@ -29,7 +30,7 @@ export * from './components/search-input/index.ts'
export * from './components/select/index.ts'
export * from './components/segmented-control/index.ts'
export * from './components/sidebar/index.ts'
export * from './components/snackbar/index.ts'
export * from './components/toaster/index.ts'
export * from './components/spinner/index.ts'
export * from './components/steps/index.ts'
export * from './components/switch/index.ts'
Expand Down

0 comments on commit e9fec88

Please sign in to comment.