Skip to content

Commit

Permalink
Merge pull request #3706 from DFE-Digital/create-events-card-component
Browse files Browse the repository at this point in the history
Create separate Events card component
  • Loading branch information
garethwilliamsdesign authored Nov 23, 2023
2 parents a78ee6e + c7ea89f commit fffb89f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/components/events/card_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<li class="category__nav-card">
<%= link_to(path, class: "link--black") do %>
<div class="category__nav-card--content">
<%= content_tag(heading_tag, title) %>
<%= tag.p(helpers.safe_html_format(description)) %>
</div>
<% end %>
</li>
12 changes: 12 additions & 0 deletions app/components/events/card_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Events::CardComponent < ViewComponent::Base
attr_reader :title, :description, :path, :heading_tag

def initialize(card:, heading_tag: "h3")
@title = card.title
@description = card.description
@path = card.path
@heading_tag = heading_tag

super
end
end
2 changes: 1 addition & 1 deletion app/views/teaching_events/about_git_events.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<section id="events" class="category__cards">
<%= tag.nav(class: "category__nav-cards") do %>
<ul class="one-column horizontal">
<%= render(Categories::CardComponent.with_collection(categorise_events(@git_events))) %>
<%= render(Events::CardComponent.with_collection(categorise_events(@git_events))) %>
</ul>
<% end %>
<div>
Expand Down

0 comments on commit fffb89f

Please sign in to comment.