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

[#44] Add styles to Lesson index #45

Merged
merged 4 commits into from
Mar 19, 2024
Merged
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
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
*
*= require_self
*= require layouts/main
*= require lesson
*/
27 changes: 2 additions & 25 deletions app/assets/stylesheets/layouts/lesson.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,6 @@
justify-self: end;
}

.lesson-item {
display: grid;
grid-template-columns: 20% 80%;
grid-template-rows: auto;
width: 50%;
}

.lesson-item-thumbnail {
grid-column: 1 / 2;
grid-row: 1 / span 3;
place-self: center;
}

.lesson-item-title {
grid-column: 2 / 3;
grid-row: 1 / 2;
padding: 10px;
}

.lesson-item-subtitle {
grid-column: 2 / 3;
grid-row: 2 / 3;
padding: 10px;
}

.lesson-list {
display: flex;
flex-wrap: wrap;
Expand All @@ -121,6 +96,8 @@

.lesson-header {
display: flex;
flex-flow: row no-wrap;
justify-content: space-between;
gap: 10px;
margin-bottom: 20px;
}
Expand Down
7 changes: 7 additions & 0 deletions app/assets/stylesheets/layouts/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,10 @@ article {
font-size: 2rem;
}
}

a {
color: var(--secondary);
text-decoration: none;
font-size: 1.2rem;
cursor: pointer;
}
74 changes: 74 additions & 0 deletions app/assets/stylesheets/lesson.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
.lessons {
.list {
display: flex;
flex-wrap: wrap;
gap: 10px;
}

.header {
display: flex;
flex-flow: row no-wrap;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;

.title {
order: 1;
align-self: flex-start;
}

.new {
order: 2;
align-self: center;
}
}
}

.video-card {
display: grid;

grid-template-columns: 20% 80%;
grid-template-rows: auto;
width: 45%;

background-color: var(--bg-dark);
border-radius: 5px;
/* border: 1px solid red; */

box-shadow:
rgba(50, 50, 93, 0.25) 0px 6px 12px -2px,
rgba(0, 0, 0, 0.3) 0px 3px 7px -3px;

.thumbnail {
grid-column: 1 / 2;
grid-row: 1 / span 3;
place-self: center;
width: 100%;
height: 100%;
}

.title {
grid-column: 2 / 3;
grid-row: 1 / 2;
padding: 10px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;

a {
color: var(--accent);
text-decoration: none;
font-size: 24px;
}
}

.subtitle {
grid-column: 2 / 3;
grid-row: 2 / 3;
padding: 10px;

color: var(--neutral);
font-size: 14px;
text-overflow: ellipsis;
}
}
8 changes: 4 additions & 4 deletions app/views/lessons/_lesson.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div id="<%= dom_id lesson %>" class="lesson-item">
<%= image_tag(video_thumbnail_url(lesson), class: "lesson-item-thumbnail", size: "314x177") %>
<div class="lesson-item-title">
<div id="<%= dom_id lesson %>" class="video-card">
<%= image_tag(video_thumbnail_url(lesson), class: "thumbnail") %>
<div class="title">
<%= instrument_emoji(lesson) %>
<%= link_to lesson.name, lesson, data: { turbo: false } %>
</div>
<% if lesson.sections.size > 0 && lesson.current_objective then %>
<div class="lesson-item-subtitle">
<div class="subtitle">
Now learning: <%= lesson.sections.where(current: true)&.first&.name %>
</div>
<% end %>
Expand Down
37 changes: 20 additions & 17 deletions app/views/lessons/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
<p style="color: green"><%= notice %></p>

<div class="lesson-header">
<div class="lesson-title">
Lessons
</div>
<div class="lesson-new">
<%= link_to "New lesson",
new_lesson_path,
data: { turbo_frame: dom_id(Lesson.new) },
class: "lesson-new"
%>
<div class="lessons">
<div class="header">
<div class="title">
<h1>Lessons</h1>
</div>

<div class="new">
<%= link_to "New lesson",
new_lesson_path,
data: { turbo_frame: dom_id(Lesson.new) }
%>
</div>
</div>
</div>

<%= turbo_frame_tag Lesson.new %>
<%= turbo_frame_tag Lesson.new %>

<%= turbo_frame_tag "lessons", class: "lesson-list" do %>
<% @lessons.each do |lesson| %>
<%= render lesson %>
<%= turbo_frame_tag "lessons", class: "list" do %>
<% @lessons.each do |lesson| %>
<%= render lesson %>
<% end %>
<% end %>
<% end %>

<%= paginate @lessons %>
<%= paginate @lessons %>
</div>

4 changes: 2 additions & 2 deletions test/system/lessons_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class LessonsTest < ApplicationSystemTestCase

test "visiting the index" do
visit lessons_url
assert_selector ".lesson-title", text: "Lessons"
assert_selector ".title", text: "Lessons"
end

test "should create lesson" do
Expand Down Expand Up @@ -37,7 +37,7 @@ class LessonsTest < ApplicationSystemTestCase
# assert_text "Lesson was successfully updated"
click_on "Back to lessons"

assert_selector ".lesson-title", text: "Lessons"
assert_selector ".title", text: "Lessons"
assert_text "New Light"
end

Expand Down