Skip to content

Commit

Permalink
Merge pull request #69 from mbaraa/dev
Browse files Browse the repository at this point in the history
release v0.1.1
  • Loading branch information
mbaraa authored Jun 5, 2024
2 parents b1fd0ac + b4c01c2 commit 607d500
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

html,
body {
overscroll-behavior-y: contain;
overscroll-behavior-y: none;
}

html,
Expand Down
9 changes: 6 additions & 3 deletions app/static/js/refresher.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"use strict";

const mainContentsEl = document.getElementById("main-contents");
const headerEl = document.getElementById("dank-header");
let _startY = 0;

async function simulateRefreshAction() {
Expand Down Expand Up @@ -51,11 +51,14 @@ document.body.addEventListener(
const y = e.touches[0].pageY;
if (
document.scrollingElement.scrollTop === 0 &&
y > _startY + 150 &&
y <=
headerEl.getBoundingClientRect().y +
headerEl.getBoundingClientRect().height &&
y > _startY + 50 &&
!document.body.classList.contains("refreshing")
) {
await simulateRefreshAction();
await updateMainContent(window.location.pathname);
await Router.updateMainContent(window.location.pathname);
}
},
{ passive: true },
Expand Down
2 changes: 2 additions & 0 deletions app/static/js/router.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use strict";

const mainContentsEl = document.getElementById("main-contents");

const links = [
{ check: (l) => l === "/", element: document.getElementById("/") },
{ check: (l) => l === "/about", element: document.getElementById("/about") },
Expand Down
4 changes: 2 additions & 2 deletions app/static/js/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ self.addEventListener("message", (event) => {

self.addEventListener("install", async (event) => {
event.waitUntil(
caches.open(CACHE).then((cache) => cache.add(offlineFallbackPage)),
caches.open(CACHE_NAME).then((cache) => cache.add(offlineFallbackPage)),
);
});

self.addEventListener("fetch", (event) => {
if (event.request.mode === "navigate") {
event.respondWith(
(async () => {
const cache = await caches.open(CACHE);
const cache = await caches.open(CACHE_NAME);
const cachedResp = await cache.match(offlineFallbackPage);
return cachedResp;
})(),
Expand Down
5 changes: 4 additions & 1 deletion app/views/components/search/search_suggestions.templ
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package search

import "fmt"
import "strings"

templ SearchSuggestions(suggestions []string, originalQuery string) {
<ul
Expand Down Expand Up @@ -28,8 +29,10 @@ templ SearchSuggestions(suggestions []string, originalQuery string) {
>
if len(suggestion) <= len(originalQuery) {
<span><b>{ suggestion }</b></span>
} else {
} else if strings.Contains(suggestion, originalQuery) {
<span><b>{ originalQuery }</b>{ suggestion[len(originalQuery):] }</span>
} else {
<span>{ suggestion }</span>
}
</a>
</li>
Expand Down

0 comments on commit 607d500

Please sign in to comment.