Skip to content

feat: add md-carousel component#110

Draft
treeder wants to merge 1 commit into
mainfrom
feat-carousel-15402652083068191811
Draft

feat: add md-carousel component#110
treeder wants to merge 1 commit into
mainfrom
feat-carousel-15402652083068191811

Conversation

@treeder
Copy link
Copy Markdown
Member

@treeder treeder commented May 12, 2026

Adds the Material 3 image carousel component. Includes the md-carousel and md-carousel-item wrappers, powered by standard native CSS Scroll Snapping (scroll-snap-type / scroll-snap-align) and Lit properties, properly exposed in the module root aliases.


PR created automatically by Jules for task 15402652083068191811 started by @treeder

Creates an initial implementation for `md-carousel` and `md-carousel-item` using `lit` and CSS Scroll Snapping. Components have been exported to `all.js` and `common.js` and are showcased in the standard demo application.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new Carousel component, including md-carousel and md-carousel-item elements, with support for horizontal scrolling and scroll snapping. The feedback suggests several improvements for better maintainability and accessibility: removing empty constructors and properties to reduce boilerplate, using CSS custom properties for gap and padding to allow for easier theming, and implementing an ariaLabel property to support localized labels. Additionally, it is recommended to reorder the imports in all.js to keep them grouped by component type.

Comment thread all.js
Comment on lines +9 to +10
import './carousel/carousel.js'
import './carousel/carousel-item.js'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The imports for the carousel component are currently interspersed with the button component imports (e.g., between button.js and filled-tonal-button.js). It is recommended to group imports by component type to maintain a clean and organized structure. Consider moving these imports after the complete buttons group.

Comment thread carousel/carousel-item.js
Comment on lines +4 to +8
static properties = {}

constructor() {
super()
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The static properties object and the constructor are currently empty and do not contain any logic. They can be removed to simplify the component definition and reduce boilerplate.

Comment thread carousel/carousel.js
Comment on lines +4 to +8
static properties = {}

constructor() {
super()
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The empty constructor can be removed. Additionally, consider adding an ariaLabel property to allow users to provide a localized or custom label for the carousel, which is important for accessibility and internationalization.

  static properties = {
    /**
     * The aria-label of the carousel.
     */
    ariaLabel: {attribute: 'aria-label'},
  };

  ariaLabel = 'Carousel';

Comment thread carousel/carousel.js

render() {
return html`
<div class="carousel" role="list" aria-label="Carousel">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Use the ariaLabel property to set the aria-label attribute on the internal carousel container. This allows the component to support dynamic and localized labels instead of a hardcoded string.

Suggested change
<div class="carousel" role="list" aria-label="Carousel">
<div class="carousel" role="list" aria-label=${this.ariaLabel || 'Carousel'}>

Comment thread carousel/carousel.js
Comment on lines +28 to +29
gap: 8px; /* Optional gap */
padding: 16px;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Using hardcoded values for gap and padding limits the flexibility of the component. It is better to use CSS custom properties to allow for easier theming and consistency with other Material components in the project.

Suggested change
gap: 8px; /* Optional gap */
padding: 16px;
gap: var(--md-carousel-gap, 8px);
padding: var(--md-carousel-padding, 16px);

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.

1 participant