Skip to content

883-feat: Make swipe gallery for merch card #889

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

Open
wants to merge 3 commits into
base: feat/786-add-merch-page
Choose a base branch
from

Conversation

chmdln
Copy link
Collaborator

@chmdln chmdln commented May 12, 2025

What type of PR is this? (select all that apply)

  • πŸ• Feature
  • πŸ› Bug Fix
  • 🚧 Breaking Change
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ“ Documentation Update

Description

Add swipe gallery for merch card.

Related Tickets & Documents

Screenshots, Recordings

swipe-2

Added/updated tests?

  • πŸ‘Œ Yes
  • πŸ™…β€β™‚οΈ No, because they aren't needed
  • πŸ™‹β€β™‚οΈ No, because I need help

[optional] Are there any post deployment tasks we need to perform?

[optional] What gif best describes this PR or how it makes you feel?

Summary by CodeRabbit

  • New Features

    • Introduced a new "Merch" page showcasing free design assets, accessible from the main navigation.
    • Added a visually rich merchandise catalog with product cards, image carousels, and download options.
    • Implemented swipe and navigation controls for browsing product images.
    • Breadcrumb navigation and hero section now support the new "Merch" page.
  • Style

    • Added new styles for merchandise cards and catalog layouts, including responsive grid and interactive elements.
    • Updated paragraph and opacity styles for improved visual consistency.
  • Bug Fixes

    • Updated internal links to route to the new "Merch" page instead of external URLs.
  • Chores

    • Added new dependencies to support swipe gestures and unique ID generation for merchandise items.

@chmdln chmdln self-assigned this May 12, 2025
@github-actions github-actions bot changed the title Feat/883 make swipe gallery for merch card 883-feat: Make swipe gallery for merch card May 12, 2025
Copy link
Contributor

coderabbitai bot commented May 12, 2025

πŸ“ Walkthrough

Walkthrough

This update introduces a new "Merch" section, including backend API integration, data transformation utilities, React components, and styling for a merchandise catalog and swipeable product cards. It also updates routing, constants, and breadcrumbs to support the new merch feature, along with related dependency and test adjustments.

Changes

