Skip to content

Commit 2ce622e

Browse files
committed
Rotate chevron icon on dropdown open
1 parent 2f13047 commit 2ce622e

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

apify-docs-theme/src/theme/LLMButtons/index.jsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import clsx from 'clsx';
12
import React, { useCallback, useState } from 'react';
23

34
import {
@@ -189,6 +190,7 @@ const MenuBase = ({
189190
ref,
190191
copyingStatus,
191192
setCopyingStatus,
193+
chevronIconRef,
192194
...props
193195
}) => (
194196
<div ref={ref} className={styles.llmButtonWrapper}>
@@ -207,7 +209,12 @@ const MenuBase = ({
207209
{getButtonText({ status: copyingStatus })}
208210
</Text>
209211
<div {...props} className={styles.chevronIconWrapper}>
210-
<ChevronDownIcon size="16" color={theme.color.neutral.icon} />
212+
<ChevronDownIcon
213+
size="16"
214+
color={theme.color.neutral.icon}
215+
className={styles.chevronIcon}
216+
ref={chevronIconRef}
217+
/>
211218
</div>
212219
</div>
213220
</div>
@@ -233,6 +240,7 @@ const Option = ({ Icon, label, description, showExternalIcon }) => (
233240

234241
export default function LLMButtons() {
235242
const [copyingStatus, setCopyingStatus] = useState('idle');
243+
const chevronIconRef = React.useRef(null);
236244

237245
const onMenuOptionClick = useCallback((value) => {
238246
switch (value) {
@@ -259,11 +267,17 @@ export default function LLMButtons() {
259267
return (
260268
<Menu
261269
className={styles.llmMenu}
270+
onMenuOpen={(isOpen) => chevronIconRef.current?.classList.toggle(
271+
styles.chevronIconOpen,
272+
isOpen,
273+
)
274+
}
262275
components={{
263276
MenuBase: (props) => (
264277
<MenuBase
265278
copyingStatus={copyingStatus}
266279
setCopyingStatus={setCopyingStatus}
280+
chevronIconRef={chevronIconRef}
267281
{...props}
268282
/>
269283
),

apify-docs-theme/src/theme/LLMButtons/styles.module.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@
5959
height: 100%;
6060
}
6161

62+
.chevronIcon {
63+
transition: transform 0.2s ease-in-out;
64+
}
65+
66+
.chevronIconOpen {
67+
transform: rotate(180deg);
68+
}
69+
6270
.menuOption {
6371
padding-block: 0.4rem;
6472
display: flex;

0 commit comments

Comments
 (0)