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

fix: replacing the light mode bg in to nextui-pro section #4355

Merged
merged 5 commits into from
Dec 20, 2024

Conversation

macci001
Copy link
Contributor

@macci001 macci001 commented Dec 13, 2024

Closes ENG-1636

📝 Description

PR changes the background image for the nextui-pro section and adds the bg for the mobile.

⛳️ Current behavior (updates)

🚀 New behavior

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

Summary by CodeRabbit

  • New Features

    • Introduced the NextUIProSection component for enhanced marketing display.
    • Added new components: NextUIProButton, NextUIProChip, and NextUIProImage.
    • Implemented a new fadeIn animation for smoother transitions.
    • Updated image sources for improved asset delivery in various components.
  • Bug Fixes

    • Adjusted image URLs for better accessibility and performance.
    • Enhanced visual presentation of background images in the DocsLayout component.

Copy link

changeset-bot bot commented Dec 13, 2024

⚠️ No Changeset found

Latest commit: 9596cc2

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

Copy link

vercel bot commented Dec 13, 2024

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

Name Status Preview Comments Updated (UTC)
nextui-docs-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2024 1:09pm
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 20, 2024 1:09pm

Copy link

linear bot commented Dec 13, 2024

Copy link
Contributor

coderabbitai bot commented Dec 13, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The changes in this pull request involve the removal of the NextUIProSection component from nextui-pro-section.tsx, the addition of a new fadeIn animation in the Tailwind CSS configuration, and updates to the src attributes of several Image components across multiple files to point to new external URLs. Additionally, new components such as NextUIProButton, NextUIProChip, and NextUIProImage have been introduced, enhancing the marketing section's functionality.

Changes

File Path Change Summary
apps/docs/components/marketing/nextui-pro-section.tsx Removed the NextUIProSection component.
apps/docs/tailwind.config.js Added a new fadeIn animation to the Tailwind CSS configuration, transitioning opacity from 0 to 1 over 0.5 seconds.
apps/docs/app/blog/layout.tsx Updated src attributes of two Image components to new external URLs.
apps/docs/app/docs/layout.tsx Modified className and src attributes of two Image components to new external URLs.
apps/docs/app/figma/page.tsx Updated src attributes of two Image components to new external URLs.
apps/docs/app/page.tsx Updated import path for NextUIProSection.
apps/docs/components/marketing/marquee.tsx Added an optional wrapperClassName property to MarqueeProps.
apps/docs/components/marketing/nextui-pro-section/index.ts Added export for NextUIProSection from the index.ts file.
apps/docs/components/marketing/nextui-pro-section/nextui-pro-button.tsx Introduced NextUIProButton component.
apps/docs/components/marketing/nextui-pro-section/nextui-pro-chip.tsx Introduced NextUIProChip component.
apps/docs/components/marketing/nextui-pro-section/nextui-pro-image.tsx Introduced NextUIProImage component.
apps/docs/config/github-info.json Updated GitHub repository statistics.
apps/docs/content/docs/guide/introduction.mdx Changed the image source for the NextUI banner.
apps/docs/next.config.js Added a new entry to allow images from heroui-assets.nyc3.cdn.digitaloceanspaces.com.
apps/docs/package.json Added clsx dependency.

Possibly related PRs

Suggested labels

📋 Scope : Docs

Suggested reviewers

  • wingkwong

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f5d64a1 and 9596cc2.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • apps/docs/app/blog/layout.tsx (1 hunks)
  • apps/docs/app/docs/layout.tsx (1 hunks)
  • apps/docs/app/figma/page.tsx (1 hunks)
  • apps/docs/app/page.tsx (1 hunks)
  • apps/docs/components/marketing/marquee.tsx (3 hunks)
  • apps/docs/components/marketing/nextui-pro-section.tsx (0 hunks)
  • apps/docs/components/marketing/nextui-pro-section/index.ts (1 hunks)
  • apps/docs/components/marketing/nextui-pro-section/nextui-pro-button.tsx (1 hunks)
  • apps/docs/components/marketing/nextui-pro-section/nextui-pro-chip.tsx (1 hunks)
  • apps/docs/components/marketing/nextui-pro-section/nextui-pro-image.tsx (1 hunks)
  • apps/docs/components/marketing/nextui-pro-section/nextui-pro-section.tsx (1 hunks)
  • apps/docs/config/github-info.json (1 hunks)
  • apps/docs/content/docs/guide/introduction.mdx (1 hunks)
  • apps/docs/next.config.js (1 hunks)
  • apps/docs/package.json (1 hunks)

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
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 (1)
apps/docs/components/marketing/nextui-pro-section.tsx (1)

