Skip to content

Commit

Permalink
Use a new event rendering template to remove boilerplate (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
crespire authored Nov 17, 2024
1 parent 472a5bd commit d3fe42a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 8 deletions.
45 changes: 45 additions & 0 deletions app/views/events/_event2.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<div
id="<%= dom_id event2 %>"
class="p-3 border rounded border-solid border-black"
>
<% future = Time.zone.now < event2.start_at %>
<div class="md:flex text-left">
<div class="w-full md:w-1/2 my-8 pr-1">
<h2 class="mb-2"><%= link_to event2.name, event2 %></h2>
<div class="flex flex-col gap-3">
<p class="mb-2"><%= event2.start_time %></p>
<%= event2.location %>
</div>
</div>

<div class="w-full md:w-1/2 my-8 pl-1">
<h2 class="mb-2">Agenda</h2>
<div class="ml-4">
<div class="w-4/5 mt-2">
<%= event2.description %>
</div>
</div>
</div>
</div>
<div class="mx-auto text-center">
<% if future %>
<div class="mb-6">
<%= link_to event2.rsvp_link, class: "rounded-full bg-ruby px-4 py-2.5 font-semibold text-white/100 shadow-sm ring-1 ring-inset ring-ruby hover:bg-red-400" do %>
Join the event
<% end %>
</div>
<% end %>
<% if event2.sponsor %>
<h3 Sponsor</h3>
<div class="flex justify-center items-center">
<%= link_to event2.sponsor_link do %>
<% if event2.sponsor_logo.present? %>
<%= image_tag "sponsors/#{event2.sponsor_logo}", class: "max-h-20" %>
<% else %>
<%= event2.sponsor.titleize %>
<% end %>
<% end %>
</div>
<% end %>
</div>
</div>
11 changes: 5 additions & 6 deletions app/views/events/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<%= content_for :event_content do %>
<%# For an upcoming event, make a "past_event" and use the partial here %>
<%# Otherwise, use the placeholder partial %>

<%= render partial: "event", collection: @events %>
<%= render partial: "event2", collection: @events %>

<h2 class="hidden only:block">We're planning our next outing, stay tuned!</h2>
<% end %>

<% content_for :page_title do %>
Home
Home
<% end %>

<% content_for :page_description do %>
Toronto Ruby is about building a community for Ruby users in the GTA and providing a positive space for everyone to connect, learn and grow. We're looking forward to seeing you!
Toronto Ruby is about building a community for Ruby users in the GTA and
providing a positive space for everyone to connect, learn and grow. We're
looking forward to seeing you!
<% end %>

<%= render partial: "layouts/event_layout" %>
4 changes: 2 additions & 2 deletions app/views/events/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<% content_for :page_title do %>
<%= @event.name %>
<%= @event.name %>
<% end %>

<%= content_for :event_content do %>
<%= render partial: "events/event", locals: { event: @event } %>
<%= render partial: "events/event2", locals: { event: @event } %>
<% end %>

<%= render partial: "layouts/event_layout" %>

0 comments on commit d3fe42a

Please sign in to comment.