Skip to content

Commit aeb03df

Browse files
author
Tania Markina
committed
animations + button update
1 parent a8170dd commit aeb03df

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

app/components/shared/ui/collapsible-card.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { cn } from '@shared/utils';
22
import React from 'react';
3+
import { ChevronDown } from 'react-feather';
34

45
type CollapsibleCardProps = {
56
title: React.ReactNode;
@@ -22,14 +23,32 @@ export const CollapsibleCard = React.forwardRef<HTMLDivElement, CollapsibleCardP
2223
{collapsible && (
2324
<button
2425
aria-expanded={expanded}
25-
className={cn('btn btn-sm d-flex', expanded ? 'btn-black active' : 'btn-white')}
26+
aria-label={expanded ? 'Collapse' : 'Expand'}
27+
className="btn btn-sm btn-white d-flex align-items-center justify-content-center e-py-[5.3px] e-transition-colors"
2628
onClick={() => setExpanded(current => !current)}
2729
>
28-
{expanded ? 'Collapse' : 'Expand'}
30+
<ChevronDown
31+
size={16}
32+
className={cn(
33+
'e-transition-transform e-duration-200 e-ease-in-out',
34+
expanded && 'e-rotate-180',
35+
)}
36+
/>
2937
</button>
3038
)}
3139
</div>
32-
{(!collapsible || expanded) && children}
40+
{collapsible ? (
41+
<div
42+
className={cn(
43+
'e-grid e-transition-[grid-template-rows] e-duration-200 e-ease-in-out',
44+
expanded ? 'e-grid-rows-[1fr]' : 'e-grid-rows-[0fr]',
45+
)}
46+
>
47+
<div className="e-overflow-hidden">{children}</div>
48+
</div>
49+
) : (
50+
children
51+
)}
3352
</div>
3453
);
3554
},

0 commit comments

Comments
 (0)