-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,19 +13,24 @@ | |
<link rel="stylesheet" href="/css/main.css"> | ||
</head> | ||
<body> | ||
<a class="btn btn--primary skip-link" href="#content">Skip to content</a> | ||
{% include "partial/header.html" %} | ||
<div class="site-wrapper"> | ||
<a class="btn btn--primary skip-link" href="#content">Skip to content</a> | ||
{% include "partial/header.html" %} | ||
|
||
<main id="content"> | ||
{% block content %}{% endblock %} | ||
</main> | ||
<main id="content"> | ||
{% block content %}{% endblock %} | ||
</main> | ||
|
||
{% include "partial/github-cta.html" %} | ||
{% include "partial/footer.html" %} | ||
{% include "partial/github-cta.html" %} | ||
{% include "partial/footer.html" %} | ||
</div> | ||
|
||
{% include "partial/search-modal.html" %} | ||
|
||
<script defer src="/js/navigation.js"></script> | ||
<script defer src="/js/accordion-card.js"></script> | ||
<script defer src="/js/theme-switcher.js"></script> | ||
<script defer src="/js/modal.js"></script> | ||
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script> | ||
<script defer src="/js/toc.js"></script> | ||
<script src="/js/cookie-consent.js?{{ assetHash }}" type="module"></script> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<span class="open-search"> | ||
{% svgIcon './src/_includes/icon/search.svg', 'open-search__icon' %} | ||
<span class="open-search__caption">Search</span> | ||
<button class="btn btn--outline-primary btn--sm open-search__btn" data-action="open-search"> | ||
Ctrl K | ||
</button> | ||
</span> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<div class="modal-backdrop"> | ||
<div class="modal" role="dialog" aria-modal="true"> | ||
<div id="search" class="search"></div> | ||
</div> | ||
</div> | ||
|
||
<script src="/_pagefind/pagefind-ui.js" onload="new PagefindUI({ element: '#search', showImages: false });"></script> |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,6 @@ | ||||||||||||||||||||
import { | ||||||||||||||||||||
setCookie, getCookie, issetCookie, removeCookie, | ||||||||||||||||||||
} from './cookie'; | ||||||||||||||||||||
} from './cookie.js'; | ||||||||||||||||||||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
szepeviktor
Contributor
|
} from './cookie.js'; // eslint-disable-line |
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
szepeviktor
Mar 7, 2024
Contributor
Maybe a "named import"??
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#named_import
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
szepeviktor
Mar 7, 2024
Contributor
🤯 There is no JavaScript build process
sprucecss-site-eleventy/src/_includes/layout/base.html
Lines 30 to 37 in aee9daa
<script defer src="/js/navigation.js"></script> | |
<script defer src="/js/accordion-card.js"></script> | |
<script defer src="/js/theme-switcher.js"></script> | |
<script defer src="/js/modal.js"></script> | |
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js"></script> | |
<script defer src="/js/toc.js"></script> | |
<script src="/js/cookie-consent.js?{{ assetHash }}" type="module"></script> | |
<script src="/js/scripts.js?{{ assetHash }}" type="module"></script> |
This comment has been minimized.
This comment has been minimized.
Sorry, something went wrong.
adamlaki
Mar 8, 2024
Author
Member
Yeah, sorry, Viktor, I had to revert it because if you use js-module without a compiler (like a native browser), you need the extension; otherwise, it can't find the file.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
(() => { | ||
let activeElement = null; | ||
const siteWrapper = document.querySelector('.site-wrapper'); | ||
const button = document.querySelector('[data-action="open-search"]'); | ||
const input = document.querySelector('.pagefind-ui__search-input'); | ||
const modal = document.querySelector('.modal-backdrop'); | ||
|
||
if (!button || !modal) return; | ||
|
||
function openModal() { | ||
activeElement = document.activeElement; | ||
siteWrapper.setAttribute('inert', ''); | ||
modal.classList.add('modal-backdrop--open'); | ||
input.focus(); | ||
} | ||
|
||
function closeModal() { | ||
siteWrapper.removeAttribute('inert'); | ||
modal.classList.remove('modal-backdrop--open'); | ||
activeElement.focus(); | ||
} | ||
|
||
function handleKeyDown(e) { | ||
if (e.code === 'Escape') { | ||
closeModal(); | ||
} | ||
|
||
if (e.ctrlKey && e.code === 'KeyK') { | ||
e.preventDefault(); | ||
openModal(); | ||
} | ||
} | ||
|
||
modal.addEventListener('click', (e) => { | ||
if (e.target === e.currentTarget) { | ||
closeModal(); | ||
} | ||
}); | ||
|
||
button.addEventListener('click', () => { | ||
openModal(); | ||
}); | ||
|
||
window.addEventListener('keydown', handleKeyDown); | ||
})(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@use 'sprucecss/scss/spruce' as *; | ||
|
||
.modal-backdrop { | ||
backdrop-filter: blur(0.35rem); | ||
background-color: hsl(0deg 0% 100% / 35%); | ||
display: none; | ||
inset: 0; | ||
padding: spacer('s'); | ||
position: fixed; | ||
z-index: 100; | ||
|
||
&--open { | ||
display: block; | ||
} | ||
} | ||
|
||
.modal { | ||
background-color: color('background'); | ||
border-radius: config('border-radius-sm', $display); | ||
box-shadow: get-css-variable(--box-shadow); | ||
margin-block: 7rem; | ||
margin-inline: auto; | ||
max-inline-size: 40rem; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@use 'sprucecss/scss/spruce' as *; | ||
|
||
.open-search { | ||
@include a11y-card-link('.open-search__btn', true); | ||
align-items: center; | ||
display: flex; | ||
gap: spacer('xs'); | ||
|
||
&__icon { | ||
--size: 1rem; | ||
block-size: var(--size); | ||
color: color('icon', 'search'); | ||
inline-size: var(--size); | ||
} | ||
} |
@adamlaki This was just fixed in #14