Skip to content

feat: Implement carousel component with mock data#107

Open
BIA3IA wants to merge 3 commits into
mainfrom
bianca/carousel
Open

feat: Implement carousel component with mock data#107
BIA3IA wants to merge 3 commits into
mainfrom
bianca/carousel

Conversation

@BIA3IA
Copy link
Copy Markdown
Contributor

@BIA3IA BIA3IA commented May 12, 2026

Add a carousel component along with mock data

Closes #104

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

Review Change Stack

Warning

Rate limit exceeded

@BIA3IA has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 42 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6407bad7-3c58-4107-9d18-e56d57876598

📥 Commits

Reviewing files that changed from the base of the PR and between 7d44b3c and 623b9bf.

📒 Files selected for processing (2)
  • src/components/home/carousel-mock.tsx
  • src/components/ui/carousel.tsx

Walkthrough

This PR introduces a reusable carousel UI component built on Embla carousel, then integrates a mock carousel with sample content into the home page. The carousel supports keyboard navigation and dot-based pagination, with full state tracking and orientation support.

Changes

Carousel Feature Implementation

Layer / File(s) Summary
Carousel UI component with Embla integration
src/components/ui/carousel.tsx
Implements Carousel wrapper that initializes Embla with axis handling, tracks scroll state (canScrollPrev, canScrollNext, selectedIndex, scrollSnaps), exposes controls via useCarousel context, and handles arrow key navigation. Includes CarouselContent (manages Embla ref and layout), CarouselItem (accessible slide container), and CarouselDots (navigation indicators that scroll to snap index and show current selection).
Mock carousel component and home page integration
src/components/home/carousel-mock.tsx, src/app/page.tsx, package.json
Adds CarouselMock component displaying sample cards with Italian captions using the carousel UI. Integrates mock into home page layout before AboutUs section. Updates dependencies to include embla-carousel-react.
🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: Implement carousel component with mock data' accurately summarizes the main changes: adding a carousel component and mock data for it.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

🧹 Nitpick comments (3)
src/components/ui/carousel.tsx (2)

150-155: ⚡ Quick win

Use div instead of fieldset for carousel items.

The <fieldset> element is semantically meant for grouping form controls, not carousel slides. Using it here creates invalid HTML semantics and may confuse screen readers. Use a <div> instead, or <article> if each slide represents independent content.

