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

Dev #227

Merged
merged 19 commits into from
Dec 8, 2024
Merged

Dev #227

merged 19 commits into from
Dec 8, 2024

Conversation

hta218
Copy link
Member

@hta218 hta218 commented Dec 8, 2024

Summary by CodeRabbit

Release Notes for Version 3.2.0

  • New Features

    • Introduced a new useClosestWeaverseItem hook for improved item selection.
    • Replaced the filter selection dialog with an accordion interface for better usability.
    • Added a FiltersDrawer component for enhanced filter management.
    • Expanded CollectionFilters with new customization options for sorting and filtering.
    • Updated internationalization capabilities in the theme schema.
  • Improvements

    • Updated the Sort component to streamline dropdown functionality.
    • Enhanced ToolsBar with more flexible filtering and sorting options.
    • Improved layout handling in various components for better responsiveness.
  • Bug Fixes

    • Updated dependencies, including @weaverse/hydrogen to ensure compatibility.
  • Documentation

    • Updated CHANGELOG.md to reflect recent changes and version updates.

Copy link
Contributor

coderabbitai bot commented Dec 8, 2024

Warning

Rate limit exceeded

@hta218 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 2 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between b6d73ab and 55da658.

Walkthrough

This pull request includes updates across multiple files, highlighting a new version entry in CHANGELOG.md for version 3.1.1, which notes dependency updates. A new custom React hook, useClosestWeaverseItem, is introduced in use-closest-weaverse-item.ts. The getSortLink function is removed from filter.ts, and the Locale type is redefined in type.ts. Significant UI changes are made to the ProductCard, Filters, and Sort components, with a shift to using Radix UI components. The package.json is updated to reflect new dependencies and version increments.

Changes

File Change Summary
CHANGELOG.md Added version entry 3.1.1 and updated @weaverse/hydrogen to 4.0.1.
app/hooks/use-closest-weaverse-item.ts Introduced useClosestWeaverseItem hook to find closest DOM element matching a selector.
app/lib/filter.ts Removed getSortLink function.
app/lib/type.ts Updated Locale type to extend I18nBase and added Storefront type.
app/modules/product-card/index.tsx Modified JSX structure and class attributes for ProductCard component.
app/root.tsx Changed type assertion for routeError in ErrorBoundary.
app/sections/collection-filters/filters.tsx Replaced Disclosure with Accordion for filter display.
app/sections/collection-filters/index.tsx Added CollectionFiltersData interface and updated internal state management.
app/sections/collection-filters/layout-switcher.tsx Introduced LayoutSwitcherProps type and updated component logic.
app/sections/collection-filters/products-loaded-on-scroll.tsx Changed ProductsLoadedOnScrollProps from type alias to interface and updated rendering logic.
app/sections/collection-filters/sort.tsx Transitioned to @radix-ui/react-dropdown-menu for sorting functionality.
app/sections/collection-filters/tools-bar.tsx Updated ToolsBarProps interface and introduced FiltersDrawer component.
app/weaverse/components.ts Updated imports and components array, excluding AliReview and AliReviewList.
app/weaverse/schema.server.ts Added i18n property to themeSchema for internationalization support.
package.json Incremented version to 3.2.0 and updated dependencies for Radix UI components.
tailwind.config.js Updated easing functions for slide-down and slide-up animations.

Possibly related PRs

  • deps: update to Hydrogen 2024.10 #219: The changes in this PR also involve an update to the CHANGELOG.md file, specifically adding a new version entry for the @weaverse/hydrogen dependency, which is directly related to the changes made in the main PR regarding the same dependency update from version 4.0.0 to 4.0.1.
  • Add support for animations #220: This PR introduces a new data-motion attribute to various components, enhancing their animation capabilities. While it does not directly relate to the dependency updates, it indicates ongoing enhancements in the project that may be relevant to the overall context of the main PR's changes.

🐇 In the meadow, changes bloom,
New hooks and filters, making room.
With Radix and updates, we leap with cheer,
A better interface, the vision is clear!
From changelogs bright to components anew,
Hopping along, we’ll see this through! 🌼


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

