This repository has been archived by the owner on Jan 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes brave/brave-browser#4773 - adds BAT token by default to accounts
Adds file override task via gulp
- Loading branch information
Showing
12 changed files
with
6,507 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,57 @@ | ||
const inherits = require('util').inherits | ||
const Component = require('react').Component | ||
const h = require('react-hyperscript') | ||
|
||
inherits(Menu, Component) | ||
function Menu () { Component.call(this) } | ||
|
||
Menu.prototype.render = function () { | ||
const { className = '', children, isShowing } = this.props | ||
return isShowing | ||
? h('div', { className: `menu ${className}` }, children) | ||
: h('noscript') | ||
} | ||
|
||
inherits(Item, Component) | ||
function Item () { Component.call(this) } | ||
|
||
Item.prototype.render = function () { | ||
const { | ||
icon, | ||
children, | ||
text, | ||
className = '', | ||
onClick, | ||
isShowing | ||
} = this.props | ||
|
||
if (isShowing === false) { | ||
return h('noscript') | ||
} | ||
|
||
const itemClassName = `menu__item ${className} ${onClick ? 'menu__item--clickable' : ''}` | ||
const iconComponent = icon ? h('div.menu__item__icon', [icon]) : null | ||
const textComponent = text ? h('div.menu__item__text', text) : null | ||
|
||
return children | ||
? h('div', { className: itemClassName, onClick }, children) | ||
: h('div.menu__item', { className: itemClassName, onClick }, [ iconComponent, textComponent ] | ||
.filter(d => Boolean(d)) | ||
) | ||
} | ||
|
||
inherits(Divider, Component) | ||
function Divider () { Component.call(this) } | ||
|
||
Divider.prototype.render = function () { | ||
return h('div.menu__divider') | ||
} | ||
|
||
inherits(CloseArea, Component) | ||
function CloseArea () { Component.call(this) } | ||
|
||
CloseArea.prototype.render = function () { | ||
return h('div.menu__close-area', { onClick: this.props.onClick }) | ||
} | ||
|
||
module.exports = { Menu, Item, Divider, CloseArea } |
69 changes: 69 additions & 0 deletions
69
brave/ui/app/components/app/dropdowns/token-menu-dropdown.js
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,69 @@ | ||
const Component = require('react').Component | ||
const PropTypes = require('prop-types') | ||
const h = require('react-hyperscript') | ||
const inherits = require('util').inherits | ||
const connect = require('react-redux').connect | ||
const actions = require('../../../store/actions') | ||
const genAccountLink = require('etherscan-link').createAccountLink | ||
const { Menu, Item, CloseArea } = require('./components/menu') | ||
|
||
TokenMenuDropdown.contextTypes = { | ||
t: PropTypes.func, | ||
} | ||
|
||
module.exports = connect(mapStateToProps, mapDispatchToProps)(TokenMenuDropdown) | ||
|
||
function mapStateToProps (state) { | ||
return { | ||
network: state.metamask.network, | ||
} | ||
} | ||
|
||
function mapDispatchToProps (dispatch) { | ||
return { | ||
showHideTokenConfirmationModal: (token) => { | ||
dispatch(actions.showModal({ name: 'HIDE_TOKEN_CONFIRMATION', token })) | ||
}, | ||
} | ||
} | ||
|
||
|
||
inherits(TokenMenuDropdown, Component) | ||
function TokenMenuDropdown () { | ||
Component.call(this) | ||
|
||
this.onClose = this.onClose.bind(this) | ||
} | ||
|
||
TokenMenuDropdown.prototype.onClose = function (e) { | ||
e.stopPropagation() | ||
this.props.onClose() | ||
} | ||
|
||
TokenMenuDropdown.prototype.render = function () { | ||
const { showHideTokenConfirmationModal } = this.props | ||
|
||
return h(Menu, { className: 'token-menu-dropdown', isShowing: true }, [ | ||
h(CloseArea, { | ||
onClick: this.onClose, | ||
}), | ||
h(Item, { | ||
onClick: (e) => { | ||
e.stopPropagation() | ||
showHideTokenConfirmationModal(this.props.token) | ||
this.props.onClose() | ||
}, | ||
isShowing: (this.props.token.symbol !== 'BAT'), | ||
text: this.context.t('hideToken'), | ||
}), | ||
h(Item, { | ||
onClick: (e) => { | ||
e.stopPropagation() | ||
const url = genAccountLink(this.props.token.address, this.props.network) | ||
global.platform.openWindow({ url }) | ||
this.props.onClose() | ||
}, | ||
text: this.context.t('viewOnEtherscan'), | ||
}), | ||
]) | ||
} |
Oops, something went wrong.