Skip to content

feat(ui): adding carousel component#399

Merged
lukasz-hycom merged 8 commits intomainfrom
feature/carousel-component
Nov 21, 2025
Merged

feat(ui): adding carousel component#399
lukasz-hycom merged 8 commits intomainfrom
feature/carousel-component

Conversation

@lukasz-hycom
Copy link
Copy Markdown
Contributor

@lukasz-hycom lukasz-hycom commented Nov 20, 2025

What does this PR do?

  • adding Carousel component

Key Changes

  • Adding new Carousel component based on Swiper.js library

Summary by CodeRabbit

  • New Features

    • Added a Carousel component with configurable slides, navigation & pagination, autoplay, looping, responsive breakpoints, custom start index, and swiping controls.
  • Documentation

    • Added Storybook stories demonstrating multiple carousel configurations, responsive behavior, autoplay, looping, start index, and no-swiping selector with interactive examples.
  • Chores

    • Updated package manifest to add the carousel runtime dependency, tidy devDependencies, and adjust dependency ordering.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown

vercel Bot commented Nov 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
o2s-docs Skipped Skipped Nov 20, 2025 1:41pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Nov 20, 2025

Walkthrough

Adds a new Swiper-based Carousel component with types and re-exports, Storybook stories demonstrating many configurations, and updates packages/ui/package.json to add swiper and adjust a devDependency ordering.

Changes

Cohort / File(s) Summary
Package configuration
packages/ui/package.json
Added dependency swiper and reordered/removed duplicate @types/throttle-debounce in devDependencies (manifest-only changes)
Carousel implementation & types
packages/ui/src/components/Carousel/Carousel.tsx, packages/ui/src/components/Carousel/Carousel.types.ts, packages/ui/src/components/Carousel/index.ts
New Carousel React component using Swiper; composes modules (A11y, Keyboard, conditional Navigation/Pagination, plus extra modules), forwards Swiper props, supports slides array, starting index and noSwipingSelector; exports Carousel and CarouselProps
Storybook
packages/ui/src/components/Carousel/Carousel.stories.tsx
New Storybook stories exercising default, without navigation/pagination, multiple slidesPerView, responsive breakpoints, autoplay, loop, starting index, and no-swiping selector
Changeset
.changeset/happy-ducks-occur.md
New changeset declaring a minor version bump for the @o2s/ui package with description "Adding new Carousel component."

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Consumer
    participant Carousel
    participant Swiper
    participant Modules

    Consumer->>Carousel: pass props (slides, showNavigation, showPagination, startingSlideIndex, noSwipingSelector, modules, ...)
    Carousel->>Modules: assemble default modules (A11y, Keyboard) + conditional (Navigation, Pagination) + extra modules
    Carousel->>Swiper: initialize with composed modules, props, startingSlideIndex
    Swiper->>Swiper: manage behavior (keyboard onlyInViewport, loop, autoplay, pagination/nav)
    Carousel->>Carousel: render slides as SwiperSlide nodes
    Swiper->>Consumer: interactive carousel UI rendered
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Focus review on:
    • Carousel.tsx — module composition, conditional inclusion of Navigation/Pagination, prop forwarding to Swiper.
    • Carousel.types.ts — correct extension/omission of SwiperProps and typings for new props (slides, startingSlideIndex, noSwipingSelector).
    • Carousel.stories.tsx — correctness of story args (Autoplay module inclusion, breakpoints, responsive behavior).
    • package.json — ensure swiper version and typings align with the code.

Poem

🐰
I hop on slides with nimble feet,
Through Swiper lanes both fast and neat,
Stories spin and autoplay,
Controls and loops that laugh and play,
A rabbit cheers — behold the feat!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete, missing several required template sections including Related Ticket(s), detailed Key Changes explanation, How to test instructions, and Media. Complete the PR description by adding Related Ticket(s), expanding Key Changes with implementation details and side effects, providing step-by-step testing instructions, and including any relevant media.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a new Carousel component to the UI package.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/carousel-component

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8e15f0 and 71282ad.

📒 Files selected for processing (1)
  • .changeset/happy-ducks-occur.md (1 hunks)
🔇 Additional comments (1)
.changeset/happy-ducks-occur.md (1)

1-5: Changeset format looks good.

The changeset file follows the correct Changesets convention with valid YAML frontmatter, appropriate minor version bump for the new component, and a clear changelog message.


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

🧹 Nitpick comments (3)
packages/ui/src/components/Carousel/Carousel.types.ts (1)

1-11: CarouselProps shape looks good; consider minor typing polish

This props interface cleanly wraps SwiperProps while exposing the extra carousel options. A couple of optional tweaks you might consider:

  • Make slides ReadonlyArray<React.ReactNode> so callers can safely pass both mutable and readonly arrays while signalling you won’t mutate them.
  • Since modules and initialSlide are important to how the wrapper behaves in Carousel.tsx, you might explicitly override them here (e.g. modules?: SwiperProps['modules'], or Omit<SwiperProps, 'children' | 'initialSlide'>) so the generated/IDE docs make the intended usage and precedence clearer.

