feat: add md-carousel component#110
Conversation
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>
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
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.
| import './carousel/carousel.js' | ||
| import './carousel/carousel-item.js' |
There was a problem hiding this comment.
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.
| static properties = {} | ||
|
|
||
| constructor() { | ||
| super() | ||
| } |
| static properties = {} | ||
|
|
||
| constructor() { | ||
| super() | ||
| } |
There was a problem hiding this comment.
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';|
|
||
| render() { | ||
| return html` | ||
| <div class="carousel" role="list" aria-label="Carousel"> |
There was a problem hiding this comment.
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.
| <div class="carousel" role="list" aria-label="Carousel"> | |
| <div class="carousel" role="list" aria-label=${this.ariaLabel || 'Carousel'}> |
| gap: 8px; /* Optional gap */ | ||
| padding: 16px; |
There was a problem hiding this comment.
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.
| gap: 8px; /* Optional gap */ | |
| padding: 16px; | |
| gap: var(--md-carousel-gap, 8px); | |
| padding: var(--md-carousel-padding, 16px); |
Adds the Material 3 image carousel component. Includes the
md-carouselandmd-carousel-itemwrappers, 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