-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(carousel): Add Carousel and Carousel Item components (#8995)
**Related Issue:** #6536 ## Summary Once this and any necessary follow up lands, we can plan to deprecate `Tip Manager` and associated components.
- Loading branch information
1 parent
e8478de
commit b1ba428
Showing
58 changed files
with
3,435 additions
and
0 deletions.
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; | ||
} | ||
|
||
.container { | ||
@apply hidden; | ||
inline-size: var(--calcite-container-size-content-fluid); | ||
} | ||
|
||
:host([selected]) .container { | ||
@apply block; | ||
} | ||
|
||
@include base-component(); |
60 changes: 60 additions & 0 deletions
60
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,60 @@ | ||
import { Component, Element, h, Host, Prop, VNode } from "@stencil/core"; | ||
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 { | ||
// -------------------------------------------------------------------------- | ||
// | ||
// Properties | ||
// | ||
// -------------------------------------------------------------------------- | ||
|
||
/** | ||
* Accessible name for the component. | ||
*/ | ||
@Prop() label!: string; | ||
|
||
/** | ||
* When `true`, the component is selected. | ||
*/ | ||
@Prop({ reflect: true }) selected = false; | ||
|
||
// -------------------------------------------------------------------------- | ||
// | ||
// Private Properties | ||
// | ||
// -------------------------------------------------------------------------- | ||
|
||
@Element() el: HTMLCalciteCarouselItemElement; | ||
|
||
private guid = `calcite-carousel-item-${guid()}`; | ||
|
||
// -------------------------------------------------------------------------- | ||
// | ||
// Render Methods | ||
// | ||
// -------------------------------------------------------------------------- | ||
|
||
render(): VNode { | ||
const id = this.el.id || this.guid; | ||
return ( | ||
<Host id={id}> | ||
<div | ||
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.