These are non-blocking; the current type is perfectly usable.

packages/ui/src/components/Carousel/Carousel.tsx (1)

1-48: Solid Swiper wrapper; watch prop precedence and configuration overlap

The implementation looks correct and matches Swiper’s React API; keyboard/a11y modules by default and the conditional Navigation/Pagination modules are a nice touch.

A few small, mostly optional points:

  • startingSlideIndex vs initialSlide precedence
    Because ...swiperProps is spread last, any consumer-provided initialSlide will silently override startingSlideIndex. If you intend startingSlideIndex to be the single source of truth, consider omitting initialSlide from CarouselProps (e.g. Omit<SwiperProps, 'children' | 'initialSlide'>) so TS prevents the conflicting prop.

  • Modules duplication
    allModules always includes A11y and Keyboard, then conditionally Navigation/Pagination, then any user-supplied modules. If a caller also adds Navigation/Pagination in modules, they’ll get duplicates. Swiper copes with this, but you may want to document that modules should not repeat those, or defensively new Set([...]) the list if you ever run into side effects.

  • CSS import location
    Importing Swiper CSS inside the component file is convenient but makes this module have side effects. That’s fine for an app-level UI package, but if you ever care about stricter tree‑shaking or giving host apps control over CSS loading, an alternative is to re-export a globals.css/theme entry and document that consumers must import it once.

None of these are blockers; behavior as written is coherent.

packages/ui/src/components/Carousel/Carousel.stories.tsx (1)

1-174: Story coverage is strong; only minor Storybook polish possible

These stories do a nice job exercising the full Carousel API (navigation, pagination, responsiveness, autoplay, looping, starting index, noSwipingSelector), which will be very helpful for both testing and documentation.

A couple of non-blocking nits:

  • The key props on <SampleSlide> elements are redundant since Carousel remaps slides into <SwiperSlide key={index}> internally; you can drop them in the story data if you like.
  • For SampleSlide, you could move the fixed height from inline style into Tailwind classes or a small CSS helper for consistency with the rest of the design system, though for Storybook-only content this is more style than substance.

Functionally, everything looks aligned with the Swiper API (including modules: [Autoplay] and the autoplay options).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8c25eae and b202225.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • packages/ui/package.json (2 hunks)
  • packages/ui/src/components/Carousel/Carousel.stories.tsx (1 hunks)
  • packages/ui/src/components/Carousel/Carousel.tsx (1 hunks)
  • packages/ui/src/components/Carousel/Carousel.types.ts (1 hunks)
  • packages/ui/src/components/Carousel/index.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
packages/ui/src/components/Carousel/Carousel.types.ts (2)
packages/ui/src/components/Carousel/index.ts (1)
  • CarouselProps (2-2)
packages/integrations/strapi-cms/generated/strapi.ts (1)
  • Omit (14-14)
packages/ui/src/components/Carousel/Carousel.stories.tsx (1)
packages/ui/src/components/Carousel/Carousel.tsx (1)
  • Carousel (14-48)
packages/ui/src/components/Carousel/Carousel.tsx (3)
packages/ui/src/components/Carousel/index.ts (2)
  • Carousel (1-1)
  • CarouselProps (2-2)
packages/ui/src/components/Carousel/Carousel.types.ts (1)
  • CarouselProps (4-11)
packages/ui/src/lib/utils.ts (1)
  • cn (5-7)
🪛 GitHub Actions: Preview Deployment
packages/ui/package.json

[error] 1-1: npm ci failed: lockfile and package.json are out of sync. Run 'npm install' to update the lockfile before continuing. Exit code 1.

🔇 Additional comments (2)
packages/ui/src/components/Carousel/index.ts (1)

1-2: Re-exports correctly expose the Carousel public API

Re-exporting both the component and its props from the local barrel keeps consumers on a single import path and matches the underlying named exports.

packages/ui/package.json (1)

31-74: Dependencies align correctly; lockfile appears synchronized

The added/updated entries (@types/throttle-debounce, typescript@^5.9.3, react-day-picker, swiper@^12.0.3) are sound and consistent with the new Carousel feature. Package versions already align across the monorepo (TypeScript ^5.9.3 is used in ~40+ packages; Swiper only in packages/ui).

No action required — the lockfile is present and synchronized with package.json. Swiper 12.0.3 and TypeScript 5.9.3 are compatible with standard tsconfig settings.

Likely an incorrect or invalid review comment.

Copy link
Copy Markdown
Collaborator

@marcinkrasowski marcinkrasowski left a comment

Choose a reason for hiding this comment

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

please run npm run changeset so that the changelog in the ui package is updated with the new component

@lukasz-hycom lukasz-hycom merged commit 51b17ed into main Nov 21, 2025
6 of 7 checks passed
@lukasz-hycom lukasz-hycom deleted the feature/carousel-component branch November 21, 2025 10:51
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