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

grant/fund redesign #2921

Merged
merged 5 commits into from
Nov 26, 2018
Merged
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
4 changes: 4 additions & 0 deletions app/assets/v2/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ span {
border-radius: 4px !important;
}

.font-weight-semibold {
font-weight: 600;
}

#tutorials li{
list-style: none;
}
Expand Down
2 changes: 1 addition & 1 deletion app/assets/v2/css/buttons.css
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,5 @@ button:focus {
background: none;
color: white;
border: 2px solid white;
border-radius: 10px;
border-radius: 4px;
}
2 changes: 1 addition & 1 deletion app/assets/v2/css/forms/input.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.form__input {
background-color: #FFF;
border-radius: 3px;
border-radius: 2px;
border: 1px solid #D3D3D3;
font-size: 14px;
padding: 5px 7px;
Expand Down
49 changes: 45 additions & 4 deletions app/assets/v2/css/grants/fund.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,52 @@
color: #43484D;
}

#frequency_count {
height: 40px !important;
#grants_form input {
height: 2.5rem !important;
}

.grant-banner-img {
.select2-container--default .select2-selection--single,
#grants_form input {
border-color: #0D0764 !important;
}

.grant-banner img {
max-height: 20rem;
width: 100%;
overflow-y: hidden;
}
}

.grant-banner {
background-color: #F2F6F9;
width: 100%;
}

.grant-banner .grant-title {
font-weight: 600;
}

.grant-banner .grant-title a {
color: #000;
}

.summary p {
margin: 0 0 4px;
}

.summary i {
font-size: 6px;
position: relative;
bottom: 2px;
}

