-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Bump validator from 13.6.0 to 13.7.0 Bumps [validator](https://github.com/validatorjs/validator.js) from 13.6.0 to 13.7.0. - [Release notes](https://github.com/validatorjs/validator.js/releases) - [Changelog](https://github.com/validatorjs/validator.js/blob/master/CHANGELOG.md) - [Commits](validatorjs/validator.js@13.6.0...13.7.0) --- updated-dependencies: - dependency-name: validator dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> * welcoming robots in certain situations * Update known vulnerabilities * trying a different approach in the config * is this how we set vars? * fix var name * test on dev since sandbox does not do what I thought * update trusworks with modal changes * need to learn how to do bash * more bash better * for christmas sake * testing complete * fix bash script var names * updated file uploader modal * updated external resource modal * move logic to circlci config * awaken robot on prod * Update .circleci/config.yml Co-authored-by: Josh Salisbury <[email protected]> * add approvedat migration * update approvedAt on approval * clean up constants, add new one * add approved and created dates to fe landing page * add approved and created date to csv download * remove console statement * fixing tests * fixed modal unit tests * updated my alert test * fixed modal tests for external resource * partial fixes for ui tests * clean up prop type * cleanup UI tests * more unit test fixes for trussworks2 * idle modal test fixes * add backend tests * fixed accessibility issue and added test coverage * add target populations to ar * add approved and created date to ar, table css fixes * fix failing ui test * fix failing tooltip test * unique id value * update known issues * fix axe * Update known vulnerabilities * fix axe again * fix axe issues again * try heading axe fix * update test for axe * update * see if remvoing display none fixes issue * hide headings * limit number of headings * added cusom accordion with heading size prop * added test for accordion * fix capitalizations while we're here * fixes based on Kryss comments * linter fixes * audit vuln Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: unknown <[email protected]> Co-authored-by: Adam Levin <[email protected]> Co-authored-by: Josh Salisbury <[email protected]> Co-authored-by: Adam Levin <[email protected]>
- Loading branch information
1 parent
97a8eae
commit 3fbe926
Showing
20 changed files
with
839 additions
and
526 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import React, { useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export const AccordionItem = ({ | ||
title, | ||
id, | ||
content, | ||
expanded, | ||
className, | ||
handleToggle, | ||
headingSize, | ||
}) => { | ||
const headingClasses = `usa-accordion__heading ${className}`; | ||
const contentClasses = `usa-accordion__content usa-prose ${className}`; | ||
const HeadingSizeTag = `h${headingSize}`; | ||
return ( | ||
<> | ||
<HeadingSizeTag className={headingClasses}> | ||
<button | ||
type="button" | ||
className="usa-accordion__button" | ||
aria-expanded={expanded} | ||
aria-controls={id} | ||
data-testid={`accordionButton_${id}`} | ||
onClick={handleToggle} | ||
> | ||
{title} | ||
</button> | ||
</HeadingSizeTag> | ||
<div | ||
id={id} | ||
data-testid={`accordionItem_${id}`} | ||
className={contentClasses} | ||
hidden={!expanded} | ||
> | ||
{content} | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
AccordionItem.propTypes = { | ||
title: PropTypes.string.isRequired, | ||
content: PropTypes.string.isRequired, | ||
expanded: PropTypes.bool.isRequired, | ||
id: PropTypes.string.isRequired, | ||
className: PropTypes.string, | ||
handleToggle: PropTypes.func, | ||
headingSize: PropTypes.number.isRequired, | ||
}; | ||
|
||
AccordionItem.defaultProps = { | ||
className: '', | ||
handleToggle: () => { }, | ||
}; | ||
|
||
export const Accordion = ({ | ||
bordered, | ||
items, | ||
multiselectable, | ||
headingSize, | ||
}) => { | ||
const [openItems, setOpenState] = useState( | ||
items.filter((i) => !!i.expanded).map((i) => i.id), | ||
); | ||
|
||
const classes = bordered ? 'usa-accordion usa-accordion--bordered' : 'usa-accordion'; | ||
|
||
const toggleItem = (itemId) => { | ||
const newOpenItems = [...openItems]; | ||
const itemIndex = openItems.indexOf(itemId); | ||
const isMultiselectable = multiselectable; | ||
|
||
if (itemIndex > -1) { | ||
newOpenItems.splice(itemIndex, 1); | ||
} else if (isMultiselectable) { | ||
newOpenItems.push(itemId); | ||
} else { | ||
newOpenItems.splice(0, newOpenItems.length); | ||
newOpenItems.push(itemId); | ||
} | ||
setOpenState(newOpenItems); | ||
}; | ||
|
||
return ( | ||
<div | ||
className={classes} | ||
data-testid="accordion" | ||
aria-multiselectable={multiselectable || undefined} | ||
> | ||
{items.map((item) => ( | ||
<AccordionItem | ||
key={`accordionItem_${item.id}`} | ||
title={item.title} | ||
id={item.id} | ||
content={item.content} | ||
className={item.className} | ||
expanded={openItems.indexOf(item.id) > -1} | ||
handleToggle={() => { | ||
toggleItem(item.id); | ||
}} | ||
headingSize={headingSize} | ||
/> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
Accordion.propTypes = { | ||
bordered: PropTypes.bool, | ||
multiselectable: PropTypes.bool, | ||
items: PropTypes.arrayOf(PropTypes.shape(AccordionItem)).isRequired, | ||
headingSize: PropTypes.number, | ||
}; | ||
|
||
Accordion.defaultProps = { | ||
bordered: false, | ||
multiselectable: false, | ||
headingSize: 2, | ||
}; | ||
|
||
export default Accordion; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.