-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Accordion): added toggle alignment functionality (#9877)
* feat(Accordion): added toggle alignment functionality * Updated prop name and description
- Loading branch information
1 parent
2ae9642
commit 58e0071
Showing
7 changed files
with
191 additions
and
24 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
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
107 changes: 107 additions & 0 deletions
107
packages/react-core/src/components/Accordion/examples/AccordionToggleIconAtStart.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,107 @@ | ||
import React from 'react'; | ||
import { Accordion, AccordionItem, AccordionContent, AccordionToggle } from '@patternfly/react-core'; | ||
|
||
export const AccordionToggleIconAtStart: React.FunctionComponent = () => { | ||
const [expanded, setExpanded] = React.useState('start-toggle-toggle2'); | ||
|
||
const onToggle = (id: string) => { | ||
if (id === expanded) { | ||
setExpanded(''); | ||
} else { | ||
setExpanded(id); | ||
} | ||
}; | ||
|
||
return ( | ||
<Accordion togglePosition="start"> | ||
<AccordionItem> | ||
<AccordionToggle | ||
onClick={() => { | ||
onToggle('start-toggle-toggle1'); | ||
}} | ||
isExpanded={expanded === 'start-toggle-toggle1'} | ||
id="start-toggle-toggle1" | ||
> | ||
Item one | ||
</AccordionToggle> | ||
<AccordionContent id="start-toggle-expand1" isHidden={expanded !== 'start-toggle-toggle1'}> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et | ||
dolore magna aliqua. | ||
</p> | ||
</AccordionContent> | ||
</AccordionItem> | ||
|
||
<AccordionItem> | ||
<AccordionToggle | ||
onClick={() => { | ||
onToggle('start-toggle-toggle2'); | ||
}} | ||
isExpanded={expanded === 'start-toggle-toggle2'} | ||
id="start-toggle-toggle2" | ||
> | ||
Item two | ||
</AccordionToggle> | ||
<AccordionContent id="start-toggle-expand2" isHidden={expanded !== 'start-toggle-toggle2'}> | ||
<p> | ||
Vivamus et tortor sed arcu congue vehicula eget et diam. Praesent nec dictum lorem. Aliquam id diam | ||
ultrices, faucibus erat id, maximus nunc. | ||
</p> | ||
</AccordionContent> | ||
</AccordionItem> | ||
|
||
<AccordionItem> | ||
<AccordionToggle | ||
onClick={() => { | ||
onToggle('start-toggle-toggle3'); | ||
}} | ||
isExpanded={expanded === 'start-toggle-toggle3'} | ||
id="start-toggle-toggle3" | ||
> | ||
Item three | ||
</AccordionToggle> | ||
<AccordionContent id="start-toggle-expand3" isHidden={expanded !== 'start-toggle-toggle3'}> | ||
<p>Morbi vitae urna quis nunc convallis hendrerit. Aliquam congue orci quis ultricies tempus.</p> | ||
</AccordionContent> | ||
</AccordionItem> | ||
|
||
<AccordionItem> | ||
<AccordionToggle | ||
onClick={() => { | ||
onToggle('start-toggle-toggle4'); | ||
}} | ||
isExpanded={expanded === 'start-toggle-toggle4'} | ||
id="start-toggle-toggle4" | ||
> | ||
Item four | ||
</AccordionToggle> | ||
<AccordionContent id="start-toggle-expand4" isHidden={expanded !== 'start-toggle-toggle4'}> | ||
<p> | ||
Donec vel posuere orci. Phasellus quis tortor a ex hendrerit efficitur. Aliquam lacinia ligula pharetra, | ||
sagittis ex ut, pellentesque diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere | ||
cubilia Curae; Vestibulum ultricies nulla nibh. Etiam vel dui fermentum ligula ullamcorper eleifend non quis | ||
tortor. Morbi tempus ornare tempus. Orci varius natoque penatibus et magnis dis parturient montes, nascetur | ||
ridiculus mus. Mauris et velit neque. Donec ultricies condimentum mauris, pellentesque imperdiet libero | ||
convallis convallis. Aliquam erat volutpat. Donec rutrum semper tempus. Proin dictum imperdiet nibh, quis | ||
dapibus nulla. Integer sed tincidunt lectus, sit amet auctor eros. | ||
</p> | ||
</AccordionContent> | ||
</AccordionItem> | ||
|
||
<AccordionItem> | ||
<AccordionToggle | ||
onClick={() => { | ||
onToggle('start-toggle-toggle5'); | ||
}} | ||
isExpanded={expanded === 'start-toggle-toggle5'} | ||
id="start-toggle-toggle5" | ||
> | ||
Item five | ||
</AccordionToggle> | ||
<AccordionContent id="start-toggle-expand5" isHidden={expanded !== 'start-toggle-toggle5'}> | ||
<p>Vivamus finibus dictum ex id ultrices. Mauris dictum neque a iaculis blandit.</p> | ||
</AccordionContent> | ||
</AccordionItem> | ||
</Accordion> | ||
); | ||
}; |