🧹 Outside diff range and nitpick comments (8)
app/sections/collection-filters/tools-bar.tsx (2)

60-62: Handle Singular and Plural Forms for Product Count

Currently, when there is only one product, the text displays "1 Products". To improve user experience, adjust the label to correctly handle singular and plural forms.

Apply this diff:

<span className="grow text-center hidden md:inline">
-  {collection?.products.nodes.length} Products
+  {collection?.products.nodes.length} {collection?.products.nodes.length === 1 ? 'Product' : 'Products'}
</span>

83-84: Optimize Conditional Rendering of FiltersDrawer

Currently, FiltersDrawer is rendered even when filtersPosition is "sidebar", but it is hidden using CSS classes. To improve performance, consider conditionally rendering FiltersDrawer only when needed.

Apply this diff:

{enableFilter && filtersPosition === "drawer" && <FiltersDrawer filtersPosition={filtersPosition} />}
app/sections/collection-filters/filters.tsx (2)

27-28: Ensure Type Safety When Casting parentInstance.data

Casting parentInstance.data as unknown and then to CollectionFiltersData may hide potential type issues. Consider using a type guard or refining the types to ensure parentInstance.data conforms to CollectionFiltersData.


Line range hint 119-167: Remove Unused Commented Code in PriceRangeFilter

The PriceRangeFilter component contains a significant amount of commented-out code. To improve readability and maintainability, consider removing it if it's no longer needed or uncommenting it if it's required.

app/sections/collection-filters/products-loaded-on-scroll.tsx (1)

39-47: Consider adding validation for grid size props.

While the CSS Grid implementation is good, consider adding validation or constraints for the grid size values to prevent potential layout issues.

 interface ProductsLoadedOnScrollProps {
-  gridSizeDesktop: number;
-  gridSizeMobile: number;
+  gridSizeDesktop: 1 | 2 | 3 | 4 | 5 | 6;
+  gridSizeMobile: 1 | 2 | 3 | 4;
   // ... other props
 }
app/sections/collection-filters/sort.tsx (1)

42-42: Consider maintaining flexibility for different sort types.

The removal of the show prop has simplified the component but might limit its reusability. Consider keeping the ability to switch between different sort lists (PRODUCT_SORT/SEARCH_SORT) through props.

