
* Switched messages endpoint to provide sse with phases & consuming info * Switched messages endpoint to provide sse with phases & consuming info * fixed comments * Fixed comparator * Fixed tests * Reduced images size * Feature/sse for messages (#681) * [#645] SSE. Cleanup Topic Messages * New messages page * Update outdated snapshots * Specs * Specs * Fixed build * Fixed possible npe in update cluster on init stage * Provided additional information with messages #677 (to messages_sse branch) (#700) * Provided additional information with messages #677 * Sse messages front (#725) * SSE. Messages page * Fix handleNextClick * Add the page loader to the list of messages Co-authored-by: Alexander <mr.afigitelniychuvak@gmail.com> * Fix merge errors * fix conflicts Co-authored-by: Timur Davletov <tdavletov@provectus.com> Co-authored-by: Oleg Shur <workshur@gmail.com> Co-authored-by: Alexander <mr.afigitelniychuvak@gmail.com>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import useOutsideClickRef from '@rooks/use-outside-click-ref';
|
|
import cx from 'classnames';
|
|
import React, { useCallback, useMemo, useState } from 'react';
|
|
|
|
export interface DropdownProps {
|
|
label: React.ReactNode;
|
|
right?: boolean;
|
|
up?: boolean;
|
|
}
|
|
|
|
const Dropdown: React.FC<DropdownProps> = ({ label, right, up, children }) => {
|
|
const [active, setActive] = useState<boolean>(false);
|
|
const [wrapperRef] = useOutsideClickRef(() => setActive(false));
|
|
const onClick = useCallback(() => setActive(!active), [active]);
|
|
|
|
const classNames = useMemo(
|
|
() =>
|
|
cx('dropdown', {
|
|
'is-active': active,
|
|
'is-right': right,
|
|
'is-up': up,
|
|
}),
|
|
[active]
|
|
);
|
|
return (
|
|
<div className={classNames} ref={wrapperRef}>
|
|
<div className="dropdown-trigger">
|
|
<button
|
|
type="button"
|
|
className="button is-small is-link"
|
|
aria-haspopup="true"
|
|
aria-controls="dropdown-menu"
|
|
onClick={onClick}
|
|
>
|
|
{label}
|
|
</button>
|
|
</div>
|
|
<div className="dropdown-menu" id="dropdown-menu" role="menu">
|
|
<div className="dropdown-content has-text-left">{children}</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Dropdown;
|