-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
121 additions
and
0 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
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,25 @@ | ||
import { FC } from 'react' | ||
import { components, events, renderClassName, EventContextProvider } from 'fastui' | ||
import BootstrapToast from 'react-bootstrap/Toast' | ||
import BootstrapToastContainer from 'react-bootstrap/ToastContainer' | ||
|
||
export const Toast: FC<components.ToastProps> = (props) => { | ||
const { className, title, body, openTrigger, openContext } = props | ||
|
||
const { eventContext, fireId, clear } = events.usePageEventListen(openTrigger, openContext) | ||
|
||
return ( | ||
<EventContextProvider context={eventContext}> | ||
<BootstrapToastContainer> | ||
<BootstrapToast className={renderClassName(className)} show={!!fireId} onClose={clear}> | ||
<BootstrapToast.Header> | ||
<strong className="me-auto">{title}</strong> | ||
</BootstrapToast.Header> | ||
<BootstrapToast.Body> | ||
<components.AnyCompList propsList={body} /> | ||
</BootstrapToast.Body> | ||
</BootstrapToast> | ||
</BootstrapToastContainer> | ||
</EventContextProvider> | ||
) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { FC, useEffect } from 'react' | ||
|
||
import type { FastProps } from './index' | ||
import type { ContextType } from '../hooks/eventContext' | ||
|
||
import { ClassName } from '../hooks/className' | ||
import { PageEvent, usePageEventListen } from '../events' | ||
|
||
export interface ToastProps { | ||
type: 'Toast' | ||
title: string | ||
body: FastProps[] | ||
openTrigger?: PageEvent | ||
openContext?: ContextType | ||
className?: ClassName | ||
} | ||
|
||
export const ToastComp: FC<ToastProps> = (props) => { | ||
const { title, openTrigger, openContext } = props | ||
|
||
const { fireId, clear } = usePageEventListen(openTrigger, openContext) | ||
|
||
useEffect(() => { | ||
if (fireId) { | ||
setTimeout(() => { | ||
alert(`${title}\n\nNote: toasts are not implemented by pure FastUI, implement a component for 'ToastProps'.`) | ||
clear() | ||
}) | ||
} | ||
}, [fireId, title, clear]) | ||
|
||
return <></> | ||
} |
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