-export function Sort() {
+export function Sort({ sortType = 'product' }: { sortType?: 'product' | 'search' }) {
   let [params] = useSearchParams();
   let location = useLocation();
-  let sortList = PRODUCT_SORT;
+  let sortList = sortType === 'product' ? PRODUCT_SORT : SEARCH_SORT;

Also applies to: 45-46

app/weaverse/components.ts (1)

33-34: Document JudgemeReview integration

New JudgemeReview components have been added. Please ensure:

  1. Migration guide is provided for users moving from AliReview
  2. New components are documented

Consider adding a migration guide in the documentation to help users transition from AliReview to JudgemeReview.

app/weaverse/schema.server.ts (1)

88-94: Consider adding type safety to i18n mapping.

While the implementation is correct, consider adding type safety to prevent potential issues if the country data structure changes.

+type Country = {
+  language: string;
+  country: string;
+  label: string;
+};

 i18n: Object.values(countries).map((i) => {
+  const country = i as Country;
   return {
-    language: i.language,
-    country: i.country,
-    label: i.label,
+    language: country.language,
+    country: country.country,
+    label: country.label,
   };
 }),
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 520764d and 5210307.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (16)
  • CHANGELOG.md (1 hunks)
  • app/hooks/use-closest-weaverse-item.ts (1 hunks)
  • app/lib/filter.ts (0 hunks)
  • app/lib/type.ts (1 hunks)
  • app/modules/product-card/index.tsx (1 hunks)
  • app/root.tsx (1 hunks)
  • app/sections/collection-filters/filters.tsx (3 hunks)
  • app/sections/collection-filters/index.tsx (3 hunks)
  • app/sections/collection-filters/layout-switcher.tsx (2 hunks)
  • app/sections/collection-filters/products-loaded-on-scroll.tsx (2 hunks)
  • app/sections/collection-filters/sort.tsx (2 hunks)
  • app/sections/collection-filters/tools-bar.tsx (2 hunks)
  • app/weaverse/components.ts (3 hunks)
  • app/weaverse/schema.server.ts (2 hunks)
  • package.json (3 hunks)
  • tailwind.config.js (1 hunks)
💤 Files with no reviewable changes (1)
  • app/lib/filter.ts
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🔇 Additional comments (13)
app/sections/collection-filters/filters.tsx (1)

141-143: Confirm option.count is Defined Before Use

When displaying the filter count, ensure that option.count is defined to prevent displaying undefined or causing errors.

If option.count can be undefined, consider providing a default value:

label={
-  showFiltersCount ? `${option.label} (${option.count})` : option.label
+  showFiltersCount ? `${option.label} (${option.count ?? 0})` : option.label
}
app/hooks/use-closest-weaverse-item.ts (1)

10-19: Ensure Client-Side Execution when Accessing document

Accessing document is only safe in the browser environment. Ensure that this hook is only used client-side to prevent errors during server-side rendering.

app/lib/type.ts (1)

2-5: Confirm Updated Imports and Type Definitions

The import statements and the redefinition of the Locale type appear correct and align with the new structure. Ensure that all dependent code is updated accordingly.

app/sections/collection-filters/products-loaded-on-scroll.tsx (1)

6-14: LGTM! Props interface changes improve type safety and responsive control.

The transition from type to interface and addition of separate grid size props for mobile and desktop provides better responsive control.

app/sections/collection-filters/sort.tsx (1)

50-81: LGTM! Radix UI implementation improves accessibility.

The migration to Radix UI components provides better accessibility and consistent behavior. The dropdown implementation is clean and well-structured.

app/modules/product-card/index.tsx (1)

44-48: LGTM! Link implementation improves interaction area.

The block display on the Link component ensures a proper clickable area for better user experience.

package.json (1)

28-32: Verify dependency compatibility

New dependencies added:

  • @radix-ui/react-accordion@^1.2.1
  • @radix-ui/react-dropdown-menu@^2.1.2
    And updated:
  • @weaverse/hydrogen from 4.0.0 to 4.0.1

Please ensure:

  1. These versions are compatible with the existing React version (18.3.1)
  2. The caret (^) versioning for Radix UI won't introduce breaking changes

Also applies to: 42-42

✅ Verification successful

Let me gather more information about the React version and other dependencies.


Let me check the Radix UI components' compatibility with React 18.3.1 by examining their peer dependencies.


Dependencies are compatible with React 18.3.1

The Radix UI components (@radix-ui/react-accordion@^1.2.1 and @radix-ui/react-dropdown-menu@^2.1.2) are fully compatible with React 18.3.1 as they support React versions from 16.8 through 19.0. The caret versioning (^) for these packages is safe as Radix UI follows semantic versioning strictly, and minor/patch updates won't introduce breaking changes.

  • No security vulnerabilities were found for the Radix UI packages
  • Both components have identical peer dependencies supporting React ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
  • The @weaverse/hydrogen update from 4.0.0 to 4.0.1 is a patch version change, which should only contain bug fixes
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential breaking changes in new dependencies
gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: NPM, package: "radix-ui__react-accordion") {
    nodes {
      advisory {
        summary
        severity
      }
      vulnerableVersionRange
    }
  }
}'

Length of output: 283


Script:

#!/bin/bash
# Check package.json for React version and other dependencies
cat package.json | jq '.dependencies'

# Search for any React version requirements in the codebase
rg "peerDependencies.*react" -A 5

Length of output: 1289


Script:

#!/bin/bash
# Check if there are any npm-shrinkwrap.json or yarn.lock files
fd -e json -e lock "^(npm-shrinkwrap|yarn).*(json|lock)$"

