-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
172 additions
and
41 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
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
88 changes: 88 additions & 0 deletions
88
ui/stories/6. Web Components Or Custom Elements/WebUI Carousel/WebUICarousel.js
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,88 @@ | ||
const style = ` | ||
<style> | ||
.carousel > * { | ||
background: hsl(51, 100%, 45%, 15%); | ||
border: 1px dashed hsl(51, 100%, 45%); | ||
padding: 5rem; | ||
} | ||
</style> | ||
`; | ||
|
||
export const WebUICarouselHtml = (args) => ` | ||
${style} | ||
<webui-carousel | ||
${args.showSlideCount === true ? 'data-slide-count="true"' : ''} | ||
${args.showSlideCountPips === true ? 'data-slide-count-pips="true"' : ''} | ||
${args.showPrevNextButtons === true ? 'data-prev-next-buttons="true"' : ''} | ||
> | ||
<section class="carousel-wrapper" aria-label="[meaningful label for carousel]" | ||
> | ||
<ul | ||
class="carousel ${args.makeFullwidth === true ? 'carousel--fullwidth' : ''}" | ||
tabindex="0" | ||
> | ||
<li class="carousel__slide"> | ||
Slide 1<br>More content<br>Slides have equal height | ||
<br><br> | ||
<a | ||
href="#" | ||
class="button button--text button--primary" | ||
> | ||
Button | ||
</a> | ||
</li> | ||
<li class="carousel__slide"> | ||
Slide 2 | ||
<br><br> | ||
<a | ||
href="#" | ||
class="button button--text button--primary" | ||
> | ||
Button | ||
</a> | ||
</li> | ||
<li class="carousel__slide"> | ||
Slide 3 | ||
<br><br> | ||
<a | ||
href="#" | ||
class="button button--text button--primary" | ||
> | ||
Button | ||
</a> | ||
</li> | ||
<li class="carousel__slide"> | ||
Slide 4 | ||
<br><br> | ||
<a | ||
href="#" | ||
class="button button--text button--primary" | ||
> | ||
Button | ||
</a> | ||
</li> | ||
<li class="carousel__slide"> | ||
Slide 5 | ||
<br><br> | ||
<a | ||
href="#" | ||
class="button button--text button--primary" | ||
> | ||
Button | ||
</a> | ||
</li> | ||
<li class="carousel__slide"> | ||
Slide 6 | ||
<br><br> | ||
<a | ||
href="#" | ||
class="button button--text button--primary" | ||
> | ||
Button | ||
</a> | ||
</li> | ||
</ul> | ||
<p class="carousel-instructions">Scroll or use your arrow keys for more</p> | ||
</section> | ||
</webui-carousel> | ||
`; |
24 changes: 24 additions & 0 deletions
24
ui/stories/6. Web Components Or Custom Elements/WebUI Carousel/WebUICarousel.mdx
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,24 @@ | ||
import { Meta, Canvas, Controls } from '@storybook/blocks'; | ||
import * as WebUICarousel from './WebUICarousel.stories'; | ||
|
||
<Meta of={WebUICarousel} /> | ||
|
||
# `<webui-carousel>` | ||
- This is an enhancement of the [default CSS carousel](/story/components-carousel--carousel) - showing a slide count, PREV and NEXT buttons, etc. | ||
- Native scrolling with `LEFT|RIGHT` arrow keys is overridden, allowing JavaScript to correctly update the slide count when using arrow keys. | ||
- Each slide has an `aria-label`, indicating the current slide number and the total number of slides. | ||
- When PREV and NEXT buttons are shown, keyboard `focus` is modified such that **only visible slides are focusable**. | ||
|
||
## Required and optional HTML or `data-` attributes | ||
|
||
Attribute | Behaviour | ||
--- | --- | ||
`data-slide-count="true"` | Optional. Displays slide count & current slide. | ||
`data-slide-count-pips="true"` | Optional. Displays slide count & current slide as pips instead of text. | ||
`data-prev-next-buttons="true"` | Optional. Displays PREV and NEXT slide buttons. | ||
|
||
## TODO | ||
- Update counter with touch/swipe events? | ||
|
||
<Canvas of={WebUICarousel.WebUICarousel} /> | ||
<Controls of={WebUICarousel.WebUICarousel} /> |
21 changes: 21 additions & 0 deletions
21
ui/stories/6. Web Components Or Custom Elements/WebUI Carousel/WebUICarousel.stories.js
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,21 @@ | ||
import { WebUICarouselHtml } from './WebUICarousel'; | ||
|
||
export default { | ||
title: 'Web Components Or Custom Elements/<webui-carousel>', | ||
parameters: { | ||
status: { | ||
type: 'stable', | ||
}, | ||
}, | ||
argTypes: { | ||
makeFullwidth: { control: 'boolean' }, | ||
showSlideCount: { control: 'boolean' }, | ||
showSlideCountPips: { control: 'boolean' }, | ||
showPrevNextButtons: { control: 'boolean' }, | ||
}, | ||
}; | ||
|
||
export const WebUICarousel = { | ||
render: (args) => WebUICarouselHtml(args), | ||
}; | ||
WebUICarousel.storyName = '<webui-carousel>'; |