2022-09-20 13:13:21 +00:00
|
|
|
import * as React from "react";
|
|
|
|
import { REGIONALIZED_RELAYER_ENDPOINTS } from "../constants/default";
|
|
|
|
import styled from "styled-components";
|
|
|
|
import Icon from "./Icon";
|
|
|
|
import { useState } from "react";
|
|
|
|
|
|
|
|
interface DropdownProps {
|
|
|
|
relayerRegion: string;
|
|
|
|
setRelayerRegion?: (relayer: string) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const SelectContainer = styled.select`
|
|
|
|
width: 150px;
|
|
|
|
background: transparent;
|
|
|
|
color: black;
|
|
|
|
height: 30px;
|
|
|
|
border-radius: 4px;
|
|
|
|
padding: 2px;
|
|
|
|
font-size: "1.25em";
|
|
|
|
position: absolute;
|
|
|
|
bottom: 40px;
|
|
|
|
left: 50px;
|
2022-10-18 10:37:52 +00:00
|
|
|
direction: ltr;
|
2022-09-20 13:13:21 +00:00
|
|
|
unicode-bidi: embed;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const SelectOption = styled.option`
|
|
|
|
font-size: "1.25em";
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Dropdown = (props: DropdownProps) => {
|
|
|
|
const { relayerRegion, setRelayerRegion } = props;
|
2022-10-18 10:37:52 +00:00
|
|
|
const [openSelect, setOpenSelect] = useState(false);
|
|
|
|
const selectRef = React.createRef();
|
2022-09-20 13:13:21 +00:00
|
|
|
|
|
|
|
const openDropdown = () => {
|
2022-10-18 10:37:52 +00:00
|
|
|
setOpenSelect(!openSelect);
|
|
|
|
};
|
2022-09-20 13:13:21 +00:00
|
|
|
|
|
|
|
return (
|
2022-10-18 10:37:52 +00:00
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
paddingTop: 72,
|
|
|
|
width: 250,
|
|
|
|
display: "flex",
|
|
|
|
justifyContent: "center",
|
|
|
|
alignItems: "flex-end",
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<button onClick={openDropdown} style={{ background: "transparent" }}>
|
|
|
|
<Icon size={30} src={"/assets/settings.svg"} />
|
2022-09-20 13:13:21 +00:00
|
|
|
</button>
|
2022-10-18 10:37:52 +00:00
|
|
|
{openSelect && (
|
2022-09-20 13:13:21 +00:00
|
|
|
<SelectContainer
|
|
|
|
value={relayerRegion}
|
|
|
|
onChange={(e) => setRelayerRegion?.(e?.target?.value)}
|
|
|
|
>
|
2022-10-18 10:37:52 +00:00
|
|
|
<option selected disabled>
|
|
|
|
Relayer Region:
|
|
|
|
</option>
|
2022-09-20 13:13:21 +00:00
|
|
|
{REGIONALIZED_RELAYER_ENDPOINTS.map((e, i) => {
|
|
|
|
return (
|
|
|
|
<SelectOption key={i} value={e.value}>
|
|
|
|
{e.label}
|
|
|
|
</SelectOption>
|
|
|
|
);
|
|
|
|
})}
|
2022-10-18 10:37:52 +00:00
|
|
|
</SelectContainer>
|
|
|
|
)}
|
2022-09-20 13:13:21 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Dropdown;
|