Files/Group Change Summary
dev-data/hero-page.data.ts Added merch section with titles, image, and alt text to heroPageData.
package.json Added react-swipeable, uuid, and @types/uuid to dependencies.
src/app/merch/page.tsx, src/views/merch/merch.tsx Added merch page route, metadata, and main Merch component.
src/core/api/app-api.ts, src/entities/merch/api/merch-api.ts Introduced MerchApi class and integrated it into the main API class.
src/core/styles/_constants.scss Added $opacity-40 variable.
src/entities/merch/types.ts Defined merchandise-related TypeScript types.
src/entities/merch/helpers/transform-merch-catalog.ts Added utility to flatten and enrich merch catalog data.
src/entities/merch/model/store.ts Created MerchStore for loading and transforming catalog data.
src/entities/merch/index.ts Centralized exports for merch types, store, and card component.
src/entities/merch/ui/merch-card/merch-card.tsx Implemented MerchCard React component with swipeable image gallery.
src/entities/merch/ui/merch-card/merch-card.module.scss Added styles for the swipeable merch card component.
src/shared/constants.ts, src/widgets/breadcrumbs/constants.ts Added "MERCH" to page names, routes, and breadcrumbs.
src/widgets/merch-catalog/ui/merch-catalog.tsx, index.ts Added MerchCatalog component and export.
src/widgets/merch-catalog/ui/merch-catalog.module.scss Added base styling for merch catalog container.
src/widgets/merch-catalog/ui/merch-list/merch-list.tsx, .module.scss Implemented and styled MerchList to display a grid of MerchCard components.
src/shared/__tests__/constants.ts Updated merch button link from external to internal route.
src/shared/ui/paragraph/paragraph.module.scss Added 4px top padding to .paragraph class.
src/widgets/merch/ui/merch.tsx Updated merch link to use new internal route and removed external prop.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MerchPage
    participant MerchCatalog
    participant MerchStore
    participant API
    participant Backend

    User->>MerchPage: Navigate to /merch
    MerchPage->>MerchCatalog: Render
    MerchCatalog->>MerchStore: loadMerchCatalog()
    MerchStore->>API: queryMerchCatalog()
    API->>Backend: GET merch/filelist.json
    Backend-->>API: MerchResponse
    API-->>MerchStore: MerchResponse
    MerchStore->>MerchCatalog: Transformed products
    MerchCatalog->>User: Display MerchList (grid of MerchCards)
    User->>MerchCard: Swipe or click arrows
    MerchCard->>User: Show next/prev product image
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement swipe gallery for merch card (#883) βœ…

Suggested labels

feature, preview

Suggested reviewers

  • andron13
  • dzmitry-varabei
  • SpaNb4

Tip

⚑️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boostβ€”your workflow just got faster.

✨ Finishing Touches
  • πŸ“ Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

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

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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

🧹 Nitpick comments (10)
package.json (1)

41-41: Ensure dependency usage and compatibility.
Added react-swipeable, swiper, and uuid (with types). Please verify that:

  • swiper is actually utilized; if not, consider removing it.
  • react-swipeable integration aligns with the component implementation.
  • uuid import and @types/uuid versions are compatible.

Also applies to: 50-52, 69-69

src/widgets/merch-catalog/ui/merch-catalog.module.scss (1)

1-4: Add layout refinements for item spacing.
Consider adding properties like gap and flex-wrap to improve the merchandising layout and ensure responsiveness.

src/widgets/merch-catalog/ui/merch-list/merch-list.module.scss (1)

5-9: Consider adding responsive breakpoints

The grid layout looks good, but consider adding media queries to handle different screen sizes for better mobile experience.

.list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
+
+  @media (max-width: 768px) {
+    grid-template-columns: repeat(2, 1fr);
+  }
+
+  @media (max-width: 480px) {
+    grid-template-columns: 1fr;
+  }
}
src/entities/merch/helpers/transform-merch-catalog.ts (1)

32-36: Enhance type guard validation.

The type guard checks for property existence but not data validity. Consider adding deeper validation for array properties.

src/entities/merch/ui/merch-card/merch-card.tsx (1)

68-77: Remove redundant conditional check.

The condition at line 68 (preview.length > 1) is redundant as it's already covered by the parent conditional at line 47.

src/entities/merch/ui/merch-card/merch-card.module.scss (5)

50-58: Specify flex basis in shorthand
You’ve used flex: 1 1; on .info-wrap, which defaults the flex-basis to 0%. If you intend to preserve content size before shrinking, consider flex: 1 1 auto; or simply flex: 1; for clarity.


66-81: Add focus styles for accessibility
Interactive elements like .download buttons should include visible focus states (e.g. :focus-visible { outline: 2px solid $color-primary; }) to improve keyboard navigation.


83-88: Review .download-img background-color
A class named .download-img suggests an <img> element, but you’re applying a background-color. If this is truly an image tag, the background won’t showβ€”consider using a <div> or renaming the class, or remove the redundant background.


90-136: Enhance swipe-button accessibility
For .swipe-btn, consider adding :focus-visible outlines, aria-label styling hooks, and perhaps pointer-events: none; on disabled buttons to reinforce the disabled state.


163-172: Improve swipeable area behavior
Consider adding overflow-x: hidden; and user-select: none; to .swipeable-area to prevent off-screen items from peeking and to avoid accidental text selection during swipes.

πŸ“œ Review details

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

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between 0c5489b and 59b2777.

