Skip to content

Commit 5ded0b6

Browse files
Merge pull request #121 from linked-planet/dev
collapsible open and close transition
2 parents f97ed78 + 6a82c00 commit 5ded0b6

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

library/src/components/Collapsible.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as CollapsibleRUI from "@radix-ui/react-collapsible"
55
ChevronUpIcon,
66
} from "@radix-ui/react-icons"*/
77

8-
import { ChevronDownIcon, ChevronUpIcon, ChevronRightIcon } from "lucide-react"
8+
import { ChevronRightIcon, ChevronLeftIcon } from "lucide-react"
99

1010
import { forwardRef, type HTMLProps } from "react"
1111
import { twMerge } from "tailwind-merge"
@@ -91,13 +91,9 @@ export const Collapsible = forwardRef(
9191
chevronClassName,
9292
)}
9393
>
94-
<ChevronDownIcon
95-
aria-label="close"
96-
className="group-data-[state=open]:block group-data-[state=closed]:hidden"
97-
/>
9894
<ChevronRightIcon
99-
aria-label="open"
100-
className="group-data-[state=closed]:block group-data-[state=open]:hidden"
95+
aria-label={opened ? "close" : "open"}
96+
className="group-data-[state=closed]:rotate-0 group-data-[state=open]:rotate-90 transform transition-transform"
10197
/>
10298
</div>
10399
)}
@@ -118,13 +114,9 @@ export const Collapsible = forwardRef(
118114
)}
119115
style={chevronStyle}
120116
>
121-
<ChevronDownIcon
122-
aria-label="close"
123-
className="group-data-[state=open]:block group-data-[state=closed]:hidden"
124-
/>
125-
<ChevronUpIcon
126-
aria-label="open"
127-
className="group-data-[state=closed]:block group-data-[state=open]:hidden"
117+
<ChevronLeftIcon
118+
aria-label={opened ? "close" : "open"}
119+
className="group-data-[state=closed]:rotate-0 group-data-[state=open]:-rotate-90 transform transition-transform"
128120
/>
129121
</div>
130122
)}

0 commit comments

Comments
 (0)