pagefind integration and search bar

This commit is contained in:
Xanazf 2024-10-04 20:14:32 +03:00
parent a787497feb
commit cd1226e333
19 changed files with 565 additions and 240 deletions

View file

@ -1,4 +1,5 @@
@import "./nav-tree.css";
@import "./search.css";
.nav-wrapper {
display: none;
@ -44,12 +45,11 @@
display: none;
}
transition:
width 0.3s ease,
height 0.3s ease,
background-color 0.3s ease,
backdrop-filter 0.3s ease,
padding 0.3s ease;
transition: width 0.3s ease,
height 0.3s ease,
background-color 0.3s ease,
backdrop-filter 0.3s ease,
padding 0.3s ease;
&.shown {
padding: 0.3rem;

View file

@ -0,0 +1,338 @@
/* is:global */
[data-search-modal-open] {
overflow: hidden;
}
#qs_search {
--search-result-spacing: calc(1.25rem * var(--pagefind-ui-scale));
--search-result-pad-inline-start: calc(3.75rem * var(--pagefind-ui-scale));
--search-result-pad-inline-end: calc(1.25rem * var(--pagefind-ui-scale));
--search-result-pad-block: calc(0.9375rem * var(--pagefind-ui-scale));
--search-result-nested-pad-block: calc(0.625rem * var(--pagefind-ui-scale));
--search-corners: calc(0.3125rem * var(--pagefind-ui-scale));
--search-page-icon-size: calc(1.875rem * var(--pagefind-ui-scale));
--search-page-icon-inline-start: calc((var(--search-result-pad-inline-start) - var(--search-page-icon-size)) / 2);
--search-tree-diagram-size: calc(2.5rem * var(--pagefind-ui-scale));
--search-tree-diagram-inline-start: calc((var(--search-result-pad-inline-start) - var(--search-tree-diagram-size)) / 2);
}
#qs_search .pagefind-ui__form::before {
--pagefind-ui-text: hsl(0 0 65);
opacity: 1;
}
#qs_search .pagefind-ui__search-input {
color: hsl(0 0 100);
font-weight: 400;
width: calc(100% - var(--search-cancel-space));
}
#qs_search input:focus {
--pagefind-ui-border: hsla(var(--accent-500));
}
#qs_search .pagefind-ui__search-clear {
inset-inline-end: var(--search-cancel-space);
width: calc(60px * var(--pagefind-ui-scale));
padding: 0;
background-color: transparent;
overflow: hidden;
}
#qs_search .pagefind-ui__search-clear:focus {
outline: 1px solid hsla(var(--accent-600));
}
#qs_search .pagefind-ui__search-clear::before {
content: "";
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m13.41 12 6.3-6.29a1 1 0 1 0-1.42-1.42L12 10.59l-6.29-6.3a1 1 0 0 0-1.42 1.42l6.3 6.29-6.3 6.29a1 1 0 0 0 .33 1.64 1 1 0 0 0 1.09-.22l6.29-6.3 6.29 6.3a1 1 0 0 0 1.64-.33 1 1 0 0 0-.22-1.09L13.41 12Z'/%3E%3C/svg%3E") center / 50% no-repeat;
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m13.41 12 6.3-6.29a1 1 0 1 0-1.42-1.42L12 10.59l-6.29-6.3a1 1 0 0 0-1.42 1.42l6.3 6.29-6.3 6.29a1 1 0 0 0 .33 1.64 1 1 0 0 0 1.09-.22l6.29-6.3 6.29 6.3a1 1 0 0 0 1.64-.33 1 1 0 0 0-.22-1.09L13.41 12Z'/%3E%3C/svg%3E") center / 50% no-repeat;
background-color: hsl(var(--accent-600));
display: block;
width: 100%;
height: 100%;
}
#qs_search .pagefind-ui__results>*+* {
margin-top: var(--search-result-spacing);
}
#qs_search .pagefind-ui__result {
border: 0;
padding: 0;
}
#qs_search .pagefind-ui__result-nested {
position: relative;
padding: var(--search-result-nested-pad-block) var(--search-result-pad-inline-end);
padding-inline-start: var(--search-result-pad-inline-start);
}
#qs_search .pagefind-ui__result-title:not( :where(.pagefind-ui__result-nested *)),
#qs_search .pagefind-ui__result-nested {
position: relative;
background-color: hsl(0 0 10);
}
#qs_search .pagefind-ui__result-title:not( :where(.pagefind-ui__result-nested *)):hover,
#qs_search .pagefind-ui__result-title:not( :where(.pagefind-ui__result-nested *)):focus-within,
#qs_search .pagefind-ui__result-nested:hover,
#qs_search .pagefind-ui__result-nested:focus-within {
outline: 1px solid hsl(var(--accent-600));
}
#qs_search .pagefind-ui__result-title:not( :where(.pagefind-ui__result-nested *)):focus-within,
#qs_search .pagefind-ui__result-nested:focus-within {
background-color: hsl(var(--accent-400));
}
#qs_search .pagefind-ui__result-thumb,
#qs_search .pagefind-ui__result-inner {
margin-top: 0;
}
#qs_search .pagefind-ui__result-inner> :first-child {
border-radius: var(--search-corners) var(--search-corners) 0 0;
}
#qs_search .pagefind-ui__result-inner> :last-child {
border-radius: 0 0 var(--search-corners) var(--search-corners);
}
#qs_search .pagefind-ui__result-inner>.pagefind-ui__result-title {
padding: var(--search-result-pad-block) var(--search-result-pad-inline-end);
padding-inline-start: var(--search-result-pad-inline-start);
}
#qs_search .pagefind-ui__result-inner>.pagefind-ui__result-title::before {
content: "";
position: absolute;
inset-block: 0;
inset-inline-start: var(--search-page-icon-inline-start);
width: var(--search-page-icon-size);
background: hsl(var(--blue) 15 33);
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='currentColor' viewBox='0 0 24 24'%3E%3Cpath d='M9 10h1a1 1 0 1 0 0-2H9a1 1 0 0 0 0 2Zm0 2a1 1 0 0 0 0 2h6a1 1 0 0 0 0-2H9Zm11-3V8l-6-6a1 1 0 0 0-1 0H7a3 3 0 0 0-3 3v14a3 3 0 0 0 3 3h10a3 3 0 0 0 3-3V9Zm-6-4 3 3h-2a1 1 0 0 1-1-1V5Zm4 14a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h5v3a3 3 0 0 0 3 3h3v9Zm-3-3H9a1 1 0 0 0 0 2h6a1 1 0 0 0 0-2Z'/%3E%3C/svg%3E") center no-repeat;
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='currentColor' viewBox='0 0 24 24'%3E%3Cpath d='M9 10h1a1 1 0 1 0 0-2H9a1 1 0 0 0 0 2Zm0 2a1 1 0 0 0 0 2h6a1 1 0 0 0 0-2H9Zm11-3V8l-6-6a1 1 0 0 0-1 0H7a3 3 0 0 0-3 3v14a3 3 0 0 0 3 3h10a3 3 0 0 0 3-3V9Zm-6-4 3 3h-2a1 1 0 0 1-1-1V5Zm4 14a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h5v3a3 3 0 0 0 3 3h3v9Zm-3-3H9a1 1 0 0 0 0 2h6a1 1 0 0 0 0-2Z'/%3E%3C/svg%3E") center no-repeat;
}
#qs_search .pagefind-ui__result-inner {
align-items: stretch;
gap: 1px;
}
#qs_search .pagefind-ui__result-link {
position: unset;
--pagefind-ui-text: hsl(0 0 85);
font-weight: 600;
}
#qs_search .pagefind-ui__result-link:hover {
text-decoration: none;
}
#qs_search .pagefind-ui__result-nested .pagefind-ui__result-link::before {
content: unset;
}
#qs_search .pagefind-ui__result-nested::before {
content: "";
position: absolute;
inset-block: 0;
inset-inline-start: var(--search-tree-diagram-inline-start);
width: var(--search-tree-diagram-size);
background: hsl(var(--blue) 5 25);
-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-linecap='round' viewBox='0 0 16 1000' preserveAspectRatio='xMinYMin slice'%3E%3Cpath d='M8 0v1000m6-988H8'/%3E%3C/svg%3E") 0% 0% / 100% no-repeat;
mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-linecap='round' viewBox='0 0 16 1000' preserveAspectRatio='xMinYMin slice'%3E%3Cpath d='M8 0v1000m6-988H8'/%3E%3C/svg%3E") 0% 0% / 100% no-repeat;
}
#qs_search .pagefind-ui__result-nested:last-child::before {
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 16 16'%3E%3Cpath d='M8 0v12m6 0H8'/%3E%3C/svg%3E");
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 16 16'%3E%3Cpath d='M8 0v12m6 0H8'/%3E%3C/svg%3E");
}
#qs_search .pagefind-ui__result-link::after {
content: "";
position: absolute;
inset: 0;
}
#qs_search .pagefind-ui__result-excerpt {
font-size: calc(1rem * var(--pagefind-ui-scale));
overflow-wrap: anywhere;
}
#qs_search mark {
color: hsl(var(--blue) 15 60);
background-color: transparent;
font-weight: 600;
}
/* default styles */
site-search {
--shadow-lg:
0px 25px 7px hsla(0, 0%, 0%, 0.03), 0px 16px 6px hsla(0,
0%,
0%,
0.1),
0px 9px 5px hsla(223, 13%, 10%, 0.33), 0px 4px 4px hsla(0,
0%,
0%,
0.75),
0px 4px 2px hsla(0, 0%, 0%, 0.25);
display: contents;
}
.search-label {
/* >720px block */
display: none;
}
.search-kbd {
/* >720px flex */
display: none;
}
.search-dialog {
padding: 0;
& .dialog-frame {
display: flex;
}
& .search-cancel {
/* >720px none */
display: flex;
}
}
/* --- */
button[data-open-modal] {
display: flex;
align-items: center;
gap: 0.5rem;
border: 0;
background-color: transparent;
color: hsl(0 0 65);
cursor: pointer;
height: 2.5rem;
font-size: 1.10rem;
}
button>kbd {
border-radius: 0.25rem;
font-size: 0.75rem;
gap: 0.25em;
padding-inline: 0.375rem;
background-color: hsl(0 0 15);
}
dialog {
margin: 0;
background-color: hsl(var(--blue) 15 12);
border: 1px solid hsl(0 0 25);
width: 100%;
max-width: 100%;
height: 100%;
max-height: 100%;
box-shadow: var(--shadow-lg);
}
dialog[open] {
display: flex;
}
dialog::backdrop {
background-color: hsla(var(--blue) 15 6 / 0.66);
-webkit-backdrop-filter: blur(0.25rem);
backdrop-filter: blur(0.25rem);
}
.dialog-frame {
flex-direction: column;
flex-grow: 1;
gap: 1rem;
padding: 1rem;
}
button[data-close-modal] {
position: absolute;
z-index: 11;
align-items: center;
align-self: flex-end;
height: calc(64px * var(--pagefind-ui-scale));
padding: 0.25rem;
border: 0;
background: transparent;
cursor: pointer;
color: hsla(var(--accent-600));
}
#qs_search {
--pagefind-ui-primary: hsla(var(--accent-400));
--pagefind-ui-text: hsla(0 0 60);
--pagefind-ui-font: Rubik;
--pagefind-ui-background: hsl(0 0 10);
--pagefind-ui-border: hsl(0 0 15);
--pagefind-ui-border-width: 1px;
--search-cancel-space: 5rem;
}
@media (min-width: 768px) {
/* difault styles */
.search-label {
display: block;
}
.search-kbd {
display: flex;
}
.search-dialog {
& .search-cancel {
display: none;
}
}
/* --- */
button[data-open-modal] {
border: 1px solid hsl(0 0 25);
border-radius: 6px;
padding-inline-start: 0.75rem;
padding-inline-end: 0.5rem;
background-color: hsla(0 0 10 / 0.5);
color: hsl(0 0 50);
font-size: 0.875rem;
width: 100%;
max-width: 15rem;
transition: color 0.23s, border-color 0.23s;
&:hover {
border-color: hsl(0 0 50);
color: hsl(0 0 85);
}
&> :last-child {
margin-inline-start: auto;
}
}
#qs_search {
--search-cancel-space: 0px;
}
dialog {
margin: 4rem auto auto;
border-radius: 0.5rem;
width: 90%;
max-width: 40rem;
height: max-content;
min-height: 15rem;
max-height: calc(100% - 8rem);
}
.dialog-frame {
padding: 1.5rem;
}
}