Skip to content

Update Toast component style to match new UI - #15

Merged
dralan71 merged 5 commits into
mainfrom
style-toasts-ui
Feb 11, 2026
Merged

dralan71 merged 5 commits into
mainfrom
style-toasts-ui

Conversation

@dralan71

@dralan71 dralan71 commented Feb 9, 2026 •

Copy link
Copy Markdown
Owner

This pull request refactors the toast notification system to use a custom React component for all toast messages, enabling consistent styling and richer visuals. It replaces the previous style-based configuration with a new ToastContent component and updates all toast calls to use toast.custom. Supporting CSS and tests are also updated to match the new approach.

Toast system refactor and visual improvements:

  • Introduced a new ToastContent React component in src/Toast.tsx that renders toast messages with a progress ring and type-colored icons, replacing the previous style-based toast configuration.
  • Added a dedicated CSS file src/Toast.css for styling the custom toast component, including progress ring animation and color themes for success and error types.
  • Updated src/ToastContext.tsx so all toast notifications now use toast.custom with the new ToastContent component, and removed the old toastConfig styling logic. All toast functions are adapted to the new system.

Testing updates:

  • Modified mocks in src/test/App.test.tsx and src/test/ToastContext.test.tsx to include toast.custom for compatibility with the new toast system. [1] [2]
  • Updated tests in src/test/ToastContext.test.tsx to assert that toast.custom is called instead of toast.success, reflecting the refactored toast notification logic.

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • Environment: Chrome
  • Test steps / commands: Tried out success and error toasts.

Checklist

  • My code follows the project’s style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the documentation as needed

Summary by CodeRabbit

  • New Features

    • Added a unified toast notification UI with animated progress ring, type-colored icons, and consistent message layout.
  • Bug Fixes / Improvements

    • Centralized toast rendering and styling with a single standardized duration for consistent appearance and behavior.
  • Tests

    • Updated tests and mocks to validate the new custom toast rendering flow and duration.

- Introduced Toast.css for styling the toast notifications.
- Created Toast.tsx to define the ToastContent and ToastRing components.
- Updated ToastContext.tsx to utilize the new Toast component for custom toast notifications.
- Modified tests to verify the use of custom toast functionality.
@coderabbitai

coderabbitai Bot commented Feb 9, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Adds a Toast UI component with animated progress ring and CSS; centralizes toast rendering via showToast using toast.custom in ToastContext; replaces per-call styles with a unified toastConfig; exports ToastType and TOAST_DURATION_MS; updates tests and mocks to use toast.custom.

Changes

Cohort / File(s) Summary
Toast component & styles
src/Toast.tsx, src/Toast.css
Adds ToastContent and internal ToastRing (SVG) plus CSS: .toast, .toast__ring, .toast__ring-track, .toast__ring-fill with toastRingShrink keyframes (2.5s) and success/error color variants; layout, icon, and message sizing.
Toast system & context
src/ToastContext.tsx, src/App.tsx
Introduces showToast using toast.custom, exports ToastType and TOAST_DURATION_MS = 2500, centralizes toastConfig (transparent container), standardizes icon coloring and replaces per-call inline toast styles.
Tests & mocks
src/test/App.test.tsx, src/test/ToastContext.test.tsx
Adds toast.custom mock and updates tests to expect toast.custom called with a renderer function and duration: 2500; tests invoke the renderer to assert rendered message and toast--success/toast--error classes.

Sequence Diagram(s)

sequenceDiagram
  participant App as App (caller)
  participant TC as ToastContext
  participant RHT as react-hot-toast
  participant UI as ToastContent
  App->>TC: showToast(type, message, icon)
  TC->>RHT: toast.custom(renderFn, { duration: TOAST_DURATION_MS, ...toastConfig })
  RHT->>UI: invoke renderFn() -> JSX (ToastContent)
  UI-->>RHT: returned DOM (SVG ring, icon, message)
  RHT-->>App: displays custom toast
  rect rgba(0,128,0,0.5)
    Note right of UI: toast ring animation runs (2.5s)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • 4 add toast notifications #10 — Similar refactor of toast usage to toast.custom and centralized toast rendering (touches ToastContext, App, and tests).

