Skip to content

Commit fd4c976

Browse files
committed
Search for mobile and mobile menu styles.
1 parent 62314df commit fd4c976

File tree

8 files changed

+1997
-3713
lines changed

8 files changed

+1997
-3713
lines changed

pnpm-lock.yaml

Lines changed: 1729 additions & 3572 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/BaseHead.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ const { title, description, image = "/social-card.png" } = Astro.props;
6161

6262
<script
6363
is:inline
64-
src="https://kit.fontawesome.com/14a4971ab3.js"
64+
src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/js/all.min.js"
6565
crossorigin="anonymous"></script>

src/components/header/header-actions.astro

Lines changed: 19 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
import ButtonLink from "../button-link/button-link.astro";
33
import Button from "@ui/Button.astro";
44
import HeaderButton from "./header-button.astro";
5-
import Search from "astro-pagefind/components/Search";
5+
import Search from "../search/Search.astro";
6+
import Icon from "@ui/Icon.astro";
67
78
export interface Props {
89
mobile?: boolean;
@@ -13,146 +14,33 @@ const { mobile = false }: Props = Astro.props;
1314
const IS_LIVE = false;
1415
---
1516

16-
<div class="flex items-center justify-end gap-2 w-1/3">
17-
<Search
18-
id="search"
19-
className="pagefind-ui"
20-
uiOptions={{
21-
showImages: false,
22-
translations: {
23-
zero_results: "Couldn't find [SEARCH_TERM]",
24-
},
25-
}}
26-
/>
17+
<div class="flex items-center justify-end gap-2 h-[85px]">
18+
<Search />
19+
<div class="ml-auto flex items-center ">
2720
{
28-
!mobile ? (
21+
!mobile ?
2922
<>
30-
<Button url="/tickets" icon="ticket">Register Now!</Button>
31-
{IS_LIVE && <Button url="/live">Live</Button>}
23+
<Button id="searchButton" icon="search" iconSize="fa-xl" clear ></Button>
24+
<Button url="/tickets" icon="ticket" class="max-xl:hidden">Register Now!</Button>
25+
{IS_LIVE && <Button url="/live">Live</Button>}
3226
</>
33-
) : null
27+
: null
3428
}
3529

30+
3631
<label for="nav_toggle" class="flex xl:hidden">
37-
<HeaderButton variant="menu">
38-
{mobile ? "Close Menu" : "Menu"}
39-
</HeaderButton>
32+
<span class="w-[3em] h-[3em] font-bold text-lg px-4 py-4 rounded-lg inline-flex items-center justify-center leading-4 transition-colors duration-200 not-prose border hover:text-black bg-primary text-white hover:bg-primary-hover border-transparent">
33+
{mobile ? <Icon name="close" size="fa-xl" /> : <Icon name="bars" size="fa-xl" />}
34+
</span>
4035
</label>
4136
</div>
4237
<script>
43-
document.addEventListener("DOMContentLoaded", function () {
44-
const searchContainer = document.querySelector(".pagefind-ui");
45-
const searchInput = searchContainer?.querySelector("input");
46-
let selectedIndex = -1;
47-
48-
function updateSelection() {
49-
const results = searchContainer?.querySelectorAll(".pagefind-ui__result");
50-
if (!results) return;
38+
const searchButton = document.getElementById("searchButton");
39+
const searchWrapper = document.querySelector(".search-wrapper") as HTMLElement;
5140

52-
results.forEach((result, index) => {
53-
if (index === selectedIndex) {
54-
result.classList.add("selected");
55-
result.scrollIntoView({ block: "nearest", behavior: "smooth" });
56-
} else {
57-
result.classList.remove("selected");
58-
}
41+
if (searchButton && searchWrapper) {
42+
searchButton.addEventListener("click", function () {
43+
searchWrapper.style.display = searchWrapper.style.display === "block" ? "none" : "block";
5944
});
6045
}
61-
62-
document.addEventListener("keydown", function (event) {
63-
if (!searchContainer || !searchInput) return;
64-
65-
const results = searchContainer.querySelectorAll(".pagefind-ui__result");
66-
if (document.activeElement === searchInput) {
67-
if (event.key === "ArrowDown") {
68-
event.preventDefault();
69-
selectedIndex = (selectedIndex + 1) % results.length;
70-
updateSelection();
71-
} else if (event.key === "ArrowUp") {
72-
event.preventDefault();
73-
selectedIndex = (selectedIndex - 1 + results.length) % results.length;
74-
updateSelection();
75-
} else if (event.key === "Enter" && selectedIndex >= 0) {
76-
event.preventDefault();
77-
results[selectedIndex].querySelector("a")?.click();
78-
}
79-
}
80-
});
81-
82-
// Reset selection when the search query changes
83-
searchInput?.addEventListener("input", function () {
84-
selectedIndex = -1;
85-
});
86-
});
8746
</script>
88-
<style is:global>
89-
.pagefind-ui__result.selected {
90-
background-color: #f5f5f5;
91-
background-image: linear-gradient(to right, #3684b6 7px, transparent 5px);
92-
-webkit-transform: translate3d(0, 0, 0);
93-
transform: translate3d(0, 0, 0);
94-
}
95-
.pagefind-ui__drawer {
96-
}
97-
.pagefind-ui__message {
98-
margin: 1em;
99-
}
100-
.pagefind-ui__result mark {
101-
background: #f9eb5d;
102-
background-image: linear-gradient(to right, #f9eb5d 10%, #fcf4a7 100%);
103-
margin: 4px;
104-
padding-right: 6px;
105-
padding-left: 6px;
106-
padding-top: 2px;
107-
padding-bottom: 2px;
108-
color: #000000;
109-
font-family: monospace;
110-
border-radius: 4px;
111-
}
112-
.pagefind-ui {
113-
--pagefind-ui-scale: 1;
114-
--pagefind-ui-primary: #141f36;
115-
--pagefind-ui-text: black;
116-
--pagefind-ui-border: #d8d8d8;
117-
--pagefind-ui-border-width: 2px;
118-
--pagefind-ui-border-radius: 0;
119-
width:50%;
120-
min-width: 10vw;
121-
}
122-
.pagefind-ui.yellow {
123-
--pagefind-ui-background: #efc302;
124-
}
125-
.pagefind-ui.red {
126-
--pagefind-ui-background: #ffb9bb;
127-
width: 50%;
128-
}
129-
.pagefind-ui .pagefind-ui__drawer:not(.pagefind-ui__hidden) {
130-
position: absolute;
131-
left: auto;
132-
right: 0;
133-
margin-top: 0px;
134-
width: 50vw;
135-
z-index: 9999;
136-
overflow-y: auto;
137-
box-shadow:
138-
0 10px 10px -5px rgba(0, 0, 0, 0.2),
139-
0 2px 2px 0 rgba(0, 0, 0, 0.1);
140-
border-bottom-right-radius: var(--pagefind-ui-border-radius);
141-
border-bottom-left-radius: var(--pagefind-ui-border-radius);
142-
background-color: var(--pagefind-ui-background);
143-
}
144-
.pagefind-ui__result {
145-
padding: 0 2em 1em !important;
146-
}
147-
.pagefind-ui .pagefind-ui__result-link {
148-
color: var(--pagefind-ui-primary);
149-
}
150-
.pagefind-ui .pagefind-ui__result-excerpt {
151-
color: var(--pagefind-ui-text);
152-
}
153-
@media (max-width: 1280px) {
154-
.pagefind-ui {
155-
display: none;
156-
}
157-
}
158-
</style>

src/components/header/header.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const links = JSON.parse(await fs.readFile("./src/data/links.json", "utf-8"));
2727
<div
2828
class="fixed bg-body-background top-0 left-0 w-screen h-screen overflow-scroll hidden peer-checked:block xl:peer-checked:hidden z-50 p-6"
2929
>
30-
<div class="flex items-center">
30+
<div class="flex items-center justify-between">
3131
<HeaderLogo />
3232
<HeaderActions mobile />
3333
</div>

0 commit comments

Comments
 (0)