BioDrop icon indicating copy to clipboard operation
BioDrop copied to clipboard

[FEATURE] Toast Error on playground page

Open NiazMorshed2007 opened this issue 3 years ago • 17 comments

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

NiazMorshed2007 avatar May 07 '23 15:05 NiazMorshed2007

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

github-actions[bot] avatar May 07 '23 15:05 github-actions[bot]

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?

amandamartin-dev avatar May 09 '23 19:05 amandamartin-dev

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...

Screenshot 2023-05-10 at 11 49 50

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&nbsp;<span aria-hidden="true">&rarr;</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>
    </>
  )
}

eddiejaoude avatar May 10 '23 04:05 eddiejaoude

There are notifications also as part of Tailwind components too https://tailwindui.com/components/application-ui/overlays/notifications

eddiejaoude avatar May 10 '23 06:05 eddiejaoude

We use the notifications from Tailwind on the icons page, we should move that to a reusable component https://linkfree.io/icons

eddiejaoude avatar May 10 '23 06:05 eddiejaoude

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?

NiazMorshed2007 avatar May 10 '23 06:05 NiazMorshed2007

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)

eddiejaoude avatar May 10 '23 06:05 eddiejaoude

Hello, I would like to take this up.

AJcodes42 avatar May 10 '23 12:05 AJcodes42

@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 avatar May 10 '23 12:05 SaraJaoude

@SaraJaoude I've already a task assigned to me. Assign this to @AJcodes42

NiazMorshed2007 avatar May 11 '23 02:05 NiazMorshed2007

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...

Screenshot 2023-05-10 at 11 49 50 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&nbsp;<span aria-hidden="true">&rarr;</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

ChinmayMhatre avatar May 11 '23 06:05 ChinmayMhatre

Hey, I am will like to work on this one.

Akhilbisht798 avatar May 11 '23 18:05 Akhilbisht798

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

eddiejaoude avatar May 11 '23 18:05 eddiejaoude

Thanks working on this

AJcodes42 avatar May 14 '23 06:05 AJcodes42

@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.

AJcodes42 avatar May 14 '23 12:05 AJcodes42

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

eddiejaoude avatar May 16 '23 06:05 eddiejaoude

Raised pull request for this feature. Let me know if any changes are required.

AJcodes42 avatar May 17 '23 11:05 AJcodes42