diff --git a/frontend/package.json b/frontend/package.json index 9dc7347..e8ac4c0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -38,6 +38,7 @@ "type": "module", "dependencies": { "@popperjs/core": "^2.11.6", + "base64-arraybuffer": "^1.0.2", "bootstrap": "5.3.0-alpha1", "bootstrap-icons": "^1.10.3", "marked": "^4.2.12", diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 37a84a8..6dc6966 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -12,6 +12,7 @@ specifiers: '@typescript-eslint/eslint-plugin': ^5.45.0 '@typescript-eslint/parser': ^5.45.0 autoprefixer: ^10.4.13 + base64-arraybuffer: ^1.0.2 bootstrap: 5.3.0-alpha1 bootstrap-icons: ^1.10.3 eslint: ^8.28.0 @@ -32,6 +33,7 @@ specifiers: dependencies: '@popperjs/core': 2.11.6 + base64-arraybuffer: 1.0.2 bootstrap: 5.3.0-alpha1_@popperjs+core@2.11.6 bootstrap-icons: 1.10.3 marked: 4.2.12 @@ -768,6 +770,11 @@ packages: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} dev: true + /base64-arraybuffer/1.0.2: + resolution: {integrity: sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==} + engines: {node: '>= 0.6.0'} + dev: false + /binary-extensions/2.2.0: resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} engines: {node: '>=8'} diff --git a/frontend/src/routes/@[username]/+page.svelte b/frontend/src/routes/@[username]/+page.svelte index 8664174..a8073fa 100644 --- a/frontend/src/routes/@[username]/+page.svelte +++ b/frontend/src/routes/@[username]/+page.svelte @@ -4,12 +4,13 @@ import type { PageData } from "./$types"; - import { Icon } from "sveltestrap"; + import { Alert, Icon } from "sveltestrap"; import FieldCard from "$lib/components/FieldCard.svelte"; import StatusIcon from "$lib/components/StatusIcon.svelte"; import PronounLink from "$lib/components/PronounLink.svelte"; import PartialMemberCard from "$lib/components/PartialMemberCard.svelte"; import FallbackImage from "$lib/components/FallbackImage.svelte"; + import { userStore } from "$lib/store"; export let data: PageData; @@ -22,74 +23,83 @@
-
+ {#if $userStore && $userStore.id === data.id} + + You are currently viewing your public profile. +
Edit your profile +
+ {/if} +
- +
-
+
{#if data.display_name} -

{data.display_name}

-
@{data.name}
+
+

{data.display_name}

+
@{data.name}
+
{:else}

@{data.name}

{/if} -
{#if bio} +

{@html bio}

{/if} - {#if data.links.length > 0} -
+
+ {#if data.links.length > 0} +
    {#each data.links as link}
  • {link}
  • {/each}
- {/if} -
+
+ {/if}
-
-
- {#if data.names.length > 0} -
-

Names

-
    - {#each data.names as name} -
  • {name.value}
  • - {/each} -
-
- {/if} - {#if data.pronouns.length > 0} -
-

Pronouns

-
    - {#each data.pronouns as pronouns} -
  • - - -
  • - {/each} -
-
- {/if} - {#each data.fields as field} -
- -
- {/each} -
- {#if data.members.length > 0} -
-
-
-

Members

-
-
-
- {#each data.members as member} - +
+ {#if data.names.length > 0} +
+

Names

+
    + {#each data.names as name} +
  • {name.value}
  • + {/each} +
+
+ {/if} + {#if data.pronouns.length > 0} +
+

Pronouns

+
    + {#each data.pronouns as pronouns} +
  • + + +
  • + {/each} +
+
+ {/if} + {#each data.fields as field} +
+ +
{/each}
- {/if} + {#if data.members.length > 0} +
+
+
+

Members

+
+
+
+ {#each data.members as member} + + {/each} +
+ {/if} +
diff --git a/frontend/src/routes/@[username]/[memberName]/+page.svelte b/frontend/src/routes/@[username]/[memberName]/+page.svelte index 947206f..336f6d3 100644 --- a/frontend/src/routes/@[username]/[memberName]/+page.svelte +++ b/frontend/src/routes/@[username]/[memberName]/+page.svelte @@ -29,24 +29,25 @@
- +
-
+

{data.display_name ?? data.name}

{data.name} (@{data.user.name})
-
{#if bio} +

{@html bio}

{/if} - {#if data.links.length > 0} -
+
+ {#if data.links.length > 0} +
    {#each data.links as link}
  • {link}
  • {/each}
- {/if} -
+
+ {/if}
{#if data.names.length > 0} diff --git a/frontend/src/routes/auth/login/discord/+page.svelte b/frontend/src/routes/auth/login/discord/+page.svelte index a6d186f..ae15086 100644 --- a/frontend/src/routes/auth/login/discord/+page.svelte +++ b/frontend/src/routes/auth/login/discord/+page.svelte @@ -18,6 +18,7 @@ onMount(() => { if (data.token && data.user) { localStorage.setItem("pronouns-token", data.token); + localStorage.setItem("pronouns-user", JSON.stringify(data.user)); userStore.set(data.user); goto("/"); } @@ -38,6 +39,7 @@ }); localStorage.setItem("pronouns-token", resp.token); + localStorage.setItem("pronouns-user", JSON.stringify(resp.user)); userStore.set(resp.user); goto("/"); } catch (e) { @@ -53,7 +55,7 @@

Log in with Discord

{#if data.error} - +

An error occurred

{data.error.code}: {data.error.message} diff --git a/frontend/src/routes/edit/profile/+page.svelte b/frontend/src/routes/edit/profile/+page.svelte new file mode 100644 index 0000000..a786bdc --- /dev/null +++ b/frontend/src/routes/edit/profile/+page.svelte @@ -0,0 +1,202 @@ + + +

+ Edit profile + {#if modified} + + {/if} +

+ +{#if error} + +

An error occurred

+

+ {error.code}: {error.message} + {#if error.details}{error.details}{/if} +

+
+{/if} + +{#if !$userStore} + Error: No user object +{:else} +
+
+
+ + + + To change your username, go to settings. +

Avatar

+
+
+ {#if avatar} + New avatar + {:else} + + {/if} +
+
+ +
+
+
+
+ + + +
+ +