1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

change interactive elements to button

This commit is contained in:
Max Berman 2020-01-15 14:04:37 +01:00
parent ab342b3fa6
commit 6290029c2a
2 changed files with 44 additions and 22 deletions

View File

@ -6,16 +6,30 @@
font-size: $font-size-mini; font-size: $font-size-mini;
} }
.networkListWrapper em { .networkSwitchButton {
color: #fff;
}
.networkSwitchButton {
display: inline-block; display: inline-block;
border: 1px solid $brand-grey-lighter; border: 1px solid $brand-grey-lighter;
padding: 4px; padding: 4px;
border-radius: $border-radius; border-radius: $border-radius;
margin: 0 4px; margin: 0 4px;
user-select: none; user-select: none;
cursor: pointer;
} }
.networkListWrapper em:after { .networkSwitchButton:active {
outline: none;
}
.networkSwitchButton:focus {
outline: none;
//border: 1px solid #000;
}
.networkSwitchButton:after {
content: ''; content: '';
display: inline-block; display: inline-block;
width: 0; width: 0;
@ -25,6 +39,16 @@
border-top: 4px solid $brand-grey-light; border-top: 4px solid $brand-grey-light;
} }
.networkSwitchButton span {
color: $brand-grey-light;
}
.networkSwitchButton span:after {
content: '';
border-right: 1px solid $brand-grey-lighter;
margin: 0 4px;
}
.networkList { .networkList {
position: absolute; position: absolute;
border: 1px solid $brand-grey-lighter; border: 1px solid $brand-grey-lighter;
@ -36,17 +60,6 @@
width: 100%; width: 100%;
} }
.networkListWrapper em {
display: block;
border: 1px solid $brand-grey-lighter;
}
.networkListWrapper em span:after {
content: '';
border-right: 1px solid $brand-grey-lighter;
margin: 0 4px;
}
.networkListWrapper.on .networkList { .networkListWrapper.on .networkList {
display: block; display: block;
} }
@ -58,14 +71,16 @@
padding: 4px; padding: 4px;
} }
.networkList li span { .listButton {
display: block;
text-transform: capitalize; text-transform: capitalize;
border: none;
width: inherit;
} }
.networkList li:hover { .networkList li:hover {
color: $brand-violet; color: $brand-violet;
font-size: $font-size-mini; font-size: $font-size-mini;
background-color: $brand-grey-lighter;
} }
.networkList li:before { .networkList li:before {

View File

@ -27,10 +27,10 @@ export function NetworkSwitcher() {
useEffect(() => { useEffect(() => {
// Handle click outside to collapse Network switcher dropdown // Handle click outside to collapse Network switcher dropdown
// add listener when mounted // add listener when mounted
document.addEventListener('mousedown', handleTogle) document.addEventListener('mousedown', handleToggle)
// return function when unmounted // return function when unmounted
return () => { return () => {
document.removeEventListener('mousedown', handleTogle) document.removeEventListener('mousedown', handleToggle)
} }
}, []) }, [])
/* /*
@ -41,7 +41,7 @@ export function NetworkSwitcher() {
}, []) }, [])
*/ */
const handleTogle = (e: any) => { const handleToggle = (e: any) => {
const isClickedInside = node.current.contains(e.target) const isClickedInside = node.current.contains(e.target)
setIsToggled(isClickedInside) setIsToggled(isClickedInside)
} }
@ -64,21 +64,28 @@ export function NetworkSwitcher() {
isToggled ? styles.on : '' isToggled ? styles.on : ''
}`} }`}
> >
<em onClick={e => handleTogle(e)}> <button
className={styles.networkSwitchButton}
onClick={e => handleToggle(e)}
>
<span>Change Network</span> <span>Change Network</span>
</em> </button>
<ul className={styles.networkList}> <ul className={styles.networkList}>
{Object.keys(CONNECTIONS).map((networkName, i) => ( {Object.keys(CONNECTIONS).map((networkName, i) => (
<li <li
key={i} key={i}
onClick={() => switchNetwork(networkName)}
className={ className={
network.toUpperCase() === networkName.toUpperCase() network.toUpperCase() === networkName.toUpperCase()
? styles.selected ? styles.selected
: '' : ''
} }
> >
<span>{networkName}</span> <button
className={styles.listButton}
onClick={() => switchNetwork(networkName)}
>
{networkName}
</button>
</li> </li>
))} ))}
</ul> </ul>