Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor select input and create provider select
- Loading branch information
1 parent
62aef2e
commit a63ae4c
Showing
3 changed files
with
88 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// @flow | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import type { ProviderEnum } from '../API/api'; | ||
import { SelectInput, SelectLabel } from './common/Inputs'; | ||
|
||
const WrapperSelectInput = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
margin-left: 40px; | ||
@media (max-width: 1125px) { | ||
margin-left: 0; | ||
} | ||
`; | ||
|
||
type Props = {| | ||
setProvider: Function, | ||
|}; | ||
|
||
const selectData = [ | ||
{ | ||
label: 'Adapools (Advanced)', | ||
value: 'adapools', | ||
}, | ||
{ | ||
label: 'Daedalus Official (Simple)', | ||
value: 'daedalus-simple', | ||
}, | ||
]; | ||
|
||
function ProviderSelect({ setProvider }: Props): React$Node { | ||
const [selectValue, setSelectValue] = React.useState<ProviderEnum>('adapools'); | ||
|
||
const handleChange = (e) => { | ||
setSelectValue(e.currentTarget.value); | ||
setProvider(e.currentTarget.value); | ||
}; | ||
|
||
return ( | ||
<WrapperSelectInput> | ||
<SelectLabel htmlFor="sort">Provider:</SelectLabel> | ||
<SelectInput name="" id="sort" value={selectValue} onChange={handleChange}> | ||
{selectData.map(({ value, label }) => ( | ||
<option key={value} value={value}> | ||
{label} | ||
</option> | ||
))} | ||
</SelectInput> | ||
</WrapperSelectInput> | ||
); | ||
} | ||
|
||
export default ProviderSelect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// @flow | ||
import styled from 'styled-components'; | ||
import arrowDownIcon from '../../assets/arrow-select-down.svg'; | ||
|
||
const SelectLabel: any = styled.label` | ||
color: #676970; | ||
font-size: 12px; | ||
line-height: 20px; | ||
margin-bottom: 6px; | ||
`; | ||
const SelectInput: any = styled.select` | ||
height: 40px; | ||
display: block; | ||
font-size: 14px; | ||
line-height: 22px; | ||
color: #2b2c32; | ||
line-height: 1.3; | ||
padding: 0.6em 1.4em 0.5em 0.8em; | ||
width: 322px; | ||
margin: 0; | ||
border: none; | ||
border-radius: 8px; | ||
-moz-appearance: none; | ||
-webkit-appearance: none; | ||
appearance: none; | ||
background-color: #f0f3f5; | ||
background-image: url(${arrowDownIcon}); | ||
background-repeat: no-repeat, repeat; | ||
background-position: right 0.7em top 50%, 0 0; | ||
background-size: 24px auto, 100%; | ||
`; | ||
|
||
export { SelectLabel, SelectInput }; |