Skip to content

Commit 4437b62

Browse files
committed
Fix css style for search modal.
1 parent 97541a2 commit 4437b62

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

src/components/search/Search.astro

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
---
22
import SearchComponent from "astro-pagefind/components/Search";
33
import Button from "@ui/Button.astro";
4+
45
---
56

67
<div class="search-wrapper hidden" style="display: none;">
78

8-
<div class="w-full flex items-center justify-between z-40 h-0 md:h-[85px] m-auto ">
9+
<div class="search-header flex items-center justify-between z-40 h-0 md:h-[85px] m-auto ">
910
<h2 class="text-black text-4xl ml-10 top-[46px] md:top-[85px]">Search<h2/>
1011
<Button
12+
id="search-close"
1113
icon="close"
1214
iconSize="fa-xl"
13-
class="search-close w-[3em] h-[3em] top-[46px] md:top-[85px]"
15+
class="w-[3em] h-[3em] top-[46px] md:top-[85px]"
1416
/>
1517
</div>
16-
1718
<div class="modal__overlay"></div>
1819

1920
<SearchComponent
@@ -33,7 +34,7 @@ document.addEventListener("DOMContentLoaded", function () {
3334
const searchWrapper = document.querySelector(".search-wrapper") as HTMLElement | null;
3435
const searchContainer = document.querySelector(".pagefind-ui") as HTMLElement | null;
3536
const searchInput = searchContainer?.querySelector("input") as HTMLInputElement | null;
36-
const closeButton = document.querySelector(".search-close") as HTMLElement | null;
37+
const closeButton = document.querySelector("#search-close") as HTMLElement | null;
3738
const searchButton = document.getElementById("searchButton") as HTMLElement | null;
3839

3940
let selectedIndex = -1;
@@ -151,11 +152,12 @@ document.addEventListener("DOMContentLoaded", function () {
151152
});
152153
</script>
153154

154-
<style is:global>
155-
.search-wrapper div{
156-
max-width: calc(48rem + 8vw);
155+
<style >
156+
.search-header {
157+
max-width: 48rem;
158+
margin:auto;
157159
}
158-
.search-wrapper h2 {
160+
.search-header h2 {
159161
position: relative;
160162
left: -12px;
161163
z-index:100;
@@ -186,13 +188,15 @@ document.addEventListener("DOMContentLoaded", function () {
186188
z-index: 100;
187189
}
188190

189-
.search-wrapper :global(.search-close) {
191+
192+
</style>
193+
<style is:global>
194+
#search-close {
190195
position: relative;
191196
left: -12px;
192197
margin: 0;
193198
border: 0;
194199
transition: opacity ease-out 0.2s;
195200
z-index: 10;
196201
}
197-
198202
</style>

src/layouts/HomePageLayout.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ const jsonLd = JSON.stringify({
5050
<a href="#main-content" class="sr-only"> Skip to main content</a>
5151

5252
<Search />
53+
5354
<Header />
5455

5556
<main id="main-content" class="layout-wrapper overflow-x-clip">

src/layouts/Layout.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import Header from "../components/header/header.astro";
33
import Footer from "../components/footer.astro";
44
import BaseHead from "../components/BaseHead.astro";
5+
import Search from "@components/search/Search.astro";
56
67
export interface Props {
78
title: string;
@@ -20,6 +21,7 @@ const { title, description } = Astro.props;
2021
<div class="flex flex-col items-stretch min-h-screen">
2122
<a href="#main-content" class="sr-only"> Skip to main content</a>
2223

24+
<Search />
2325
<Header />
2426

2527
<main id="main-content" class="layout-wrapper overflow-x-clip">

0 commit comments

Comments
 (0)