Skip to content

feat(UI-1394): enhance toast component with customizable position, offset, and styles #1119

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

J1za
Copy link
Collaborator

@J1za J1za commented Mar 26, 2025

Description

It can be similar to the toast we have today - it should be simple, easily clickable to allow the user to open the session he just ran.

Linear Ticket

https://linear.app/autokitteh/issue/UI-1394/add-toast-with-the-session-link-under-the-run-button-after-manual-run

What type of PR is this? (check all applicable)

  • 💡 (feat) - A new feature (non-breaking change which adds functionality)
  • 🔄 (refactor) - Code Refactoring - A code change that neither fixes a bug nor adds a feature
  • 🐞 (fix) - Bug Fix (non-breaking change which fixes an issue)
  • 🏎 (perf) - Optimization
  • 📄 (docs) - Documentation - Documentation only changes
  • 📄 (test) - Tests - Adding missing tests or correcting existing tests
  • 🎨 (style) - Styles - Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
  • ⚙️ (ci) - Continuous Integrations - Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
  • ☑️ (chore) - Chores - Other changes that don't modify src or test files
  • ↩️ (revert) - Reverts - Reverts a previous commit(s).

@RonenMars
Copy link
Contributor

When I opened it for the first time, I got this error:
Screenshot 2025-03-26 at 22 48 00

Also, when we run it manually from the drawer, it should be on top as well:
https://github.com/user-attachments/assets/1d896d9b-14ab-4fbf-9888-9aa8039edda6

@RonenMars
Copy link
Contributor

  1. We need the toast to close after we click on it, otherwise it's annoying.

  2. Still not checked the code, hope I'll be able to get to it tomorrow.

@J1za
Copy link
Collaborator Author

J1za commented Apr 2, 2025

For the improvement toast component, I created a new Linear Ticket https://linear.app/autokitteh/issue/UI-1462/improve-toast-component

@J1za J1za force-pushed the vitaly/feat/change-toast-component-and-show-under-run-button branch from 47ad843 to 4fa38f0 Compare April 2, 2025 15:10
Comment on lines 24 to 25
let topPosition = 15;
let bottomPosition = 15;
Copy link
Contributor

Choose a reason for hiding this comment

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

We can extract this animation logic to a separate constant:

const TOAST_ANIMATION = {
  variants: {
    hidden: { opacity: 0, y: 50 },
    visible: { opacity: 1, y: 0 },
  },
  transition: { duration: 0.3 }
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

but it's let not motion. Maybe u mean something else?


const titleStyle = (toastType: ToasterTypes) =>
cn("w-full font-semibold", {
"text-error": toastType === "error",
"text-green-800": toastType === "success",
});

const positionStyle = (position: string, offset: number) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should extract ToastPosition to type or interface:

type ToastPosition = 'top-right' | 'bottom-right' | 'default';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added type

>
<div className="flex flex-col">
<span className="font-semibold text-green-800">{t("executionSucceed")}</span>
<Button className="mt-0.5 flex items-center gap-1 p-0 text-green-800 underline">
Copy link
Contributor

Choose a reason for hiding this comment

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

if the root html tag of this component is button we can't have another Button in the button

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, refactored

@RonenMars
Copy link
Contributor

RonenMars commented Apr 3, 2025

Bug with clicking a few times... it redirects to undefined deployment:

Screen.Recording.2025-04-03.at.17.39.00.mov

fixed

@RonenMars
Copy link
Contributor

Also - improvement suggestion: - You can add, for example, last 4 characters of the newSessionId - and then you will know which session each toast is. - but it's optional and not critical.

@J1za J1za force-pushed the vitaly/feat/change-toast-component-and-show-under-run-button branch from a472a37 to 3939571 Compare April 4, 2025 19:29
@J1za
Copy link
Collaborator Author

J1za commented Apr 4, 2025

Also - improvement suggestion: - You can add, for example, last 4 characters of the newSessionId - and then you will know which session each toast is. - but it's optional and not critical.

I didn't quite understand your point

</>
<button
aria-label={t("executionSucceed")}
className="px-4 py-3 cursor-pointer"
Copy link
Contributor

@RonenMars RonenMars Apr 21, 2025

Choose a reason for hiding this comment

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

@J1za, please note that and the rest of the eslint tailwind classnames warnings

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@RonenMars
Copy link
Contributor

Also - improvement suggestion: - You can add, for example, last 4 characters of the newSessionId - and then you will know which session each toast is. - but it's optional and not critical.

I didn't quite understand your point

I thought, maybe we can display the toast with this text - this way you'll know what is the ID of the session you click on:
image

But I'm not sure that it's a good or relevant feature. You know what, never mind, it will create more mess than benefit.

className="px-4 py-3 cursor-pointer"
onClick={() => navigate(`/projects/${projectId}/sessions/${sessionId}`)}
>
<div className="flex flex-col">
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can place this flex flex-col inside the button element above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed div, because unnecessary

@RonenMars
Copy link
Contributor

I played with it a little bit, and in the following code, I managed to make the toasts be one under (or above) each other when we close some of them.
For example, we have 5 toasts, we close the third, then currently, we will have a gap between the second and the fourth.
Take a look and tell me what you think:
toast.tsx.zip

@RonenMars
Copy link
Contributor

Please rebase.

@J1za J1za force-pushed the vitaly/feat/change-toast-component-and-show-under-run-button branch from a4ee05e to 3f03027 Compare April 21, 2025 09:19
@J1za
Copy link
Collaborator Author

J1za commented Apr 21, 2025

I played with it a little bit, and in the following code, I managed to make the toasts be one under (or above) each other when we close some of them. For example, we have 5 toasts, we close the third, then currently, we will have a gap between the second and the fourth. Take a look and tell me what you think: toast.tsx.zip

image

Looks good, but I want to add a custom offset. Also, when there's an error, the toasts stack on top of each other.

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

Successfully merging this pull request may close these issues.

2 participants