-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Axel Boberg <[email protected]>
- Loading branch information
1 parent
db0bb79
commit 1994eee
Showing
6 changed files
with
199 additions
and
2 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
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
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,46 @@ | ||
import React from 'react' | ||
|
||
import * as api from '../../api' | ||
|
||
import { Popover } from '../Popover' | ||
import { PopupConfirm } from '../Popup/confirm' | ||
|
||
import './style.css' | ||
|
||
export function Role ({ currentRole = 0, open, onClose = () => {} }) { | ||
const [popupIsOpen, setPopupIsOpen] = React.useState() | ||
|
||
async function handleAssumeMain (value) { | ||
if (value) { | ||
const bridge = await api.load() | ||
const id = bridge.client.getIdentity() | ||
bridge.client.setRole(id, bridge.client.roles.main) | ||
} | ||
setPopupIsOpen(false) | ||
} | ||
|
||
return ( | ||
<> | ||
<PopupConfirm open={popupIsOpen} confirmText='Become main' abortText='Cancel' onChange={value => handleAssumeMain(value)}> | ||
<div className='u-heading--2'>Become main</div> | ||
This will turn the current<br />main client into satellite mode | ||
</PopupConfirm> | ||
<Popover open={open} onClose={onClose}> | ||
<div className='Role u-theme--light'> | ||
<div className='Role-content'> | ||
Only the main client's selections can be triggered by the api. | ||
{ | ||
currentRole === 1 | ||
? <div className='Role-status'>This is the main client.</div> | ||
: ( | ||
<button className='Button Button--secondary u-width--100pct Sharing-copyBtn' onClick={() => setPopupIsOpen(true)}> | ||
Become main | ||
</button> | ||
) | ||
} | ||
</div> | ||
</div> | ||
</Popover> | ||
</> | ||
) | ||
} |
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,21 @@ | ||
.Role { | ||
width: 300px; | ||
|
||
text-align: left; | ||
font-size: 1em; | ||
color: var(--base-color); | ||
} | ||
|
||
.Role-content { | ||
padding: 10px; | ||
box-sizing: border-box; | ||
} | ||
|
||
.Role-info { | ||
margin: 5px; | ||
} | ||
|
||
.Role-status { | ||
margin-top: 10px; | ||
opacity: 0.7; | ||
} |
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 |
---|---|---|
|
@@ -28,4 +28,4 @@ html, body, #root { | |
|
||
.u-width--100pct { | ||
width: 100%; | ||
} | ||
} |