This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
feat(carousel): adding actionable items into carousel #2271
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
244f89c
adding carousel with actionable items
mituron f7c7e69
improvements to labelling
mituron 1d10412
typo fix
mituron 7e28927
carousel improvement
mituron f9b4d11
prettier
mituron 12e99c0
change the name
mituron 6f3afe8
adressing pr review, adding unit tests
mituron 4253692
adding specification line
mituron 7bd8ce0
fix the test adding carousel as circular
mituron 2f4e0fe
amending changelog
mituron 65aaaa7
Merge branch 'master' into mituron/carousel-focusable-elements
kolaps33 f31c45d
prettier
mituron 22984d4
Merge branch 'mituron/carousel-focusable-elements' of https://github.…
mituron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
135 changes: 135 additions & 0 deletions
135
docs/src/examples/components/Carousel/Variations/CarouselExampleWithFocusableElements.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,135 @@ | ||
import * as React from 'react' | ||
import { Carousel, Image, Flex, Text, Button, Toolbar, Header } from '@fluentui/react' | ||
|
||
const imageAltTags = { | ||
ade: 'Portrait of Ade', | ||
elliot: 'Portrait of Elliot', | ||
kristy: 'Portrait of Kristy', | ||
nan: 'Portrait of Nan', | ||
} | ||
|
||
const tabAriaLabel = { | ||
ade: 'Ade', | ||
elliot: 'Elliot', | ||
kristy: 'Kristy', | ||
nan: 'Nan', | ||
} | ||
|
||
const carouselTextContent = ( | ||
<Text> | ||
<Header as="h3"> Card </Header> | ||
text or any other text 1 , text or any other text 2, text or any other text 3 text or any other | ||
text 4, text or any other text 5, text or any other text 6 | ||
</Text> | ||
) | ||
|
||
const buttonStyles = { margin: '40px 0px 10px 10px' } | ||
const imageStyles = { maxWidth: '70px', maxHeight: '70px', margin: '15px 0px 0px 5px' } | ||
|
||
const carouselToolbarContent = ( | ||
<Toolbar | ||
aria-label="Actions" | ||
styles={{ marginTop: '40px' }} | ||
items={[ | ||
{ | ||
key: 'custom-button-1', | ||
kind: 'custom', | ||
content: <Button content="First" />, | ||
fitted: 'horizontally', | ||
}, | ||
{ | ||
key: 'custom-button-2', | ||
kind: 'custom', | ||
content: <Button content="Second" />, | ||
fitted: 'horizontally', | ||
}, | ||
{ | ||
key: 'custom-button-3', | ||
kind: 'custom', | ||
content: <Button content="Third" />, | ||
fitted: 'horizontally', | ||
}, | ||
]} | ||
/> | ||
) | ||
|
||
const carouselItems = [ | ||
{ | ||
key: 'ade', | ||
id: 'ade', | ||
content: ( | ||
<div> | ||
<Flex gap="gap.medium"> | ||
<Image | ||
styles={imageStyles} | ||
src="public/images/avatar/large/ade.jpg" | ||
fluid | ||
alt={imageAltTags.ade} | ||
/> | ||
{carouselTextContent} | ||
</Flex> | ||
<Button content="Open" styles={buttonStyles} /> | ||
</div> | ||
), | ||
'aria-label': 'Ade card', | ||
}, | ||
{ | ||
key: 'elliot', | ||
id: 'elliot', | ||
content: ( | ||
<div> | ||
<Flex gap="gap.medium"> | ||
<Image | ||
styles={imageStyles} | ||
src="public/images/avatar/large/elliot.jpg" | ||
fluid | ||
alt={imageAltTags.elliot} | ||
/> | ||
{carouselTextContent} | ||
</Flex> | ||
{carouselToolbarContent} | ||
</div> | ||
), | ||
'aria-label': 'Elliot card', | ||
}, | ||
{ | ||
key: 'kristy', | ||
id: 'kristy', | ||
content: ( | ||
<div> | ||
<Flex gap="gap.medium"> | ||
<Image | ||
styles={imageStyles} | ||
src="public/images/avatar/large/kristy.png" | ||
fluid | ||
alt={imageAltTags.kristy} | ||
/> | ||
{carouselTextContent} | ||
</Flex> | ||
<Flex gap="gap.medium" styles={buttonStyles}> | ||
<Button content="Call" /> | ||
<Button content="Video call" /> | ||
</Flex> | ||
</div> | ||
), | ||
'aria-label': 'Kristy card', | ||
}, | ||
] | ||
|
||
const CarouselExample = () => ( | ||
<Carousel | ||
ariaRoleDescription="carousel" | ||
navigation={{ | ||
'aria-label': 'people cards', | ||
items: carouselItems.map((item, index) => ({ | ||
key: item.id, | ||
'aria-label': tabAriaLabel[item.id], | ||
'aria-controls': item.id, | ||
})), | ||
}} | ||
items={carouselItems} | ||
getItemPositionText={(index: number, size: number) => `${index + 1} of ${size}`} | ||
/> | ||
) | ||
|
||
export default CarouselExample |
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
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
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.
Let's add a unit test for this.
It should check that left/right arrows sent to a child of the container (the visible item for instance, or a child of that visible item) should not move the slides.
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.
thanks :) for this catch. Tests added, as well a specification line in the top of file.