(add) stakes progress modal

pull/1704/head
Gabriel Rodriguez Alsina 6 years ago
parent ee635fa42a
commit afcf48168d
  1. 24
      apps/block_scout_web/assets/css/_mixins.scss
  2. 5
      apps/block_scout_web/assets/css/app.scss
  3. 6
      apps/block_scout_web/assets/css/components/_btn_add_full.scss
  4. 6
      apps/block_scout_web/assets/css/components/_btn_add_line.scss
  5. 6
      apps/block_scout_web/assets/css/components/_btn_full.scss
  6. 6
      apps/block_scout_web/assets/css/components/_btn_line.scss
  7. 6
      apps/block_scout_web/assets/css/components/_form.scss
  8. 22
      apps/block_scout_web/assets/css/components/_modal.scss
  9. 1
      apps/block_scout_web/assets/css/components/_stakes.scss
  10. 74
      apps/block_scout_web/assets/css/components/_stakes_progress.scss
  11. 40
      apps/block_scout_web/assets/js/lib/modals.js
  12. 9
      apps/block_scout_web/lib/block_scout_web/templates/common_components/_btn_add_full.html.eex
  13. 9
      apps/block_scout_web/lib/block_scout_web/templates/common_components/_btn_add_line.html.eex
  14. 9
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_btn_stake_more.html.eex
  15. 2
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_control_move.html.eex
  16. 2
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_control_stake.html.eex
  17. 2
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_control_withdraw.html.eex
  18. 2
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex
  19. 52
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_stake.html.eex
  20. 2
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_validator_info.html.eex
  21. 32
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_progress.html.eex
  22. 4
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_stats_item_account.html.eex
  23. 13
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_table.html.eex
  24. 2
      apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_title.html.eex

@ -72,16 +72,19 @@
align-items: center;
background-color: $bg-color;
border-radius: 2px;
border: 1px solid $bg-color;
cursor: pointer;
display: flex;
height: 36px;
justify-content: center;
outline: none;
padding: 0 15px;
transition: all 0.25s;
width: fit-content;
&:hover {
background-color: darken($bg-color, 10%);
border-color: darken($bg-color, 10%);
}
&-text {
@ -99,6 +102,16 @@
&.full-width {
width: 100%;
}
&[disabled] {
&,
&:hover {
background-color: $bg-color;
border-color: $bg-color;
cursor: default;
opacity: 0.5;
}
}
}
@mixin btn-line($bg-color: #fff, $text-color: $secondary) {
@ -110,6 +123,7 @@
display: flex;
height: 36px;
justify-content: center;
outline: none;
padding: 0 15px;
transition: all 0.25s;
width: fit-content;
@ -133,4 +147,14 @@
&.full-width {
width: 100%;
}
&[disabled] {
&,
&:hover {
background-color: $bg-color;
border-color: $text-color;
cursor: default;
opacity: 0.5;
}
}
}

