Skip to content

Commit

Permalink
Better markup saving feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
amyjko committed Jul 4, 2024
1 parent cbcb9e3 commit afd1d8f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Dates should be in`YYYY-MM-DD` format and versions are in [semantic versioning](
- Cleaned up landing page.
- Don't blur dialog background so that errors are visible.
- Moved navigation feedback to the header.
- Better markup saving feedback.

## v0.5.2

Expand Down
16 changes: 11 additions & 5 deletions src/lib/Loading.svelte
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<script lang="ts">
import { onMount } from 'svelte';
import { locale } from '../types/Locales';
import Text from './Text.svelte';
import Logo from './Logo';
export let inline = true;
export let text: string = 'Loading...';
let count = 1;
const Increments = 5;
onMount(() => {
const timer = setInterval(() => {
count = (count + 1) % 5;
}, 100);
count = (count + 1) % Increments;
}, 50);
return () => {
clearInterval(timer);
};
});
</script>

<div class:inline>
<span class="dots"><Text text={$locale?.term.loading} /> {Logo.repeat(count)}</span>
{text} <span class="dots" style:transform="rotate({360 * (count / Increments)}deg)">{Logo}</span>
</div>

<style>
Expand All @@ -36,4 +36,10 @@
display: inline;
width: auto;
}
.dots {
display: inline-block;
text-align: center;
transform-origin: center;
}
</style>
30 changes: 18 additions & 12 deletions src/lib/MarkupView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { tick } from 'svelte';
import { addError, getErrors } from './contexts';
import Note from './Note.svelte';
import Loading from './Loading.svelte';
/** The markup's text */
export let markup: string;
Expand All @@ -32,7 +33,7 @@
$: if (edit === undefined) markup = revisedText;
async function startEditing() {
revisedText = markup ?? '';
revisedText = markup;
editing = true;
await tick();
input?.focus();
Expand All @@ -41,6 +42,7 @@
async function save() {
if (edit) {
saving = true;
await new Promise((resolve) => setTimeout(resolve, 2000));
const error = await edit(revisedText ?? '');
if (error) {
addError(errors, 'Unable to save markup.', error);
Expand Down Expand Up @@ -84,17 +86,21 @@
</div>
{/if}
{#if edit}<div class="control">
<Button
tip={editing ? 'Save your edits.' : 'Start editing this markup.'}
action={async () => {
if (editing) {
save();
} else {
startEditing();
}
}}
>{#if editing}&checkmark;{:else}✎{/if}</Button
>
{#if saving}<Loading text="" />
{:else}
<Button
tip={editing ? 'Save your edits.' : 'Start editing this markup.'}
action={async () => {
if (editing) {
save();
} else {
startEditing();
}
}}
active={!saving}
>{#if editing}&checkmark;{:else}✎{/if}</Button
>
{/if}
</div>
{/if}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</script>

<div class="header">
<Link to="/">{Logo}</Link>{#if $navigating}<Loading />{/if}<span class="account"
<Link to="/">{Logo}</Link>{#if $navigating}<Loading inline={false} />{/if}<span class="account"
>{#if $user}<Link to="/login">{$user.email}</Link>{:else}<Link to="/login">Login</Link
>{/if}</span
>
Expand Down

0 comments on commit afd1d8f

Please sign in to comment.