Skip to content

Commit

Permalink
fixed up some formatting and linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
d3rpp committed Nov 7, 2024
1 parent a0be2f9 commit 0635dd5
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 140 deletions.
26 changes: 12 additions & 14 deletions src/lib/components/inline-codeblock.svelte
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<script lang="ts">
import type { HTMLAttributes } from "svelte/elements"
import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils";
const {
children,
class: className,
...rest
}: HTMLAttributes<HTMLSpanElement> = $props();
const {
children,
class: className,
...rest
}: HTMLAttributes<HTMLSpanElement> = $props();
</script>

<code class={cn(
"rounded-sm bg-slate-500/30 p-1 font-mono",
className
)}
{...rest}
<code
class={cn("rounded-sm bg-slate-500/30 p-1 font-mono", className)}
{...rest}
>
{@render children?.()}
</code>
{@render children?.()}
</code>
2 changes: 1 addition & 1 deletion src/lib/components/theme-toggle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import Gear from "svelte-radix/Gear.svelte";
import { resetMode, setMode } from "mode-watcher";
import { Button, buttonVariants } from "$lib/components/ui/button/index.js";
import { buttonVariants } from "$lib/components/ui/button/index.js";
import * as DropdownMenu from "$lib/components/ui/dropdown-menu/index.js";
</script>

Expand Down
11 changes: 7 additions & 4 deletions src/routes/(app)/app/account/create_key_dialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
key_pair_encoded_download_blob = window.URL.createObjectURL(blob);
tabs_value = "download";
reset_pk_query();
};
// button cannot be pressed without the values being valid
Expand All @@ -76,7 +77,7 @@
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
// `+` like this just parses it to an integer
modulusLength: +modulus,
} satisfies RsaHashedKeyGenParams);
});
final_kid = confirmed_kid;
Expand Down Expand Up @@ -193,9 +194,10 @@
</Select.Content>
</Select.Root>
<span class="text-sm opacity-50">
If you don't know what this means, just use <InlineCodeblock>
If you don't know what this means, just use <InlineCodeblock
>
SHA-256
</InlineCodeblock>
</InlineCodeblock>
</span>
</div>

