Remove turbo

This commit is contained in:
DrMint 2023-09-22 13:24:48 +02:00
parent 04caf4c60b
commit 8234208102
8 changed files with 72 additions and 140 deletions

File diff suppressed because one or more lines are too long

View File

@ -29,7 +29,11 @@ const { isReduced = false } = Astro.props;
<p id="title" class:list={{ hidden: isReduced }}>Accords Library</p>
<div id="buttons" class:list={["when-js", { reduced: isReduced }]}>
<ReduceToggleButton icon={isReduced ? "material-symbols:chevron-right": "material-symbols:chevron-left"} />
<ReduceToggleButton
icon={isReduced
? "material-symbols:chevron-right"
: "material-symbols:chevron-left"}
/>
<ThemeToggleButton />
</div>
@ -203,9 +207,6 @@ const { isReduced = false } = Astro.props;
<script>
import tippy, { createSingleton } from "tippy.js";
import { onLoad } from "utils/turbo";
onLoad(() => {
createSingleton(
tippy("#menu-panel > .when-reduced > [data-tippy-template]", {
content: (reference) => {
@ -226,5 +227,4 @@ const { isReduced = false } = Astro.props;
inertia: true,
}
);
});
</script>

View File

@ -70,9 +70,7 @@ const { title, showSubPanel } = Astro.props;
<script>
import { Elementos } from "utils/Elementos";
import { observable } from "utils/micro-observables";
import { onLoad } from "utils/turbo";
onLoad(() => {
const isMenuPanelOpened = observable(false);
const menuPanel = new Elementos("#menu-panel");
const menuPanelToggle = new Elementos("#toggle-menu-panel");
@ -93,5 +91,4 @@ const { title, showSubPanel } = Astro.props;
});
subPanel.setClass("opened", isSubPanelOpened);
subPanelToggle.setClass("on", isSubPanelOpened);
});
</script>

View File

@ -24,9 +24,7 @@ const { icon } = Astro.props;
import { Elementos } from "utils/Elementos";
import { CookieNames } from "utils/cookies";
import { observableWithPersistence } from "utils/micro-observables";
import { onLoad } from "utils/turbo";
onLoad(() => {
const toggleReducedButton = new Elementos("#reduce-toggle");
const menuPanel = new Elementos("#menu-panel");
@ -37,9 +35,7 @@ const { icon } = Astro.props;
toggleReducedButton.onClick(() => {
isReduced.update((oldValue) => !oldValue);
Turbo.cache.clear();
});
menuPanel.setClass("reduced", isReduced);
});
</script>

View File

@ -50,9 +50,7 @@ const themeColors = parseCookie<string>(
import { Elementos } from "utils/Elementos";
import { CookieNames } from "utils/cookies";
import { observableWithPersistence } from "utils/micro-observables";
import { onLoad } from "utils/turbo";
onLoad(() => {
const body = new Elementos("body");
const themeToggleButton = new Elementos("#theme-toggle");
@ -61,9 +59,7 @@ const themeColors = parseCookie<string>(
"theme-color-light"
);
const isDarkMode = themeColor.select(
(value) => value === "theme-color-dark"
);
const isDarkMode = themeColor.select((value) => value === "theme-color-dark");
themeToggleButton.onClick(() => {
themeColor.update((oldValue) =>
@ -71,17 +67,12 @@ const themeColors = parseCookie<string>(
? "theme-color-dark"
: "theme-color-light"
);
Turbo.cache.clear();
});
themeToggleButton.setClass(
{ ifFalse: "light", ifTrue: "dark" },
isDarkMode
);
themeToggleButton.setClass({ ifFalse: "light", ifTrue: "dark" }, isDarkMode);
body.setClass(
{ ifFalse: "theme-color-light", ifTrue: "theme-color-dark" },
isDarkMode
);
});
</script>

View File

@ -22,7 +22,6 @@ const themeColors = parseCookie(
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>{title}</title>
<script is:inline src="/js/turbo.es2017-umd.js" async defer></script>
<link href="/css/sanitize.min.css" rel="stylesheet" />
<link href="/css/tippy.css" rel="stylesheet" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
@ -43,10 +42,6 @@ const themeColors = parseCookie(
</body>
</html>
<script>
Turbo.setProgressBarDelay(0);
</script>
{
/* ------------------------------------------- CSS -------------------------------------------- */
}
@ -389,20 +384,6 @@ const themeColors = parseCookie(
}
}
.turbo-progress-bar {
position: fixed;
display: block;
top: 0;
left: 0;
height: 5px;
background-color: #b07751;
z-index: 2147483647;
transition:
width 1000ms ease-out,
opacity 500ms 500ms ease-in;
transform: translate3d(0, 0, 0);
}
.when-no-js {
display: none;
}

View File

@ -1,7 +0,0 @@
// https://turbo.hotwired.dev/reference/drive
declare namespace Turbo {
const cache: {
clear: () => void;
};
const setProgressBarDelay: (delayInMs: number) => void;
}

View File

@ -1,2 +0,0 @@
export const onLoad = (callback: () => void) =>
document.documentElement.addEventListener("turbo:load", callback);