-
-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add md-carousel component #110
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { html, LitElement, css } from 'lit' | ||
|
|
||
| export class CarouselItem extends LitElement { | ||
| static properties = {} | ||
|
|
||
| constructor() { | ||
| super() | ||
| } | ||
|
Comment on lines
+4
to
+8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| render() { | ||
| return html` | ||
| <div role="listitem" class="item"> | ||
| <slot></slot> | ||
| </div> | ||
| ` | ||
| } | ||
|
|
||
| static styles = css` | ||
| :host { | ||
| display: block; | ||
| scroll-snap-align: start; | ||
| flex-shrink: 0; | ||
| } | ||
| .item { | ||
| display: block; | ||
| border-radius: var(--md-carousel-item-shape, 24px); | ||
| overflow: hidden; | ||
| } | ||
| ` | ||
| } | ||
|
|
||
| customElements.define('md-carousel-item', CarouselItem) | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,41 @@ | ||||||||||
| import { html, LitElement, css } from 'lit' | ||||||||||
|
|
||||||||||
| export class Carousel extends LitElement { | ||||||||||
| static properties = {} | ||||||||||
|
|
||||||||||
| constructor() { | ||||||||||
| super() | ||||||||||
| } | ||||||||||
|
Comment on lines
+4
to
+8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The empty constructor can be removed. Additionally, consider adding an 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"> | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the
Suggested change
|
||||||||||
| <slot></slot> | ||||||||||
| </div> | ||||||||||
| ` | ||||||||||
| } | ||||||||||
|
|
||||||||||
| static styles = css` | ||||||||||
| :host { | ||||||||||
| display: block; | ||||||||||
| } | ||||||||||
| .carousel { | ||||||||||
| display: flex; | ||||||||||
| overflow-x: auto; | ||||||||||
| scroll-snap-type: x mandatory; | ||||||||||
| scrollbar-width: none; /* Firefox */ | ||||||||||
| -ms-overflow-style: none; /* IE and Edge */ | ||||||||||
| gap: 8px; /* Optional gap */ | ||||||||||
| padding: 16px; | ||||||||||
|
Comment on lines
+28
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using hardcoded values for
Suggested change
|
||||||||||
| scroll-behavior: smooth; | ||||||||||
| } | ||||||||||
| .carousel::-webkit-scrollbar { | ||||||||||
| display: none; /* Chrome, Safari and Opera */ | ||||||||||
| } | ||||||||||
| ::slotted(*) { | ||||||||||
| scroll-snap-align: start; | ||||||||||
| } | ||||||||||
| ` | ||||||||||
| } | ||||||||||
|
|
||||||||||
| customElements.define('md-carousel', Carousel) | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The imports for the carousel component are currently interspersed with the button component imports (e.g., between
button.jsandfilled-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 completebuttonsgroup.