-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: bump versions and update snackbar impl
- Loading branch information
1 parent
081d702
commit c875a3a
Showing
37 changed files
with
1,978 additions
and
1,798 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
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
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
13 changes: 6 additions & 7 deletions
13
nodejs-tools/nodejs-apps/vighnesh153-astro/src/components/solid/snackbar/SnackbarHost.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 |
---|---|---|
@@ -1,15 +1,14 @@ | ||
import { type JSX } from 'solid-js'; | ||
import { useSnackbar } from './SnackbarUtils'; | ||
import { For, type JSX } from 'solid-js'; | ||
import { useStore } from '@nanostores/solid'; | ||
import { snackbarList } from '@/stores/snackbar'; | ||
import { Snackbar } from './Snackbar'; | ||
|
||
export function SnackbarHost(): JSX.Element { | ||
const { snackbarList } = useSnackbar(); | ||
const $snackbarList = useStore(snackbarList); | ||
|
||
return ( | ||
<div class="fixed top-10 right-10"> | ||
{snackbarList().map((snackbar) => ( | ||
<Snackbar {...snackbar} /> | ||
))} | ||
<div class="fixed top-10 right-10 z-snackbar"> | ||
<For each={$snackbarList()}>{(snackbar) => <Snackbar {...snackbar} />}</For> | ||
</div> | ||
); | ||
} |
73 changes: 0 additions & 73 deletions
73
nodejs-tools/nodejs-apps/vighnesh153-astro/src/components/solid/snackbar/SnackbarUtils.tsx
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
nodejs-tools/nodejs-apps/vighnesh153-astro/src/components/solid/snackbar/index.ts
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
export * from './SnackbarHost'; | ||
export { SnackbarProvider, useSnackbar } from './SnackbarUtils'; |
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
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
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
49 changes: 49 additions & 0 deletions
49
nodejs-tools/nodejs-apps/vighnesh153-astro/src/stores/snackbar.ts
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,49 @@ | ||
import { atom, type ReadableAtom } from 'nanostores'; | ||
|
||
export type SnackbarPropsApi = { | ||
type: 'success' | 'error' | 'info' | 'warn'; | ||
message: string; | ||
|
||
manualDismissible?: boolean; | ||
autoDismissible?: boolean; | ||
autoDismissTimeMillis?: number; | ||
}; | ||
|
||
export type SnackbarProps = SnackbarPropsApi & { | ||
id: string; | ||
dismiss: () => void; | ||
}; | ||
|
||
export const mutableSnackbarList = atom<SnackbarProps[]>([]); | ||
export const snackbarList: ReadableAtom<SnackbarProps[]> = mutableSnackbarList; | ||
|
||
function removeSnackbar(id: string): void { | ||
mutableSnackbarList.set(snackbarList.get().filter((snackbar) => snackbar.id !== id)); | ||
} | ||
|
||
export function createSnackbar({ | ||
type, | ||
message, | ||
manualDismissible = false, | ||
autoDismissible = true, | ||
autoDismissTimeMillis = 5000, | ||
}: SnackbarPropsApi) { | ||
const id = Math.random().toString(16).slice(2); | ||
|
||
if (autoDismissible) { | ||
setTimeout(() => removeSnackbar(id), autoDismissTimeMillis); | ||
} | ||
|
||
mutableSnackbarList.set([ | ||
...snackbarList.get(), | ||
{ | ||
id, | ||
dismiss: () => removeSnackbar(id), | ||
type, | ||
message, | ||
manualDismissible, | ||
autoDismissible, | ||
autoDismissTimeMillis, | ||
}, | ||
]); | ||
} |
Oops, something went wrong.