-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from NafaaBout/master
Adds User attributes validations, displays errors on the forms and tweak the design.
- Loading branch information
Showing
22 changed files
with
180 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,106 @@ | ||
$input_width: 300px; | ||
|
||
.form { | ||
text-align: center; | ||
|
||
&.signup { | ||
margin-left: 13%; | ||
|
||
.form-group { | ||
display: inline-block; | ||
min-width: 60%; | ||
} | ||
|
||
} | ||
|
||
&.signin { | ||
|
||
.form-group { | ||
display: inline-block; | ||
text-align: center; | ||
} | ||
|
||
} | ||
} | ||
|
||
.form-errors { | ||
max-width: $input_width - 50px; | ||
margin: auto; | ||
border-bottom: 2px solid $error; | ||
padding-bottom: 5px; | ||
// margin-bottom: 10px; | ||
color: orangered; | ||
text-align: center; | ||
} | ||
|
||
.form-field { | ||
margin: 20px auto 50px 30px; | ||
margin: 20px auto 50px auto; | ||
text-align: center; | ||
|
||
input { | ||
font-size: $medium; | ||
font-weight: $light; | ||
color: $secondary; | ||
background: transparent; | ||
border: none; | ||
border-bottom: 2px solid $default; | ||
outline: none; | ||
padding: 10px; | ||
text-align: center; | ||
max-width: $input_width; | ||
|
||
input { | ||
font-size: $medium; | ||
font-weight: $light; | ||
&::-webkit-input-placeholder { | ||
color: $secondary; | ||
background: transparent; | ||
border: none; | ||
border-bottom: 2px solid $default; | ||
outline: none; | ||
padding: 10px; | ||
text-align: center; | ||
} | ||
|
||
&::-webkit-input-placeholder { | ||
color: $secondary; | ||
} | ||
&:-moz-placeholder { /* Firefox 18- */ | ||
color: $secondary; | ||
} | ||
|
||
&:-moz-placeholder { /* Firefox 18- */ | ||
color: $secondary; | ||
} | ||
&::-moz-placeholder { /* Firefox 19+ */ | ||
color: $secondary; | ||
} | ||
|
||
&:-ms-input-placeholder { | ||
color: $secondary; | ||
} | ||
} | ||
|
||
.field_with_errors input { | ||
border-bottom: 2px solid $error; | ||
|
||
&::-moz-placeholder { /* Firefox 19+ */ | ||
color: $secondary; | ||
} | ||
&::-webkit-input-placeholder { | ||
color: lighten($error, 10%); | ||
} | ||
|
||
&:-moz-placeholder { /* Firefox 18- */ | ||
color: lighten($error, 10%); | ||
} | ||
|
||
&:-ms-input-placeholder { | ||
color: $secondary; | ||
} | ||
&::-moz-placeholder { /* Firefox 19+ */ | ||
color: lighten($error, 10%); | ||
} | ||
|
||
&:-ms-input-placeholder { | ||
color: lighten($error, 10%); | ||
} | ||
} | ||
|
||
.error-msg { | ||
color: $error; | ||
max-width: $input_width + 50px; | ||
} | ||
} | ||
|
||
.submit-form { | ||
text-align:center; | ||
|
||
input { | ||
@extend .button | ||
} | ||
} | ||
|
||
.form-field--login { | ||
@extend .form-field; | ||
margin-left: 0; | ||
} | ||
|
||
.login-or-register { | ||
margin-top: 10px; | ||
display: inline-block; | ||
text-align: center; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module UsersHelper | ||
def add_errors_of(errors, field) | ||
if errors.include?(field) | ||
errors.full_messages_for(field).each do |msg| | ||
concat(content_tag(:div, msg, class: 'error-msg')) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,30 @@ | ||
.verba-brand | ||
= image_tag("https://d1015h9unskp4y.cloudfront.net/attachments/bae8bafd-4081-4b2b-b6f4-c9d4c367ded8/verba.png", class: "verba-logo") | ||
.row | ||
.col-sm-12 | ||
.verba-brand | ||
= image_tag("https://d1015h9unskp4y.cloudfront.net/attachments/bae8bafd-4081-4b2b-b6f4-c9d4c367ded8/verba.png", class: "verba-logo") | ||
|
||
.form.col-sm-6.col-lg-offset-3 | ||
= form_tag(login_path) do | ||
.form-field--login.col-sm-12 | ||
= text_field_tag :username, nil, placeholder: "username" | ||
.form-field--login.col-sm-12 | ||
= password_field_tag :password, nil, placeholder: "password" | ||
.submit-form.col-sm-12 | ||
= submit_tag "Login" | ||
.row | ||
.col-sm-12 | ||
= form_tag(login_path, html: { class: "form signin" }) do | ||
- if flash.alert | ||
.form-group | ||
.row | ||
.col-sm-12 | ||
.form-errors | ||
= flash.alert | ||
|
||
= link_to "Register", new_user_path, class: "link login-or-register" | ||
.row | ||
.col-sm-12 | ||
.form-field | ||
= text_field_tag :username, nil, placeholder: "username" | ||
.row | ||
.col-sm-12 | ||
.form-field | ||
= password_field_tag :password, nil, placeholder: "password" | ||
.row | ||
.col-md-12 | ||
.submit-form | ||
= submit_tag "Login" | ||
|
||
.login-or-register | ||
= link_to "Register", new_user_path, class: "link" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
.verba-brand | ||
= image_tag("https://d1015h9unskp4y.cloudfront.net/attachments/bae8bafd-4081-4b2b-b6f4-c9d4c367ded8/verba.png", class: "verba-logo") | ||
.row | ||
.col-sm-12 | ||
.verba-brand | ||
= image_tag("https://d1015h9unskp4y.cloudfront.net/attachments/bae8bafd-4081-4b2b-b6f4-c9d4c367ded8/verba.png", class: "verba-logo") | ||
|
||
.form.signup.col-sm-9 | ||
= form_for(@user) do |f| | ||
.form-group | ||
.form-field.col-sm-5 | ||
= f.text_field :username, placeholder: "username" | ||
.form-field.col-sm-5.col-sm-offset-2 | ||
= f.text_field :email, placeholder: "email" | ||
.form-group | ||
.form-field.col-sm-5 | ||
= f.password_field :password, placeholder: "password" | ||
.form-field.col-sm-5.col-sm-offset-2 | ||
= f.password_field :password_confirmation, placeholder: "password confirmation" | ||
.submit-form | ||
= submit_tag "Sign up" | ||
.row | ||
.col-sm-12 | ||
= form_for(@user, html: {class: "form signup" }) do |f| | ||
|
||
= link_to "Log in", login_path, class: "link login-or-register" | ||
.form-group | ||
.row | ||
.col-md-6.col-sm-12 | ||
.form-field | ||
= f.text_field :username, placeholder: "username" | ||
- add_errors_of(@user.errors, :username ) | ||
.col-md-6.col-sm-12 | ||
.form-field | ||
= f.text_field :email, placeholder: "email" | ||
- add_errors_of(@user.errors, :email ) | ||
.form-group | ||
.row | ||
.col-md-6.col-sm-12 | ||
.form-field | ||
= f.password_field :password, placeholder: "password" | ||
- add_errors_of(@user.errors, :password ) | ||
.col-md-6.col-sm-12 | ||
.form-field | ||
= f.password_field :password_confirmation, placeholder: "password confirmation" | ||
- add_errors_of(@user.errors, :password_confirmation ) | ||
.row | ||
.col-sm-12 | ||
.submit-form | ||
= submit_tag "Sign up" | ||
|
||
.login-or-register | ||
= link_to "Log in", login_path, class: 'link' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
FactoryGirl.define do | ||
factory :user do | ||
username "garrettqmartin" | ||
password "12345" | ||
password_confirmation "12345" | ||
password "12345678" | ||
password_confirmation { password } | ||
email "garrett@example.com" | ||
end | ||
end |
2 changes: 1 addition & 1 deletion
2
spec/models/achievement_awarder_spec.rb → .../achievements/achievement_awarder_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...els/bronze_word_count_achievement_spec.rb → ...nts/bronze_word_count_achievement_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...els/silver_word_count_achievement_spec.rb → ...nts/silver_word_count_achievement_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.