-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
376 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,77 @@ | ||
<script lang="ts"> | ||
import { idIconDataUrl } from "../frontend-utilities" | ||
import SkeletonText from "./low-level/SkeletonText.svelte" | ||
import type { User } from "../lib/simple-comment-types" | ||
import { dispatchableStore, loginStateStore } from "../lib/svelte-stores" | ||
import { fade } from "svelte/transition" | ||
import { idIconDataUrl } from "../frontend-utilities" | ||
export let currentUser: User | undefined = undefined | ||
export let currentUser: User | undefined | ||
let loginStateValue | ||
let loginStateNextEvents | ||
let isProcessing = true | ||
loginStateStore.subscribe(state => { | ||
const { value, nextEvents } = state | ||
loginStateValue = value | ||
loginStateNextEvents = nextEvents | ||
}) | ||
$: { | ||
isProcessing = | ||
loginStateValue === "verifying" || | ||
loginStateValue === "loggingIn" || | ||
loginStateValue === "loggingOut" | ||
} | ||
const onLogoutClick = (e: Event) => { | ||
e.preventDefault() | ||
dispatchableStore.dispatch("logoutIntent") | ||
} | ||
</script> | ||
|
||
{#if loginStateValue === "verifying" || loginStateValue === "loggingIn" || loginStateValue === "loggingOut"} | ||
<section class="self-display"> | ||
<div class="self-avatar skeleton" /> | ||
<div class="self-info skeleton" /> | ||
</section> | ||
{:else if currentUser} | ||
<section class="self-display" id="self-display"> | ||
<div class="self-avatar"> | ||
<img src={idIconDataUrl(currentUser.id)} alt="" /> | ||
</div> | ||
<div class="self-info"> | ||
<h2 id="self-user-name">{currentUser.name}</h2> | ||
<p id="self-name"> | ||
@{currentUser.id} | ||
{currentUser.isAdmin ? "(admin)" : ""} | ||
</p> | ||
<p id="self-email">{currentUser.email}</p> | ||
</div> | ||
{#if loginStateNextEvents.includes("LOGOUT")} | ||
<button id="log-out-button" on:click={onLogoutClick}>Log out</button> | ||
{/if} | ||
</section> | ||
{/if} | ||
<div class="self-display-container"> | ||
{#if isProcessing} | ||
<section class="skeleton self-display" transition:fade> | ||
<div class="self-avatar skeleton"><SkeletonText avatar /></div> | ||
<div class="self-info"> | ||
<h2><SkeletonText width="30%" height="1.2rem" /></h2> | ||
<p><SkeletonText width="50%" /></p> | ||
<p><SkeletonText width="45%" /></p> | ||
</div> | ||
<div><SkeletonText width="7rem" height="2rem" /></div> | ||
</section> | ||
{/if} | ||
|
||
{#if currentUser} | ||
<section class="self-display" id="self-display"> | ||
<div class="self-avatar"> | ||
<img src={idIconDataUrl(currentUser.id)} alt="" /> | ||
</div> | ||
<div class="self-info"> | ||
<h2 id="self-user-name">{currentUser.name}</h2> | ||
<p id="self-name"> | ||
@{currentUser.id} | ||
{currentUser.isAdmin ? "(admin)" : ""} | ||
</p> | ||
<p id="self-email">{currentUser.email}</p> | ||
</div> | ||
{#if loginStateNextEvents.includes("LOGOUT")} | ||
<button id="log-out-button" on:click={onLogoutClick}>Log out</button> | ||
{/if} | ||
</section> | ||
{/if} | ||
</div> | ||
|
||
<style lang="scss"> | ||
.self-display-container { | ||
position: relative; | ||
width: 100%; | ||
display: block; | ||
height: 10rem; | ||
.self-display.skeleton { | ||
position: absolute; | ||
width: 100%; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<script lang="ts"> | ||
import SkeletonText from "./SkeletonText.svelte" | ||
export let isHidden = false | ||
</script> | ||
|
||
<div class="skeleton-comment" class:is-hidden={isHidden}> | ||
<header class="comment-header"> | ||
<div class="user-avatar"><SkeletonText avatar /></div> | ||
<div class="comment-info"> | ||
<p class="user-name"><SkeletonText width="8rem" /></p> | ||
<p class="comment-date"><SkeletonText width="12rem" /></p> | ||
</div> | ||
</header> | ||
<article class="comment-body"> | ||
<SkeletonText paragraph /> | ||
</article> | ||
</div> | ||
|
||
<style lang="scss"> | ||
.comment-header { | ||
align-items: center; | ||
display: flex; | ||
flex-direction: row; | ||
margin-bottom: 0.25rem; | ||
min-height: unset; | ||
p { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
.user-avatar { | ||
flex: 0 0 3rem; | ||
margin-right: 0.9rem; | ||
display: inline-flex; | ||
max-width: 2.5rem; | ||
border-radius: 50%; | ||
overflow: hidden; | ||
} | ||
.comment-info { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
width: calc(100% - 3rem - 1.3rem); | ||
.user-name { | ||
margin-right: 1rem; | ||
} | ||
} | ||
} | ||
.comment-body { | ||
margin-left: 0.5rem; | ||
padding-left: 2rem; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script lang="ts"> | ||
import SkeletonText from "./SkeletonText.svelte" | ||
export let isHidden = false | ||
export let width = "100%" | ||
export let height = "7rem" | ||
</script> | ||
|
||
<div class="skeleton-comment-input" class:is-hidden={isHidden}> | ||
<SkeletonText {width} {height} /> | ||
<div class="button-row"><SkeletonText width="10rem" height="2rem" /></div> | ||
</div> |
Oops, something went wrong.