Skip to content

Commit 900efff

Browse files
committed
Add search form
1 parent c42a3d8 commit 900efff

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

apps/components_guide_web/lib/components_guide_web/templates/layout/_header.html.eex renamed to apps/components_guide_web/lib/components_guide_web/templates/layout/_banner.html.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<span>Components <br>·Guide</span>
55
</a>
66
<nav role="navigation" class="flex-grow sm:pl-8 lg:px-16 text-base md:text-lg text-center">
7-
<ul class="h-full grid grid-cols-2 flex flex-col md:flex-row justify-around items-stretch tracking-wide">
7+
<ul class="h-full grid grid-cols-2 md:grid-cols-3 flex flex-col md:flex-row justify-around items-stretch tracking-wide">
88
<%= nav_items(@path_info) %>
99

1010
<% if false do %>

apps/components_guide_web/lib/components_guide_web/templates/layout/app.html.eex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<meta charset="utf-8"/>
55
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
66
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
7-
<title>Components.Guide</title>
7+
<title>Components.Guide — Web tutorials on React, Accessibility, Modern CSS, TypeScript</title>
88
<link rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/>
99
</head>
1010
<body>
11-
<%= render ComponentsGuideWeb.LayoutView, "_header.html", path_info: @conn.path_info %>
11+
<%= render ComponentsGuideWeb.LayoutView, "_banner.html", path_info: @conn.path_info %>
1212
<main role="main">
1313
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
1414
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>

apps/components_guide_web/lib/components_guide_web/views/layout_view.ex

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,28 @@ defmodule ComponentsGuideWeb.LayoutView do
88
@nav_links [
99
{"By Concept", to: "/concepts"},
1010
{"By Technology", to: "/links"},
11-
{"Patterns", to: "/patterns"},
11+
{:search},
12+
# {"Patterns", to: "/patterns"},
1213
{"Live Feed", to: "/feed"},
1314
{"About", to: "/about"}
1415
]
1516

17+
defp search_form do
18+
~E"""
19+
<li>
20+
<form role=search action="/research" class="flex h-full px-2 items-center">
21+
<input type=text name=q placeholder="Search" class="w-full py-1 px-2 bg-white text-black">
22+
</form>
23+
"""
24+
end
25+
1626
def nav_items(path_info) do
17-
Enum.map(@nav_links, fn
18-
{title, to: to} -> nav_link_item(title: title, to: to, path_info: path_info)
19-
end)
27+
[
28+
Enum.map(@nav_links, fn
29+
{:search} -> search_form()
30+
{title, to: to} -> nav_link_item(title: title, to: to, path_info: path_info)
31+
end)
32+
]
2033
end
2134

2235
def nav_link_item(assigns) do
@@ -29,7 +42,7 @@ defmodule ComponentsGuideWeb.LayoutView do
2942
end
3043

3144
~E"""
32-
<li><a href="<%= @to %>" aria-current="<%= current %>" class="flex h-full px-4 py-2 md:py-4 font-bold border-b-4 border-transparent hover:bg-gray-800 hover:border-red-400"><%= @title %></a>
45+
<li><a href="<%= @to %>" aria-current="<%= current %>" class="flex h-full px-4 py-2 md:py-2 font-bold border-4 border-transparent hover:bg-gray-800 hover:border-white"><%= @title %></a>
3346
"""
3447
end
3548
end

0 commit comments

Comments
 (0)