bruno/renderer/components/EnvironmentSelector/index.js

54 lines
1.7 KiB
JavaScript
Raw Normal View History

2022-03-13 08:48:15 +01:00
import React, { useRef, forwardRef } from 'react';
import Dropdown from 'components/Dropdown';
import { IconAdjustmentsHorizontal, IconCaretDown } from '@tabler/icons';
2022-03-13 08:48:15 +01:00
import StyledWrapper from './StyledWrapper';
const EnvironmentSelector = () => {
const dropdownTippyRef = useRef();
const Icon = forwardRef((props, ref) => {
return (
2022-03-22 13:48:20 +01:00
<div ref={ref} className="current-enviroment flex items-center justify-center pl-3 pr-2 py-1 select-none">
No Environment
<IconCaretDown className="caret" size={14} strokeWidth={2}/>
2022-03-13 08:48:15 +01:00
</div>
);
});
const onDropdownCreate = (ref) => dropdownTippyRef.current = ref;
return (
<StyledWrapper>
2022-03-22 13:48:20 +01:00
<div className="flex items-center cursor-pointer environment-selector">
<Dropdown onCreate={onDropdownCreate} icon={<Icon />} placement='bottom-end'>
2022-03-13 08:48:15 +01:00
<div className="dropdown-item" onClick={() => {
dropdownTippyRef.current.hide();
}}>
<span>QA1</span>
</div>
<div className="dropdown-item" onClick={() => {
dropdownTippyRef.current.hide();
}}>
<span>STG</span>
</div>
<div className="dropdown-item" onClick={() => {
dropdownTippyRef.current.hide();
}}>
<span>No Environment</span>
</div>
<div className="dropdown-item" style={{borderTop: 'solid 1px #e7e7e7'}} onClick={() => {
dropdownTippyRef.current.hide();
}}>
<div className="pr-2 text-gray-600">
<IconAdjustmentsHorizontal size={18} strokeWidth={1.5}/>
</div>
<span>Settings</span>
</div>
</Dropdown>
</div>
</StyledWrapper>
);
};
export default EnvironmentSelector;