# Check for any React version constraints in package-lock.json if it exists
fd "package-lock.json" --exec cat {} | jq '.packages."node_modules/@radix-ui/react-accordion".peerDependencies, .packages."node_modules/@radix-ui/react-dropdown-menu".peerDependencies'

# Look for any React version requirements in README or documentation
rg -i "react(\s+version|\s+compatibility)" README.md docs/ 2>/dev/null

Length of output: 665

app/sections/collection-filters/layout-switcher.tsx (3)

13-17: LGTM: Type definition improves component API

The new LayoutSwitcherProps type provides better type safety and clearer contract for the component.


41-44: Verify grid size logic

The data-active logic assumes grid sizes > 2 are for desktop. Please ensure this assumption is documented and consistent across the codebase.

✅ Verification successful

Based on the search results, I can now provide a conclusive response about the grid size logic:

Grid size logic is consistently implemented

The assumption about grid sizes > 2 being for desktop is actually part of a well-structured system where:

  • Desktop grid sizes default to 3 columns (productsPerRowDesktop || 3)
  • Mobile grid sizes default to 1 column (productsPerRowMobile || 1)
  • The logic is consistently implemented across the collection filters components
  • The grid size change handler in index.tsx explicitly uses the same logic: if (v > 2) { setGridSizeDesktop(v) }
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for similar grid size assumptions
rg "gridSize.*> 2" 

Length of output: 20


Script:

#!/bin/bash
# Let's search for any grid size related logic in the codebase
rg -A 3 "gridSize"

# Also search for any grid-related constants or configurations
rg -A 3 "grid.*size"

Length of output: 10453


46-47: UI dimensions update

Button and icon sizes have been increased:

  • Button: w-10 h-10 → w-12 h-12
  • Icon: w-5 h-5 → w-[22px] h-[22px]

Please ensure these changes are consistent with the design system.

Also applies to: 50-50

✅ Verification successful

UI dimensions are consistent with the design system

The changes to button and icon dimensions in the layout switcher are consistent with the design system:

  • The w-12 h-12 button size matches the "lg" size variant used in the product form options component (app/modules/product-form/options.tsx)
  • The w-[22px] h-[22px] icon size is appropriate for a large button container of 48x48px (w-12 h-12), maintaining proper visual proportions and spacing
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for similar button dimensions in the codebase
rg "w-12 h-12" 

Length of output: 254


Script:

#!/bin/bash
# Let's check for other button dimensions in the codebase to understand the design patterns
rg "w-\d+ h-\d+" -A 2 

Length of output: 15032


Script:

#!/bin/bash
# Let's also check for icon dimensions to verify consistency
rg "w-\[22px\] h-\[22px\]"
rg "w-5 h-5"

Length of output: 2760


Script:

#!/bin/bash
# Check the specific files for context
cat app/modules/product-form/options.tsx
cat app/sections/collection-filters/layout-switcher.tsx

Length of output: 11528

app/weaverse/components.ts (1)

63-64: Verify removal of AliReview components

The AliReview components have been commented out. This could be a breaking change if these components are still in use.

tailwind.config.js (1)

73-75: LGTM! Enhanced animation timing.

The custom cubic-bezier curve (0.87, 0, 0.13, 1) provides a more refined animation feel with quick initial acceleration and smooth deceleration.

app/weaverse/schema.server.ts (1)

2-2: LGTM! Added countries data import.

Clean import of countries data for i18n support.

app/sections/collection-filters/tools-bar.tsx Outdated Show resolved Hide resolved
app/sections/collection-filters/index.tsx Show resolved Hide resolved
app/hooks/use-closest-weaverse-item.ts Show resolved Hide resolved
app/modules/product-card/index.tsx Show resolved Hide resolved
package.json Show resolved Hide resolved
app/root.tsx Outdated Show resolved Hide resolved
hta218 and others added 3 commits December 8, 2024 11:24
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@hta218 hta218 merged commit 7f7bdbf into main Dec 8, 2024
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