♻️ Proposed fix
     return (
-      <fieldset
+      <div
         aria-roledescription="slide"
+        role="group"
         data-slot="carousel-item"
         className={cn("min-w-0 shrink-0 grow-0 basis-full", orientation === "horizontal" ? "pl-4" : "pt-4", className)}
         {...props}
       />
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/ui/carousel.tsx` around lines 150 - 155, The carousel slide
element currently renders a <fieldset> (see the JSX that returns <fieldset
aria-roledescription="slide" data-slot="carousel-item" className={cn(...)}
{...props} />) which is semantically incorrect; replace that <fieldset> with a
non-form container such as a <div> (or <article> if slides are independent
content) while preserving all attributes (aria-roledescription,
data-slot="carousel-item"), the className expression using cn(...), and
spreading {...props} so behavior and styling remain unchanged.

125-125: ⚡ Quick win

Prefer onKeyDown over onKeyDownCapture.

Using onKeyDownCapture runs the handler before child components receive the event, which can interfere with keyboard handling in child elements (e.g., inputs, buttons). Use onKeyDown instead to allow event bubbling and let children handle keyboard events first.

♻️ Proposed change
       <section
-        onKeyDownCapture={handleKeyDown}
+        onKeyDown={handleKeyDown}
         className={cn("relative", className)}
         data-slot="carousel"
         {...props}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/ui/carousel.tsx` at line 125, Replace the use of the capturing
keyboard handler with the regular bubbling handler: change the prop on the
Carousel root (currently onKeyDownCapture={handleKeyDown}) to
onKeyDown={handleKeyDown} so handleKeyDown will run during normal bubbling and
allow child controls to receive key events first; update any related tests or
comments referencing onKeyDownCapture to reflect the new onKeyDown prop and
ensure handleKeyDown behavior remains correct.
src/components/home/carousel-mock.tsx (1)

31-31: ⚖️ Poor tradeoff

Clarify the temporary nature of this component.

The TODO comment indicates this carousel mock should be deleted when merging. However, the PR title suggests adding a carousel component as a feature. Should this mock remain for demonstration purposes, or is it only for development/testing? If it's temporary, consider moving it to a separate demo route or Storybook story instead of the main home page.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/home/carousel-mock.tsx` at line 31, The inline TODO "// TODO:
delete this when merging" in carousel-mock.tsx is ambiguous—either make the mock
explicitly temporary or move it out of the main Home flow; update the file to
clarify intent and relocate usage: if this is temporary for development, change
the TODO to a clear comment referencing the PR/issue and remove any import/use
of the mock from the Home page (e.g., where Home imports CarouselMock);
otherwise extract the component (named CarouselMock or the default export in
carousel-mock.tsx) into a demo route (e.g., /demo/carousel) or a Storybook story
under src/stories so the mock remains accessible without being shipped in the
main page, and update the README or PR description to note where the demo lives.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/home/carousel-mock.tsx`:
- Around line 17-31: The mockCards array contains extra blank lines inside the
object literals (e.g., the entries with title "WiFiLinux" and "The TOL Project")
causing Biome formatting errors; remove the stray blank lines inside each card
object so the properties are compact and then run pnpm exec biome check --write
to auto-fix and reformat the file (src/components/home/carousel-mock.tsx) and
commit the result.

In `@src/components/ui/carousel.tsx`:
- Around line 124-191: The file fails Biome formatting (extra spaces/line
breaks) in Carousel components; run the formatter or fix JSX spacing: run `pnpm
exec biome check --write` to auto-fix, or manually remove stray spaces and
incorrect line breaks around the CarouselContent, CarouselItem, and CarouselDots
JSX (e.g., stray spaces before closing tags, extra blank lines, and inconsistent
indentation) so the return blocks and component wrappers (CarouselContent,
CarouselItem, CarouselDots and their inner div/fieldset/Button elements) conform
to Biome formatting rules.
- Around line 98-107: The effect registers two Embla event listeners but only
removes one; in the useEffect that depends on api and onSelect, ensure you
unsubscribe both events by calling api.off("reInit", onSelect) and
api.off("select", onSelect) in the cleanup (mirror the two api.on calls). Update
the cleanup to reference the same handler (onSelect) for both "reInit" and
"select" so the reInit listener is removed when the component unmounts or api
changes.
- Line 174: The aria-label in the Carousel JSX is hardcoded in Italian ("Vai
alla slide ${index + 1}"); update it to use internationalization instead of a
hardcoded string—replace the inline Italian text in the aria-label attribute
with either an English default like `Go to slide ${index + 1}` or call your i18n
helper (e.g. t('carousel.go_to_slide', { index: index + 1 })) so the label is
localizable; locate the aria-label usage in the Carousel component (the JSX
containing aria-label={`Vai alla slide ${index + 1}`}) and switch it to the
translation helper or English fallback while preserving the dynamic index
interpolation.
- Around line 80-91: The handleKeyDown handler currently only handles
ArrowLeft/ArrowRight, breaking vertical carousels; update the handler to check
the carousel's orientation prop (e.g., orientation === "vertical") and when
vertical respond to ArrowUp/ArrowDown (calling scrollPrev/scrollNext and
event.preventDefault()), otherwise keep ArrowLeft/ArrowRight behavior; also
include orientation in the React.useCallback dependency array so the handler
updates when orientation changes.

---

Nitpick comments:
In `@src/components/home/carousel-mock.tsx`:
- Line 31: The inline TODO "// TODO: delete this when merging" in
carousel-mock.tsx is ambiguous—either make the mock explicitly temporary or move
it out of the main Home flow; update the file to clarify intent and relocate
usage: if this is temporary for development, change the TODO to a clear comment
referencing the PR/issue and remove any import/use of the mock from the Home
page (e.g., where Home imports CarouselMock); otherwise extract the component
(named CarouselMock or the default export in carousel-mock.tsx) into a demo
route (e.g., /demo/carousel) or a Storybook story under src/stories so the mock
remains accessible without being shipped in the main page, and update the README
or PR description to note where the demo lives.

In `@src/components/ui/carousel.tsx`:
- Around line 150-155: The carousel slide element currently renders a <fieldset>
(see the JSX that returns <fieldset aria-roledescription="slide"
data-slot="carousel-item" className={cn(...)} {...props} />) which is
semantically incorrect; replace that <fieldset> with a non-form container such
as a <div> (or <article> if slides are independent content) while preserving all
attributes (aria-roledescription, data-slot="carousel-item"), the className
expression using cn(...), and spreading {...props} so behavior and styling
remain unchanged.
- Line 125: Replace the use of the capturing keyboard handler with the regular
bubbling handler: change the prop on the Carousel root (currently
onKeyDownCapture={handleKeyDown}) to onKeyDown={handleKeyDown} so handleKeyDown
will run during normal bubbling and allow child controls to receive key events
first; update any related tests or comments referencing onKeyDownCapture to
reflect the new onKeyDown prop and ensure handleKeyDown behavior remains
correct.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3dbd7376-9f42-47de-8541-5717652e8a84

📥 Commits

Reviewing files that changed from the base of the PR and between f34cf16 and 7d44b3c.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • package.json
  • src/app/page.tsx
  • src/components/home/carousel-mock.tsx
  • src/components/ui/carousel.tsx

Comment thread src/components/home/carousel-mock.tsx Outdated
Comment thread src/components/ui/carousel.tsx
Comment thread src/components/ui/carousel.tsx
Comment thread src/components/ui/carousel.tsx Outdated
Comment thread src/components/ui/carousel.tsx Outdated
@BIA3IA BIA3IA self-assigned this May 12, 2026
@BIA3IA BIA3IA added the priority: high High priority — critical for functionality or release label May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: high High priority — critical for functionality or release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Carousel

1 participant