Expand Down Expand Up @@ -230,7 +232,8 @@
</Select.Content>
</Select.Root>
<span class="text-sm opacity-50">
If you don't know what this means, just use <InlineCodeblock>
If you don't know what this means, just use <InlineCodeblock
>
4096
</InlineCodeblock>
</span>
Expand Down
26 changes: 18 additions & 8 deletions src/routes/(app)/app/account/key_managerment_section.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,29 @@
<Table.Row>
<Table.Cell>{key.name}</Table.Cell>
<Table.Cell class="flex flex-col gap-2">
<span>Key ID: <InlineCodeblock>{key.kid}</InlineCodeblock></span>
<span>Fingerprint: <InlineCodeblock>{create_md5_fingerprint(key.key as Uint8Array)}</InlineCodeblock></span>
<span>
Key ID: <InlineCodeblock>
{key.kid}
</InlineCodeblock>
</span>
<span>
Fingerprint: <InlineCodeblock>
{create_md5_fingerprint(
key.key as Uint8Array,
)}
</InlineCodeblock>
</span>
</Table.Cell>
<Table.Cell>Actions (todo)</Table.Cell>
</Table.Row>
{/each}
</Table.Body>
<Table.Footer>
<Table.Row>
<Table.Cell colspan={2}>Total Key Count</Table.Cell>
<Table.Cell>{$pkquery.data.length}</Table.Cell>
</Table.Row>
</Table.Footer>
<Table.Footer>
<Table.Row>
<Table.Cell colspan={2}>Total Key Count</Table.Cell>
<Table.Cell>{$pkquery.data.length}</Table.Cell>
</Table.Row>
</Table.Footer>
</Table.Root>
{/if}
</Card.Content>
Expand Down
13 changes: 1 addition & 12 deletions src/routes/(auth)/auth/login/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
<script lang="ts">
import type { ValidOauthMethods } from "$lib/server/auth/oauth_methods";
import { trpc } from "$lib/trpc/client";
import { page } from "$app/stores";
import Main from "@/main.svelte";
import { Button } from "@/ui/button";
import * as Card from "@/ui/card";
import { Input } from "@/ui/input";
import { Label } from "@/ui/label";
import { Separator } from "@/ui/separator";
import { GithubLogo } from "svelte-radix";
import { PAGE_TRANSITION_TIME } from "$lib";
import { fade, slide } from "svelte/transition";
import { fade } from "svelte/transition";
import { goto } from "$app/navigation";
let username = $state("");
let password = $state("");
const rpc = trpc($page);
const oauthLoginGenerator =
(provider: ValidOauthMethods) => (ev: MouseEvent) => {
ev.stopPropagation();
Expand Down
101 changes: 1 addition & 100 deletions src/routes/(auth)/auth/sign-up/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,113 +1,18 @@
<script lang="ts">
import type { ValidOauthMethods } from "$lib/server/auth/oauth_methods";
import { page } from "$app/stores";
import { goto } from "$app/navigation";
import { trpc } from "$lib/trpc/client";
import { PASSWORD_SCHEMA } from "$lib/trpc/schemas";
import { debounce } from "$lib/utils";
import { PAGE_TRANSITION_TIME } from "$lib";
// renamed because it clashes with the $derived rune?
// ¯\_(ツ)_/¯
//
// Damn you Rich Harris
import {
derived as derived_store,
get,
writable,
type Readable,
} from "svelte/store";
import { slide, fade } from "svelte/transition";
import { fade } from "svelte/transition";
import Main from "@/main.svelte";
import { Button } from "@/ui/button";
import * as Card from "@/ui/card";
import { Input } from "@/ui/input";
import { Label } from "@/ui/label";
import { Separator } from "@/ui/separator";
import { AnimatedLoading } from "$lib/icons";
import { CircleCheck, CircleX } from "lucide-svelte";
import { GithubLogo } from "svelte-radix";
const rpc = trpc($page);
// const utils = rpc.createUtils();
// #region Username Validation
const username = writable("");
const username_is_empty = derived_store(
username,
(val) => val.length == 0,
true,
);
const username_availability_query =
rpc.auth.checkUsernameAvailability.createQuery(
username,
derived_store(username_is_empty, (val) => {
return {
retry: false,
enabled: !val,
placeholderData: { available: true },
};
}),
);
/**
* Error text generated from zod error, error reasons (used in `reason`) are defined
* in the server handler for the `username_availability_query`.
*/
const username_invalid_error_text: Readable<string | undefined> =
derived_store(username_availability_query, (val) => {
if (val.data && val.data.available === false)
return "Username is Taken";
if (!val.error) return undefined;
if (
!val.error.data?.zodError ||
val.error.data?.zodError.formErrors.length == 0
)
return "Unknown Error";
const first_form_error = val.error.data.zodError.formErrors[0];
if (first_form_error) return first_form_error;
});
// #endregion
// #region Password Validation
let password = $state("");
const password_validation: string | boolean = $derived.by(() => {
if (password.length === 0) return false;
const validity = PASSWORD_SCHEMA.safeParse(password);
if (validity.success) return true;
return validity.error.format()._errors[0];
});
// #endregion
const signUpMutation = rpc.auth.signUp.createMutation({
onSuccess: () => {
goto("/auth/sign-up/onboarding");
},
});
/**
* On Submit form handler
*/
const onsubmit = (ev: SubmitEvent) => {
ev.stopPropagation();
ev.preventDefault();
$signUpMutation.mutate({ username: get(username), password });
};
const oauthLoginGenerator =
(provider: ValidOauthMethods) => (ev: MouseEvent) => {
ev.stopPropagation();
Expand Down Expand Up @@ -139,7 +44,3 @@
</Card.Root>
</div>
</Main>

{#if $username_availability_query.isError}
<pre>{$username_availability_query.error.message}</pre>
{/if}
1 change: 0 additions & 1 deletion src/routes/(auth)/oauth/[method=oauth]/+error.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts">
import { goto } from "$app/navigation";
import { page } from "$app/stores";
import Main from "@/main.svelte";
Expand Down

0 comments on commit 0635dd5

Please sign in to comment.