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

User Profile: Course cards from user reviews #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 19 additions & 0 deletions app/assets/stylesheets/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,22 @@ body {
margin-top: -0.1em;
}

.text-bg-primary {
background: rgba($gray-100, 0.9);
padding: .075em;
}

.text-limit {
position: relative;
}

$text-limit-line-height: 1.25em;

.text-limit-4-inner {
position: relative;
display: inline-block;
word-wrap: break-word;
overflow: hidden;
line-height: $text-limit-line-height;
max-height: $text-limit-line-height * 4;
}
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выделить в какой-то класс типа user-profile-course-card и вынести в отдельный файл, вряд ли я буду это где-то использовать.

1 change: 1 addition & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class UsersController < ApplicationController
before_action :set_user

def show
@reviews = @user.reviews
end

def edit
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Allcourses</title>
<title><%= t 'app_name' %></title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

Expand All @@ -23,7 +23,7 @@
</div>

<footer class="page-footer container pb-4">
&copy; <a href="#">AllCourses.com</a>
&copy; <%= t 'app_name' %> 2018&ndash;&infin;
</footer>
</body>
</html>
2 changes: 1 addition & 1 deletion app/views/partials/_navbar.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<ul class="navbar-nav mr-auto">
<a class="navbar-brand" href="/">AllCourses.com</a>
<a class="navbar-brand font-weight-bold" href="/"><%= t 'app_name' %></a>
</ul>

<button class="navbar-toggler" type="button" data-toggle="collapse"
Expand Down
25 changes: 25 additions & 0 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,30 @@
class: 'btn btn-outline-primary btn-sm' %></p>
<% end %>
</div>

</div>

<div class="row">
<% @reviews.each do |review| %>
<% course = review.course %>

<div class="col-md-4 col-lg-3 col-sm-6 mb-4">
<div class="card bg-light">
<img class="card-img" src="https://placeimg.com/300/200/tech?t=<%= rand(10000) %>" alt="[Logo]">

<div class="card-img-overlay">
<h5 class="font-weight-bold h3 text-limit my-0">
<span class="text-limit-4-inner">
<span class="text-bg-primary"><%= course.title %></span>
</span>
</h5>
<div><small class="badge badge-primary"><%= course.genre %></small></div>
</div>

<div class="card-footer">
<div><%= rating_stars_for(review.rating) %></div>
</div>
</div>
</div>
<% end %>
</div>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Выделить карточку в отдельный паршал, посмотреть, можно ли влить это в тот же .row.

1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
# available at http://guides.rubyonrails.org/i18n.html.

en:
app_name: AllCourses
time:
formats:
date: '%d %B %Y'