diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 131ff91..3aa3366 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -1,2 +1,3 @@ @import "theme"; @import "bootstrap"; +@import "books"; diff --git a/app/assets/stylesheets/books.scss b/app/assets/stylesheets/books.scss index 81379d1..2a59d1a 100644 --- a/app/assets/stylesheets/books.scss +++ b/app/assets/stylesheets/books.scss @@ -1,3 +1,42 @@ -// Place all the styles related to the books controller here. -// They will automatically be included in application.css. -// You can use Sass (SCSS) here: http://sass-lang.com/ +.books-page { + .book { + border:none; + + .card-title small { + display: block; + color: #999; + margin-top: 5px; + } + + img { + padding: 10px; + @include media-breakpoint-down(xs) { max-height: 250px; } + @include media-breakpoint-up(sm) { width: 160px; } + } + } +} + +.book-page { + margin-top: 30px; + + header.main { + margin: 30px 0 30px; + + .author { + font-size: 1.2rem; + color: #999; + margin-top: -3px; + } + } + + .book { + border: none; + + img { + @include media-breakpoint-down(xs) { max-height: 250px; } + @include media-breakpoint-up(sm) { width: 160px; } + } + + .book-details { padding: 0 20px 0 40px; } + } +} diff --git a/app/views/books/edit.html.erb b/app/views/books/edit.html.erb index 4a9cf97..1275e33 100644 --- a/app/views/books/edit.html.erb +++ b/app/views/books/edit.html.erb @@ -1,31 +1,41 @@ -

Editar Libro

-<%= form_for @book do |f| %> -
- <%= f.label :title %> - <%= f.text_field :title %> +
+
+
+
+
Editar Libro
+ <%= form_for @book do |f| %> +
+
+ <%= f.label :title %> + <%= f.text_field :title, class: "form-control" %> +
+
+ <%= f.label :author %> + <%= f.text_field :author, class: "form-control" %> +
+
+ <%= f.label :description %> + <%= f.text_area :description, rows: 4, class: "form-control" %> +
+
+ <%= f.label :image_url %> + <%= f.url_field :image_url, class: "form-control" %> +
+
+ <%= f.label :publication_date %> + <%= f.date_field :publication_date, class: "form-control" %> +
+
+ <%= f.label :price %> + <%= f.number_field :price, class: "form-control", step: :any %> +
+
+ + <% end %> +
+
-
- <%= f.label :author %> - <%= f.text_field :author %> -
-
- <%= f.label :description %> - <%= f.text_area :description %> -
-
- <%= f.label :image_url %> - <%= f.text_field :image_url %> -
-
- <%= f.label :publication_date %> - <%= f.date_field :publication_date %> -
-
- <%= f.label :price %> - <%= f.number_field :price, step: :any %> -
- -
- <%= f.submit %> -
-<% end %> +
diff --git a/app/views/books/index.html.erb b/app/views/books/index.html.erb index bd9abdd..075da1c 100644 --- a/app/views/books/index.html.erb +++ b/app/views/books/index.html.erb @@ -1,28 +1,23 @@ -

Libros

-<%= link_to "Nuevo Libro", new_book_path %> - - - - - - - - - - +
+
+
<%= link_to "Agregar Libro", new_book_path, class: "btn btn-primary rounded-0" %>
+ <% @books.each do |book| %> -
- - - - - + + <% end %> - -
TítuloDescripciónFecha de Publicación
<%= book.title %><%= book.description %><%= book.publication_date %> - <%= link_to "Mostrar", book %> +
+ <%= book.title %> +
+
+ <%= book.title %> + <%= book.author %> +
+

<%= book.description %>

+ <%= link_to "Detalles", book, class: "btn btn-primary" %> <% if signed_in? %> - <%= link_to "Editar", edit_book_path(book) %> - <%= link_to "Eliminar", book, method: :delete, data: { confirm: "¿Estás seguro de eliminar este libro?" } %> + <%= link_to "Editar", edit_book_path(book), class: "btn btn-link" %> + <%= link_to "Eliminar", book, class: "btn btn-link text-danger", method: :delete, data: { confirm: "¿Estás seguro de eliminar este libro?" } %> <% end %> -
+
+ diff --git a/app/views/books/new.html.erb b/app/views/books/new.html.erb index c661f70..59953b8 100644 --- a/app/views/books/new.html.erb +++ b/app/views/books/new.html.erb @@ -1,31 +1,42 @@ -

Nuevo Libro

