-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add single Toast logic and UI * WIP * add info toasts * refactor toast logic * add WarningToast and docs * fix toggle
- Loading branch information
Showing
50 changed files
with
496 additions
and
127 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,3 +65,4 @@ yarn-error.log | |
.yarn-integrity | ||
.next | ||
build | ||
.fontello-session |
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
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 |
---|---|---|
@@ -1,5 +1,31 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export const InfoToast = () => { | ||
return <div>Info toast</div>; | ||
import {Toast} from '@/ui/Toast'; | ||
import {Icon} from '@/ui/Icon'; | ||
import {useActionTimer} from '@/utils/useActionTimer'; | ||
|
||
import classes from './InfoToast.module.css'; | ||
|
||
export const InfoToast = ({text, onClose}) => { | ||
const handleClose = () => { | ||
onClose(); | ||
}; | ||
useActionTimer(handleClose, 10); | ||
return ( | ||
<Toast className={classes.toast}> | ||
<div className={classes.iconWrapper}> | ||
<Icon name="info" color="white" className={classes.icon} /> | ||
</div> | ||
<div className={classes.textWrapper}>{text}</div> | ||
<div className={classes.closeWrapper} role="button" onClick={handleClose}> | ||
<Icon name="close" color="white" className={classes.close} /> | ||
</div> | ||
</Toast> | ||
); | ||
}; | ||
|
||
InfoToast.propTypes = { | ||
text: PropTypes.string.isRequired, | ||
onClose: PropTypes.func.isRequired, | ||
}; |
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,27 @@ | ||
.toast { | ||
width: calc(44 * var(--baseUnit)); | ||
} | ||
|
||
.textWrapper { | ||
margin-left: calc(2 * var(--baseUnit)); | ||
margin-right: calc(2 * var(--baseUnit)); | ||
} | ||
|
||
.iconWrapper { | ||
align-self: flex-start; | ||
margin-right: auto; | ||
|
||
& .icon { | ||
font-size: calc(5 * var(--baseUnit)); | ||
} | ||
} | ||
|
||
.closeWrapper { | ||
align-self: start; | ||
margin-left: auto; | ||
|
||
& .close { | ||
cursor: pointer; | ||
font-size: calc(2.5 * var(--baseUnit)); | ||
} | ||
} |
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 +1,2 @@ | ||
export {InfoToast} from './InfoToast'; | ||
export {useInfoToast} from './useInfoToast'; |
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,19 @@ | ||
import {useCallback} from 'react'; | ||
|
||
import {useToastActions} from '@/features/toast'; | ||
import {toastTypes} from '@/components/ToastManager'; | ||
|
||
export const useInfoToast = () => { | ||
const {openToast} = useToastActions(); | ||
return useCallback( | ||
({text}) => { | ||
openToast({ | ||
toastType: toastTypes.INFO, | ||
toastProps: { | ||
text, | ||
}, | ||
}); | ||
}, | ||
[openToast] | ||
); | ||
}; |
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
Oops, something went wrong.
95c6495
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
structure – ./
structure-git-master-morewings.vercel.app
structure.ninja
structure-morewings.vercel.app