Skip to content

Commit d1d324c

Browse files
committed
Second pass at Turbo topic navigation with sidebar
1 parent 4a1b236 commit d1d324c

File tree

3 files changed

+68
-6
lines changed

3 files changed

+68
-6
lines changed

app/javascript/css/components/article-content.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,9 @@
131131
padding-inline-start: var(--space-s);
132132
}
133133
}
134+
135+
.column-content {
136+
& li:has(+ li) {
137+
margin-bottom: var(--space-xs);
138+
}
139+
}

app/views/topics/index.html.erb

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1-
<%= turbo_frame_tag :topic_articles, class: "row-gap-none", data: {turbo_action: "advance"} do %>
2-
<%= render "topic", topics: @topics %>
3-
<% end %>
1+
<% topics = @topics %>
2+
3+
<%= render Pages::Header.new(title: "Topics") %>
4+
5+
<div class="column-content container py-gap mb-3xl">
6+
<nav class="sidebar" data-turbo-permanent>
7+
<%= turbo_frame_tag :topics_sidebar do %>
8+
<% topics.each do |topic| %>
9+
<%= tag.div id: dom_id(topic), class: "text-small mb-2" do %>
10+
<%= link_to topic.name, topic_path(topic), data: {turbo_frame: :topics_mainbar} %>
11+
<span class="text-faint">(<%= topic.pages_count %>)</span>
12+
<% end %>
13+
<% end %>
14+
<% end %>
15+
</nav>
16+
<div class="mainbar w-full">
17+
<%= turbo_frame_tag :topics_mainbar, data: {turbo_action: "advance"} do %>
18+
<div>
19+
<h2>Welcome!</h2>
20+
<div>
21+
<p>Here you‘ll find topics currently covered at Joy of Rails.</p>
22+
<p>Choose a topic from the sidebar to view articles.</p>
23+
</div>
24+
</div>
25+
<% end %>
26+
</div>
27+
</div>

app/views/topics/show.html.erb

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1-
<%= turbo_frame_tag :topic_articles, class: "row-gap-none", data: {turbo_action: "advance"} do %>
2-
<%= render @topic, topics: @topics %>
3-
<% end %>
1+
<% topic = @topic
2+
topics = @topics %>
3+
4+
<%= render Pages::Header.new(title: "Topics") %>
5+
6+
<div class="column-content container py-gap mb-3xl">
7+
<nav class="sidebar" data-turbo-permanent>
8+
<%= turbo_frame_tag :topics_sidebar, src: topics_path %>
9+
</nav>
10+
<div class="mainbar w-full">
11+
<%= turbo_frame_tag :topics_mainbar, data: {turbo_action: "advance"} do %>
12+
<% if topic.pages.blank? %>
13+
<div>
14+
<h2>No articles have been added for this topic yet!</h2>
15+
<div>
16+
<p>Coming soon. Maybe ;)</p>
17+
</div>
18+
</div>
19+
<% else %>
20+
<ul>
21+
<% topic.pages.as_published_articles.each do |page| %>
22+
<%= tag.li id: dom_id(page) do %>
23+
<%= render Pages::Info.new(
24+
title: page.title,
25+
request_path: page.request_path,
26+
description: page.description,
27+
image: page.image
28+
) %>
29+
<% end %>
30+
<% end %>
31+
</ul>
32+
<% end %>
33+
<% end %>
34+
</div>
35+
</div>

0 commit comments

Comments
 (0)