Skip to content

Commit

Permalink
add titles
Browse files Browse the repository at this point in the history
  • Loading branch information
milomg committed Jun 30, 2024
1 parent 57425c6 commit 004832a
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@mdx-js/mdx": "^3.0.1",
"@mdx-js/rollup": "^3.0.1",
"@rollup/pluginutils": "^5.1.0",
"@solidjs/meta": "^0.29.4",
"@solidjs/router": "^0.13.6",
"@solidjs/start": "^1.0.2",
"@types/mdx": "^2.0.13",
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/components/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { onCleanup, onMount } from "solid-js";
export function createGlobals() {
onMount(() => {
function tripleClick(evt: MouseEvent) {
if (evt.detail === 3) {
document.body.classList.toggle("light");
}
}
window.addEventListener("click", tripleClick);
onCleanup(() => window.removeEventListener("click", tripleClick));

function hashchange() {
document.querySelector(window.location.hash)?.scrollIntoView();
}
window.addEventListener("hashchange", hashchange);
onCleanup(() => window.removeEventListener("hashchange", hashchange));
});
}
6 changes: 5 additions & 1 deletion src/routes/2022-12-01/reactivity.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import MDXComponent from "~/blogs/reactivity.mdx";
import { Title } from "@solidjs/meta";
import { createGlobals } from "~/components/global";
import { createMermaid } from "~/components/mermaid";
import MDXComponent from "~/blogs/reactivity.mdx";

export default function Page() {
createMermaid();
createGlobals();

return (
<>
<Title>Super Charging Fine-Grained Reactive Performance · milomg.dev</Title>
<nav>
<div>
<a href="/#top" id="logo">
Expand Down
34 changes: 26 additions & 8 deletions src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { onMount } from "solid-js";
import { onCleanup, onMount } from "solid-js";
import { createSim, toggleBaseColor } from "~/components/sim/shaders";
import { createPointers } from "~/components/sim/pointers";
import { A } from "@solidjs/router";
import "./index.css";
import { createGlobals } from "~/components/global";
import { Title } from "@solidjs/meta";

const App = () => {
onMount(() => {
Expand All @@ -12,13 +14,31 @@ const App = () => {
console.log("The fluid simulation was made with https://regl.party and is inspired by GPU Gems");
});

createGlobals();

let c: HTMLCanvasElement;
onMount(() => {
function tripleClick(evt: MouseEvent) {
if (evt.detail === 3) {
document.body.classList.toggle("light");
toggleBaseColor();
}
}
window.addEventListener("click", tripleClick);
onCleanup(() => window.removeEventListener("click", tripleClick));

function hashchange() {
document.querySelector(window.location.hash)?.scrollIntoView();
}
window.addEventListener("hashchange", hashchange);
onCleanup(() => window.removeEventListener("hashchange", hashchange));

function resize() {
c.width = window.innerWidth;
c.height = window.innerHeight;
}
window.addEventListener("resize", resize);
onCleanup(() => window.removeEventListener("resize", resize));
resize();

try {
Expand All @@ -42,25 +62,23 @@ const App = () => {
});
});

window.addEventListener("click", function (evt) {
function tripleClick(evt: MouseEvent) {
if (evt.detail === 3) {
document.body.classList.toggle("light");
toggleBaseColor();
}
});
}
window.addEventListener("click", tripleClick);
onCleanup(() => window.removeEventListener("click", tripleClick));
} catch (e) {
console.error(e);
c.remove();
document.querySelector("#logo-placeholder")!.id = "logo-img";
}

window.onhashchange = () => {
document.querySelector(window.location.hash)?.scrollIntoView();
};
});

return (
<>
<Title>Milo's Homepage · milomg.dev</Title>
<canvas ref={c!} id="c"></canvas>
<nav>
<div>
Expand Down

0 comments on commit 004832a

Please sign in to comment.