Skip to content
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

fixes: Fix Button Text Overflow on Product Cards #2377 #2378

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

Conversation

sagarbendale2004
Copy link

@sagarbendale2004 sagarbendale2004 commented Oct 25, 2024

fixes #2377

Description:

This pull request addresses the issue of button text overflow on the product cards located at https://www.vigybag.com/popularCategories/fashionAccessories. The "Add to Cart" and "Buy Now" buttons were previously truncating text, making it difficult for users to see the full button labels.

Changes proposed:

  • Increased the font size of the buttons to improve text visibility.
  • Adjusted the padding of the buttons to provide more space for the text.
  • Ensured the buttons have sufficient width to prevent overflow.

Screenshots:

sc

Testing:

Verified that both buttons now display their full text on various screen sizes.
Ensured that the buttons are responsive and maintain usability across devices.

Summary by CodeRabbit

  • Style

    • Updated button styles in the ProductCard component for a more compact appearance.
    • Unified styling for the "Add to Cart" and "Buy Now" buttons, with reduced text size.
  • Bug Fixes

    • No changes to button functionality or click handling; overall functionality remains intact.
  • Chores

    • Updated routing path for the privacy policy from "privacy-policy" to "privacy."
    • Added a duplicate route for the help page.

Copy link

vercel bot commented Oct 25, 2024

@sagarbendale2004 is attempting to deploy a commit to the Vivek Prajapati's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Oct 25, 2024

Walkthrough

The changes in this pull request focus on the ProductGrid.jsx file, specifically modifying the styles of buttons within the ProductCard component. The button classes for "Add to Cart" and "Buy Now" have been updated to adjust their padding, border radius, and text size, resulting in a more compact appearance. The functionality of the buttons remains unchanged, with no alterations to their click handling or conditions for enabling/disabling based on cart items. Additionally, the routing structure in App.jsx has been modified by changing the privacy policy path.

Changes

Files Change Summary
src/User/components/Popular_Categories/ProductGrid.jsx Modified button styles in ProductCard component, adjusting padding, border radius, and text size.
src/App.jsx Updated route path for privacy policy from "privacy-policy" to "privacy".

Assessment against linked issues

