mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
added toasts
This commit is contained in:
parent
ef959af711
commit
39e801f6f3
10 changed files with 92 additions and 7 deletions
20
src/utils/toast/index.tsx
Normal file
20
src/utils/toast/index.tsx
Normal file
|
@ -0,0 +1,20 @@
|
|||
import React from 'react';
|
||||
import toast from 'react-hot-toast';
|
||||
import styles from './styles.module.scss';
|
||||
import { ToastOptions } from 'react-hot-toast/dist/core/types';
|
||||
import classNames from 'classnames';
|
||||
import { isTablet } from '~/constants/dom';
|
||||
|
||||
const defaultOptions: ToastOptions = {
|
||||
icon: null,
|
||||
duration: 3000,
|
||||
position: isTablet() ? 'top-center' : 'bottom-center',
|
||||
};
|
||||
|
||||
export const showToastError = (message: string) =>
|
||||
toast.error(t => <span onClick={() => toast.dismiss(t.id)}>{message}</span>, {
|
||||
...defaultOptions,
|
||||
className: classNames(styles.toast, styles.error),
|
||||
});
|
||||
|
||||
export const hideToast = (id: string) => toast.dismiss(id);
|
14
src/utils/toast/styles.module.scss
Normal file
14
src/utils/toast/styles.module.scss
Normal file
|
@ -0,0 +1,14 @@
|
|||
@import "src/styles/variables";
|
||||
|
||||
.toast {
|
||||
@include outer_shadow;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.error {
|
||||
font: $font_14_semibold;
|
||||
background: $red_gradient_alt;
|
||||
color: white;
|
||||
user-select: none;
|
||||
text-transform: uppercase;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue