Skip to content

refactor(docs): refactoring the toast docs to have capital button names#4883

Merged
jrgarciadev merged 1 commit into
mainfrom
macci001/fix-toast-docs
Feb 20, 2025
Merged

refactor(docs): refactoring the toast docs to have capital button names#4883
jrgarciadev merged 1 commit into
mainfrom
macci001/fix-toast-docs

Conversation

@macci001
Copy link
Copy Markdown
Contributor

@macci001 macci001 commented Feb 20, 2025

Closes #

PR refactors the toast docs to have capital names in the Button copy.

📝 Description

⛳️ Current behavior (updates)

🚀 New behavior

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

📝 Additional Information

Summary by CodeRabbit

  • Style

    • Improved toast UI labels for color, placement, radius, and variant options to enhance clarity and consistency.
  • Documentation

    • Updated the default documentation value for the maximum number of visible toast notifications from 5 to 3.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 20, 2025

⚠️ No Changeset found

Latest commit: a4f5985

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 20, 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 20, 2025 11:03am
heroui-sb ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 20, 2025 11:03am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 20, 2025

Walkthrough

This update refactors the toast notification components by modifying the way UI options are represented. The changes convert displayed text for colors, placements, radii, and variants to a more user-friendly format (title case) while ensuring that the underlying logic continues to use lowercase values. In addition, the documentation for the ToastProvider has been updated to change the default maximum number of visible toasts from 5 to 3.

Changes

File Path(s) Summary of Changes
apps/docs/.../toast/color.raw.jsx Modified the color array to use title case for display. Converted the color prop to lowercase using toLowerCase() when passed to the Button and addToast functions.
apps/docs/.../toast/placement.raw.jsx, apps/docs/.../toast/radius.raw.jsx Changed simple string arrays to arrays of tuples containing a display label and corresponding value. Updated the button key and label assignments and ensured that the correct value (e.g., placement or radius) is used in state and addToast calls.
apps/docs/.../toast/variants.raw.jsx Updated variant arrays to capitalize the display text. The variant passed to addToast is now converted to lowercase using toLowerCase().
apps/docs/.../docs/components/toast.mdx Updated the default value of maxVisibleToasts in the ToastProvider Props documentation from "5" to "3".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant Button
    participant ToastManager

    User->>Button: Clicks a toast option button
    Button->>App: Triggers onPress with selected tuple value
    App->>App: Converts display value to lowercase (if needed)
    App->>ToastManager: Calls addToast with the processed value
    ToastManager-->>User: Displays the toast notification
Loading

Suggested labels

📋 Scope : Docs

Suggested reviewers

  • wingkwong
  • jrgarciadev
✨ 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: 1

🔭 Outside diff range comments (1)
apps/docs/content/components/toast/variants.raw.jsx (1)

13-14: 🛠️ Refactor suggestion

Remove @ts-ignore by adding proper types.

The presence of @ts-ignore suggests potential type issues that should be addressed properly.

Consider adding proper types:

+type Variant = "solid" | "bordered" | "faded";
+const TOAST_VARIANTS: Array<[string, Variant]> = [
+  ["Solid", "solid"],
+  ["Bordered", "bordered"],
+  ["Flat", "faded"],
+];

 export default function App() {
🧹 Nitpick comments (3)
apps/docs/content/components/toast/color.raw.jsx (1)

6-20: LGTM! Consider extracting color mapping to a constant.

The changes improve readability while maintaining functionality. The color values are properly converted to lowercase when used in props and toast configuration.

Consider extracting the color mapping to a constant to improve maintainability:

+const TOAST_COLORS = [
+  "Default",
+  "Primary",
+  "Secondary",
+  "Success",
+  "Warning",
+  "Danger"
+] as const;

 export default function App() {
   return (
     <div className="flex flex-wrap gap-2">
-      {["Default", "Primary", "Secondary", "Success", "Warning", "Danger"].map((color) => (
+      {TOAST_COLORS.map((color) => (
apps/docs/content/components/toast/radius.raw.jsx (1)

6-26: Consider using destructuring for better readability.

The changes improve clarity by separating display text from values. However, array index access could be made more readable.

Consider using destructuring for better readability:

-      {[
-        ["None", "none"],
-        ["Small", "sm"],
-        ["Medium", "md"],
-        ["Large", "lg"],
-        ["Full", "full"],
-      ].map((radius) => (
+      {[
+        ["None", "none"],
+        ["Small", "sm"],
+        ["Medium", "md"],
+        ["Large", "lg"],
+        ["Full", "full"],
+      ].map(([label, value]) => (
         <Button
-          key={radius[1]}
-          radius={radius[1]}
+          key={value}
+          radius={value}
           variant={"flat"}
           onPress={() =>
             addToast({
               title: "Toast title",
               description: "Toast displayed successfully",
-              radius: radius[1],
+              radius: value,
             })
           }
         >
-          {radius[0]}
+          {label}
         </Button>
apps/docs/content/components/toast/placement.raw.jsx (1)

11-31: Consider extracting positions and using destructuring.

The changes improve readability, but could benefit from constant extraction and destructuring.

Consider these improvements:

+const TOAST_POSITIONS = [
+  ["Top Left", "top-left"],
+  ["Top Center", "top-center"],
+  ["Top Right", "top-right"],
+  ["Bottom Left", "bottom-left"],
+  ["Bottom Center", "bottom-center"],
+  ["Bottom Right", "bottom-right"],
+] as const;

 export default function App() {
   return (
     <div className="flex flex-wrap gap-2">
-        {[
-          ["Top Left", "top-left"],
-          ["Top Center", "top-center"],
-          ["Top Right", "top-right"],
-          ["Bottom Left", "bottom-left"],
-          ["Bottom Center", "bottom-center"],
-          ["Bottom Right", "bottom-right"],
-        ].map((position) => (
+        {TOAST_POSITIONS.map(([label, value]) => (
           <Button
-            key={position[1]}
+            key={value}
             variant={"flat"}
             onPress={() => {
-              setPlacement(position[1]);
+              setPlacement(value);
               addToast({
                 title: "Toast title",
                 description: "Toast displayed successfully",
               });
             }}
           >
-            {position[0]}
+            {label}
           </Button>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 99d1674 and a4f5985.

📒 Files selected for processing (5)
  • apps/docs/content/components/toast/color.raw.jsx (1 hunks)
  • apps/docs/content/components/toast/placement.raw.jsx (1 hunks)
  • apps/docs/content/components/toast/radius.raw.jsx (1 hunks)
  • apps/docs/content/components/toast/variants.raw.jsx (2 hunks)
  • apps/docs/content/docs/components/toast.mdx (1 hunks)
🔇 Additional comments (1)
apps/docs/content/docs/components/toast.mdx (1)

298-303: Default Value Update: maxVisibleToasts Changed to "3"

The documentation now reflects that the maxVisibleToasts default value has been updated from "5" to "3". This change aligns with the intention to refine configuration parameters in the docs. Please verify that this update is consistent with the component’s implementation and that all related examples are updated accordingly.

Comment thread apps/docs/content/components/toast/variants.raw.jsx
@jrgarciadev jrgarciadev merged commit 8052b54 into main Feb 20, 2025
@jrgarciadev jrgarciadev deleted the macci001/fix-toast-docs branch February 20, 2025 14:29
@wingkwong wingkwong added this to the v2.7.3 milestone Feb 20, 2025
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.

3 participants