-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Accordian typescript * Types are green! * Accordian is no more * removed unecessary type
- Loading branch information
Showing
14 changed files
with
345 additions
and
356 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,32 @@ | ||
import React, { forwardRef, useMemo, ReactElement } from 'react' | ||
import createId from 'lodash/uniqueId' | ||
import type { AccordionProps } from './Accordion.types' | ||
|
||
const Accordion = forwardRef< | ||
HTMLDivElement, | ||
AccordionProps & JSX.IntrinsicElements['div'] | ||
>(function Accordion( | ||
{ headerLevel = 'h2', chevronPosition = 'left', children, ...props }, | ||
ref, | ||
) { | ||
const accordionId = useMemo<string>(() => createId('accordion-'), []) | ||
|
||
const AccordionItems = React.Children.map(children, (child, index) => { | ||
return React.cloneElement(child as ReactElement, { | ||
accordionId, | ||
index, | ||
headerLevel, | ||
chevronPosition, | ||
}) | ||
}) | ||
|
||
return ( | ||
<div {...props} ref={ref}> | ||
{AccordionItems} | ||
</div> | ||
) | ||
}) | ||
|
||
Accordion.displayName = 'eds-accordion' | ||
|
||
export { Accordion } |
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,6 @@ | ||
export type AccordionProps = { | ||
/** The header level, i.e. h1, h2, h3 etc. */ | ||
headerLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | ||
/** Which side the chevron should be on */ | ||
chevronPosition?: 'left' | 'right' | ||
} |
Oops, something went wrong.