aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-04-29 01:48:56 +0100
committerGravatar Joe Banks <[email protected]>2024-04-29 01:48:56 +0100
commitfd871aa478a192929cb581e231268d9b9bd0e473 (patch)
treeef5ef4f484bb18937a941c93e54f983142634e9b
parentAdd mousetrap (diff)
Add something
-rw-r--r--gatsby-browser.ts36
1 files changed, 36 insertions, 0 deletions
diff --git a/gatsby-browser.ts b/gatsby-browser.ts
new file mode 100644
index 0000000..6271f83
--- /dev/null
+++ b/gatsby-browser.ts
@@ -0,0 +1,36 @@
+import { default as mousetrap } from "mousetrap";
+
+declare global {
+ interface Window {
+ rick: HTMLIFrameElement | null;
+ }
+}
+
+export const onInitialClientRender = (
+ _: any,
+ {
+ sequence = "up up down down left right left right b a",
+ }: { sequence?: string } = {}
+) => {
+
+ mousetrap.bind(sequence, () => {
+ let iframe = document.createElement("iframe");
+ iframe.src = "https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1&controls=0";
+ iframe.style.position = "fixed";
+ iframe.style.top = "0";
+ iframe.style.left = "0";
+ iframe.style.width = "100%";
+ iframe.style.height = "100%";
+ iframe.style.border = "none";
+ iframe.style.zIndex = "999999";
+ document.body.appendChild(iframe);
+ window.rick = iframe;
+ });
+
+ mousetrap.bind("esc", () => {
+ if (window.rick) {
+ window.rick.remove();
+ window.rick = null;
+ }
+ });
+};