β›” Files ignored due to path filters (4)
  • package-lock.json is excluded by !**/package-lock.json
  • src/shared/assets/svg/chevron-left-solid.svg is excluded by !**/*.svg
  • src/shared/assets/svg/chevron-right-solid.svg is excluded by !**/*.svg
  • src/shared/assets/svg/download.svg is excluded by !**/*.svg
πŸ“’ Files selected for processing (23)
  • dev-data/hero-page.data.ts (2 hunks)
  • package.json (3 hunks)
  • src/app/merch/page.tsx (1 hunks)
  • src/core/api/app-api.ts (2 hunks)
  • src/core/styles/_constants.scss (1 hunks)
  • src/entities/merch/api/merch-api.ts (1 hunks)
  • src/entities/merch/helpers/transform-merch-catalog.ts (1 hunks)
  • src/entities/merch/index.ts (1 hunks)
  • src/entities/merch/model/store.ts (1 hunks)
  • src/entities/merch/types.ts (1 hunks)
  • src/entities/merch/ui/merch-card/merch-card.module.scss (1 hunks)
  • src/entities/merch/ui/merch-card/merch-card.tsx (1 hunks)
  • src/shared/__tests__/constants.ts (1 hunks)
  • src/shared/constants.ts (2 hunks)
  • src/shared/ui/paragraph/paragraph.module.scss (1 hunks)
  • src/views/merch/merch.tsx (1 hunks)
  • src/widgets/breadcrumbs/constants.ts (1 hunks)
  • src/widgets/merch-catalog/index.ts (1 hunks)
  • src/widgets/merch-catalog/ui/merch-catalog.module.scss (1 hunks)
  • src/widgets/merch-catalog/ui/merch-catalog.tsx (1 hunks)
  • src/widgets/merch-catalog/ui/merch-list/merch-list.module.scss (1 hunks)
  • src/widgets/merch-catalog/ui/merch-list/merch-list.tsx (1 hunks)
  • src/widgets/merch/ui/merch.tsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
src/views/merch/merch.tsx (2)
src/shared/constants.ts (1)
  • PAGE_NAMES (25-31)
src/widgets/merch-catalog/ui/merch-catalog.tsx (1)
  • MerchCatalog (10-20)
src/core/api/app-api.ts (3)
src/entities/merch/api/merch-api.ts (1)
  • MerchApi (4-10)
src/shared/api/api-base-class.ts (1)
  • ApiBaseClass (14-127)
src/entities/trainer/api/trainer-api.ts (1)
  • TrainerApi (6-19)
src/entities/merch/api/merch-api.ts (1)
src/entities/merch/types.ts (1)
  • MerchResponse (16-18)
src/entities/merch/helpers/transform-merch-catalog.ts (1)
src/entities/merch/types.ts (4)
  • MerchResponse (16-18)
  • MerchProduct (20-27)
  • ApiMerchItemAdapt (15-15)
  • ApiMerchItem (1-5)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: CI
πŸ”‡ Additional comments (20)
src/shared/ui/paragraph/paragraph.module.scss (1)

2-4: Validate new top padding across layouts.
The padding-top: 4px; may affect existing paragraph spacing. Please confirm it doesn’t introduce visual regressions, especially in shared components.

src/core/styles/_constants.scss (1)

85-85: Sync SCSS constants with e2e viewports.
You added $opacity-40. The file header notes updating viewports.ts in e2e/utils after changing variablesβ€”please ensure those configs remain in sync.

src/widgets/breadcrumbs/constants.ts (1)

16-16: Confirm breadcrumb and route integration.
With 'merch': 'Merch' added, verify that the /merch route exists and that the BreadcrumbNameMap type includes this key to prevent type errors.

src/widgets/merch-catalog/index.ts (1)

1-2: Clean barrel export - looks good!

This is a proper barrel file that exports the MerchCatalog component, following the project's module structure pattern.

src/shared/constants.ts (2)

30-30: Consistent route naming - approved

Adding MERCH to PAGE_NAMES maintains the established naming pattern and supports the new merch feature.


105-105: Route definition looks good

Adding MERCH to ROUTES ensures consistent routing for the new merch page throughout the application.

src/shared/__tests__/constants.ts (1)

214-214: Correctly updated link to use internal routing

Changed from external URL to relative path, aligning with the new internal merch page routing structure.

src/entities/merch/index.ts (1)

1-3: Well-structured exports for the merch entity

This barrel file properly exports the essential components for the merch feature: the type definition, UI component, and data store.

src/widgets/merch/ui/merch.tsx (2)

5-5: Correctly updated import to use ROUTES

Changed from LINKS to ROUTES import to support the new internal routing strategy.


24-26: Properly updated link to use internal routing

The link now correctly uses the ROUTES constant with template string formatting and appropriately removes the external prop.

src/views/merch/merch.tsx (1)

6-14: Clean and well-structured component implementation

The Merch component follows a good pattern of composing a page from multiple specialized components. The async declaration is appropriate since it renders the async MerchCatalog component.

src/core/api/app-api.ts (1)

1-1: API integration follows established patterns

The merch API integration is properly implemented following the same pattern as existing API modules in the codebase.

Also applies to: 11-11, 18-18

src/entities/merch/api/merch-api.ts (1)

4-10: Clean, focused API implementation.

The MerchApi class provides a single responsibility of fetching merchandise data using a REST GET request. The implementation follows good practices with dependency injection via constructor.

dev-data/hero-page.data.ts (1)

30-36: Hero data structure for merch section looks good.

The new merch section follows the same structure as other sections with appropriate title, subtitle, and image properties.

src/widgets/merch-catalog/ui/merch-list/merch-list.tsx (1)

1-21: Well-structured component with clean implementation.

The MerchList component efficiently renders the grid of merchandise cards with proper key usage. The implementation is straightforward and follows React best practices.

src/entities/merch/types.ts (1)

1-27: Type definitions are comprehensive and well-structured.

The types clearly model the hierarchical structure of merchandise data and provide good type safety throughout the application.

src/entities/merch/ui/merch-card/merch-card.tsx (1)

19-39: Good state management and swipe implementation.

The component effectively manages state for the image carousel with clean navigation functions.

src/entities/merch/ui/merch-card/merch-card.module.scss (3)

15-23: Verify CSS Color Module Level 4 support
This file uses modern color functions (hsla(from $color-black h s l / ...) and slash alpha notation like rgb(0 0 0 / 30%)). Ensure your build pipeline (Dart Sass, PostCSS preset-env, autoprefixer, etc.) supports CSS Color Module Level 4, or provide fallbacks for older browsers.

Also applies to: 43-46


60-64: Image styling looks good
width: 100%; height: 100%; object-fit: contain; ensures images scale correctly within the card. Nice work!


174-178: Responsive touch layout approved
Hiding .swipe-btn under the max-width: $mobile-landscape-width breakpoint makes sense for touch devices. Good use of media queries!

Comment on lines 10 to 20
export const MerchCatalog = async () => {
const products = await merchStore.loadMerchCatalog();

return (
<section className={cx('container')}>
<div className={cx('content', 'merch-catalog')}>
{products && <MerchList products={products} />}
</div>
</section>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Consider adding error and loading states.

The async component loads data but doesn't handle loading states or display errors to users if the API call fails.

export const MerchCatalog = async () => {
  const products = await merchStore.loadMerchCatalog();

  return (
    <section className={cx('container')}>
      <div className={cx('content', 'merch-catalog')}>
-        {products && <MerchList products={products} />}
+        {products ? (
+          <MerchList products={products} />
+        ) : (
+          <div className={cx('error-message')}>
+            Unable to load merchandise. Please try again later.
+          </div>
+        )}
      </div>
    </section>
  );
};

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines 5 to 15
public loadMerchCatalog = async () => {
try {
const res = await api.merch.queryMerchCatalog();

if (res.isSuccess) {
return transformMerchCatalog(res.result);
}
} catch (e) {
console.error(e);
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Improve error handling in loadMerchCatalog method.

Currently, the method returns undefined when an error occurs, which could lead to confusing UI states. Consider returning an empty array or error state that components can properly handle.

public loadMerchCatalog = async () => {
  try {
    const res = await api.merch.queryMerchCatalog();

    if (res.isSuccess) {
      return transformMerchCatalog(res.result);
    }
+   return []; // Return empty array if request was not successful
  } catch (e) {
    console.error(e);
+   return []; // Return empty array on error
  }
};
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public loadMerchCatalog = async () => {
try {
const res = await api.merch.queryMerchCatalog();
if (res.isSuccess) {
return transformMerchCatalog(res.result);
}
} catch (e) {
console.error(e);
}
};
public loadMerchCatalog = async () => {
try {
const res = await api.merch.queryMerchCatalog();
if (res.isSuccess) {
return transformMerchCatalog(res.result);
}
return []; // Return empty array if request was not successful
} catch (e) {
console.error(e);
return []; // Return empty array on error
}
};

Comment on lines 5 to 30
export const transformMerchCatalog = (data: MerchResponse): MerchProduct[] => {
const products: MerchProduct[] = [];
const baseUrl = process.env.API_BASE_URL;
const processCategory = (category: ApiMerchItemAdapt, parentTags: string[]) => {
for (const [key, value] of Object.entries(category)) {
if (isApiMerchItem(value)) {
products.push({
id: uuidv4(),
name: key,
title: value.name,
preview: value.preview.map((path) => `${baseUrl}/${path}`),
download: value.download.map((path) => `${baseUrl}/${path}`),
tags: parentTags,
});
} else {
processCategory(value, [...parentTags, key]);
}
}
};

for (const [categoryName, categoryData] of Object.entries(data)) {
processCategory(categoryData, [categoryName]);
}

return products;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Add error handling and improve URL construction.

The transformation function works well for flattening the nested catalog structure, but lacks error handling and proper URL construction. Consider these improvements:

  1. Add validation for baseUrl to ensure it's defined
  2. Implement URL joining logic to prevent double slashes if baseUrl ends with a slash or path starts with one
  3. Add try-catch blocks to handle errors during transformation

Comment on lines +153 to +156
background-color: rgb(0 0 0 / 20%);

transition: background-color all 0.3s ease;

Copy link
Contributor

@coderabbitai coderabbitai bot May 12, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix transition property syntax
transition: background-color all 0.3s ease; is invalid. It should be either:

transition: background-color 0.3s ease;

or

transition: all 0.3s ease;

Please correct this to ensure the active dot transitions smoothly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's good point, please fix it

Copy link
Contributor

Choose a reason for hiding this comment

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

No description provided.

Copy link
Contributor

Choose a reason for hiding this comment

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

A summary of the edits CodeRabbit can apply:

Fix the transition property syntax by removing the invalid "all" keyword in src/entities/merch/ui/merch-card/merch-card.module.scss

A plan of each step that CodeRabbit will take in order to execute the edits for each file (with inline rough draft snippets):

✏️ src/entities/merch/ui/merch-card/merch-card.module.scss

Open src/entities/merch/ui/merch-card/merch-card.module.scss and navigate to the .swipe-dot block. Locate the line:

    transition: background-color all 0.3s ease;

Replace it exactly with:

    transition: background-color 0.3s ease;

Save the file, restart your SCSS compiler or development server, and verify in the browser that the swipe dots’ background-color now transitions smoothly without any syntax errors.

A summary of the context that CodeRabbit is considering across the codebase:

We’ll use ripgrep to locate the invalid transition syntax and confirm its exact line number and surrounding context before editing.

  • βœ… Create PR with these edits

  • πŸ“Œ Create commit in current branch

  • πŸ“‹ Get copyable edits

Comment on lines 31 to 47
&::after {
pointer-events: none;
content: '';

position: absolute;
top: 0;
left: 0;

width: 100%;
height: 100%;

background: linear-gradient(
to bottom,
transparent 0%,
hsla(from $color-black h s l / $opacity-10) 100%
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Add explicit z-index to gradient overlay
The &::after pseudo-element in .preview-wrap creates a gradient overlay but has no z-index. Without it, stacking of images, buttons, or dots may be inconsistent. Add z-index: 1; to the pseudo-element and ensure interactive elements (e.g. swipe buttons) sit above it (z-index: 2;).

.merch-card {
position: relative;

overflow: hidden;
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Overflow hidden may clip pagination dots
.merch-card { overflow: hidden; } will clip any absolutely-positioned .swipe-dots placed outside its bounds (e.g. bottom: -15px). Consider adjusting overflow to visible on the lower section or repositioning dots within the container.

@chmdln chmdln changed the base branch from main to feat/786-add-merch-page May 12, 2025 17:08
@@ -38,6 +38,7 @@
"react-double-marquee": "^1.1.0",
"react-markdown": "^10.1.0",
"react-responsive-carousel": "^3.2.23",
"react-swipeable": "^7.0.2",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason we're using react-swipeable here instead of Swiper, given that Swiper is already listed in the dependencies?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@gbogdanova good point, since we also have the following issue: #877

@@ -65,6 +66,7 @@
"@types/node": "^22.15.3",
"@types/react": "19.1.2",
"@types/react-dom": "19.1.3",
"@types/uuid": "^10.0.0",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This library was used in the 786 branch but it has now been removed. Try pulling the changes from branch 786 again, so that you have the current version and don't add unnecessary dependencies

Comment on lines +6 to +10
import { useSwipeable } from 'react-swipeable';

import { MerchProduct } from '@/entities/merch/types';
import chevronLeft from '@/shared/assets/svg/chevron-left-solid.svg';
import chevronRight from '@/shared/assets/svg/chevron-right-solid.svg';
Copy link
Collaborator

Choose a reason for hiding this comment

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

The Slider component uses the swiper library, can we reuse it? And maybe then we won't need new arrow icons?

Comment on lines +47 to +76
{preview.length > 1 && (
<>
<button className={cx('swipe-btn', 'is-prev')} onClick={goToPrev} disabled={currentIndex === 0}>
<Image
src={chevronLeft}
alt="chevron left icon"
width={20}
height={20}
className={cx('arrow-img')}
/>
</button>
<button className={cx('swipe-btn', 'is-next')} onClick={goToNext} disabled={currentIndex === preview.length - 1}>
<Image
src={chevronRight}
alt="chevron right icon"
width={20}
height={20}
className={cx('arrow-img')}
/>
</button>

{preview.length > 1 && (
<div className={cx('swipe-dots')}>
{preview.map((_, index) => (
<span
key={index}
className={cx('swipe-dot', { active: index === currentIndex })}
/>
))}
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why we make check two times?
{preview.length > 1....

@@ -1,5 +1,6 @@
.paragraph {
margin: 0;
padding-top: 4px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This component is used in the whole project, this will change the markup of all components that use it. If you need to separate the text from the slider, use gap

Comment on lines +153 to +156
background-color: rgb(0 0 0 / 20%);

transition: background-color all 0.3s ease;

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's good point, please fix it

font-size: 20px;
color: $color-white;

background-color: rgb(0 0 0 / 30%);
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use this syntax:
background-color: hsla(from $color-black h s l / $opacity-30);

Comment on lines +120 to +126
&.is-prev {
left: 8px;
}

&.is-next {
right: 8px;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets make this

Suggested change
&.is-prev {
left: 8px;
}
&.is-next {
right: 8px;
}
&.is-prev,
&.is-next {
left: 8px;
}

}

&:hover {
background-color: rgb(0 0 0 / 60%);
Copy link
Collaborator

Choose a reason for hiding this comment

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

the same, use hsla


&:disabled {
cursor: default;
opacity: 0.3;
Copy link
Collaborator

Choose a reason for hiding this comment

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

use $opacity-30

height: 8px;
border-radius: 50%;

background-color: rgb(0 0 0 / 20%);
Copy link
Collaborator

Choose a reason for hiding this comment

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

use hsla

@KristiBo KristiBo added the feature New feature or request label May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make swipe gallery for merch card
5 participants