Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/header profile action #994

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions src/components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,27 @@ export const Header = () => {
context.setTheme(getItem('theme') || setItem('theme', 'dark'))
}, [])

// we assume user isn't connected
let button = 'sync'

// but if they are
if (context.acc?.address) {
// is menu closed?
if (context.collapsed) {
button = walletPreview(context.acc.address)
} else {
// menu is open
button = 'unsync'
}
}

//const activeAccount = await wallet.client.getActiveAccount()
//console.log(activeAccount)
const handleRoute = (path, data) => {
context.setMenu(true)
history.push(path, data)
}

const handleSyncUnsync = () => {
if (context.acc?.address && !context.collapsed) {
// disconnect wallet
context.disconnect()
// we assume user isn't connected
let headerButtonHandler = () => context.syncTaquito()
let headerButtonText = 'sync'

// but if they are
if (context.acc?.address) {
// is menu closed?
if (context.collapsed) {
headerButtonHandler = () => handleRoute('/sync', 'tz')
headerButtonText = walletPreview(context.acc.address)
} else {
// connect wallet
context.syncTaquito()
// menu is open
headerButtonHandler = () => context.disconnect()
headerButtonText = 'unsync'
}
}

Expand Down Expand Up @@ -138,8 +131,8 @@ export const Header = () => {
</Button>

<div className={styles.right}>
<Button onClick={handleSyncUnsync} secondary>
<Primary>{button}</Primary>
<Button onClick={headerButtonHandler} secondary>
<Primary>{headerButtonText}</Primary>
</Button>

<Button onClick={context.toogleNavbar} secondary>
Expand Down
9 changes: 3 additions & 6 deletions src/components/header/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,9 @@
display: flex;
align-items: center;
font-size: 16px;
}

.hamburger {
width: 30px;
height: auto;
margin-left: 10px;
+ * {
margin-left: 10px;
}
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/components/icons/styles.module.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
@import '../../styles/variables.scss';

.menu {
margin-left: 6px;
// border: 1px dashed black;

svg {
display: block;
width: 30px;
Expand Down