Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion fragments/auth/template/src/components/Auth/Link.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { user, authenticating } from "./store";
import { url } from "@roxi/routify";
</script>

<ul>
<li>
{#if $authenticating}
Expand All @@ -12,6 +13,9 @@
<a href={$url("/login")}>Login</a>
{/if}
</li>
<li>
<a href={$url("/protected")}>Go to protected pages</a>
</li>
</ul>

<style>
Expand All @@ -23,7 +27,7 @@
display: block;
}
li {
margin-left: 6px;
margin: 1rem;
list-style: none;
}
</style>
8 changes: 8 additions & 0 deletions fragments/auth/template/src/components/Auth/Login.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@
{/if}
</form>
</div>

<style>
input {
color: black;
padding: 6px;
border-radius: 5px;
}
</style>
56 changes: 37 additions & 19 deletions fragments/auth/template/src/pages/protected/_reset.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,55 @@
</script>

<div class="protected">
<a href={$url("/")}>Go back</a>
<h1>
Protected module {#if $user}<button on:click={logout}>logout</button>{/if}
</h1>
<main class="container">
{#if $user}
<slot />
{:else if $authenticating}
<h2>authenticating...</h2>
{:else}
<Login />
{/if}
</main>
<div class="wrapper">
<nav>
<a href={$url("/")}>Go back</a>
{#if $user}<button on:click={logout}>logout</button>{/if}
</nav>
<h1>Protected module</h1>
<main class="container">
{#if $user}
<slot />
{:else if $authenticating}
<h2>authenticating...</h2>
{:else}
<Login />
{/if}
</main>
</div>
</div>

<style>
.protected {
position: absolute;
height: 100%;
width: 100%;
height: calc(100% - 16px);
width: calc(100% - 16px);
background: black;
}

.wrapper {
padding: 2rem;
}

* :global(*) {
color: white;
}
* :global(code) {
color: initial;
color: yellow;
font-weight: bold;
}

nav {
display: flex;
justify-content: space-between;
height: 2rem;
align-items: center;
}

button {
position: absolute;
right: 16px;
top: 16px;
padding: 8px;
color: black;
border-radius: 6px;
cursor: pointer;
}
</style>