41-42: Add transition duration for smoother effect

While the ease-in-out timing function is added, specifying a transition duration would make the effect more noticeable.

-    ? "ease-in-out h-full w-full bg-[radial-gradient(at_80%_50%,_rgba(255,255,255,_0)_20%,_rgba(0,0,0,_0.8)_40%,_rgba(0,0,0,1)_100%)]"
-    : "ease-in-out h-full w-full bg-[radial-gradient(at_80%_50%,_rgba(0,0,0,_0)_20%,_rgba(255,255,255,_0.9)_40%,_rgba(255,255,255,1)_100%)]";
+    ? "transition-all duration-300 ease-in-out h-full w-full bg-[radial-gradient(at_80%_50%,_rgba(255,255,255,_0)_20%,_rgba(0,0,0,_0.8)_40%,_rgba(0,0,0,1)_100%)]"
+    : "transition-all duration-300 ease-in-out h-full w-full bg-[radial-gradient(at_80%_50%,_rgba(0,0,0,_0)_20%,_rgba(255,255,255,_0.9)_40%,_rgba(255,255,255,1)_100%)]";
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between fd86056 and 3b3135a.

📒 Files selected for processing (1)
  • apps/docs/components/marketing/nextui-pro-section.tsx (2 hunks)
🔇 Additional comments (2)
apps/docs/components/marketing/nextui-pro-section.tsx (2)

37-38: Improved mobile gradient transition!

The switch from radial to linear gradient for mobile provides a better controlled fade effect, with appropriate transparency handling for both dark and light modes.


159-160: Verify contrast with reduced opacity

The changes improve the background handling with dynamic viewport height and simplified animation. However, please ensure that the 15% opacity on mobile provides sufficient contrast for content visibility.

✅ Verification successful

Let me gather more information about the opacity and contrast usage in the codebase.


The opacity change is safe and well-implemented

The reduced opacity (15%) is applied to a background image element that has multiple safeguards ensuring content visibility:

  • The content is rendered in a separate z-indexed layer (z-30) above the background
  • There are gradient overlays that enhance contrast (mobileClassName and webClassName)
  • The opacity is only reduced on mobile, where the gradient overlay is stronger
  • Text elements have additional contrast enhancement with text shadow
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any contrast-related accessibility guidelines in the codebase
rg -i "contrast|a11y|accessibility" --type md

Length of output: 510


Script:

#!/bin/bash
# Check for similar opacity patterns in the codebase
rg -i "opacity-\d+" --type tsx -A 2

# Check the parent component structure to understand the contrast context
ast-grep --pattern 'className="$$$opacity-15$$$"'

Length of output: 117


Script:

#!/bin/bash
# Check for similar opacity patterns in the codebase, using correct file extensions
rg -i "opacity-\d+" --type ts --type jsx --type tsx

# Check the component content to understand what's being rendered
cat "apps/docs/components/marketing/nextui-pro-section.tsx"

Length of output: 6416

@macci001
Copy link
Contributor Author

@jrgarciadev since this section was looking bit plain on mobile, I have added the bg to mobile as well.
We can remove it if it is not looking better.

@wingkwong wingkwong added this to the v2.6.9 milestone Dec 16, 2024
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

🧹 Nitpick comments (2)
apps/docs/components/marketing/nextui-pro-section.tsx (2)

