From c7ea89f0a703b0f8ab906d71e95e7c0fd0c8d6d1 Mon Sep 17 00:00:00 2001 From: Gareth Williams Date: Tue, 21 Nov 2023 10:26:43 +0000 Subject: [PATCH] Create separate Events card component --- app/components/events/card_component.html.erb | 8 ++++++++ app/components/events/card_component.rb | 12 ++++++++++++ app/views/teaching_events/about_git_events.html.erb | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 app/components/events/card_component.html.erb create mode 100644 app/components/events/card_component.rb diff --git a/app/components/events/card_component.html.erb b/app/components/events/card_component.html.erb new file mode 100644 index 0000000000..b6a9bc1542 --- /dev/null +++ b/app/components/events/card_component.html.erb @@ -0,0 +1,8 @@ +
  • + <%= link_to(path, class: "link--black") do %> +
    + <%= content_tag(heading_tag, title) %> + <%= tag.p(helpers.safe_html_format(description)) %> +
    + <% end %> +
  • diff --git a/app/components/events/card_component.rb b/app/components/events/card_component.rb new file mode 100644 index 0000000000..ce88e14a09 --- /dev/null +++ b/app/components/events/card_component.rb @@ -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 diff --git a/app/views/teaching_events/about_git_events.html.erb b/app/views/teaching_events/about_git_events.html.erb index 3d961419e7..ce80149468 100644 --- a/app/views/teaching_events/about_git_events.html.erb +++ b/app/views/teaching_events/about_git_events.html.erb @@ -51,7 +51,7 @@
    <%= tag.nav(class: "category__nav-cards") do %> <% end %>