[FEATURE] Toast Error on playground page
Description
Solution
update: Please see comment https://github.com/EddieHubCommunity/LinkFree/issues/6681#issuecomment-1541427897
Problem
On the playground, if we somehow forget to add github username or add invalid json, it shows an error on the top. But it can be confusing for some users at first if they scroll all the way down to the bottom, meaning it doesn't indicate any error.
Here is a video to understand:
https://user-images.githubusercontent.com/77217706/236687975-e54e343b-d676-49f4-840a-3d53a3a507b7.mp4
The Feature
If user forget to add something or anything that causes error. Put a toast rather than showing the button on top.
Screenshots
No response
Additional information
No response
To reduce notifications, issues are locked until they are https://github.com/EddieHubCommunity/LinkFree/labels/%F0%9F%8F%81%20status%3A%20ready%20for%20dev and to be assigned. You can learn more in our contributing guide https://github.com/EddieHubCommunity/LinkFree/blob/main/CONTRIBUTING.md
Hello @NiazMorshed2007 confirmed that this happens and may be a confusing UX. I would suggest perhaps an auto scroll to top on error as the solution wdyt?
Another option, is we could use the toast component from Tailwind's paid components, we bought it for the project, so it is available to us...
https://tailwindui.com/components/marketing/elements/banners#component-dd9098382f8067c3d90b99dbad8351a3
import { XMarkIcon } from '@heroicons/react/20/solid'
export default function Example() {
return (
<>
{/*
Make sure you add some bottom padding to pages that include a sticky banner like this to prevent
your content from being obscured when the user scrolls to the bottom of the page.
*/}
<div className="pointer-events-none fixed inset-x-0 bottom-0 sm:flex sm:justify-center sm:px-6 sm:pb-5 lg:px-8">
<div className="pointer-events-auto flex items-center justify-between gap-x-6 bg-gray-900 px-6 py-2.5 sm:rounded-xl sm:py-3 sm:pl-4 sm:pr-3.5">
<p className="text-sm leading-6 text-white">
<a href="#">
<strong className="font-semibold">GeneriCon 2023</strong>
<svg viewBox="0 0 2 2" className="mx-2 inline h-0.5 w-0.5 fill-current" aria-hidden="true">
<circle cx={1} cy={1} r={1} />
</svg>
Join us in Denver from June 7 – 9 to see what’s coming next <span aria-hidden="true">→</span>
</a>
</p>
<button type="button" className="-m-1.5 flex-none p-1.5">
<span className="sr-only">Dismiss</span>
<XMarkIcon className="h-5 w-5 text-white" aria-hidden="true" />
</button>
</div>
</div>
</>
)
}
There are notifications also as part of Tailwind components too https://tailwindui.com/components/application-ui/overlays/notifications
We use the notifications from Tailwind on the icons page, we should move that to a reusable component https://linkfree.io/icons
Hello @NiazMorshed2007 confirmed that this happens
We can scroll user to top in this case as @amandamartin-dev said, cause we already showing the error on the top so, why it's not ideal to show toast and that error at the same time,
Alternatively, we can remove the top error and show all error in toast.
What do you think?
Yes I think remove the current alert component usage on this page should be removed and then move the notification on the icons page to a new component so we can reuse it here (and in other places)
Hello, I would like to take this up.
@NiazMorshed2007 you have done quite a bit of work on this already - do you want this assigned to you? If not, I will assign to @AJcodes42
@SaraJaoude I've already a task assigned to me. Assign this to @AJcodes42
Another option, is we could use the
toastcomponent from Tailwind's paid components, we bought it for the project, so it is available to us...https://tailwindui.com/components/marketing/elements/banners#component-dd9098382f8067c3d90b99dbad8351a3
import { XMarkIcon } from '@heroicons/react/20/solid' export default function Example() { return ( <> {/* Make sure you add some bottom padding to pages that include a sticky banner like this to prevent your content from being obscured when the user scrolls to the bottom of the page. */} <div className="pointer-events-none fixed inset-x-0 bottom-0 sm:flex sm:justify-center sm:px-6 sm:pb-5 lg:px-8"> <div className="pointer-events-auto flex items-center justify-between gap-x-6 bg-gray-900 px-6 py-2.5 sm:rounded-xl sm:py-3 sm:pl-4 sm:pr-3.5"> <p className="text-sm leading-6 text-white"> <a href="#"> <strong className="font-semibold">GeneriCon 2023</strong> <svg viewBox="0 0 2 2" className="mx-2 inline h-0.5 w-0.5 fill-current" aria-hidden="true"> <circle cx={1} cy={1} r={1} /> </svg> Join us in Denver from June 7 – 9 to see what’s coming next <span aria-hidden="true">→</span> </a> </p> <button type="button" className="-m-1.5 flex-none p-1.5"> <span className="sr-only">Dismiss</span> <XMarkIcon className="h-5 w-5 text-white" aria-hidden="true" /> </button> </div> </div> </> ) }
I think adding a floating toast is a great idea. Another problem with the current alert is that it shifts the ui whenever an error or success happens.
I recently learned about something called CLS (cumulative layout shift). which is a performance or UX metrics which basically says, it is bad practise for the ui element to shift while using the page. So a floating toast would solve this problem
Hey, I am will like to work on this one.
Sorry @Akhilbisht798 it was already requested
@AJcodes42 I will assign it to you, please see my solution here https://github.com/EddieHubCommunity/LinkFree/issues/6681#issuecomment-1541427897
Thanks working on this
@eddiejaoude, Looked into the code and found that in icons page also the same alert component is being used as in playground page. There is no notifications component present as mentioned in https://github.com/EddieHubCommunity/LinkFree/issues/6681#issuecomment-1541427897 Do I have to create a new notification component which is reusable and use it here.
The notifications (toast) is in the Icon page, but deeper in the components/IconCard.js component. Yes the existing notifications code should be moved to its own reusable component and used on both pages
Raised pull request for this feature. Let me know if any changes are required.
https://tailwindui.com/components/marketing/elements/banners#component-dd9098382f8067c3d90b99dbad8351a3