Skip to content

Commit

Permalink
another button!
Browse files Browse the repository at this point in the history
  • Loading branch information
thecristen committed Dec 27, 2024
1 parent 1594d50 commit 2b2257d
Showing 1 changed file with 6 additions and 25 deletions.
31 changes: 6 additions & 25 deletions lib/dotcom_web/components/trip_planner/itinerary_detail.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,22 @@ defmodule DotcomWeb.Components.TripPlanner.ItineraryDetail do
<div :if={Enum.count(@itineraries) > 1}>
<p class="text-sm mb-2 mt-3">Depart at</p>
<div id="itinerary-detail-departure-times" class="flex flex-wrap gap-2">
<.depart_at_button
<.button
:for={{itinerary, index} <- Enum.with_index(@itineraries)}
active={@itinerary_selection == index}
type="button"
class={if(@itinerary_selection == index, do: "bg-brand-primary-lightest")}
size={:small}
variant={:secondary}
phx-click="select_itinerary"
phx-value-index={index}
>
{Timex.format!(itinerary.start, "%-I:%M%p", :strftime)}
</.depart_at_button>
</.button>
</div>
</div>
"""
end

attr :active, :boolean
attr :rest, :global
slot :inner_block

defp depart_at_button(%{active: active} = assigns) do
background_class = if active, do: "bg-brand-primary-lightest", else: "bg-transparent"
assigns = assign(assigns, :background_class, background_class)

~H"""
<button
type="button"
class={[
"border border-brand-primary rounded px-2.5 py-1.5 text-brand-primary text-lg",
"hover:bg-brand-primary-lightest #{@background_class}"
]}
{@rest}
>
{render_slot(@inner_block)}
</button>
"""
end

defp specific_itinerary_detail(assigns) do
assigns =
assigns
Expand Down

0 comments on commit 2b2257d

Please sign in to comment.