@ -90,8 +90,8 @@ $fa-font-path: "~@fortawesome/fontawesome-free/webfonts";
@import "components/coin-balance-tile";
@import "components/highlight";
@import "components/copy_icon";
@import "components/btn_add_full";
@import "components/btn_add_line";
@import "components/btn_full";
@import "components/btn_line";
@import "components/stakes";
@import "components/check";
@import "components/stakes_table";
@ -104,6 +104,7 @@ $fa-font-path: "~@fortawesome/fontawesome-free/webfonts";
@import "components/modal";
@import "components/modal_validator_info";
@import "components/form";
@import "components/stakes_progress";
:export {
primary: $primary;

@ -1,6 +0,0 @@
$btn-add-full-bg: $primary !default;
$btn-add-full-color: #fff !default;
.btn-add-full {
@include btn-full($btn-add-full-bg, $btn-add-full-color);
}

@ -1,6 +0,0 @@
$btn-add-line-bg: #fff !default;
$btn-add-line-color: $secondary !default;
.btn-add-line {
@include btn-line($btn-add-line-bg, $btn-add-line-color);
}

@ -0,0 +1,6 @@
$btn-full-primary-bg: $primary !default;
$btn-full-primary-color: #fff !default;
.btn-full-primary {
@include btn-full($btn-full-primary-bg, $btn-full-primary-color);
}

@ -0,0 +1,6 @@
$btn-line-bg: #fff !default;
$btn-line-color: $secondary !default;
.btn-line {
@include btn-line($btn-line-bg, $btn-line-color);
}

@ -14,11 +14,15 @@ $form-control-border-color: #e2e5ec !default;
color: #a3a9b5;
font-size: 12px;
font-weight: normal;
line-height: 1.5;
line-height: 1.8;
.text-dark {
color: #333;
}
&.m-b-0 {
margin-bottom: 0;
}
}
.input-group-prepend.last {

@ -15,11 +15,14 @@ $modal-gray-background: #f6f7f9 !default;
.modal-header {
border-bottom: none;
padding: #{ $modal-vertical-padding } #{ $modal-horizontal-padding };
}
.close.close-modal {
margin: -70px -70px 0 0;
.close.close-modal {
left: auto;
opacity: 1;
}
position: absolute;
right: -35px;
top: -35px;
}
.modal-body {
@ -35,6 +38,7 @@ $modal-gray-background: #f6f7f9 !default;
.modal-content {
border-radius: $modal-border-radius;
position: relative;
}
.modal-bottom-disclaimer {
@ -49,6 +53,10 @@ $modal-gray-background: #f6f7f9 !default;
padding: #{ $modal-vertical-padding } #{ $modal-horizontal-padding };
text-align: left;
&.b-b-r-0 {
border-bottom-right-radius: 0;
}
.modal-bottom-disclaimer-graphic {
flex-shrink: 0;
padding-right: 15px;
@ -62,3 +70,11 @@ $modal-gray-background: #f6f7f9 !default;
.modal-become-candidate {
width: 280px;
}
.modal-stake {
width: 460px;
}
.modal-stake-two-cols {
display: flex;
}

@ -67,6 +67,7 @@ $stakes-banned-background: #fff3f7!default;
.stakes-top-stats-login {
color: $primary;
cursor: pointer;
margin-right: 8px;
}

@ -0,0 +1,74 @@
.stakes-progress {
.modal-stake-right & {
border-left: 1px solid $base-border-color;
flex-shrink: 0;
height: 100%;
padding: $modal-vertical-padding $modal-horizontal-padding;
width: 190px;
}
}
.stakes-progress-info {
margin-bottom: 25px;
&:last-child {
margin-bottom: 0;
}
}
.stakes-progress-info-title {
color: #a3a9b5;
font-size: 12px;
font-weight: normal;
line-height: 1.2;
margin: 0 0 12px;
text-align: left;
}
.stakes-progress-info-value {
color: #333;
font-size: 14px;
font-weight: normal;
line-height: 1.2;
margin: 0;
text-align: left;
&.link-color {
color: $primary;
}
}
.stakes-progress-graph {
margin: 0 0 20px;
position: relative;
}
.stakes-progress-graph-canvas {
position: relative;
z-index: 1;
}
.stakes-progress-data {
left: 50%;
position: absolute;
top: 50%;
transform: translateX(-50%) translateY(-50%);
z-index: 12;
}
.stakes-progress-data-total {
color: #a3a9b5;
font-size: 12px;
font-weight: normal;
line-height: 1.2;
text-align: center;
}
.stakes-progress-data-progress {
color: #333;
font-size: 24px;
font-weight: bold;
line-height: 1.2;
margin: 0 0 8px;
text-align: center;
}

@ -1,4 +1,5 @@
import $ from 'jquery'
import Chart from 'chart.js'
$(function () {
$('.js-become-candidate').on('click', function () {
@ -8,4 +9,43 @@ $(function () {
$('.js-validator-info-modal').on('click', function () {
$('#validatorInfoModal').modal()
})
$('.js-stake-stake').on('click', function () {
$('#stakeModal').modal()
const progress = parseInt($('.js-stakes-progress-data-progress').text())
const total = parseInt($('.js-stakes-progress-data-total').text())
setupStakesProgress(progress, total)
})
function setupStakesProgress (progress, total) {
const stakeProgress = $('#stakeProgress')
const primaryColor = $('.btn-full-primary').css('background-color')
const backgroundColors = [
primaryColor,
'rgba(202, 199, 226, 0.5)'
]
const progressBackground = total - progress
let myChart = new Chart(stakeProgress, {
type: 'doughnut',
data: {
datasets: [{
data: [progress, progressBackground],
backgroundColor: backgroundColors,
hoverBackgroundColor: backgroundColors,
borderWidth: 0
}]
},
options: {
cutoutPercentage: 80,
legend: {
display: false
},
tooltips: {
enabled: false
}
}
})
}
})

@ -1,6 +1,9 @@
<span class="btn-add-full <%= if assigns[:extra_class] do @extra_class end %>">
<button
class="btn-add-full btn-full-primary <%= if assigns[:extra_class] do @extra_class end %>"
<%= if assigns[:disabled] do "disabled" end %>
>
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14">
<path fill-rule="evenodd" d="M13 8H8v5a1 1 0 0 1-2 0V8H1a1 1 0 0 1 0-2h5V1a1 1 0 0 1 2 0v5h5a1 1 0 0 1 0 2z"/>
</svg>
<span class="btn-add-full-text"><%= @text %></span>
</span>
<span class="btn-full-primary-text"><%= @text %></span>
</button>

@ -1,6 +1,9 @@
<span class="btn-add-line <%= if assigns[:extra_class] do @extra_class end %>">
<button
class="btn-add-line btn-line <%= if assigns[:extra_class] do @extra_class end %>"
<%= if assigns[:disabled] do "disabled" end %>
>
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14">
<path fill-rule="evenodd" d="M13 8H8v5a1 1 0 0 1-2 0V8H1a1 1 0 0 1 0-2h5V1a1 1 0 0 1 2 0v5h5a1 1 0 0 1 0 2z"/>
</svg>
<span class="btn-add-line-text"><%= @text %></span>
</span>
<span class="btn-line-text"><%= @text %></span>
</button>

@ -0,0 +1,9 @@
<button
class="btn-stake-more-full btn-full-primary <%= if assigns[:extra_class] do @extra_class end %>"
<%= if assigns[:disabled] do "disabled" end %>
>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<path fill="#FFF" fill-rule="evenodd" d="M15 16H1a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1zm-1-3H2v1h12v-1zM8.785 8.675c-.114.114-.25.187-.394.237-.007.003-.012.01-.02.013a1.036 1.036 0 0 1-1.136-.221L4.296 5.765a1.038 1.038 0 1 1 1.469-1.469L7 5.531V1a1 1 0 0 1 2 0v4.54l1.246-1.246a1.033 1.033 0 0 1 1.46 1.46L8.785 8.675z"/>
</svg>
<span class="btn-full-primary-text"><%= @text %></span>
</button>

@ -1,4 +1,4 @@
<span class="stakes-control js-move-stake">
<span class="stakes-control <%= if assigns[:extra_class] do @extra_class end %>">
<svg class="stakes-control-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<path fill-rule="evenodd" d="M15 16H1a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h4.347l1.778 2H2v1h12v-1H8.875l1.778-2H15a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1zm0-11H9v3.532l1.252-1.253a1.028 1.028 0 1 1 1.455 1.456l-2.909 2.91c-.038.038-.087.054-.129.085a.945.945 0 0 1-.653.27h-.032a.971.971 0 0 1-.713-.315c-.006-.005-.013-.006-.018-.011L4.326 8.745A1.036 1.036 0 0 1 5.79 7.281L7 8.492V5H1a1 1 0 0 1-1-1V1a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1zm-1-3H2v1h12V2z"/>
</svg>

@ -1,4 +1,4 @@
<span class="stakes-control js-stake-stake">
<span class="stakes-control <%= if assigns[:extra_class] do @extra_class end %>">
<svg class="stakes-control-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<path fill-rule="evenodd" d="M15 16H1a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1zm-1-3H2v1h12v-1zM8.785 8.675c-.114.114-.25.187-.394.237-.007.003-.012.01-.02.013a1.035 1.035 0 0 1-1.136-.221L4.296 5.765a1.038 1.038 0 1 1 1.469-1.469L7 5.531V1a1 1 0 0 1 2 0v4.54l1.246-1.246a1.033 1.033 0 0 1 1.46 1.46L8.785 8.675z"/>
</svg>

@ -1,4 +1,4 @@
<span class="stakes-control js-withdraw-stake">
<span class="stakes-control <%= if assigns[:extra_class] do @extra_class end %>">
<svg class="stakes-control-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16">
<path fill-rule="evenodd" d="M15 16H1a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1zm-1-3H2v1h12v-1zm-3.754-8.279L9 3.479V8a1 1 0 0 1-2 0V3.488L5.765 4.719a1.042 1.042 0 0 1-1.469 0 1.032 1.032 0 0 1 0-1.464L7.235.326a1.04 1.04 0 0 1 1.137-.22c.007.003.012.01.019.013.144.049.28.122.394.236l2.921 2.911a1.027 1.027 0 0 1 0 1.455 1.036 1.036 0 0 1-1.46 0z"/>
</svg>

@ -3,12 +3,12 @@
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title"><%= gettext("Become Candidate") %></h5>
</div>
<button type="button" class="close close-modal" data-dismiss="modal" aria-label="Close">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18">
<path fill="#F6F7F9" fill-rule="evenodd" d="M10.435 8.983l7.261 7.261a1.027 1.027 0 1 1-1.452 1.452l-7.261-7.261-7.262 7.262a1.025 1.025 0 1 1-1.449-1.45l7.262-7.261L.273 1.725A1.027 1.027 0 1 1 1.725.273l7.261 7.261 7.23-7.231a1.025 1.025 0 1 1 1.449 1.45l-7.23 7.23z"/>
</svg>
</button>
</div>
<div class="modal-body">
<form>
<div class="input-group form-group">

@ -0,0 +1,52 @@
<div class="modal fade" id="stakeModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-stake" role="document">
<div class="modal-content">
<button type="button" class="close close-modal" data-dismiss="modal" aria-label="Close">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18">
<path fill="#F6F7F9" fill-rule="evenodd" d="M10.435 8.983l7.261 7.261a1.027 1.027 0 1 1-1.452 1.452l-7.261-7.261-7.262 7.262a1.025 1.025 0 1 1-1.449-1.45l7.262-7.261L.273 1.725A1.027 1.027 0 1 1 1.725.273l7.261 7.261 7.23-7.231a1.025 1.025 0 1 1 1.449 1.45l-7.23 7.23z"/>
</svg>
</button>
<div class="modal-stake-two-cols">
<div class="modal-stake-left">
<div class="modal-header">
<h5 class="modal-title"><%= gettext("Stake") %></h5>
</div>
<div class="modal-body">
<form>
<div class="input-group form-group">
<input type="text" class="form-control n-b-r" placeholder='<%= gettext("Amount") %>'>
<div class="input-group-prepend last">
<div class="input-group-text">POA20</div>
</div>
</div>
<p class="form-p m-b-0">Minimum Stake: <span class="text-dark">100 POA20</span></p>
<p class="form-p">Your Balance: <span class="text-dark">2000 POA20</span></p>
<div class="form-button">
<%= render BlockScoutWeb.StakesView, "_stakes_btn_stake_more.html", text: gettext("Stake More"), extra_class: "full-width" %>
</div>
</form>
</div>
<div class="modal-bottom-disclaimer b-b-r-0">
<div class="modal-bottom-disclaimer-graphic">
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="16">
<path fill="#333" fill-rule="evenodd" d="M9 16H1a1 1 0 0 1 0-2h3V6H1a1 1 0 0 1 0-2h4a1 1 0 0 1 1 1v9h3a1 1 0 0 1 0 2zM5 2H4a1 1 0 0 1 0-2h1a1 1 0 0 1 0 2z"/>
</svg>
</div>
<div class="modal-bottom-disclaimer-text">Lorem ipsum dolor sit amet, consect adipiscing elit, sed do eiusmod temp incididunt ut labore et dolore magna. Sed do eiusmod temp incididunt ut.</div>
</div>
</div>
<div class="modal-stake-right">
<%=
render BlockScoutWeb.StakesView,
"_stakes_progress.html",
progress: "900",
total: "2700",
pool: "0x7130-95a480",
stakes_ratio: "2.75%",
delegators: "1367"
%>
</div>
</div>
</div>
</div>
</div>

@ -3,12 +3,12 @@
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">0x18Bea833D503341C529a788c82909337e552a44e</h5>
</div>
<button type="button" class="close close-modal" data-dismiss="modal" aria-label="Close">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18">
<path fill="#F6F7F9" fill-rule="evenodd" d="M10.435 8.983l7.261 7.261a1.027 1.027 0 1 1-1.452 1.452l-7.261-7.261-7.262 7.262a1.025 1.025 0 1 1-1.449-1.45l7.262-7.261L.273 1.725A1.027 1.027 0 1 1 1.725.273l7.261 7.261 7.23-7.231a1.025 1.025 0 1 1 1.449 1.45l-7.23 7.23z"/>
</svg>
</button>
</div>
<div class="modal-validator-info-content">
<%=
render BlockScoutWeb.StakesView,

@ -0,0 +1,32 @@
<div class="stakes-progress">
<div class="stakes-progress-graph">
<canvas
class="stakes-progress-graph-canvas"
height="125"
id="stakeProgress"
width="125"
></canvas>
<div class="stakes-progress-data">
<div class="stakes-progress-data-progress js-stakes-progress-data-progress"><%= if assigns[:progress] do @progress end %></div>
<div class="stakes-progress-data-total js-stakes-progress-data-total"><%= if assigns[:total] do @total end %></div>
</div>
</div>
<div class="stakes-progress-info">
<h2 class="stakes-progress-info-title"><%= gettext("Pool") %></h2>
<p class="stakes-progress-info-value link-color">
<%= if assigns[:pool] do @pool end %>
</p>
</div>
<div class="stakes-progress-info">
<h2 class="stakes-progress-info-title"><%= gettext("Stakes Ratio") %></h2>
<p class="stakes-progress-info-value">
<%= if assigns[:stakes_ratio] do @stakes_ratio end %>
</p>
</div>
<div class="stakes-progress-info">
<h2 class="stakes-progress-info-title"><%= gettext("Delegators") %></h2>
<p class="stakes-progress-info-value link-color">
<%= if assigns[:delegators] do @delegators end %>
</p>
</div>
</div>

@ -7,9 +7,9 @@
<path fill-rule="evenodd" d="M13 10a1 1 0 0 1-1-1V2H5a1 1 0 0 1 0-2h8a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1zm-3-5v8a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h8a1 1 0 0 1 1 1zM8 6H2v6h6V6z"/>
</svg>
</div>
<%= else %>
<% else %>
<span class="stakes-top-stats-login">Login</span> with MetaMask
<%= end %>
<% end %>
</span>
<span class="stakes-top-stats-label">
<span class="stakes-top-stats-label-item"><%= gettext "Balance" %>:

@ -17,7 +17,7 @@
<%= render BlockScoutWeb.StakesView, "_stakes_empty_content.html" %>
</td>
</tr>
<%= end %>
<% end %>
<%= if not @empty_content do %>
<tr class="stakes-tr-banned">
<td class="stakes-td"><div class="stakes-td-order">1</div></td>
@ -68,18 +68,19 @@
<td class="stakes-td"><span class="stakes-td-link-style">1455</span></td>
<td class="stakes-td">
<div class="stakes-controls">
<%= render BlockScoutWeb.StakesView, "_stakes_control_move.html" %>
<%= render BlockScoutWeb.StakesView, "_stakes_control_withdraw.html" %>
<%= render BlockScoutWeb.StakesView, "_stakes_control_stake.html" %>
<%= render BlockScoutWeb.StakesView, "_stakes_control_move.html", extra_class: "js-move-stake" %>
<%= render BlockScoutWeb.StakesView, "_stakes_control_withdraw.html", extra_class: "js-withdraw-stake" %>
<%= render BlockScoutWeb.StakesView, "_stakes_control_stake.html", extra_class: "js-stake-stake" %>
</div>
</td>
</tr>
<%= end %>
<%= end %>
<% end %>
<% end %>
</tbody>
</table>
</div>
<%= render BlockScoutWeb.StakesView, "_stakes_modal_validator_info.html" %>
<%= render BlockScoutWeb.StakesView, "_stakes_modal_stake.html" %>
<%=
render BlockScoutWeb.CommonComponentsView,
"_pagination.html"

@ -7,7 +7,7 @@
<div class="check-icon"></div>
<div class="check-text">Show banned only</div>
</div>
<%= end %>
<% end %>
<div class="check card-title-control">
<input type="checkbox" />
<div class="check-icon"></div>

Loading…
Cancel
Save