Skip to content

Commit

Permalink
updated city
Browse files Browse the repository at this point in the history
  • Loading branch information
Levin committed Oct 19, 2024
1 parent c17afc8 commit 49d518e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/algground_web/live/components/region.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defmodule AlggroundWeb.Components.Region do
|> assign(:region, region)}
end

# <img src={@region.image} class="absolute h-14 left-0 top-9 " />
def render(assigns) do
~H"""
<div
Expand All @@ -20,7 +21,6 @@ defmodule AlggroundWeb.Components.Region do
class="py-4 cursor-pointer text-center text-base font-semibold text-indigo-800 mb-2 bg-gray-50 rounded-lg"
>
<%= display_region(assigns) %>
<img src={@region.image} class="absolute h-14 left-0 top-9 " />
<div id={"information_" <> @region.region} class="hidden">
<div class=" mb-8">
Expand Down
46 changes: 46 additions & 0 deletions lib/algground_web/live/components/search_bar.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
defmodule AlggroundWeb.SearchBar do
use AlggroundWeb, :live_component

def update(%{regions: regions}, socket) do
{:ok,
socket
|> assign(:regions, regions)
|> assign(:found_regions, [])}
end

def handle_event("search_region", %{"region" => region}, socket) do
regions =
case Enum.filter(
socket.assigns.regions,
fn stored_region ->
String.contains?(stored_region.region, region)
end
) do
[] -> socket.assigns.regions
filtered -> filtered
end

{:noreply,
socket
|> assign(:regions, regions)}
end

def render(assigns) do
~H"""
<div>
<div class="mb-4">
<.simple_form for={%{}} phx-target={@myself} phx-change="search_region">
<.input type="text" name="region" value="" class="" placeholder="where are you going ?" />
</.simple_form>
</div>
<%= for region <- @regions do %>
<.live_component
module={AlggroundWeb.Components.Region}
region={region}
id={region.region <> "#{System.unique_integer()}"}
/>
<% end %>
</div>
"""
end
end
4 changes: 2 additions & 2 deletions lib/algground_web/live/pages/live_home_page.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ defmodule AlggroundWeb.LiveHomePage do
<%= Datex.Date.format_date(@date, "DD/MM/YYYY") %>
</p>
<p class="mx-auto max-w-lg text-pretty text-center font-medium tracking-tight text-gray-950 text-3xl">
Albufeira
<%= Enum.random(@regions).region %>
</p>
<p class="mx-auto max-w-lg text-pretty text-center text-4xl font-medium tracking-tight text-gray-950 sm:text-3xl ">
<%= display_groundwater(assigns) %>
Expand All @@ -84,7 +84,6 @@ defmodule AlggroundWeb.LiveHomePage do
</p>
<div class="mt-10 grid gap-4 sm:mt-4 ">
<div class="relative mb-4">
<div class="absolute inset-px bg-white rounded-t-[2rem]"></div>
<div class="relative flex h-full flex-col overflow-hidden rounded-[calc(2rem+1px)]">
<div class="flex justify-evenly mb-8">
<div class="px-8 pt-8 sm:px-10 sm:pt-10">
Expand All @@ -109,6 +108,7 @@ defmodule AlggroundWeb.LiveHomePage do
</div>
</div>
</div>
<div class="mb-4"></div>
<div class="relative">
<div class="absolute inset-px rounded-lg bg-white lg:rounded-l-[2rem]"></div>
<div class="relative flex h-full flex-col overflow-hidden rounded-[calc(theme(borderRadius.lg)+1px)] lg:rounded-l-[calc(2rem+1px)]">
Expand Down

0 comments on commit 49d518e

Please sign in to comment.