Poem

A hop, a ring, I spun with glee 🥕
I painted colors for all to see.
Success in green, error in red,
My tiny toast dances near your head.
Hooray — a hopped-up toast, well-bred! 🐇✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Update Toast component style to match new UI' accurately summarizes the main objective of the pull request, which refactors the toast notification system with new styling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch style-toasts-ui

No actionable comments were generated in the recent review. 🎉

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dralan71
dralan71 requested a review from Copilot February 9, 2026 23:43
@dralan71 dralan71 changed the title Update Toast component with customizable success and error notifications Update Toast component style to match new UI Feb 9, 2026
@dralan71 dralan71 self-assigned this Feb 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/Toast.tsx`:
- Line 4: Remove the duplicate type declaration by keeping the ToastType
definition in Toast.tsx and deleting the separate declaration in
ToastContext.tsx; then update ToastContext.tsx to import ToastType from
Toast.tsx and re-export it (so consumers import from the context file while the
canonical type lives in Toast.tsx). Ensure you only have one exported ToastType
symbol (the one in Toast.tsx) and adjust any imports accordingly.
🧹 Nitpick comments (2)
src/Toast.css (1)

1-58: Clean BEM-structured CSS with well-matched animation timing.

The ring circumference math is correct (2π × 8 ≈ 50.27), and the 2.5s animation duration aligns with the duration: 2500 in the JS toast config.

One minor note: the success color #5a9a6e is hardcoded here (Lines 38, 52) and also in ToastContext.tsx as SUCCESS_ICON_COLOR. Consider using a CSS custom property (e.g., --toast-success) to keep the color in one place.

src/test/ToastContext.test.tsx (1)

33-54: Consider adding a test for customToast.error to cover both toast types.

Currently only "success" paths are tested (addItem, addBaggage, removeItem). Adding a test for customToast.error would verify the "error" type flows through showToast correctly and exercises both branches of ToastType.

Comment thread src/Toast.tsx Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the app’s toast notification system to use a custom toast UI (with a progress ring + styling) instead of the default react-hot-toast success/error toasts, and adjusts tests accordingly.

Changes:

  • Added a new Toast component (ToastContent) and stylesheet to render custom success/error notifications.
  • Updated ToastContext to route all toast helpers through toast.custom(...).
  • Updated tests/mocks to include toast.custom and to validate the new call path.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/ToastContext.tsx Switches toast helpers from toast.success/error to toast.custom rendering ToastContent.
src/Toast.tsx Introduces the custom toast UI (ring + icon + message).
src/Toast.css Adds styles/animation for the custom toast appearance and progress ring.
src/test/ToastContext.test.tsx Updates tests to expect toast.custom usage.
src/test/App.test.tsx Updates react-hot-toast mock to include toast.custom.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ToastContext.tsx Resolved
Comment thread src/ToastContext.tsx Resolved
Comment thread src/Toast.tsx Resolved
Comment thread src/Toast.css Resolved
Comment thread src/test/ToastContext.test.tsx Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/ToastContext.tsx`:
- Around line 43-49: Replace the inline color string in the error toast with the
shared constant: in the error method that calls showToast and renders <PiXCircle
... />, use the TRASH_COLOR constant instead of the hard-coded "var(--accent)";
update the JSX in the error function (the PiXCircle style prop) to reference
TRASH_COLOR so the icon color is sourced from the single constant (or swap to a
new ERROR_ICON_COLOR constant if you want a separate token).
🧹 Nitpick comments (2)
src/ToastContext.tsx (2)

8-9: Inconsistent theming approach between constants.

