Skip to content

fix(docs): toast docs to have performant placement buttons#4857

Merged
jrgarciadev merged 1 commit into
mainfrom
macci001/fixing-toast-docs
Feb 19, 2025
Merged

fix(docs): toast docs to have performant placement buttons#4857
jrgarciadev merged 1 commit into
mainfrom
macci001/fixing-toast-docs

Conversation

@macci001
Copy link
Copy Markdown
Contributor

@macci001 macci001 commented Feb 19, 2025

Closes #

📝 Description

⛳️ Current behavior (updates)

🚀 New behavior

💣 Is this a breaking change (Yes/No):

📝 Additional Information

Summary by CodeRabbit

  • New Features

    • Introduced interactive control for toast notifications, allowing users to dynamically adjust their on-screen placement.
  • Documentation

    • Updated guidance on toast notification configuration for improved clarity on available placement options.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 19, 2025

⚠️ No Changeset found

Latest commit: db270e8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
heroui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2025 5:37am
heroui-sb ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2025 5:37am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 19, 2025

Walkthrough

The changes adjust how toast notifications are handled and documented in the application. In one location, the ToastProvider component was removed from the main Providers function, while another file introduces a dynamic mechanism that allows the placement of toast notifications to be updated via state changes triggered by user interaction. The associated documentation was also updated to clarify the type signature for available toast placement options.

Changes

Files Change Summary
apps/docs/app/providers.tsx
apps/docs/content/components/toast/placement.raw.jsx
In the providers file, the ToastProvider was removed from the Providers function. In the placement component, a new state variable (placement) was introduced to dynamically control toast positioning, with button interactions updating this state.
apps/docs/content/docs/components/toast.mdx Updated the type signature for the toast placement prop by replacing hyphen-separated options with a pipe-separated format for improved clarity in the documentation.

Sequence Diagram(s)

sequenceDiagram
    participant User as User
    participant Button as Button Component
    participant App as App Component
    participant Toast as ToastProvider

    User->>Button: Click button with desired placement
    Button->>App: Trigger onClick event with new placement value
    App->>App: Update placement state using setPlacement
    App->>Toast: Render ToastProvider with updated placement
    Toast-->>User: Display toast notification at new position
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

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.
    • Generate unit testing code for this file.
    • 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. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/docs/content/components/toast/placement.raw.jsx (1)

9-9: Consider extracting the offset logic to a constant or utility function.

The inline calculation of toastOffset could be made more maintainable by extracting it.

-      <ToastProvider placement={placement} toastOffset={placement.includes("top") ? 60 : 0} />
+      const getToastOffset = (placement) => placement.includes("top") ? 60 : 0;
+      <ToastProvider placement={placement} toastOffset={getToastOffset(placement)} />
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 943dfdb and db270e8.

📒 Files selected for processing (3)
  • apps/docs/app/providers.tsx (1 hunks)
  • apps/docs/content/components/toast/placement.raw.jsx (2 hunks)
  • apps/docs/content/docs/components/toast.mdx (1 hunks)
🔇 Additional comments (4)
apps/docs/content/components/toast/placement.raw.jsx (2)

5-5: LGTM! Good use of React hooks for state management.

The useState hook is appropriately used to manage the toast placement state with a sensible default value.


10-33: LGTM! Well-structured placement options UI.

The implementation provides a clear and interactive way to demonstrate different toast placements.

apps/docs/app/providers.tsx (1)

46-48:

Details

✅ Verification successful

Verify the impact of removing ToastProvider from global providers.

The removal of ToastProvider from the global providers suggests a shift to more localized toast management. Ensure that:

  1. All components that need toast functionality have access to a ToastProvider
  2. There's no unintended breaking change for existing toast implementations

🏁 Script executed:

#!/bin/bash
# Search for direct toast usage in components
rg "addToast\(" --type jsx --type tsx

# Search for ToastProvider usage
rg "ToastProvider" --type jsx --type tsx

Length of output: 136


ToastProvider Removal Impact Verification

The removal of the global ToastProvider indicates a move toward localized toast management. However, the initial verification script failed due to incorrect file type flags. Please re-run the verification using the updated commands below to confirm that no components are unexpectedly relying on global toast management:

  • Ensure that no components are directly calling addToast( without a locally provided ToastProvider.
  • Confirm that references to ToastProvider are not present where they are expected to be removed.

Once these commands are executed and the output is verified, ensure that:

  • All components that require toast functionality either receive it through a localized provider or have been updated accordingly.
  • There are no unintended breaking changes in toast implementations.

🏁 Script executed:

#!/bin/bash
# Search for direct toast usage in components (all .jsx and .tsx files)
rg "addToast\(" --glob "*.jsx" --glob "*.tsx"

# Search for ToastProvider usage in .jsx and .tsx files
rg "ToastProvider" --glob "*.jsx" --glob "*.tsx"

Length of output: 4181


Global ToastProvider Removal Confirmed

The repository inspection indicates that toast functionality is now managed locally. Specifically:

  • References to addToast( are found only within localized contexts—primarily in the toast stories, tests, and documentation files.
  • Usage of ToastProvider remains in relevant parts (e.g. in apps/docs/content/components/toast/placement.raw.jsx, packages/components/toast/stories/toast.stories.tsx, and tests), ensuring that components needing toast functionality are provided with the context they require.

The removal of ToastProvider from the global providers in apps/docs/app/providers.tsx is in line with this localized approach. Please verify that all components depending on toasts are correctly wrapped with a local ToastProvider to maintain consistent behavior.

apps/docs/content/docs/components/toast.mdx (1)

306-306: LGTM! Improved type declaration format.

The updated type declaration format using pipe (|) separators improves readability while maintaining the same functionality.

@wingkwong wingkwong changed the title Fix: toast docs to have performant placement buttons fix(docs): toast docs to have performant placement buttons Feb 19, 2025
@wingkwong wingkwong added the 📋 Scope : Docs Related to the documentation label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📋 Scope : Docs Related to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants