(refactor) general cards refactoring

This commit is contained in:
Gabriel Rodriguez Alsina 2018-12-20 20:07:03 -03:00
parent 0573e1a33f
commit b68dab972f
21 changed files with 310 additions and 95 deletions

View File

@ -1,23 +1,5 @@
$padding-left-items: 25px;
.info-container {
background-color: #f8f8f8;
margin-bottom: 30px;
margin-left: -#{ $desktop-indent };
margin-right: -#{ $desktop-indent };
padding-bottom: #{ $desktop-indent };
padding-left: #{ $desktop-indent };
padding-right: #{ $desktop-indent };
padding-top: #{ $desktop-indent };
@media screen and (max-width: $breakpoint-md) {
margin-left: -#{ $tablet-indent };
margin-right: -#{ $tablet-indent };
padding-left: #{ $tablet-indent };
padding-right: #{ $tablet-indent };
}
}
.info {
color: #000;

View File

@ -104,16 +104,6 @@
}
}
textarea {
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
overflow: auto;
outline: none;
border-radius: 3px;
width: 100%;
}
.color-primary {
color: $poa-purple;
.sokol & {

View File

@ -0,0 +1,7 @@
textarea {
border-radius: 3px;
box-shadow: none;
outline: none;
overflow: auto;
width: 100%;
}

View File

@ -3,4 +3,5 @@
@import 'display';
@import 'effects';
@import 'forms';
@import 'typography';

View File

@ -1,4 +1,5 @@
.lo-App {
align-items: center;
display: flex;
flex-direction: column;
height: 100%;
@ -8,6 +9,7 @@
.lo-App_Content {
flex-grow: 1;
max-width: 100%;
padding-bottom: 30px;
position: relative;
z-index: 1;

View File

@ -1,10 +1,13 @@
.ballots-about {
.sw-BallotAbout {
$cell-right-padding: 12px;
margin-top: -8px;
@media screen and (max-width: $breakpoint-md) {
display: table;
width: 100%;
}
$this: &;
p {
line-height: 28px;

View File

@ -0,0 +1,150 @@
.sw-BallotCard {
.title {
margin-bottom: 50px;
@media screen and (max-width: $breakpoint-md) {
margin-bottom: $tablet-indent;
}
@media screen and (max-width: $mobile-width) {
margin-bottom: $mobile-indent;
}
}
background-color: #fff;
border-radius: 6px;
border: 1px solid $base-border-color;
margin-bottom: 30px;
padding: $desktop-indent;
transition: 0.15s box-shadow;
@media screen and (max-width: $breakpoint-md) {
margin-bottom: $tablet-indent;
padding: $tablet-indent;
}
}
.sw-BallotCard_Scale {
border-top: 1px solid $base-border-color;
display: flex;
margin-bottom: 30px;
margin-top: 30px;
padding: 30px 0 0 0;
@media screen and (max-width: $breakpoint-md) {
display: block;
margin-top: $tablet-indent;
padding: $tablet-indent 0 0 0;
}
@media screen and (max-width: $mobile-width) {
margin-top: $mobile-indent;
padding: $mobile-indent 0 0 0;
}
}
.sw-BallotCard_ScaleColumn {
display: flex;
flex-grow: 1;
justify-content: space-between;
margin-right: 40px;
@media screen and (max-width: $breakpoint-md) {
margin-bottom: 30px;
margin-right: 0;
overflow: hidden;
width: 100%;
}
&:last-child {
margin-right: 0;
}
&.reverse-responsive {
@media screen and (max-width: $breakpoint-md) {
flex-direction: row-reverse;
}
}
}
.sw-BallotCard_Name {
overflow: hidden;
text-overflow: ellipsis;
}
.sw-BallotCard_Vote {
border-radius: 2px;
border: 0;
box-sizing: border-box;
cursor: pointer;
display: inline-block;
font-size: 13px;
font-weight: bold;
line-height: 36px;
outline: none;
padding: 0 13px;
text-transform: uppercase;
transition: 0.3s opacity;
&:hover {
opacity: 0.9;
text-decoration: none;
}
}
.sw-BallotCard_VoteLabel {
color: #333;
cursor: default;
font-size: 14px;
font-weight: 700;
line-height: 1.2;
@media screen and (max-width: $mobile-width) {
margin-bottom: 25px;
}
}
.sw-BallotCard_VoteLabel-right {
margin-left: auto !important;
}
.sw-BallotCard_VoteButton {
line-height: 44px;
min-width: 55px;
text-transform: capitalize;
&.xl {
min-width: 78px;
}
&.m-r-20 {
margin-right: 20px;
}
&.m-l-20 {
margin-left: 20px;
}
@media screen and (max-width: $breakpoint-md) {
&.m-r-20,
&.m-l-20 {
margin-left: 0;
margin-right: 20px;
}
}
}
///////////////////////////
///////////////////////////
///////////////////////////
///////////////////////////
///////////////////////////
.color-primary {
color: $poa-purple;
.sokol & {
color: $sokol-cyan;
}
}
.color-danger {
color: $poa-danger-color;
.sokol & {
color: $sokol-danger-color;
}
}
.color-success {
color: $poa-green-color;
.sokol & {
color: $sokol-cyan;
}
}

View File

@ -0,0 +1,52 @@
.bc-BallotInfoContainer {
background-color: #f8f8f8;
margin-bottom: 30px;
margin-left: -#{ $desktop-indent };
margin-right: -#{ $desktop-indent };
padding-bottom: #{ $desktop-indent };
padding-left: #{ $desktop-indent };
padding-right: #{ $desktop-indent };
padding-top: #{ $desktop-indent };
@media screen and (max-width: $breakpoint-md) {
margin-left: -#{ $tablet-indent };
margin-right: -#{ $tablet-indent };
padding-left: #{ $tablet-indent };
padding-right: #{ $tablet-indent };
}
}
.bc-BallotInfoContainer_Info {
background-position: 0 2px;
background-repeat: no-repeat;
color: #333333;
font-size: 14px;
font-weight: normal;
letter-spacing: normal;
line-height: 1.71;
margin-bottom: 20px;
max-width: 100%;
min-height: 32px;
padding-left: 30px;
text-align: left;
word-break: break-word;
&:last-child {
margin-bottom: 0;
}
&#{ & }-minimum {
background-image: url('#{ $base-images-path }/icons/icon-min.svg');
background-size: 18px 18px;
}
&#{ & }-details {
background-image: url('#{ $base-images-path }/icons/icon-info.svg');
background-size: 10px 18px;
position: relative;
}
&#{ & }-collapsed {
height: 90px;
overflow: hidden;
}
}

View File

@ -0,0 +1,3 @@
.sw-Ballots {
@include content-layout-width();
}

View File

@ -1,6 +1,7 @@
.sw-MainTitle {
display: flex;
justify-content: center;
max-width: 100%;
min-height: fit-content;
padding: 30px 0;
}

View File

@ -0,0 +1,10 @@
.tg-ToggleShow {
color: $poa-purple;
cursor: pointer;
display: inline-block;
margin-left: 5px;
.sokol & {
color: $sokol-cyan;
}
}

View File

@ -1,4 +1,8 @@
@import "App";
@import "BallotAbout";
@import "BallotCard";
@import "Ballots";
@import "BallotInfoContainer";
@import "BaseLoader";
@import "ButtonNewBallot";
@import "Footer";
@ -20,4 +24,5 @@
@import "MobileMenuLinks";
@import "NavigationLinks";
@import "SearchBar";
@import "SocialIcons";
@import "SocialIcons";
@import "ToggleShow";

File diff suppressed because one or more lines are too long

View File

@ -14,6 +14,6 @@
@import 'application/ballot-types';
@import 'application/ballots/placeholders';
@import 'application/ballots/base';
@import 'application/ballots/about';
// @import 'application/ballots/base';
// @import 'application/ballots/about';
@import 'application/ballots/footer';

View File

@ -2,8 +2,8 @@ import React from 'react'
import moment from 'moment'
import { observable, action, computed } from 'mobx'
import { inject, observer } from 'mobx-react'
import { messages } from '../utils/messages'
import { sendTransactionByVotingKey } from '../utils/helpers'
import { messages } from '../../utils/messages'
import { sendTransactionByVotingKey } from '../../utils/helpers'
import swal from 'sweetalert2'
const ACCEPT = 1
@ -648,14 +648,9 @@ export class BallotCard extends React.Component {
render() {
let { contractsStore, votingType, children } = this.props
let ballotClass = this.showCard()
? this.isFinalized
? 'ballots-i'
: 'ballots-i ballots-i-not-finalized'
: 'ballots-i display-none'
let voteScaleClass = 'vote-scale'
let hasAlreadyVotedLabel = (
<div className="ballots-i--vote ballots-i--vote-label ballots-i--vote-label-right ballots-i--vote_no">
<div className="sw-BallotCard_Vote sw-BallotCard_VoteLabel sw-BallotCard_VoteLabel-right sw-BallotCard_Vote_no">
You already voted
</div>
)
@ -663,21 +658,22 @@ export class BallotCard extends React.Component {
const threshold = this.getThreshold(contractsStore, votingType)
let toggleShowMore =
this.memo.length > maxDetailsLength ? (
<span className="toggle-show more" onClick={this.toggleDetails}>
<span className="tg-ToggleShow" onClick={this.toggleDetails}>
{this.state.detailsCollapsed ? 'More...' : 'Less'}
</span>
) : (
''
)
let votingScale
if (votingType === 'votingToManageEmissionFunds') {
votingScale = (
<div className="ballots-i-scale">
<div className="ballots-i-scale-column ballots-i-scale-column-3">
<div className="sw-BallotCard_Scale">
<div className="sw-BallotCard_ScaleColumn sw-BallotCard_ScaleColumn-3">
<button
type="button"
onClick={e => this.vote({ choice: BURN })}
className="btn btn-danger ballots-i--vote_btn xl m-r-20"
className="btn btn-danger sw-BallotCard_VoteButton xl m-r-20"
>
Burn
</button>
@ -692,11 +688,11 @@ export class BallotCard extends React.Component {
</div>
</div>
</div>
<div className="ballots-i-scale-column ballots-i-scale-column-3">
<div className="sw-BallotCard_ScaleColumn sw-BallotCard_ScaleColumn-3">
<button
type="button"
onClick={e => this.vote({ choice: FREEZE })}
className="btn btn-freeze ballots-i--vote_btn xl m-r-20"
className="btn btn-freeze sw-BallotCard_VoteButton xl m-r-20"
>
Freeze
</button>
@ -711,9 +707,9 @@ export class BallotCard extends React.Component {
</div>
</div>
</div>
<div className="ballots-i-scale-column ballots-i-scale-column-3">
<div className="sw-BallotCard_ScaleColumn sw-BallotCard_ScaleColumn-3">
<button
className="btn btn-success ballots-i--vote_btn xl m-r-20"
className="btn btn-success sw-BallotCard_VoteButton xl m-r-20"
onClick={e => this.vote({ choice: SEND })}
type="button"
>
@ -734,12 +730,12 @@ export class BallotCard extends React.Component {
)
} else {
votingScale = (
<div className="ballots-i-scale">
<div className="ballots-i-scale-column">
<div className="sw-BallotCard_Scale">
<div className="sw-BallotCard_ScaleColumn">
<button
type="button"
onClick={e => this.vote({ choice: REJECT })}
className="btn btn-danger ballots-i--vote_btn m-r-20"
className="btn btn-danger sw-BallotCard_VoteButton m-r-20"
>
No
</button>
@ -754,7 +750,7 @@ export class BallotCard extends React.Component {
</div>
</div>
</div>
<div className="ballots-i-scale-column reverse-responsive">
<div className="sw-BallotCard_ScaleColumn reverse-responsive">
<div className="vote-scale--container">
<p className="vote-scale--votes">{this.votesForNumber} Votes</p>
<p className="vote-scale--percentage">{this.votesForPercents}%</p>
@ -763,7 +759,7 @@ export class BallotCard extends React.Component {
</div>
</div>
<button
className="btn btn-success ballots-i--vote_btn m-l-20"
className="btn btn-success sw-BallotCard_VoteButton m-l-20"
onClick={e => this.vote({ choice: ACCEPT })}
type="button"
>
@ -773,23 +769,28 @@ export class BallotCard extends React.Component {
</div>
)
}
return (
<div className={ballotClass}>
<div className="ballots-about">
<div className="ballots-about-i ballots-about-i_name">
<div className="ballots-about-td ballots-about-td-title">
<p className="ballots-about-i--title">Proposer</p>
<div
className={`sw-BallotCard ${this.isFinalized ? 'ballots-i-not-finalized' : ''} ${
!this.showCard() ? 'hidden' : ''
}`}
>
<div className="sw-BallotAbout">
<div className="sw-BallotAbout-i sw-BallotAbout-i_name">
<div className="sw-BallotAbout-td sw-BallotAbout-td-title">
<p className="sw-BallotAbout-i--title">Proposer</p>
</div>
<div className="ballots-about-td ballots-about-td-value">
<p className="ballots-i--name">{this.creator}</p>
<div className="sw-BallotAbout-td sw-BallotAbout-td-value">
<p className="sw-BallotCard_Name">{this.creator}</p>
</div>
</div>
{children}
<div className="ballots-about-i ballots-about-i_time">
<div className="ballots-about-td ballots-about-td-title">
<p className="ballots-about-i--title">Ballot Time (UTC)</p>
<div className="sw-BallotAbout-i sw-BallotAbout-i_time">
<div className="sw-BallotAbout-td sw-BallotAbout-td-title">
<p className="sw-BallotAbout-i--title">Ballot Time (UTC)</p>
</div>
<div className="ballots-about-td ballots-about-td-value">
<div className="sw-BallotAbout-td sw-BallotAbout-td-value">
<p className="ballots-i--created">{this.startTime}</p>
<p className="ballots-i--time">
{this.timeTo.displayValue}&nbsp;({this.timeTo.title})
@ -798,11 +799,15 @@ export class BallotCard extends React.Component {
</div>
</div>
{votingScale}
<div className="info-container">
<div className="info info-minimum">
<div className="bc-BallotInfoContainer">
<div className="bc-BallotInfoContainer_Info bc-BallotInfoContainer_Info-minimum">
Minimum {threshold} from {contractsStore.validatorsLength} validators are required to pass the proposal
</div>
<div className={`info info-details ${this.state.detailsCollapsed ? 'collapsed' : ''}`}>
<div
className={`bc-BallotInfoContainer_Info bc-BallotInfoContainer_Info-details ${
this.state.detailsCollapsed ? 'bc-BallotInfoContainer_Info-collapsed' : ''
}`}
>
{this.state.detailsCollapsed
? this.memo.substr(0, this.memo.lastIndexOf(' ', maxDetailsLength))
: this.memo}
@ -817,7 +822,7 @@ export class BallotCard extends React.Component {
<p>{this.cancelOrFinalizeDescription}</p>
</div>
{showHasAlreadyVotedLabel}
<div className="ballots-i--vote-label">
<div className="sw-BallotCard_VoteLabel">
{this.typeName(votingType)} Ballot ID: {this.props.id}
</div>
</div>

View File

@ -1,6 +1,6 @@
import React from 'react'
import { inject, observer } from 'mobx-react'
import { BallotCard } from './BallotCard.jsx'
import { BallotCard } from './BallotCard'
@inject('contractsStore')
@observer
@ -10,17 +10,17 @@ export class BallotEmissionFundsCard extends React.Component {
const amount = contractsStore.web3Instance.utils.fromWei(votingState.amount, 'ether')
return (
<BallotCard votingType="votingToManageEmissionFunds" votingState={votingState} id={id} pos={pos}>
<div className="ballots-about-i ballots-about-i_proposed_receiver">
<div className="sw-BallotAbout-i sw-BallotAbout-i_proposed_receiver">
<div className="ballots-about-td ballots-about-td-title">
<p className="ballots-about-i--title">Proposed Receiver</p>
<p className="sw-BallotAbout-i--title">Proposed Receiver</p>
</div>
<div className="ballots-about-td ballots-about-td-value">
<p>{votingState.receiver}</p>
</div>
</div>
<div className="ballots-about-i ballots-about-i_funds_amount">
<div className="sw-BallotAbout-i sw-BallotAbout-i_funds_amount">
<div className="ballots-about-td ballots-about-td-title">
<p className="ballots-about-i--title">Funds Amount</p>
<p className="sw-BallotAbout-i--title">Funds Amount</p>
</div>
<div className="ballots-about-td ballots-about-td-value">
<p>{amount} POA</p>

View File

@ -1,6 +1,6 @@
import React from 'react'
import { inject, observer } from 'mobx-react'
import { BallotCard } from './BallotCard.jsx'
import { BallotCard } from './BallotCard'
@inject('commonStore', 'routing')
@observer
@ -14,18 +14,18 @@ export class BallotKeysCard extends React.Component {
let miningKeyDiv
if (votingState.isAddMining) {
affectedKeyClassName = 'ballots-about-i_key_wide'
affectedKeyClassName = 'sw-BallotAbout-i_key_wide'
if (votingState.newVotingKey || votingState.newPayoutKey) {
affectedKey = <p>Mining: {votingState.affectedKey}</p>
if (votingState.newVotingKey) newVotingKey = <p>Voting: {votingState.newVotingKey}</p>
if (votingState.newPayoutKey) newPayoutKey = <p>Payout: {votingState.newPayoutKey}</p>
}
} else {
affectedKeyClassName = 'ballots-about-i_key'
affectedKeyClassName = 'sw-BallotAbout-i_key'
miningKeyDiv = (
<div className="ballots-about-i ballots-about-i_key">
<div className="sw-BallotAbout-i sw-BallotAbout-i_key">
<div className="ballots-about-td ballots-about-td-title">
<p className="ballots-about-i--title">Validator key</p>
<p className="sw-BallotAbout-i--title">Validator key</p>
</div>
<div className="ballots-about-td ballots-about-td-value">
<p>{votingState.miningKey}</p>
@ -36,25 +36,25 @@ export class BallotKeysCard extends React.Component {
return (
<BallotCard votingType="votingToChangeKeys" votingState={votingState} id={id} pos={pos}>
<div className="ballots-about-i ballots-about-i_action">
<div className="sw-BallotAbout-i sw-BallotAbout-i_action">
<div className="ballots-about-td ballots-about-td-title">
<p className="ballots-about-i--title">Action</p>
<p className="sw-BallotAbout-i--title">Action</p>
</div>
<div className="ballots-about-td ballots-about-td-value">
<p>{votingState.ballotTypeDisplayName}</p>
</div>
</div>
<div className="ballots-about-i ballots-about-i_type">
<div className="sw-BallotAbout-i sw-BallotAbout-i_type">
<div className="ballots-about-td ballots-about-td-title">
<p className="ballots-about-i--title">Key type</p>
<p className="sw-BallotAbout-i--title">Key type</p>
</div>
<div className="ballots-about-td ballots-about-td-value">
<p>{votingState.affectedKeyTypeDisplayName}</p>
</div>
</div>
<div className={`ballots-about-i ${affectedKeyClassName}`}>
<div className={`sw-BallotAbout-i ${affectedKeyClassName}`}>
<div className="ballots-about-td ballots-about-td-title">
<p className="ballots-about-i--title">Affected key</p>
<p className="sw-BallotAbout-i--title">Affected key</p>
</div>
<div className="ballots-about-td ballots-about-td-value">
{affectedKey}

View File

@ -1,6 +1,6 @@
import React from 'react'
import { inject, observer } from 'mobx-react'
import { BallotCard } from './BallotCard.jsx'
import { BallotCard } from './BallotCard'
@inject('commonStore', 'routing')
@observer
@ -9,9 +9,9 @@ export class BallotMinThresholdCard extends React.Component {
let { id, votingState, pos } = this.props
return (
<BallotCard votingType="votingToChangeMinThreshold" votingState={votingState} id={id} pos={pos}>
<div className="ballots-about-i ballots-about-i_proposed-min-threshold">
<div className="sw-BallotAbout-i sw-BallotAbout-i_proposed-min-threshold">
<div className="ballots-about-td ballots-about-td-title">
<p className="ballots-about-i--title">Proposed min threshold</p>
<p className="sw-BallotAbout-i--title">Proposed min threshold</p>
</div>
<div className="ballots-about-td ballots-about-td-value">
<p>{votingState.proposedValue}</p>

View File

@ -1,6 +1,6 @@
import React from 'react'
import { inject, observer } from 'mobx-react'
import { BallotCard } from './BallotCard.jsx'
import { BallotCard } from './BallotCard'
@inject('commonStore', 'ballotStore', 'routing')
@observer
@ -9,17 +9,17 @@ export class BallotProxyCard extends React.Component {
const { id, votingState, pos } = this.props
return (
<BallotCard votingType="votingToChangeProxy" votingState={votingState} id={id} pos={pos}>
<div className="ballots-about-i ballots-about-i_contract-type">
<div className="sw-BallotAbout-i sw-BallotAbout-i_contract-type">
<div className="ballots-about-td ballots-about-td-title">
<p className="ballots-about-i--title">Contract type</p>
<p className="sw-BallotAbout-i--title">Contract type</p>
</div>
<div className="ballots-about-td ballots-about-td-value">
<p>{votingState.contractTypeDisplayName}</p>
</div>
</div>
<div className="ballots-about-i ballots-about-i_proposed-address">
<div className="sw-BallotAbout-i sw-BallotAbout-i_proposed-address">
<div className="ballots-about-td ballots-about-td-title">
<p className="ballots-about-i--title">Proposed contract address</p>
<p className="sw-BallotAbout-i--title">Proposed contract address</p>
</div>
<div className="ballots-about-td ballots-about-td-value">
<p>{votingState.proposedValue}</p>

View File

@ -139,6 +139,7 @@ export class Ballots extends React.Component {
render() {
const { ballotsStore, commonStore } = this.props
let ballotCards = ballotsStore.ballotCards.toJS().sort((a, b) => {
return b.props.votingState.startTime - a.props.votingState.startTime
})
@ -148,6 +149,7 @@ export class Ballots extends React.Component {
}
let loadMoreButton
if (ballotCards.length > this.limit && !commonStore.isActiveFilter && !commonStore.isToFinalizeFilter) {
loadMoreButton = (
<div className="center">
@ -160,10 +162,12 @@ export class Ballots extends React.Component {
</button>
</div>
)
ballotCards.splice(this.limit)
}
return (
<section className="container ballots">
<section className="sw-Ballots">
{ballotCards}
{loadMoreButton}
</section>

View File

@ -1,4 +1,4 @@
export { Ballots } from './Ballots.jsx'
export { Ballots } from './Ballots'
export { BaseLoader } from './BaseLoader'
export { Footer } from './Footer'
export { Header } from './Header'