-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
feat(UI-1394): enhance toast component with customizable position, offset, and styles #1119
Conversation
When I opened it for the first time, I got this error: Also, when we run it manually from the drawer, it should be on top as well: |
|
For the improvement toast component, I created a new Linear Ticket https://linear.app/autokitteh/issue/UI-1462/improve-toast-component |
47ad843
to
4fa38f0
Compare
src/components/molecules/toast.tsx
Outdated
let topPosition = 15; | ||
let bottomPosition = 15; |
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.
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 }
};
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.
but it's let
not motion
. Maybe u mean something else?
src/components/molecules/toast.tsx
Outdated
|
||
const titleStyle = (toastType: ToasterTypes) => | ||
cn("w-full font-semibold", { | ||
"text-error": toastType === "error", | ||
"text-green-800": toastType === "success", | ||
}); | ||
|
||
const positionStyle = (position: string, offset: number) => { |
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.
I think we should extract ToastPosition to type or interface:
type ToastPosition = 'top-right' | 'bottom-right' | 'default';
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.
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"> |
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.
if the root html tag of this component is button
we can't have another Button
in the button
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.
yes, refactored
Bug with clicking a few times... it redirects to Screen.Recording.2025-04-03.at.17.39.00.movfixed |
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. |
a472a37
to
3939571
Compare
I didn't quite understand your point |
</> | ||
<button | ||
aria-label={t("executionSucceed")} | ||
className="px-4 py-3 cursor-pointer" |
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.
@J1za, please note that and the rest of the eslint tailwind classnames warnings
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.
fixed
className="px-4 py-3 cursor-pointer" | ||
onClick={() => navigate(`/projects/${projectId}/sessions/${sessionId}`)} | ||
> | ||
<div className="flex flex-col"> |
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.
I think you can place this flex flex-col
inside the button element above.
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.
removed div, because unnecessary
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. |
Please rebase. |
a4ee05e
to
3f03027
Compare
![]() Looks good, but I want to add a custom offset. Also, when there's an error, the toasts stack on top of each other. |
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)