Added anchorOrigin props to AlertDisplay
Signed-off-by: Mehmet Mallı <mehmet.malli@trendyol.com> Signed-off-by: Mehmet Mallı <mallimehmet@gmail.com> Signed-off-by: Mehmet Mallı <mehmet.malli@trendyol.com>
This commit is contained in:
@@ -31,10 +31,18 @@ import pluralize from 'pluralize';
|
||||
* Shown as SnackBar at the top of the page
|
||||
*/
|
||||
// TODO: improve on this and promote to a shared component for use by all apps.
|
||||
export function AlertDisplay(_props: {}) {
|
||||
|
||||
type Props = {
|
||||
vertical?: 'top' | 'bottom';
|
||||
horizontal?: 'left' | 'center' | 'right';
|
||||
}
|
||||
|
||||
export function AlertDisplay(props: Props) {
|
||||
const [messages, setMessages] = useState<Array<AlertMessage>>([]);
|
||||
const alertApi = useApi(alertApiRef);
|
||||
|
||||
const { vertical = 'top', horizontal = 'center' } = props;
|
||||
|
||||
useEffect(() => {
|
||||
const subscription = alertApi
|
||||
.alert$()
|
||||
@@ -56,7 +64,7 @@ export function AlertDisplay(_props: {}) {
|
||||
};
|
||||
|
||||
return (
|
||||
<Snackbar open anchorOrigin={{ vertical: 'top', horizontal: 'center' }}>
|
||||
<Snackbar open anchorOrigin={{ vertical, horizontal}}>
|
||||
<Alert
|
||||
action={
|
||||
<IconButton
|
||||
|
||||
Reference in New Issue
Block a user