@media (max-width: 767.98px) {

.banner-img {
text-align: center;
}

.banner-img img {
width: auto;
max-width: 100%;
}
}
41 changes: 37 additions & 4 deletions app/assets/v2/js/grants/fund.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
/* eslint-disable no-console */
$(document).ready(function() {

$('#period').select2();

$('.js-select2').each(function() {
$(this).select2();
});

$('.select2-selection__rendered').hover(function() {
$(this).removeAttr('title');
});

updateSummary();

// alert("Just so you know, you will perform two actions in MetaMask on this page!")

$('#js-fundGrant').validate({
Expand Down Expand Up @@ -37,11 +41,12 @@ $(document).ready(function() {
}

let deployedSubscription = new web3.eth.Contract(compiledSubscription.abi, data.contract_address);
let deployedToken;

if (data.token_address != '0x0000000000000000000000000000000000000000') {
let deployedToken = new web3.eth.Contract(compiledToken.abi, data.token_address);
deployedToken = new web3.eth.Contract(compiledToken.abi, data.token_address);
} else {
let deployedToken = new web3.eth.Contract(compiledToken.abi, data.denomination);
deployedToken = new web3.eth.Contract(compiledToken.abi, data.denomination);
}

deployedToken.methods.decimals().call(function(err, decimals) {
Expand Down Expand Up @@ -169,3 +174,31 @@ $(document).ready(function() {
$('#js-token').select2();
});
});

const updateSummary = (element) => {

$('#summary-period').html($('input#frequency_count').val());
$('#summary-amount').html($('input#amount').val() ? $('input#amount').val() : 0);
$('#summary-frequency').html($('input#period').val() ? $('input#period').val() : 0);
$('#summary-frequency-unit').html($('#frequency_unit').val());

$('#js-token').on('select2:select', event => {
$('#summary-token').html(event.params.data.text);
});

$('#frequency_unit').on('select2:select', event => {
$('#summary-frequency-unit').html(event.params.data.text);
});

$('input#frequency_count').on('input', () => {
$('#summary-period').html($('input#frequency_count').val());
});

$('input#amount').on('input', () => {
$('#summary-amount').html($('input#amount').val());
});

$('input#period').on('input', () => {
$('#summary-frequency').html($('input#period').val());
});
};
16 changes: 15 additions & 1 deletion app/assets/v2/js/grants/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $(document).ready(function() {
});
};

setInterval(listen_web3_1_changes, 300);
setInterval(listen_web3_1_changes, 1000);

const show_error_banner = (result) => {
if ($('#grants_form').length) {
Expand All @@ -32,10 +32,22 @@ $(document).ready(function() {
$('#grants_form').addClass('hidden');
$('.submit_bounty .newsletter').addClass('hidden');
$('#unlock_metamask_error').css('display', 'none');
$('#connect_metamask_error').css('display', 'none');
$('#no_issue_error').css('display', 'none');
mixpanel_track_once('No Metamask Error', params);
} else if (is_metamask_unlocked && !is_metamask_approved) {
$('#connect_metamask_error').css('display', 'block');
$('#unlock_metamask_error').css('display', 'none');
$('#zero_balance_error').css('display', 'none');
$('#no_metamask_error').css('display', 'none');
$('#robot_error').removeClass('hidden');
$('#grants_form').addClass('hidden');
$('.submit_bounty .newsletter').addClass('hidden');
$('#no_issue_error').css('display', 'none');
mixpanel_track_once('Unlock Metamask Error', params);
} else if (!result) {
$('#unlock_metamask_error').css('display', 'block');
$('#connect_metamask_error').css('display', 'none');
$('#zero_balance_error').css('display', 'none');
$('#no_metamask_error').css('display', 'none');
$('#robot_error').removeClass('hidden');
Expand All @@ -49,13 +61,15 @@ $(document).ready(function() {
$('#grants_form').addClass('hidden');
$('.submit_bounty .newsletter').addClass('hidden');
$('#unlock_metamask_error').css('display', 'none');
$('#connect_metamask_error').css('display', 'none');
$('#no_metamask_error').css('display', 'none');
$('#no_issue_error').css('display', 'none');
mixpanel_track_once('Zero Balance Metamask Error', params);
} else {
$('#zero_balance_error').css('display', 'none');
$('#unlock_metamask_error').css('display', 'none');
$('#no_metamask_error').css('display', 'none');
$('#connect_metamask_error').css('display', 'none');
$('#no_issue_error').css('display', 'block');
$('#robot_error').addClass('hidden');
$('#grants_form').removeClass('hidden');
Expand Down
2 changes: 1 addition & 1 deletion app/assets/v2/js/metamask-approval.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function ask_metamask_connection() {

shown_on = [ '/tip/send/2', '/kudos/send', '/ens' ];
var len = page_url.length - 1;

if (page_url.lastIndexOf('/') === len) {
page_url = page_url.substring(0, len);
}
Expand Down
32 changes: 16 additions & 16 deletions app/assets/v2/js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,22 +938,22 @@ var listen_for_web3_changes = async function() {
document.listen_for_web3_iterations += 1;
}

if (typeof web3 == 'undefined') {
currentNetwork();
trigger_form_hooks();
} else if (typeof web3 == 'undefined' || typeof web3.eth == 'undefined' || typeof web3.eth.coinbase == 'undefined' || !web3.eth.coinbase) {
currentNetwork('locked');
trigger_form_hooks();
} else {
is_metamask_unlocked = true;
web3.eth.getBalance(web3.eth.coinbase, function(errors, result) {
if (errors) {
return;
}
if (typeof result != 'undefined') {
document.balance = result.toNumber();
}
});
if (typeof web3 == 'undefined') {
currentNetwork();
trigger_form_hooks();
} else if (typeof web3 == 'undefined' || typeof web3.eth == 'undefined' || typeof web3.eth.coinbase == 'undefined' || !web3.eth.coinbase) {
currentNetwork('locked');
trigger_form_hooks();
} else {
is_metamask_unlocked = true;
web3.eth.getBalance(web3.eth.coinbase, function(errors, result) {
if (errors) {
return;
}
if (typeof result != 'undefined') {
document.balance = result.toNumber();
}
});

web3.version.getNetwork(function(error, netId) {
if (error) {
Expand Down
9 changes: 8 additions & 1 deletion app/dashboard/templates/shared/connect_metamask.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,18 @@ <h3>{% trans "Please Connect to Metamask to Continue" %}</h3>
</p>
<p>
{% trans "Please connect to Metamask and refresh the page." %}
<button id="metamask_connect" onclick="approve_metamask()">{% trans "Click here to connect to metamask" %}</button>
<button id="metamask_connect" class="font-caption mx-1" onclick="approve_metamask()">{% trans "Click here to connect to metamask" %}</button>
</p>
</div>
<div class="col-lg-2 col-sm-12">
<img src="{% static "v2/images/metamask.svg" %}" alt="Metamask Logo">
</div>
</div>
</div>

<style>
#connect_metamask_error #metamask_connect {
position: relative;
bottom: 2px;
}
</style>
3 changes: 2 additions & 1 deletion app/grants/templates/grants/cancel.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@
{% include 'shared/no_metamask_error.html' %}
{% include 'shared/zero_balance_error.html' %}
{% include 'shared/unlock_metamask.html' %}
{% include 'shared/connect_metamask.html' %}
</div>
</div>
</div>
<img src="{% static "v2/images/bitmap.png" %}" width="100%" />

<div class="row">
<div id="robot_error" class="hidden">
<div id="robot_error" class="hidden my-5">
<img src="{% static "v2/images/prime.png" %}">
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions app/grants/templates/grants/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ <h1 class="grant__title font-title-lg {% if is_admin %} mt-4 {% endif %}">
</div>
</div>
</div>
{% if user_subscription %}
<h5>
{% trans 'You have agreed to contribute' %} {{ user_subscription.amount_per_period|floatformat:2|intcomma }} {{ user_subscription.token_symbol }} every {{ user_subscription.frequency }} {{ user_subscription.frequency_unit }}
</h5>
{% endif %}
</div>
{% if grant_is_inactive %}
<h4 class="my-4" >{% trans "This grant has ended. You can find all active grants" %}
Expand Down Expand Up @@ -145,6 +140,11 @@ <h5 class="font-body token_symbol">
</button>
</div>
{% endif %}
{% if user_subscription %}
<h5 class="font-body mt-2 font-weight-semibold">
{% trans 'You have agreed to contribute' %} {{ user_subscription.amount_per_period|floatformat:2|intcomma }} {{ user_subscription.token_symbol }} every {{ user_subscription.frequency }} {{ user_subscription.frequency_unit }}
</h5>
{% endif %}
</div>
</div>
</div>
Expand Down
Loading