Skip to content

Commit

Permalink
docs(PPDSC-2653): remove wrapping divs
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenitsn committed Jan 6, 2023
1 parent fa12244 commit a5eae88
Show file tree
Hide file tree
Showing 14 changed files with 3,700 additions and 4,213 deletions.
408 changes: 190 additions & 218 deletions src/accordion/__tests__/__snapshots__/accordion.test.tsx.snap

Large diffs are not rendered by default.

48 changes: 23 additions & 25 deletions src/accordion/accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {useEffect, useRef} from 'react';
import {CSSTransition} from 'react-transition-group';
import composeRefs from '@seznam/compose-react-refs';
import {withOwnTheme} from '../utils/with-own-theme';
import {
StyledAccordionButton,
Expand All @@ -24,14 +25,12 @@ import {getRefScrollHeight} from './utils';
import {EventTrigger, useInstrumentation} from '../instrumentation';

// Based on https://www.w3schools.com/howto/howto_js_accordion.asp
const MaxHeightTransitionPanel = ({
expanded,
children,
overrides,
className,
}: Pick<AccordionProps, 'expanded' | 'children' | 'overrides'> & {
className: string;
}) => {
const MaxHeightTransitionPanel = React.forwardRef<
HTMLDivElement,
Pick<AccordionProps, 'expanded' | 'children' | 'overrides'> & {
className: string;
}
>(({expanded, children, overrides, className}, transitionRef) => {
const ref = useRef<HTMLDivElement>(null);
const [width] = useResizeObserver(ref);
useEffect(() => {
Expand All @@ -44,15 +43,15 @@ const MaxHeightTransitionPanel = ({
return (
<StyledPanelTransitionContainer
data-testid="panel-transition-container"
ref={ref}
ref={composeRefs(transitionRef, ref)}
expanded={expanded}
overrides={overrides}
className={className}
>
{children}
</StyledPanelTransitionContainer>
);
};
});

const DefaultIcon = ({expanded, overrides}: AccordionIconProps) =>
expanded ? (
Expand Down Expand Up @@ -151,24 +150,23 @@ const ThemelessAccordion = React.forwardRef<HTMLDivElement, AccordionProps>(
classNames="nk-accordion"
>
{(state: string) => (
<div ref={cssTransitionNodeRef}>
<MaxHeightTransitionPanel
className={getTransitionClassName('nk-accordion', state)}
<MaxHeightTransitionPanel
className={getTransitionClassName('nk-accordion', state)}
expanded={expanded}
overrides={overrides}
ref={cssTransitionNodeRef}
>
<StyledPanel
aria-labelledby={ariaLabelledById}
id={ariaControlsId}
data-testid="accordion-content"
role="region"
expanded={expanded}
overrides={overrides}
>
<StyledPanel
aria-labelledby={ariaLabelledById}
id={ariaControlsId}
data-testid="accordion-content"
role="region"
expanded={expanded}
overrides={overrides}
>
{children}
</StyledPanel>
</MaxHeightTransitionPanel>
</div>
{children}
</StyledPanel>
</MaxHeightTransitionPanel>
)}
</CSSTransition>
</div>
Expand Down
Loading

0 comments on commit a5eae88

Please sign in to comment.