Skip to content

Commit 1bf0884

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

File tree

4 files changed

+131
-50
lines changed

4 files changed

+131
-50
lines changed

src/components/search/Search.astro

Lines changed: 5 additions & 50 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;
@@ -150,49 +151,3 @@ document.addEventListener("DOMContentLoaded", function () {
150151
closeButton?.addEventListener("click", closeSearch);
151152
});
152153
</script>
153-
154-
<style is:global>
155-
.search-wrapper div{
156-
max-width: calc(48rem + 8vw);
157-
}
158-
.search-wrapper h2 {
159-
position: relative;
160-
left: -12px;
161-
z-index:100;
162-
}
163-
.modal__overlay {
164-
z-index: 1;
165-
position: absolute;
166-
top: 0;
167-
left: 0;
168-
width: 100%;
169-
height: 100%;
170-
}
171-
172-
.search-wrapper {
173-
width: 100%;
174-
height: 100%;
175-
position: fixed;
176-
display: block;
177-
top: 0;
178-
bottom: 0;
179-
left: 0;
180-
right: 0;
181-
z-index: 500;
182-
box-sizing: border-box;
183-
display: none;
184-
transition: opacity ease-out 0.2s;
185-
background: rgba(37,40,43,0.9);
186-
z-index: 100;
187-
}
188-
189-
.search-wrapper :global(.search-close) {
190-
position: relative;
191-
left: -12px;
192-
margin: 0;
193-
border: 0;
194-
transition: opacity ease-out 0.2s;
195-
z-index: 10;
196-
}
197-
198-
</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">

src/styles/global.css

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,3 +253,126 @@ p.cross::after {
253253
--max-fs: 1.5;
254254
}
255255
}
256+
257+
.search-pagefind {
258+
padding: 85px 10px 10px 10px;
259+
position: relative;
260+
max-height: 80vh;
261+
width: 100%;
262+
max-width: 48rem;
263+
margin: auto;
264+
background: #f5e5d6;
265+
border-radius: 0.5rem;
266+
box-shadow: 0 8px 24px -2px rgba(0, 0, 0, 0.4);
267+
overflow: auto;
268+
transition: background ease-out 0.2s;
269+
z-index: 2;
270+
overflow: auto;
271+
height: 100%;
272+
273+
border-bottom: 1px solid #e1e3e6;
274+
border-bottom-color: rgb(225, 227, 230);
275+
}
276+
277+
.pagefind-ui__search-input {
278+
border: 1px solid #ccc;
279+
border-radius: 20px;
280+
padding-inline-start: 0.75rem;
281+
padding-inline-end: 0.5rem;
282+
background-color: #fff;
283+
font-size: 16px;
284+
color: #5f3d1b;
285+
}
286+
287+
.pagefind-ui__result.selected {
288+
background-color: #f5f5f5;
289+
background-image: linear-gradient(to right, #3684b6 7px, transparent 5px);
290+
-webkit-transform: translate3d(0, 0, 0);
291+
transform: translate3d(0, 0, 0);
292+
}
293+
.pagefind-ui__result:hover {
294+
background-color: #f5f5f5;
295+
}
296+
.pagefind-ui__message {
297+
margin: 1em;
298+
}
299+
.pagefind-ui__result mark {
300+
background: #f9eb5d;
301+
background-image: linear-gradient(to right, #f9eb5d 10%, #fcf4a7 100%);
302+
margin: 4px;
303+
padding-right: 6px;
304+
padding-left: 6px;
305+
padding-top: 2px;
306+
padding-bottom: 2px;
307+
color: #000000;
308+
font-family: monospace;
309+
border-radius: 4px;
310+
}
311+
.pagefind-ui {
312+
--pagefind-ui-scale: 1;
313+
--pagefind-ui-primary: #141f36;
314+
--pagefind-ui-text: black;
315+
--pagefind-ui-border: #d8d8d8;
316+
--pagefind-ui-border-width: 2px;
317+
--pagefind-ui-border-radius: 0.5rem;
318+
/*width: 50%;*/
319+
}
320+
.pagefind-ui .pagefind-ui__drawer:not(.pagefind-ui__hidden) {
321+
z-index: 9999;
322+
position: relative;
323+
overflow: auto;
324+
height: 100%;
325+
}
326+
.pagefind-ui__result {
327+
padding: 0 2em 1em !important;
328+
}
329+
.pagefind-ui .pagefind-ui__result-link {
330+
color: var(--pagefind-ui-primary);
331+
}
332+
.pagefind-ui .pagefind-ui__result-excerpt {
333+
color: var(--pagefind-ui-text);
334+
}
335+
336+
.search-header {
337+
max-width: 48rem;
338+
margin: auto;
339+
}
340+
.search-header h2 {
341+
position: relative;
342+
left: -12px;
343+
z-index: 100;
344+
}
345+
.modal__overlay {
346+
z-index: 1;
347+
position: absolute;
348+
top: 0;
349+
left: 0;
350+
width: 100%;
351+
height: 100%;
352+
}
353+
354+
.search-wrapper {
355+
width: 100%;
356+
height: 100%;
357+
position: fixed;
358+
display: block;
359+
top: 0;
360+
bottom: 0;
361+
left: 0;
362+
right: 0;
363+
z-index: 500;
364+
box-sizing: border-box;
365+
display: none;
366+
transition: opacity ease-out 0.2s;
367+
background: rgba(37, 40, 43, 0.9);
368+
z-index: 100;
369+
}
370+
371+
#search-close {
372+
position: relative;
373+
left: -12px;
374+
margin: 0;
375+
border: 0;
376+
transition: opacity ease-out 0.2s;
377+
z-index: 10;
378+
}

0 commit comments

Comments
 (0)