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
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitpaulk committed Jul 15, 2017
1 parent 24a770d commit c0d2aca
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 17 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
18 changes: 15 additions & 3 deletions templates/sign-in-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,21 @@
</header>
<section>
<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:') }}">
{{ _('Use a third-party provider to sign in or create an account on Gratipay:') }}
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>
{{ _('Alternatively, use a third-party provider:') }}
</p>
<ul class="auth-links">
{% for platform in website.signin_platforms %}
Expand Down
2 changes: 1 addition & 1 deletion tests/ttw/test_sign_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ def test_401_page_opens_modal_automatically(self):
self.visit('/about/me/emails.json')

assert self.css('#sign-in-modal').visible
assert self.css('#sign-in-modal p')[0].text == 'Please sign in to continue'
assert self.css('#sign-in-modal p')[0].text == 'Enter your email to sign-in to Gratipay'

0 comments on commit c0d2aca

Please sign in to comment.