Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create toaster component #142

Merged
merged 20 commits into from
Nov 18, 2020
Merged

Create toaster component #142

merged 20 commits into from
Nov 18, 2020

Conversation

bramvanhoutte
Copy link
Contributor

Closes #73

@codecov
Copy link

codecov bot commented Nov 15, 2020

Codecov Report

Merging #142 (078b03c) into master (ed10966) will decrease coverage by 3.12%.
The diff coverage is 87.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #142      +/-   ##
==========================================
- Coverage   98.00%   94.87%   -3.13%     
==========================================
  Files          22       25       +3     
  Lines         300      429     +129     
  Branches       47       75      +28     
==========================================
+ Hits          294      407     +113     
- Misses          6       22      +16     
Impacted Files Coverage Δ
...c/components/Toaster/ToastManager/ToastManager.tsx 74.41% <74.41%> (ø)
src/components/Toaster/Toaster.tsx 90.00% <90.00%> (ø)
src/components/Toaster/Toast/Toast.tsx 95.91% <95.91%> (ø)
src/components/Alert/Alert.tsx 100.00% <100.00%> (ø)
src/index.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed10966...078b03c. Read the comment docs.


.toastPadding {
padding: 8px 8px 0 0;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra space here. Which makes me wonder, is prettier not working in css?

src/components/Toaster/Toast/Toast.tsx Outdated Show resolved Hide resolved
src/components/Toaster/Toast/Toast.tsx Outdated Show resolved Hide resolved
}: Props) => {
const [isShown, setIsShown] = useState(true);
const [height, setHeight] = useState(0);
const closeTimer = useRef<number | null>(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What it looks like for me, is that the ref is used to save the timeout id so that it can be cleared later. In Bloodhound we use react-timer-hook for timer functionality. By using this we can remove clearCloseTimer, startCloseTimer and the input ref and replace it with the hook. WDYT?

message,
isClosable,
}: Props) => {
const [isShown, setIsShown] = useState(true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is isShown a state that is managed inside the component and also managed outside with a prop? Is it possible to have only one place were isShown state is managed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was for the animation right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was so the ToastManager could close the toasts from the parent.

src/components/Toaster/ToastManager/ToastManager.tsx Outdated Show resolved Hide resolved
src/components/Toaster/ToastManager/ToastManager.tsx Outdated Show resolved Hide resolved
message: string,
{ isClosable = true, duration = 5, id, intent }: ToastSettings,
): ToastInstance => {
const uniqueId = idCounter;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think keeping state of the latest id can be avoided when using a Date() timestamp with ms as id

src/components/Toaster/Toaster.test.tsx Show resolved Hide resolved
@bramvanhoutte bramvanhoutte merged commit 7787105 into master Nov 18, 2020
@bramvanhoutte bramvanhoutte deleted the toaster-component branch November 18, 2020 13:23
@github-actions
Copy link

🎉 This PR is included in version 1.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement notification component
2 participants