166-166: Fix duplicate transition property

The className contains a duplicate transition property:

-"transition transition-opacity h-full w-full bg-[linear-gradient(to_left,_rgba(255,255,255,_0)_5%,_rgba(0,0,0,1)_100%)]"
+"transition-opacity h-full w-full bg-[linear-gradient(to_left,_rgba(255,255,255,_0)_5%,_rgba(0,0,0,1)_100%)]"

163-194: Consider optimizing overlay transitions and performance

  1. Transition properties are inconsistent:

    • Mobile overlays: simple transition
    • Desktop overlays: includes ease-linear, delay-75, duration-300
  2. Multiple absolute-positioned overlays might impact performance.

Consider:

  1. Standardizing transition properties across all overlays
  2. Combining overlays using CSS variables for gradient colors to reduce DOM elements:
-<div className="absolute md:hidden inset-0 pointer-events-none top-0 z-20">
-  <div className={cn("transition-opacity h-full w-full bg-[linear-gradient(...)]",
-    isDarkMode && isMobile ? "opacity-100" : "opacity-0")} />
-</div>
-<div className="absolute md:hidden inset-0 pointer-events-none top-0 z-20">
-  <div className={cn("transition-opacity h-full w-full bg-[linear-gradient(...)]",
-    !isDarkMode && isMobile ? "opacity-100" : "opacity-0")} />
-</div>
+<div className="absolute inset-0 pointer-events-none top-0 z-20">
+  <div 
+    className="transition-all h-full w-full"
+    style={{
+      '--gradient-color': isDarkMode ? 'rgba(0,0,0,1)' : 'rgba(255,255,255,1)',
+      background: isMobile 
+        ? `linear-gradient(to left, rgba(255,255,255, 0) 5%, var(--gradient-color) 100%)`
+        : `radial-gradient(at 80% 50%, rgba(255,255,255, 0) 20%, var(--gradient-color) 100%)`,
+      opacity: shouldShow ? 1 : 0
+    }} 
+  />
+</div>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3b3135a and e8abe24.

📒 Files selected for processing (1)
  • apps/docs/components/marketing/nextui-pro-section.tsx (3 hunks)
🔇 Additional comments (3)
apps/docs/components/marketing/nextui-pro-section.tsx (3)

3-3: LGTM: Import change is appropriate

The addition of cn from @nextui-org/react is appropriate for the conditional class name handling implemented in the background overlays.


150-151: LGTM: Marquee component improvements

Good improvements:

  • Reduced opacity on mobile (0.15) improves content visibility while maintaining the background effect
  • Simplified duration prop removes unnecessary complexity

Line range hint 1-194: Overall implementation successfully meets PR objectives

The changes effectively:

  • Improve mobile background visibility with appropriate opacity and gradients
  • Handle both light and dark modes smoothly
  • Maintain responsive design principles

While there are some minor optimization opportunities noted above, the implementation is solid and achieves the intended goals.

Copy link
Member

@wingkwong wingkwong left a comment

Choose a reason for hiding this comment

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

pr4355-comment.webm

You can try to keep clicking the theme switch and compare the pro section and other sections. When switching theme, you will see pro section got a box for a sec. It should look like other sections.

@jrgarciadev jrgarciadev changed the base branch from canary to main December 17, 2024 14:17
@macci001 macci001 force-pushed the macci001/adding-nextuipro-bg-to-mobile branch from 62e5fe8 to 7828510 Compare December 17, 2024 14:28
@macci001 macci001 force-pushed the macci001/adding-nextuipro-bg-to-mobile branch from 7828510 to 1a08a17 Compare December 17, 2024 14:33
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: 1

🧹 Nitpick comments (3)
apps/docs/components/marketing/nextui-pro-section.tsx (3)

37-54: Consolidate image preloading logic

There's duplicate image preloading implementation:

  1. useEffect hook creating Image objects
  2. Head component with preload link tags

Consider removing one of these implementations to avoid unnecessary duplicate preloading.

