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

New signature request v3 UI #6891

Merged
merged 9 commits into from
Nov 4, 2019
3 changes: 3 additions & 0 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,9 @@
"signatureRequest": {
"message": "Signature Request"
},
"signatureRequest1": {
"message": "Message"
},
"signed": {
"message": "Signed"
},
Expand Down
2 changes: 1 addition & 1 deletion ui/app/components/app/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@

@import 'home-notification/index';

@import 'multiple-notifications/index';
@import 'signature-request/index';
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ SignatureRequest.prototype.renderBody = function () {
let notice = this.context.t('youSign') + ':'

const { txData } = this.props
const { type, msgParams: { data, version } } = txData
const { type, msgParams: { data } } = txData

if (type === 'personal_sign') {
rows = [{ name: this.context.t('message'), value: this.msgHexToText(data) }]
Expand Down Expand Up @@ -275,17 +275,15 @@ SignatureRequest.prototype.renderBody = function () {
}, [notice]),

h('div.request-signature__rows',
type === 'eth_signTypedData' && (version === 'V3' || version === 'V4') ?
this.renderTypedData(data) :
rows.map(({ name, value }) => {
if (typeof value === 'boolean') {
value = value.toString()
}
return h('div.request-signature__row', [
h('div.request-signature__row-title', [`${name}:`]),
h('div.request-signature__row-value', value),
])
}),
rows.map(({ name, value }, index) => {
if (typeof value === 'boolean') {
value = value.toString()
}
return h('div.request-signature__row', { key: `request-signature-row-${index}` }, [
h('div.request-signature__row-title', [`${name}:`]),
h('div.request-signature__row-value', value),
])
})
),
])
}
Expand Down
1 change: 1 addition & 0 deletions ui/app/components/app/signature-request/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './signature-request.container'
96 changes: 96 additions & 0 deletions ui/app/components/app/signature-request/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
@import 'signature-request-footer/index';
@import 'signature-request-header/index';
@import 'signature-request-message/index';

.signature-request {
display: flex;
flex: 1 1 auto;
flex-direction: column;
min-width: 0;

@media screen and (min-width: 576px) {
flex: initial;
}
}

.signature-request-header {
flex: 1;

.network-display__container {
padding: 0;
justify-content: flex-end;
}

.network-display__name {
font-size: 12px;
white-space: nowrap;
font-weight: 500;
}
}

.signature-request-content {
flex: 1 40%;
margin-top: 1rem;
display: flex;
align-items: center;
flex-direction: column;
margin-bottom: 25px;
min-height: min-content;

&__title {
font-family: Roboto;
font-style: normal;
font-weight: 500;
font-size: 18px;
}

&__identicon-container {
padding: 1rem;
flex: 1;
position: relative;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}

&__identicon-border {
height: 75px;
width: 75px;
border-radius: 50%;
border: 1px solid white;
position: absolute;
box-shadow: 0 2px 2px 0.5px rgba(0, 0, 0, 0.19);
}

&__identicon-initial {
position: absolute;
font-family: Roboto;
font-style: normal;
font-weight: 500;
font-size: 60px;
color: white;
z-index: 1;
text-shadow: 0px 4px 6px rgba(0, 0, 0, 0.422);
}

&__info {
font-size: 12px;
}

&__info--bolded {
font-size: 16px;
font-weight: 500;
}

p {
color: #999999;
font-size: 0.8rem;
}

.identicon {}
}

.signature-request-footer {
flex: 1 1 auto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './signature-request-footer.component'
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.signature-request-footer {
display: flex;
border-top: 1px solid #d2d8dd;

button {
text-transform: uppercase;
flex: 1;
margin: 1rem 0.5rem;
border-radius: 3px;
}

button:first-child() {
margin-left: 1rem;
}
button:last-child() {
margin-right: 1rem;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import Button from '../../../ui/button'

export default class SignatureRequestFooter extends PureComponent {
static propTypes = {
cancelAction: PropTypes.func.isRequired,
signAction: PropTypes.func.isRequired,
}

static contextTypes = {
t: PropTypes.func,
}

render () {
const { cancelAction, signAction } = this.props
return (
<div className="signature-request-footer">
<Button onClick={cancelAction} type="default" large>{this.context.t('cancel')}</Button>
<Button onClick={signAction} type="primary" large>{this.context.t('sign')}</Button>
</div>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './signature-request-header.component'
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.signature-request-header {
display: flex;
padding: 1rem;
border-bottom: 1px solid $geyser;
justify-content: space-between;
font-size: .75rem;

&--account, &--network {
flex: 1;
}

&--account {
display: flex;
align-items: center;

.account-list-item__account-name {
font-size: 12px;
font-weight: 500;
}

.account-list-item__top-row {
margin: 0px;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import AccountListItem from '../../../../pages/send/account-list-item/account-list-item.component'
import NetworkDisplay from '../../network-display'

export default class SignatureRequestHeader extends PureComponent {
static propTypes = {
selectedAccount: PropTypes.object.isRequired,
}

render () {
const { selectedAccount } = this.props

return (
<div className="signature-request-header">
<div className="signature-request-header--account">
{selectedAccount && <AccountListItem
displayBalance={false}
account={selectedAccount}
/>}
{name}
</div>
<div className="signature-request-header--network">
<NetworkDisplay colored={false} />
</div>
</div>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './signature-request-message.component'
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
.signature-request-message {
flex: 1 60%;
display: flex;
flex-direction: column;

&__title {
font-weight: 500;
font-size: 14px;
color: #636778;
margin-left: 12px;
}

h2 {
flex: 1 1 0;
text-align: left;
font-size: 0.8rem;
border-bottom: 1px solid #d2d8dd;
padding: 0.5rem;
margin: 0;
color: #ccc;
}

&--root {
flex: 1 100%;
background-color: #f8f9fb;
padding-bottom: 0.5rem;
overflow: auto;
padding-left: 12px;
padding-right: 12px;
width: 360px;
font-family: monospace;

@media screen and (min-width: 576px) {
width: auto;
}
}

&__type-title {
font-family: monospace;
font-style: normal;
font-weight: normal;
font-size: 14px;
margin-left: 12px;
margin-top: 6px;
margin-bottom: 10px;
}

&--node, &--node-leaf {
padding-left: 0.8rem;

&-label {
color: #5B5D67;
}

&-value {
color: black;
margin-left: 0.5rem;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
}

&--node-leaf {
display: flex;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import classnames from 'classnames'

export default class SignatureRequestMessage extends PureComponent {
static propTypes = {
data: PropTypes.object.isRequired,
}

static contextTypes = {
t: PropTypes.func,
}

renderNode (data) {
return (
<div className="signature-request-message--node">
{Object.entries(data).map(([ label, value ], i) => (
<div
className={classnames('signature-request-message--node', {
'signature-request-message--node-leaf': typeof value !== 'object' || value === null,
})}
key={i}
>
<span className="signature-request-message--node-label">{label}: </span>
{
typeof value === 'object' && value !== null ?
this.renderNode(value)
whymarrh marked this conversation as resolved.
Show resolved Hide resolved
: <span className="signature-request-message--node-value">{value}</span>
}
</div>
))}
</div>
)
}


render () {
const { data } = this.props

return (
<div className="signature-request-message">
<div className="signature-request-message__title">{this.context.t('signatureRequest1')}</div>
<div className="signature-request-message--root">
<div className="signature-request-message__type-title">{this.context.t('signatureRequest1')}</div>
{this.renderNode(data)}
</div>
</div>
)
}
}
Loading