Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Commit

Permalink
fix: improve Accordion behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Rickk137 committed Jul 6, 2022
1 parent f297fc1 commit 2f6e1bf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
14 changes: 12 additions & 2 deletions src/components/Accordion/Accordion.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ export const Primary = Template.bind({});

Primary.args = {
title: 'toggle me',
children:
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
children: (
<>
<br />
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
been the industrys standard dummy text ever since the 1500s, when an unknown printer took a
galley of type and scrambled it to make a type specimen book. It has survived not only five
centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It
was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
passages, and more recently with desktop publishing software like Aldus PageMaker including
versions of Lorem Ipsum.
</>
),
variant: 'dark-blue'
};
16 changes: 8 additions & 8 deletions src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const Accordion: React.FC<AccordionProps> = ({
flat = false,
title,
children,
className,
className = 'ui-p-4 sm:ui-p-4',
variant,
wrapperClassName = ''
}) => {
Expand All @@ -31,9 +31,12 @@ export const Accordion: React.FC<AccordionProps> = ({
return (
<Card className={className} variant={variant} wrapperClassName={wrapperClassName}>
<div
className={clsx('ui-flex ui-justify-between ui-items-center ui-select-none', {
'ui-cursor-default': flat
})}
className={clsx(
'ui-flex ui-outline-none ui-justify-between ui-items-center ui-select-none',
{
'ui-cursor-default': flat
}
)}
role='button'
tabIndex={0}
onClick={toggleIsActive}
Expand Down Expand Up @@ -61,10 +64,7 @@ export const Accordion: React.FC<AccordionProps> = ({
nodeRef={nodeRef}
timeout={300}
>
<div ref={nodeRef}>
<br />
{children}
</div>
<div ref={nodeRef}>{children}</div>
</CSSTransition>
</Card>
);
Expand Down
4 changes: 2 additions & 2 deletions src/styles/_transitions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
.ui-accordion-enter.ui-accordion-enter-active {
opacity: 1;
max-height: 1000px;
transition: max-height 0.6s ease-in-out, opacity 220ms ease-in;
transition: max-height 0.5s ease-in-out, opacity 220ms ease-in;
}
.ui-accordion-exit {
opacity: 1;
Expand All @@ -50,5 +50,5 @@
opacity: 0.01;
overflow: hidden;
max-height: 0;
transition: max-height 0.4s cubic-bezier(0, 1, 0, 1), opacity 120ms ease-in;
transition: max-height 0.3s cubic-bezier(0, 1, 0, 1), opacity 120ms ease-in;
}

0 comments on commit 2f6e1bf

Please sign in to comment.