Objective Addressed Explanation
Ensure full text visibility on buttons (#2377)
Adjust button styles to prevent text overflow (#2377)

Possibly related PRs

  • corrected the cards of the categories #2325: This PR modifies the ProductGrid.jsx file and includes updates to the ProductCard component's button elements, which aligns with the main PR's changes to button styles in the same component.
  • Added borders to product detail page #2335: This PR also involves changes to the ProductGrid.jsx file, specifically focusing on the ProductCard component, which relates to the main PR's modifications to button styles and functionality.

Suggested labels

good first issue, hacktoberfest, hacktoberfest-accepted, gssoc, gssoc-ext

Poem

In the grid where products shine,
Buttons now fit just fine.
"Add to Cart," so clear and bright,
With styles that bring pure delight!
A compact look, a joyful cheer,
Shopping's easier, have no fear! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 981ee95 and b620610.

📒 Files selected for processing (1)
  • src/App.jsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/App.jsx

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 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.

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.
  • 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

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
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

🧹 Outside diff range and nitpick comments (3)
src/User/components/Popular_Categories/ProductGrid.jsx (3)

Line range hint 118-126: Consider improving button text visibility without reducing font size.

While the changes address the overflow issue, reducing the text size to text-xs might impact readability. Instead, consider:

  1. Using responsive classes for better adaptability
  2. Maintaining the original text-sm size but adjusting the layout
-            className="mt-1 bg-[#166635ff] text-white px-8 py-1 rounded-lg text-xs w-full hover:bg-[#3d9970ff] transition-colors disabled:opacity-45 disabled:pointer-events-none"
+            className="mt-1 bg-[#166635ff] text-white px-4 py-2 rounded-lg text-sm w-full hover:bg-[#3d9970ff] transition-colors disabled:opacity-45 disabled:pointer-events-none sm:text-xs sm:px-3 sm:py-1"

Line range hint 132-137: Simplify the Buy Now button text condition.

The ternary condition returns the same text in both cases, making it unnecessary.

-            {cartItems.find((item) => item.id === product.id)
-              ? "⚡Buy Now"
-              : "⚡Buy Now"}
+            ⚡Buy Now

Line range hint 117-138: Consider a more responsive button layout for smaller screens.

The current implementation with two full-width buttons might cause layout issues on very small screens. Consider a more responsive approach:

  1. Stack buttons vertically on very small screens
  2. Use responsive classes to adjust the layout based on screen size
-        <div className="flex h-10 gap-2">
+        <div className="flex flex-col sm:flex-row h-auto sm:h-10 gap-2">
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 91bca48 and 1e546b7.

📒 Files selected for processing (1)
  • src/User/components/Popular_Categories/ProductGrid.jsx (2 hunks)
🔇 Additional comments (1)
src/User/components/Popular_Categories/ProductGrid.jsx (1)

118-118: Verify button text visibility across different languages.

Since this is an e-commerce site, ensure the button text remains visible if translated to languages with longer words.

Also applies to: 132-132

✅ Verification successful

Button text is safe for internationalization

The button text is very concise ("Added", "Add to Cart", and "⚡Buy Now") and the container has a flexible width (w-full). The text-size is also appropriately small (text-xs). These factors combined with the padding (px-8 py-1) provide enough space to accommodate longer translations without visibility issues.

Additionally, there's no internationalization setup in the project currently (no i18n packages in package.json), so this is a forward-looking consideration for when translations are added in the future.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any translation files or language configurations
rg -g '!node_modules' -g '*.{json,js,jsx,ts,tsx}' -i 'translation|i18n|language'

Length of output: 82


Script:

#!/bin/bash
# Let's check for any text content in the button or surrounding component
ast-grep --pattern 'button|Button' -l jsx,tsx

# Also check for any internationalization setup or language-related imports
rg -g '!node_modules' -g '*.{json,js,jsx,ts,tsx}' -i 'intl|locale|lang'

# Look for the specific component to understand the button's context
fd -e jsx -e tsx "ProductGrid"

Length of output: 1571


Script:

#!/bin/bash
# Let's examine the ProductGrid component to see the button's content and context
cat src/User/components/Popular_Categories/ProductGrid.jsx

# Check if there's any internationalization setup in package.json
cat package.json

Length of output: 7291

Copy link

vercel bot commented Oct 29, 2024

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

Name Status Preview Comments Updated (UTC)
vigybag ❌ Failed (Inspect) Oct 29, 2024 8:08am

@sagarbendale2004
Copy link
Author

@codervivek5 if my changes is accurate then please merge my PR as soon as possible.

@codervivek5
Copy link
Owner

fix this ..build are failed

[13:38:24.791] Running build in Washington, D.C., USA (East) – iad1
[13:38:24.922] Cloning github.com/codervivek5/VigyBag (Branch: main, Commit: 1e546b7)
[13:38:33.916] Cloning completed: 8.998s
[13:38:34.403] Restored build cache from previous deployment (H33W53ApmyZS32FuSVRGX2AkW2Rf)
[13:38:34.496] Running "vercel build"
[13:38:34.992] Vercel CLI 37.12.1
[13:38:35.896] Installing dependencies...
[13:38:39.900]
[13:38:39.900] up to date in 4s
[13:38:39.901]
[13:38:39.902] 174 packages are looking for funding
[13:38:39.902] run npm fund for details
[13:38:39.920] Running "npm run build"
[13:38:40.088]
[13:38:40.089] > [email protected] build
[13:38:40.089] > vite build
[13:38:40.089]
[13:38:40.346] �[36mvite v5.4.9 �[32mbuilding for production...�[36m�[39m
[13:38:40.400] transforming...
[13:38:40.756] �[32m✓�[39m 7 modules transformed.
[13:38:40.757] �[31mx�[39m Build failed in 384ms
[13:38:40.757] �[31merror during build:
[13:38:40.758] �[31m[vite:esbuild] Transform failed with 1 error:
[13:38:40.758] /vercel/path0/src/App.jsx:160:1: ERROR: Expected identifier but found "<"�[31m
[13:38:40.758] file: �[36m/vercel/path0/src/App.jsx:160:1�[31m
[13:38:40.758] �[33m
[13:38:40.758] �[33mExpected identifier but found "<"�[33m
[13:38:40.758] 158| <Route path="contributors" element={} />
[13:38:40.758] 159| <Route path="about-us" element={} />
[13:38:40.758] 160| <<<<<<< HEAD
[13:38:40.758] | ^
[13:38:40.758] 161| <Route path="help" element={} /> {/* Help page route */}
[13:38:40.759] 162| <Route path="privacy-policy" element={} />
[13:38:40.765] �[31m
[13:38:40.765] at failureErrorWithLog (/vercel/path0/node_modules/esbuild/lib/main.js:1472:15)
[13:38:40.765] at /vercel/path0/node_modules/esbuild/lib/main.js:755:50
[13:38:40.765] at responseCallbacks. (/vercel/path0/node_modules/esbuild/lib/main.js:622:9)
[13:38:40.765] at handleIncomingPacket (/vercel/path0/node_modules/esbuild/lib/main.js:677:12)
[13:38:40.765] at Socket.readFromStdout (/vercel/path0/node_modules/esbuild/lib/main.js:600:7)
[13:38:40.765] at Socket.emit (node:events:520:28)
[13:38:40.766] at addChunk (node:internal/streams/readable:559:12)
[13:38:40.766] at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
[13:38:40.766] at Readable.push (node:internal/streams/readable:390:5)
[13:38:40.766] at Pipe.onStreamRead (node:internal/stream_base_commons:191:23)�[39m
[13:38:40.783] Error: Command "npm run build" exited with 1
[13:38:41.099]

@sagarbendale2004
Copy link
Author

@codervivek5 i fixes the error in app.jsx file can you try to merge it again please..

@sagarbendale2004
Copy link
Author

@codervivek5 as I check there is no error or conflict in Branch so can you please merge my PR

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.

bug: Button Text Overflow on Product Cards
2 participants