Initial commit

This commit is contained in:
Sawyer 2025-03-08 15:44:09 -06:00
commit 40182703e4
17 changed files with 1993 additions and 0 deletions

13
src/app.html Normal file
View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="/style.css">
<link rel="icon" href="%sveltekit.assets%/favicon.png">
<meta name="viewport" content="width=device-width, initial-scale=1">
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>

1
src/lib/index.js Normal file
View file

@ -0,0 +1 @@
// place files you want to import through the `$lib` alias in this folder.

46
src/routes/+page.svelte Normal file
View file

@ -0,0 +1,46 @@
<script>
import { browser } from '$app/environment';
import { onMount } from 'svelte';
import { countWords } from 'alfaaz';
let text;
function wordCount(text) {
if (text == undefined) {
return '0';
} else {
return countWords(text);
}
}
function characterCount(text) {
if (text == undefined) {
return '0';
} else {
return text.length;
}
}
onMount(() => {
if (browser) {
const savedText = localStorage.getItem('text');
if (savedText !== null) {
text = savedText; // Ensure reactivity
}
}
});
$: if (browser && text !== undefined) {
localStorage.setItem('text', text);
}
</script>
<svelte:head>
<title>Word Counter</title>
</svelte:head>
<main>
<p class="word-count center">{wordCount(text)} words, {characterCount(text)} characters</p>
<!-- svelte-ignore a11y_autofocus -->
<textarea class="center" autofocus bind:value={text}></textarea>
</main>