Add colours and Sentry feedback form

This commit is contained in:
Jade Ellis
2024-09-10 04:11:45 +01:00
parent 3ff04eba7e
commit d6da36314d
10 changed files with 294 additions and 147 deletions
+4 -3
View File
@@ -1,5 +1,5 @@
import { SENTRY_DSN } from '$lib/config'; import { SENTRY_DSN } from '$lib/config';
import { init as initSentry, handleErrorWithSentry, makeBrowserOfflineTransport, makeFetchTransport } from '@sentry/sveltekit'; import { init as initSentry, handleErrorWithSentry, makeBrowserOfflineTransport, makeFetchTransport, feedbackIntegration } from '@sentry/sveltekit';
initSentry({ initSentry({
dsn: SENTRY_DSN, dsn: SENTRY_DSN,
@@ -14,8 +14,9 @@ initSentry({
// sessions when an error occurs. // sessions when an error occurs.
replaysOnErrorSampleRate: 1.0, replaysOnErrorSampleRate: 1.0,
// If you don't want to use Session Replay, just remove the line below: integrations: [feedbackIntegration({
// integrations: [replayIntegration()], autoInject: false,
})],
// To enable offline events caching, use makeBrowserOfflineTransport to wrap // To enable offline events caching, use makeBrowserOfflineTransport to wrap
// existing transports and queue events using the browsers' IndexedDB storage // existing transports and queue events using the browsers' IndexedDB storage
+34 -1
View File
@@ -33,6 +33,11 @@
--code-background-color: #0d1117; --code-background-color: #0d1117;
--code-color: #fff; --code-color: #fff;
--color-primary: hsl(230, 50%, 90%);
--color-secondary: hsl(230, 50%, 10%);
--color-tertiary: hsl(290, 80%, 20%);
--color-accent: hsl(227, 80%, 20%);
--color-red: #e93147; --color-red: #e93147;
--color-orange: #ec7500; --color-orange: #ec7500;
--color-yellow: #e0ac00; --color-yellow: #e0ac00;
@@ -61,6 +66,11 @@
--font-color-contrast: rgba(0, 0, 0, .87); --font-color-contrast: rgba(0, 0, 0, .87);
--font-color-secondary: rgba(255, 255, 255, .6); --font-color-secondary: rgba(255, 255, 255, .6);
--color-primary: hsl(230, 50%, 10%);
--color-secondary: hsl(230, 50%, 90%);
--color-tertiary: hsl(290, 80%, 80%);
--color-accent: hsl(195, 80%, 80%);
--color-red: #fb464c; --color-red: #fb464c;
--color-orange: #e9973f; --color-orange: #e9973f;
--color-yellow: #e0de71; --color-yellow: #e0de71;
@@ -109,7 +119,8 @@ html {
body { body {
padding: 0; padding: 0;
margin: 0 margin: 0;
min-height: 100vh;
} }
iframe, iframe,
@@ -125,6 +136,13 @@ svg {
display: block; display: block;
} }
a {
color: var(--color-accent);
}
a:visited {
color: var(--color-tertiary);
}
.container { .container {
--container-max-width: var(--page-width); --container-max-width: var(--page-width);
--padding-x: var(--spacing); --padding-x: var(--spacing);
@@ -176,3 +194,18 @@ svg {
} }
button {
display: inline-block;
color: var(--color-primary);
background: var(--color-accent);
border-radius: 4px;
margin: 8px 8px 8px 0px;
padding: 12px 24px;
border: solid 2px var(--color-accent);
}
.secondary {
border: solid 2px var(--color-accent);
color: var(--color-accent);
background: transparent;
}
@@ -5,7 +5,7 @@
import { bookmarkify, parseMeta } from "./bookmarklets"; import { bookmarkify, parseMeta } from "./bookmarklets";
import type { Config } from "./config"; import type { Config } from "./config";
import { init } from "$lib/workers/terser"; import { init } from "$lib/workers/terser";
import { SITE_URL } from '$lib/metadata'; import { SITE_URL } from "$lib/metadata";
/** @type {import('./$types').Snapshot<string>} */ /** @type {import('./$types').Snapshot<string>} */
export const snapshot = { export const snapshot = {
@@ -13,7 +13,7 @@
restore: (v: string) => (value = v), restore: (v: string) => (value = v),
}; };
let minify = init().minify let minify = init().minify;
let value = ""; let value = "";
let output = ""; let output = "";
@@ -26,7 +26,7 @@
} }
} }
let contentAttributes = {"aria-label": "Bookmarklet editor"} let contentAttributes = { "aria-label": "Bookmarklet editor" };
$: progress = process(value); $: progress = process(value);
</script> </script>
@@ -36,6 +36,8 @@
description="Make booklets in your browser with this tool. Make handy shortcuts to save time." description="Make booklets in your browser with this tool. Make handy shortcuts to save time."
canonical={SITE_URL + "/bookmarklets"} canonical={SITE_URL + "/bookmarklets"}
/> />
<main class="main container" id="page-content">
<h1>Bookmarklet Maker</h1> <h1>Bookmarklet Maker</h1>
<Editor <Editor
{value} {value}
@@ -53,17 +55,26 @@
<p style="color: red">{error.message}</p> <p style="color: red">{error.message}</p>
{/await} {/await}
<label for="output">Bookmarklet code</label> <label for="output">Bookmarklet code</label>
<textarea name="output" id="output" class="output card" rows="1" value={output} readonly <textarea
name="output"
id="output"
class="output card"
rows="1"
value={output}
readonly
></textarea> ></textarea>
<!-- <Editor readonly={true} /> --> <!-- <Editor readonly={true} /> -->
<p> <p>
Bookmark this link: <a href={output}>{options.name || "My Bookmarklet"}</a> Bookmark this link: <a href={output}
>{options.name || "My Bookmarklet"}</a
>
</p> </p>
<p> <p>
Either drag the link to your bookmarlets bar or, on FireFox, right click and Either drag the link to your bookmarlets bar or, on FireFox, right click
select "Bookmark Link". and select "Bookmark Link".
</p> </p>
</main>
<style> <style>
.code-header { .code-header {
@@ -3,7 +3,7 @@
import { javascript } from "@codemirror/lang-javascript"; import { javascript } from "@codemirror/lang-javascript";
import SvelteSeo from "svelte-seo"; import SvelteSeo from "svelte-seo";
import { init } from "$lib/workers/terser"; import { init } from "$lib/workers/terser";
import { SITE_URL } from '$lib/metadata'; import { SITE_URL } from "$lib/metadata";
/** @type {import('./$types').Snapshot<string>} */ /** @type {import('./$types').Snapshot<string>} */
export const snapshot = { export const snapshot = {
@@ -11,24 +11,24 @@
restore: (v: string) => (value = v), restore: (v: string) => (value = v),
}; };
let minify = init().minify let minify = init().minify;
let value = ""; let value = "";
let output = ""; let output = "";
async function process(str: string) { async function process(str: string) {
if (value === "") { if (value === "") {
output = ""; output = "";
return return;
} }
let result = await minify(str) let result = await minify(str);
if (typeof result.code == "string") { if (typeof result.code == "string") {
output = result.code output = result.code;
} else { } else {
console.error(result) console.error(result);
} }
} }
let contentAttributes = {"aria-label": "Javascript editor"} let contentAttributes = { "aria-label": "Javascript editor" };
$: progress = process(value); $: progress = process(value);
</script> </script>
@@ -38,6 +38,8 @@
description="Reduce JavaScript code size with this handy online tool. It's easy to minify your JavaScript code." description="Reduce JavaScript code size with this handy online tool. It's easy to minify your JavaScript code."
canonical={SITE_URL + "/javascript-minifier"} canonical={SITE_URL + "/javascript-minifier"}
/> />
<main class="main container" id="page-content">
<h1>Javascript Minifier</h1> <h1>Javascript Minifier</h1>
<Editor <Editor
{value} {value}
@@ -55,9 +57,15 @@
<p style="color: red">{error.message}</p> <p style="color: red">{error.message}</p>
{/await} {/await}
<label for="output">Minified code</label> <label for="output">Minified code</label>
<textarea name="output" id="output" class="output card" rows="1" value={output} readonly <textarea
name="output"
id="output"
class="output card"
rows="1"
value={output}
readonly
></textarea> ></textarea>
</main>
<style> <style>
.code-header { .code-header {
+78
View File
@@ -0,0 +1,78 @@
<script lang="ts">
import { page } from "$app/stores";
import * as Sentry from "@sentry/sveltekit";
import { onMount } from "svelte";
import SvelteSeo from "svelte-seo";
const { status, error } = $page;
const message = error?.message || "Hmm";
const title = `${status}: ${message}`;
let sentryElement: HTMLDivElement;
let openForm = () => {};
onMount(async () => {
const feedback = Sentry.getFeedback({
el: sentryElement,
});
if (!feedback) {
return;
}
// console.log("feedback", feedback);
const form = await feedback.createForm({});
form.appendToDom();
form.open();
openForm = async () => {
form.open();
};
});
</script>
<SvelteSeo {title} />
<main class="main container" id="page-content">
<div class="wrapper">
<h1>{title}</h1>
<div bind:this={sentryElement} class="feedback"></div>
<button on:click={openForm}>Send Feedback</button>
<button class="secondary" on:click={()=> window.location.reload()}>Reload</button>
<!-- <div role="doc-subtitle">{status}</div> -->
</div>
</main>
<style>
main {
display: grid;
place-items: center;
}
.wrapper {
flex-grow: 2;
width: 40vw;
max-width: 500px;
margin: 0 auto;
/* display: flex;
flex-direction: column;
align-items: center;
gap: var(--spacing);
margin: 48px auto;
max-width: 320px;
padding: 3rem 0.5rem; */
}
h1 {
margin: 0;
font-size: 4em;
/* font-weight: 100; */
}
/* [role="doc-subtitle"] {
padding-block-start: 0;
font-size: 2em;
font-weight: 600;
} */
:global(#sentry-feedback) {
--dialog-inset: auto auto 0;
}
p {
width: 95%;
font-size: 1.5em;
line-height: 1.4;
}
</style>
@@ -11,7 +11,4 @@
<meta property="og:site_name" content={SITE_TITLE}> <meta property="og:site_name" content={SITE_TITLE}>
</svelte:head> </svelte:head>
<Nav /> <Nav />
<main class="main container" id="page-content">
<slot /> <slot />
</main>
+15 -3
View File
@@ -6,8 +6,18 @@
</script> </script>
<svelte:head> <svelte:head>
<link rel="alternate" type="application/rss+xml" title={SITE_TITLE} href={SITE_URL + "/blog/rss.xml"}> <link
<link rel="alternate" type="application/feed+json" title={SITE_TITLE} href={SITE_URL + "/blog/feed.json"}> rel="alternate"
type="application/rss+xml"
title={SITE_TITLE}
href={SITE_URL + "/blog/rss.xml"}
/>
<link
rel="alternate"
type="application/feed+json"
title={SITE_TITLE}
href={SITE_URL + "/blog/feed.json"}
/>
</svelte:head> </svelte:head>
<SvelteSeo <SvelteSeo
@@ -15,6 +25,8 @@
description="Student, Creative & Computer Scientist. See what I'm doing." description="Student, Creative & Computer Scientist. See what I'm doing."
canonical="https://jade.ellis.link" canonical="https://jade.ellis.link"
/> />
<Hero />
<main class="main container" id="page-content">
<Hero />
<Homepage /> <Homepage />
</main>
@@ -53,6 +53,7 @@
<SvelteSeo title="Jade's Blog - Posts" canonical={SITE_URL + "/blog"} /> <SvelteSeo title="Jade's Blog - Posts" canonical={SITE_URL + "/blog"} />
<main class="main container" id="page-content">
<section role="feed" class="h-feed" id="feed"> <section role="feed" class="h-feed" id="feed">
<h1 class="p-name"> <h1 class="p-name">
<a <a
@@ -91,6 +92,7 @@
<button type="submit" on:click={handleClick}>See more {H_ELLIPSIS_ENTITY}</button> <button type="submit" on:click={handleClick}>See more {H_ELLIPSIS_ENTITY}</button>
{/if} --> {/if} -->
</section> </section>
</main>
<style> <style>
.permalink { .permalink {
@@ -48,11 +48,11 @@
}); });
gtag("event", "share", { gtag("event", "share", {
"share_url": url.href, share_url: url.href,
"share_title": data.post.title, share_title: data.post.title,
"share_button": "article_top", share_button: "article_top",
"method": "navigator_share", method: "navigator_share",
"content_type": "article", content_type: "article",
}); });
} catch (error: any) { } catch (error: any) {
if (error.toString().includes("AbortError")) { if (error.toString().includes("AbortError")) {
@@ -176,6 +176,7 @@
}} }}
/> />
<main class="main container" id="page-content">
<article class="h-entry"> <article class="h-entry">
<h1 id="title" class="p-name">{data.post.title}</h1> <h1 id="title" class="p-name">{data.post.title}</h1>
<aside> <aside>
@@ -212,6 +213,7 @@
<svelte:component this={data.component} /> <svelte:component this={data.component} />
</div> </div>
</article> </article>
</main>
<style> <style>
aside { aside {
@@ -18,6 +18,8 @@
description={data.post.description} description={data.post.description}
canonical={SITE_URL + "/projects/" + data.post.slug} canonical={SITE_URL + "/projects/" + data.post.slug}
/> />
<main class="main container" id="page-content">
<h1>{data.post.title}</h1> <h1>{data.post.title}</h1>
<!-- {#await GhReleasesDownload} <!-- {#await GhReleasesDownload}
@@ -30,3 +32,4 @@
{/if} {/if}
<svelte:component this={data.component} /> <svelte:component this={data.component} />
</main>