Skip to content

Commit df269c7

Browse files
guillaumebridayguillaumebriday-pamarcoroth
authored
Using cards for links in pages (#8)
* Using cards for links in pages * Use `Page::CardSectionComponent` for index pages * Lint --------- Co-authored-by: Guillaume Briday <guillaume.briday@per-angusta.com> Co-authored-by: Marco Roth <marco.roth@intergga.ch>
1 parent 694ea6a commit df269c7

File tree

4 files changed

+10
-19
lines changed

4 files changed

+10
-19
lines changed

app/components/page/card_section_component.html.erb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
<h2 class="text-2xl font-bold mt-12 mb-6">
2-
<%= @title %>
3-
</h2>
1+
<% if @title %>
2+
<h2 class="text-2xl font-bold mt-12 mb-6">
3+
<%= @title %>
4+
</h2>
5+
<% end %>
46

57
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 mb-4">
68
<% @resources.each do |resource| %>
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# frozen_string_literal: true
22

33
class Page::CardSectionComponent < ViewComponent::Base
4-
def initialize(title:, resources:, limit: 3, all_url: nil)
4+
def initialize(resources:, title: nil, all_url: nil)
55
@title = title
66
@resources = resources
7-
@limit = limit
87
@all_url = all_url
98
end
109
end

app/content/pages/community.html.erb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ title: Community
55
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
66
<% page.with_title(title: current_page.data.fetch("title")) %>
77

8-
<div class="grid grid-cols-3">
9-
<% CommunityModel.all.sort_by(&:title).each do |page| %>
10-
<div class="flex flex-col gap-x-4">
11-
<h2 class="font-bold text-lg underline"><%= link_to page.title, page.request_path %></h2>
12-
</div>
13-
<% end %>
14-
</div>
8+
<% pages = CommunityModel.all.sort_by(&:title) %>
9+
<%= render Page::CardSectionComponent.new(resources: pages) %>
1510
<% end %>

app/content/pages/documentation.html.erb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ title: Documentation
55
<%= render Page::ContainerComponent.new(page: current_page) do |page| %>
66
<% page.with_title(title: current_page.data.fetch("title")) %>
77

8-
<div class="grid grid-cols-3">
9-
<% DocumentationModel.all.sort_by(&:title).each do |page| %>
10-
<div class="flex flex-col gap-x-4">
11-
<h2 class="font-bold text-lg underline"><%= link_to page.title, page.request_path %></h2>
12-
</div>
13-
<% end %>
14-
</div>
8+
<% pages = DocumentationModel.all.sort_by(&:title) %>
9+
<%= render Page::CardSectionComponent.new(resources: pages) %>
1510
<% end %>

0 commit comments

Comments
 (0)