You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.6 KiB
TypeScript
62 lines
1.6 KiB
TypeScript
4 years ago
|
import React, { useState } from 'react';
|
||
3 years ago
|
import { SessionIcon, SessionIconType } from '../icon';
|
||
5 years ago
|
|
||
4 years ago
|
import { SessionDropdownItem, SessionDropDownItemType } from './SessionDropdownItem';
|
||
5 years ago
|
|
||
5 years ago
|
// THIS IS DROPDOWN ACCORDIAN STYLE OPTIONS SELECTOR ELEMENT, NOT A CONTEXTMENU
|
||
5 years ago
|
|
||
5 years ago
|
type Props = {
|
||
5 years ago
|
label: string;
|
||
5 years ago
|
onClick?: any;
|
||
5 years ago
|
expanded?: boolean;
|
||
|
options: Array<{
|
||
5 years ago
|
content: string;
|
||
|
id?: string;
|
||
|
icon?: SessionIconType | null;
|
||
|
type?: SessionDropDownItemType;
|
||
|
active?: boolean;
|
||
|
onClick?: any;
|
||
|
}>;
|
||
5 years ago
|
};
|
||
5 years ago
|
|
||
5 years ago
|
export const SessionDropdown = (props: Props) => {
|
||
|
const { label, options } = props;
|
||
|
const [expanded, setExpanded] = useState(!!props.expanded);
|
||
|
const chevronOrientation = expanded ? 180 : 0;
|
||
5 years ago
|
|
||
5 years ago
|
return (
|
||
|
<div className="session-dropdown">
|
||
|
<div
|
||
|
className="session-dropdown__label"
|
||
|
onClick={() => {
|
||
|
setExpanded(!expanded);
|
||
|
}}
|
||
|
role="button"
|
||
|
>
|
||
|
{label}
|
||
3 years ago
|
<SessionIcon iconType="chevron" iconSize="small" iconRotation={chevronOrientation} />
|
||
5 years ago
|
</div>
|
||
5 years ago
|
|
||
5 years ago
|
{expanded && (
|
||
|
<div className="session-dropdown__list-container">
|
||
|
{options.map((item: any) => {
|
||
|
return (
|
||
|
<SessionDropdownItem
|
||
|
key={item.content}
|
||
|
content={item.content}
|
||
|
icon={item.icon}
|
||
|
type={item.type}
|
||
|
active={item.active}
|
||
|
onClick={() => {
|
||
|
setExpanded(false);
|
||
|
item.onClick();
|
||
|
}}
|
||
|
/>
|
||
|
);
|
||
|
})}
|
||
|
</div>
|
||
|
)}
|
||
|
</div>
|
||
|
);
|
||
|
};
|