-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat(carousel): Add Carousel and Carousel Item components #8995
Merged
macandcheese
merged 77 commits into
main
from
macandcheese/6536-add-new-carousel-component
Apr 30, 2024
Merged
Changes from 53 commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
2529282
feat(carousel): Add Carousel and Carousel Item components
macandcheese 14565bf
Update Stencil config
macandcheese 16e1846
Clean up
macandcheese bb61196
Clean up stories
macandcheese ecba582
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 4202fd7
Add `tooltipsDisabled` property
macandcheese 2cf3c34
Clean up
macandcheese ab95eb4
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 0172cbc
Add `arrowType`, `controlApperance`, `label` properties
macandcheese 7f9ea62
Clean up
macandcheese e957363
Clean up
macandcheese 6d3f778
Remove `control-appearance` property
macandcheese 7666e9a
Clean up
macandcheese 280c955
Pr feedback
macandcheese 64ef0d7
Pr feedback
macandcheese 8792610
Clean up
macandcheese e36ba3e
Fix tests
macandcheese f8859ce
Update a11y
macandcheese 14c37e8
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 7b27dd4
Update keyboard navigation
macandcheese e4f8cf5
Add tokens
macandcheese 60523da
Clean up
macandcheese 5e01998
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 232aea7
Pr feedback
macandcheese c5b8f1c
Pr feedback
macandcheese a356ff5
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 1acd4b7
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese c8083b3
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 263fc0f
Pr feedback
macandcheese 8985835
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese b8cc6f8
Clean up
macandcheese 7ffd224
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese dd41da3
Clean up
macandcheese 332ad7a
Add `rotation` functionality
macandcheese 5d298ff
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 8193945
Clean up
macandcheese bd3fe0b
Add swipe support
macandcheese 63fafd2
Revert unrelated changes
macandcheese c143e53
Clean up
macandcheese 3ee9203
Update tests
macandcheese 6680d1a
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese c484694
Update `rotation` functionality
macandcheese 2876f66
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 192c400
Clean up
macandcheese c78fe66
Add `rotationDuration` property
macandcheese 72b889b
Clean up
macandcheese 67517e9
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 2dfe6e6
Pause rotation on focus and hover, clean up
macandcheese 2ee3d67
Clean up
macandcheese ba669a0
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 00ec116
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese dcdfcff
Localize a11y strings
macandcheese 62f161f
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese b234d63
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese c5e648d
Pr feedback
macandcheese f6366cb
Pr feedback
macandcheese 6fdc62e
Pr feedback
macandcheese fc7fdf7
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 18f9bc5
Clean up
macandcheese bc696d2
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 30e71a9
Clean up
macandcheese 83e11c4
Pr feedback
macandcheese 33f7914
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 79e9e9f
Pr feedback
macandcheese 000c6b0
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 25c38d9
Pr feedback
macandcheese ba3842e
Pr feedback
macandcheese a41cee9
Pr feedback
macandcheese db346aa
Clean up
macandcheese 683c1d0
Add method test
macandcheese d3a5df4
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese 37424bb
Clean Up
macandcheese 6ceea9d
Clean up
macandcheese 93f8799
Merge branch 'main' into macandcheese/6536-add-new-carousel-component
macandcheese aeade1d
Clean up
macandcheese 410141d
Clean up
macandcheese 3b3576f
Clean up
macandcheese File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
packages/calcite-components/src/components/carousel-item/carousel-item.e2e.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { accessible, hidden, renders } from "../../tests/commonTests"; | ||
|
||
describe("calcite-carousel-item", () => { | ||
describe("renders", () => { | ||
renders("<calcite-carousel-item selected></calcite-carousel-item>", { | ||
display: "flex", | ||
}); | ||
}); | ||
|
||
describe("honors hidden attribute", () => { | ||
hidden("calcite-carousel-item"); | ||
}); | ||
|
||
describe("accessible", () => { | ||
accessible("calcite-carousel-item"); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
packages/calcite-components/src/components/carousel-item/carousel-item.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
:host { | ||
@apply flex; | ||
} | ||
|
||
:host([selected]) .container { | ||
display: block; | ||
} | ||
|
||
.container { | ||
macandcheese marked this conversation as resolved.
Show resolved
Hide resolved
|
||
display: none; | ||
inline-size: var(--calcite-container-size-content-fluid); | ||
} | ||
|
||
@include base-component(); |
79 changes: 79 additions & 0 deletions
79
packages/calcite-components/src/components/carousel-item/carousel-item.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { Component, Element, h, Host, Prop, VNode } from "@stencil/core"; | ||
import { | ||
LoadableComponent, | ||
setComponentLoaded, | ||
setUpLoadableComponent, | ||
} from "../../utils/loadable"; | ||
import { guid } from "../../utils/guid"; | ||
import { CSS } from "./resources"; | ||
|
||
/** | ||
* @slot - A slot for adding content. | ||
*/ | ||
@Component({ | ||
tag: "calcite-carousel-item", | ||
styleUrl: "carousel-item.scss", | ||
shadow: true, | ||
}) | ||
export class CarouselItem implements LoadableComponent { | ||
// -------------------------------------------------------------------------- | ||
// | ||
// Properties | ||
// | ||
// -------------------------------------------------------------------------- | ||
|
||
/** | ||
* When `true`, the component is selected. | ||
*/ | ||
@Prop({ reflect: true }) selected = false; | ||
|
||
/** | ||
* Accessible name for the component. | ||
*/ | ||
@Prop() label!: string; | ||
macandcheese marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// -------------------------------------------------------------------------- | ||
// | ||
// Private Properties | ||
// | ||
// -------------------------------------------------------------------------- | ||
|
||
@Element() el: HTMLCalciteCarouselItemElement; | ||
|
||
private guid = `calcite-carousel-item-${guid()}`; | ||
|
||
// -------------------------------------------------------------------------- | ||
// | ||
// Lifecycle | ||
// | ||
// -------------------------------------------------------------------------- | ||
|
||
componentDidLoad(): void { | ||
setComponentLoaded(this); | ||
macandcheese marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
async componentWillLoad(): Promise<void> { | ||
setUpLoadableComponent(this); | ||
} | ||
|
||
// -------------------------------------------------------------------------- | ||
// | ||
// Render Methods | ||
// | ||
// -------------------------------------------------------------------------- | ||
|
||
render(): VNode { | ||
const id = this.el.id || this.guid; | ||
driskull marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
<Host id={id}> | ||
<div | ||
macandcheese marked this conversation as resolved.
Show resolved
Hide resolved
|
||
aria-label={this.label} | ||
class={{ [CSS.container]: true, [CSS.selected]: this.selected }} | ||
role="tabpanel" | ||
> | ||
<slot /> | ||
</div> | ||
</Host> | ||
); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
packages/calcite-components/src/components/carousel-item/readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# calcite-carousel-item | ||
|
||
<!-- Auto Generated Below --> | ||
|
||
## Properties | ||
|
||
| Property | Attribute | Description | Type | Default | | ||
| -------------------- | ---------- | ---------------------------------------------------------------------------------------- | --------------------- | ----------- | | ||
| `active` | `active` | When `true`, the component is active if it has a parent `calcite-carousel`. | `boolean` | `false` | | ||
| `disabled` | `disabled` | When `true`, interaction is prevented and the component is displayed with lower opacity. | `boolean` | `false` | | ||
| `label` *(required)* | `label` | The component label text. | `string` | `undefined` | | ||
| `messageOverrides` | -- | Use this property to override individual strings used by the component. | `{ close?: string; }` | `undefined` | | ||
|
||
## Methods | ||
|
||
### `setFocus() => Promise<void>` | ||
|
||
Sets focus on the component. | ||
|
||
#### Returns | ||
|
||
Type: `Promise<void>` | ||
|
||
## Slots | ||
|
||
| Slot | Description | | ||
| ---- | -------------------------- | | ||
| | A slot for adding content. | | ||
|
||
--- | ||
|
||
*Built with [StencilJS](https://stenciljs.com/)* |
4 changes: 4 additions & 0 deletions
4
packages/calcite-components/src/components/carousel-item/resources.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const CSS = { | ||
container: "container", | ||
selected: "selected", | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/calcite-components/src/components/carousel/assets/carousel/t9n/messages.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"previous": "Previous", | ||
"next": "Next", | ||
"play": "Play", | ||
"pause": "Pause", | ||
"carousel": "Carousel", | ||
"carouselItemProgress": "Progress indicator for Carousel Item" | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/calcite-components/src/components/carousel/assets/carousel/t9n/messages_ar.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"previous": "السابق", | ||
"next": "التالي", | ||
"play": "Play", | ||
"pause": "Pause", | ||
"carousel": "Carousel", | ||
"carouselItemProgress": "Progress indicator for Carousel Item" | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should
carousel
be handling the visibility of items instead? I find it odd that a component would render invisible by default. cc @driskullThere 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.
I updated this to match Tab's css rules, can change if needed.
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.
Let's move forward with this since there's already precedent. We can discuss hidden-by-default rules and make any adjustments in 3.x or 4.x. Impact might be low since item/child components aren't expected to be used standalone.