Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Add sign-in UI WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed Jul 13, 2017
1 parent abb0eb9 commit 11ebe8a
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 14 deletions.
2 changes: 1 addition & 1 deletion js/gratipay.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gratipay.init = function() {
Gratipay.warnOffUsersFromDeveloperConsole();
Gratipay.adaptToLongUsernames();
Gratipay.forms.initCSRF();
Gratipay.signIn.wireUpButton();
Gratipay.signIn.wireUp();
Gratipay.signOut();
Gratipay.payments.initSupportGratipay();
Gratipay.tabs.init();
Expand Down
35 changes: 31 additions & 4 deletions js/gratipay/sign-in.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
Gratipay.signIn = {};

Gratipay.signIn.wireUp = function() {
Gratipay.signIn.wireUpButton();
Gratipay.signIn.wireUpEmailInput();
}

Gratipay.signIn.wireUpButton = function() {
$('.sign-in button').click(Gratipay.signIn.openSignInOrSignUpModal);
}

Gratipay.signIn.openSignInToContinueModal = function () {
Gratipay.signIn.wireUpEmailInput = function() {
$('#sign-in-modal form.email-form').submit(function(e) {
e.preventDefault();
jQuery.ajax({
url: '/auth/email/send_link.json',
type: 'POST',
data: {
'email_address': $(this).find('input').val()
},
success: function(data) {
Gratipay.notification(data.message, 'success');
},
error: Gratipay.error
});
});
}

Gratipay.signIn.openSignInToContinueModal = function() {
Gratipay.signIn.replaceTextInModal('sign-in-to-continue');
Gratipay.modal.open('#sign-in-modal');
Gratipay.signIn.openModalAndFocusInput();
}

Gratipay.signIn.openSignInOrSignUpModal = function () {
Gratipay.signIn.openSignInOrSignUpModal = function() {
Gratipay.signIn.replaceTextInModal('sign-in-or-sign-up');
Gratipay.modal.open('#sign-in-modal');
Gratipay.signIn.openModalAndFocusInput();
}

Gratipay.signIn.replaceTextInModal = function(dataKey) {
Expand All @@ -20,3 +42,8 @@ Gratipay.signIn.replaceTextInModal = function(dataKey) {
$(this).text(textToReplace);
});
}

Gratipay.signIn.openModalAndFocusInput = function() {
Gratipay.modal.open('#sign-in-modal');
$('#sign-in-modal input').focus();
}
2 changes: 1 addition & 1 deletion scss/components/modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
text-align: center;
display: none;
background: transparentize($light-brown, 0.3);
z-index: 1000;
z-index: 900;
}

.modal {
Expand Down
28 changes: 22 additions & 6 deletions scss/components/sign_in.scss
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,15 @@
}
}

.email-form input {
color: $black;
height: auto;
padding: 10px;
}

.auth-links {
margin-top: 5px;
margin-bottom: 10px;
}

.auth-links li {
Expand All @@ -71,14 +78,27 @@
}
}

.auth-links button {
.auth-links button, .email-form button {
text-align: left;
background: $green;
color: white;
padding: 15px 45px 15px 15px;
position: relative;
font: normal 14px $Ideal;

&:hover {
background: $darker-green;
}
}

.email-form button {
padding: 15px 15px 15px 15px;
margin: 15px 0px 20px 0px;
text-align: center;
}

.auth-links button {
padding: 15px 45px 15px 15px; // 30px for icon on the right

span {
vertical-align: middle;
}
Expand All @@ -95,10 +115,6 @@
span.icon.github { @include has-icon("github"); }
span.icon.openstreetmap { @include has-icon("openstreetmap"); }
span.icon.bitbucket { @include has-icon("bitbucket"); }

&:hover {
background: $darker-green;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion scss/elements/elements.scss
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ textarea {
}

input {
&[type="text"], &[type="number"], &[type="password"] {
&[type="text"], &[type="number"], &[type="password"], &[type="email"] {
@include border-radius(3px);
height: 22px;
border: 1px solid $brown;
Expand Down
14 changes: 14 additions & 0 deletions templates/sign-in-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@
</button>
</header>
<section>
<p class="sign-in-togglable"
data-sign-in-to-continue="{{ _('Enter your email to sign-in to Gratipay') }}"
data-sign-in-or-sign-up="{{ _('Enter your email to sign-in or create an account on Gratipay') }}">
{{ _('Enter your email to sign-in or create an account on Gratipay') }}
</p>

<form class="email-form">
<input type="email" placeholder="[email protected]" required/>

<button class="button" type="submit">
{{ _("Email me a link") }}
</button>
</form>

<p class="sign-in-togglable"
data-sign-in-to-continue="{{ _('Please sign in to continue') }}"
data-sign-in-or-sign-up="{{ _('Use a third-party provider to sign in or create an account on Gratipay:') }}">
Expand Down
2 changes: 1 addition & 1 deletion www/auth/email/send_link.json.spt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if participant:
message = _("We've sent you a link to sign in. Please check your inbox.")
else:
# TODO: Create sign-up link!
raise Response(400, "no participant exists by this address")
raise Response(400, _("No user found by this address. Sign-up via email not implemented yet, stay tuned."))

[---] application/json via json_dump
{"message": message}

0 comments on commit 11ebe8a

Please sign in to comment.