-<%= form_for @book do |f| %> -
- <%= f.label :title %> - <%= f.text_field :title %> -
-
- <%= f.label :author %> - <%= f.text_field :author %> -
-
- <%= f.label :description %> - <%= f.text_area :description %> -
-
- <%= f.label :image_url %> - <%= f.text_field :image_url %> -
-
- <%= f.label :publication_date %> - <%= f.date_field :publication_date %> -
-
- <%= f.label :price %> - <%= f.number_field :price, step: :any %> -
+
+
+
+
+
Agregar Libro
+ <%= form_for @book do |f| %> +
+
+ <%= f.label :title %> + <%= f.text_field :title, class: "form-control", autofocus: true %> +
+
+ <%= f.label :author %> + <%= f.text_field :author, class: "form-control" %> +
+
+ <%= f.label :description %> + <%= f.text_area :description, rows: 4, class: "form-control" %> +
+
+ <%= f.label :image_url %> + <%= f.url_field :image_url, class: "form-control" %> +
+
+ <%= f.label :publication_date %> + <%= f.date_field :publication_date, class: "form-control" %> +
+
+ <%= f.label :price %> + <%= f.number_field :price, class: "form-control", step: :any %> +
-
- <%= f.submit %> +
+ + <% end %> +
+
-<% end %> +
diff --git a/app/views/books/show.html.erb b/app/views/books/show.html.erb index 3501e25..9a02d86 100644 --- a/app/views/books/show.html.erb +++ b/app/views/books/show.html.erb @@ -1,6 +1,29 @@ -

Detalles del Libro

-
Nombre: <%= @book.title %>
-
Autor: <%= @book.author %>
-
Descripción: <%= @book.description %>
-
Fecha de publicación: <%= @book.publication_date %>
-
Precio: <%= @book.price %>
+
+
+ <%= link_to "← Volver".html_safe, books_path, class: "btn btn-link" %> + +
+

<%= @book.title %>

+
<%= @book.author %>
+
+ +
+ <%= @book.title %> +
+

<%= @book.description %>

+
+
Fecha de publicación
+
<%= @book.publication_date %>
+
Precio
+
<%= @book.price %>
+
+
+ <% if signed_in? %> + <%= link_to "Editar", edit_book_path(@book), class: "btn btn-link" %> + <%= link_to "Eliminar", @book, class: "btn btn-link text-danger", method: :delete, data: { confirm: "¿Estás seguro de eliminar este libro?" } %> + <% end %> +
+
+
+
+
diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb new file mode 100644 index 0000000..1e66f3d --- /dev/null +++ b/app/views/devise/registrations/edit.html.erb @@ -0,0 +1,43 @@ +

Edit <%= resource_name.to_s.humanize %>

+ +<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true %> +
+ + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> +
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
+ <% end %> + +
+ <%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, autocomplete: "off" %> + <% if @minimum_password_length %> +
+ <%= @minimum_password_length %> characters minimum + <% end %> +
+ +
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: "off" %> +
+ +
+ <%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password, autocomplete: "off" %> +
+ +
+ <%= f.submit "Update" %> +
+<% end %> + +

Cancel my account

+ +

Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>

+ +<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb new file mode 100644 index 0000000..3702b0f --- /dev/null +++ b/app/views/devise/registrations/new.html.erb @@ -0,0 +1,41 @@ +
+
+
+
+
+
Sign up
+
+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> + <%= devise_error_messages! %> + +
+ <%= f.label :email %> + <%= f.email_field :email, class: "form-control", autofocus: true %> +
+ +
+ <%= f.label :password %> + <% if @minimum_password_length %> + (<%= @minimum_password_length %> characters minimum) + <% end %> + <%= f.password_field :password, class: "form-control", autocomplete: "off" %> +
+ +
+ <%= f.label :password_confirmation %> + <%= f.password_field :password_confirmation, class: "form-control", autocomplete: "off" %> +
+ +
+ <%= f.submit "Sign up", class: "btn btn-primary" %> +
+ <% end %> +
+
+ + <%= render "devise/shared/links" %> + +
+
+
+
diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb new file mode 100644 index 0000000..57cf594 --- /dev/null +++ b/app/views/devise/sessions/new.html.erb @@ -0,0 +1,38 @@ +
+
+
+
+
+
Login
+
+ <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> +
+ <%= f.label :email %> + <%= f.email_field :email, class: "form-control", autofocus: true %> +
+ +
+ <%= f.label :password %> + <%= f.password_field :password, class: "form-control", autocomplete: "off" %> +
+ + <% if devise_mapping.rememberable? -%> +
+ <%= f.check_box :remember_me %> + <%= f.label :remember_me %> +
+ <% end -%> + +
+ <%= f.submit "Log in", class: "btn btn-primary" %> +
+ <% end %> +
+
+ + <%= render "devise/shared/links" %> + +
+
+
+
diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb new file mode 100644 index 0000000..e6a3e41 --- /dev/null +++ b/app/views/devise/shared/_links.html.erb @@ -0,0 +1,25 @@ +<%- if controller_name != 'sessions' %> + <%= link_to "Log in", new_session_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.registerable? && controller_name != 'registrations' %> + <%= link_to "Sign up", new_registration_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> + <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> + <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> + <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+<% end -%> + +<%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %>
+ <% end -%> +<% end -%> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index c72a917..dc4a6e3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -9,14 +9,25 @@ -
- <% if signed_in? %> - <%= link_to "Salir", destroy_user_session_path, method: :delete %> - <% else %> - <%= link_to "Registrarse", new_user_registration_path %> - <%= link_to "Ingresar", new_user_session_path %> - <% end %> -
+ <%= yield %>