TRASH_COLOR references a CSS custom property (var(--accent)), making it theme-aware, while SUCCESS_ICON_COLOR is a hardcoded hex #5a9a6e. If the app supports theming or dark mode, the success color won't adapt. Consider defining a CSS variable (e.g. --success-icon-color) for consistency.


11-16: toast.custom render callback ignores the t argument — exit animations won't work.

toast.custom passes a Toast object to the render function, where t.visible toggles to false before removal. By discarding it, there is no way to trigger a CSS exit transition — toasts will vanish abruptly when the duration expires. If you want smooth enter/exit behaviour, thread t.visible through to ToastContent (or at minimum to a wrapper class/style).

Suggested approach
-function showToast(type: ToastType, message: string, icon: React.ReactElement) {
-  return toast.custom(
-    () => <ToastContent type={type} message={message} icon={icon} />,
-    { duration: 2500 }
-  );
+function showToast(type: ToastType, message: string, icon: React.ReactElement) {
+  return toast.custom(
+    (t) => (
+      <div style={{ opacity: t.visible ? 1 : 0, transition: "opacity 0.3s ease" }}>
+        <ToastContent type={type} message={message} icon={icon} />
+      </div>
+    ),
+    { duration: 2500 }
+  );
 }

Alternatively, pass visible as a prop to ToastContent and handle the transition inside the component.

Comment thread src/ToastContext.tsx Resolved
- Introduced a constant for toast duration in ToastContext.tsx.
- Updated App.tsx to use the new TOAST_DURATION_MS constant for toast duration.
- Modified Toast.tsx to accept a durationMs prop and apply it via CSS variables for better customization.
- Enhanced accessibility by adding aria-hidden and focusable attributes to the ToastRing SVG component.
- Adjusted Toast.css to utilize the new CSS variable for animation duration.
@dralan71

Copy link
Copy Markdown
Owner Author

@coderabbitai help

@coderabbitai

coderabbitai Bot commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@dralan71

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Feb 10, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/App.tsx`:
- Around line 302-308: The toastConfig.style object is being spread directly
into toastOptions instead of nested under the style key, so move
...toastConfig.style into toastOptions.style (i.e., set toastOptions={{
duration: TOAST_DURATION_MS, style: { ...toastConfig.style, ...(other style
overrides) } }}). Update the Toaster usage (component name Toaster and prop
toastOptions) to ensure wrapper styles from toastConfig.style are applied
correctly while preserving duration via TOAST_DURATION_MS.
🧹 Nitpick comments (3)
src/ToastContext.tsx (1)

5-6: Dual export of ToastType creates an ambiguous import path.

ToastType is already exported from src/Toast.tsx (line 3) and re-exported here on line 6. Consumers can import from either module, which may cause confusion over the canonical source. Consider picking one authoritative module for the export and importing from there consistently.

src/test/ToastContext.test.tsx (2)

38-43: Hard-coded 2500 will silently drift if TOAST_DURATION_MS changes.

Import and reference the constant to keep the assertion in sync:

Proposed fix
+import { TOAST_DURATION_MS } from '../ToastContext';
 // ...
-      expect.objectContaining({ duration: 2500 })
+      expect.objectContaining({ duration: TOAST_DURATION_MS })

Apply the same change to the other three expect.objectContaining({ duration: 2500 }) assertions (lines 55, 68, 81).


33-88: Consider splitting the monolithic test into individual cases per toast type.

A single test exercising four distinct toast paths makes failures harder to diagnose — a failure on the third assertion obscures whether the first two still pass. Extracting each toast call (addItem, addBaggage, removeItem, error) into its own it(...) block improves isolation and readability.

Comment thread src/App.tsx Resolved
- Updated the toastOptions in App.tsx to spread the style property correctly, ensuring proper application of toast styles.
@dralan71

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Feb 11, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@dralan71
dralan71 merged commit 56cbce3 into main Feb 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants