parent
cba2296e4a
commit
a4d6eb3c48
@ -0,0 +1,3 @@ |
||||
.disabled-cursor { |
||||
cursor: not-allowed; |
||||
} |
@ -0,0 +1,33 @@ |
||||
import React from 'react' |
||||
import './ContractDropdown.css' |
||||
interface ContractDropdownItem { |
||||
value: string |
||||
name: string |
||||
} |
||||
|
||||
interface ContractDropdownProps { |
||||
label: string |
||||
contractNames: ContractDropdownItem[] |
||||
id: string |
||||
} |
||||
|
||||
export const ContractDropdown: React.FC<ContractDropdownProps> = ({label, contractNames, id}) => { |
||||
const hasContracts = contractNames && contractNames.length > 0 |
||||
return ( |
||||
<div className="form-group"> |
||||
<label htmlFor={id}>{label}</label> |
||||
|
||||
<select className={`form-control custom-select pr-4 ${!hasContracts ? 'disabled-cursor' : ''}`} id={id} disabled={!hasContracts}> |
||||
{hasContracts ? ( |
||||
contractNames.map((item, index) => ( |
||||
<option value={item.value} key={index}> |
||||
{item.name} |
||||
</option> |
||||
)) |
||||
) : ( |
||||
<option>No Compiled Contracts. Please compile and select a contract</option> |
||||
)} |
||||
</select> |
||||
</div> |
||||
) |
||||
} |
@ -1,27 +0,0 @@ |
||||
import React from 'react' |
||||
|
||||
interface DropdownItem { |
||||
value: string |
||||
name: string |
||||
} |
||||
|
||||
interface DropdownProps { |
||||
label: string |
||||
items: DropdownItem[] |
||||
id: string |
||||
} |
||||
|
||||
export const Dropdown: React.FC<DropdownProps> = ({label, items, id}) => { |
||||
return ( |
||||
<div className="form-group"> |
||||
<label htmlFor={id}>{label}</label> |
||||
<select className="form-control custom-select pr-4" id={id}> |
||||
{items.map((item, index) => ( |
||||
<option value={item.value} key={index}> |
||||
{item.name} |
||||
</option> |
||||
))} |
||||
</select> |
||||
</div> |
||||
) |
||||
} |
@ -1,3 +1,3 @@ |
||||
export {NavMenu} from './NavMenu' |
||||
export {Dropdown} from './Dropdown' |
||||
export {ContractDropdown} from './ContractDropdown' |
||||
export {SearchableDropdown} from './SearchableDropdown' |
||||
|
Loading…
Reference in new issue