- useEffect(() => {
-   const imagesToPreload = [
-     "/images/nextuipro-section-background.webp",
-     "/images/nextuipro-section-background-light.webp",
-     "/images/nextuipro-section-background@mobile.webp",
-     "/images/nextuipro-section-background-light@mobile.webp",
-   ];
-
-   const preloadImages = (images) => {
-     images.forEach((src) => {
-       const img = new Image();
-       img.src = src;
-     });
-   };
-
-   preloadImages(imagesToPreload);
- }, []);

Also applies to: 72-75


185-192: Extract mask styles for better maintainability

The mask implementation mixes complex conditional logic with styles. Consider extracting these styles into constants or a utility function for better maintainability.

+ const getMaskStyle = (isMobile: boolean) => {
+   const baseStyle = "absolute inset-0 pointer-events-none z-20 bg-white dark:bg-black transition transition-all duration-300";
+   const desktopMask = "[-webkit-mask-image:radial-gradient(at_70%_50%,_rgba(255,255,255,0)_20%,_rgba(255,255,255,0.8)_40%,_rgba(0,0,0,1)_60%)]";
+   const mobileMask = "[-webkit-mask-image:linear-gradient(to_left,_rgba(255,255,255,_0)_5%,_rgba(0,0,0,1)_100%)]";
+   return cn(baseStyle, isMobile ? mobileMask : desktopMask);
+ };

- className={cn(
-   "absolute inset-0 pointer-events-none z-20 bg-white dark:bg-black transition transition-all duration-300",
-   !isMobile &&
-     "[-webkit-mask-image:radial-gradient(at_70%_50%,_rgba(255,255,255,0)_20%,_rgba(255,255,255,0.8)_40%,_rgba(0,0,0,1)_60%)]",
-   isMobile &&
-     "[-webkit-mask-image:linear-gradient(to_left,_rgba(255,255,255,_0)_5%,_rgba(0,0,0,1)_100%)]",
- )}
+ className={getMaskStyle(isMobile)}

178-181: Improve Marquee component configuration

The Marquee implementation has hardcoded values and mixed concerns in className. Consider:

  1. Making duration configurable
  2. Separating opacity and layout classes
+ const MARQUEE_DURATION = 60;
+ const MARQUEE_BASE_CLASSES = "flex w-screen mt-4 absolute top-0 inset-0 isolate max-h-dvh";
+ const MARQUEE_OPACITY_CLASSES = "opacity-15 md:opacity-100";

  <Marquee
    vertical
-   className="flex opacity-15 md:opacity-100 w-screen mt-4 absolute top-0 inset-0 isolate max-h-dvh "
-   duration={60}
+   className={cn(MARQUEE_BASE_CLASSES, MARQUEE_OPACITY_CLASSES)}
+   duration={MARQUEE_DURATION}
  >
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 62e5fe8 and 1a08a17.

📒 Files selected for processing (2)
  • apps/docs/components/marketing/nextui-pro-section.tsx (3 hunks)
  • apps/docs/tailwind.config.js (2 hunks)
🔇 Additional comments (1)
apps/docs/tailwind.config.js (1)

330-333: LGTM! Animation configuration looks good

The fadeIn animation configuration is well-implemented with appropriate timing and easing function.

Also applies to: 343-343

apps/docs/components/marketing/nextui-pro-section.tsx Outdated Show resolved Hide resolved
@macci001 macci001 force-pushed the macci001/adding-nextuipro-bg-to-mobile branch from 5a3c368 to cae01bc Compare December 17, 2024 17:56
@macci001 macci001 changed the title fix: replacing the light mode bg and adding bg to nextui-pro section … fix: replacing the light mode bg in to nextui-pro section Dec 20, 2024
@jrgarciadev jrgarciadev merged commit c1baa74 into main Dec 20, 2024
1 of 3 checks passed
@jrgarciadev jrgarciadev deleted the macci001/adding-nextuipro-bg-to-mobile branch December 20, 2024 13:05
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