chadtmiller.com/group-host
atmosphere group host
0
0
The console takes a look of its own, and signs in from a dialog
harness/e2e/pages.mjs+5−3
| @@ -18,12 +18,14 @@ export const approve = async (page, name) => { | ||
await page.getByRole('button', { name: /^(accept|authorize|allow)$/i }).click() | ||
} | ||
| ||
/// Signs in to the console as `name` from the header's form: their | ||
/// Signs in to the console as `name` from the header's dialog: their | ||
/// handle, then their PDS's page, which sends the browser back. | ||
export const signIn = async (page, name) => { | ||
const back = page.url() | ||
await page.getByRole('textbox', { name: 'Your handle' }).fill(who[name].handle) | ||
await page.getByRole('button', { name: 'Sign in' }).click() | ||
await page.getByRole('banner').getByRole('button', { name: 'Sign in' }).click() | ||
const dialog = page.getByRole('dialog', { name: 'Sign in with your Atmosphere account' }) | ||
await dialog.getByRole('textbox', { name: 'Your handle' }).fill(who[name].handle) | ||
await dialog.getByRole('button', { name: 'Continue' }).click() | ||
await approve(page, name) | ||
await page.waitForURL(back) | ||
} | ||
web/src/lib/molecules/Dialog.sveltenew+22−0
| @@ -0,0 +1,22 @@ | ||
<script lang="ts"> | ||
import type { Snippet } from 'svelte'; | ||
/** | ||
* A dialog over the dimmed page, opened by a button whose | ||
* `popovertarget` is its `id`: its `title`, a | ||
* button to close it, then `children`. Light dismiss closes it too, as a | ||
* popover does, with no script. | ||
*/ | ||
let { id, title, children }: { id: string; title: string; children: Snippet } = $props(); | ||
// Opened, the first thing to fill in is the one being typed into. | ||
function toggled(e: ToggleEvent) { | ||
if (e.newState !== 'open') return; | ||
const into = (e.currentTarget as HTMLElement).querySelector<HTMLInputElement>('input:not([type=hidden])'); | ||
into?.focus(); | ||
} | ||
</script> | ||
| ||
<div class="dialog" {id} popover="auto" role="dialog" aria-modal="true" aria-labelledby="{id}-title" ontoggle={toggled}> | ||
<h2 id="{id}-title" class="dialog-title">{title}</h2> | ||
<button class="close" type="button" popovertarget={id} popovertargetaction="hide" aria-label="Close">×</button> | ||
{@render children()} | ||
</div> | ||
web/src/lib/molecules/Section.sveltenew+10−0
| @@ -0,0 +1,10 @@ | ||
<script lang="ts"> | ||
import type { Snippet } from 'svelte'; | ||
/** A part of a page, apart from the rest: its heading, then what it holds. */ | ||
let { title, children }: { title: string; children: Snippet } = $props(); | ||
</script> | ||
| ||
<section class="card stack"> | ||
<h2>{title}</h2> | ||
{@render children()} | ||
</section> | ||
web/src/lib/molecules/SignIn.svelte+3−13
| @@ -1,16 +1,6 @@ | ||
<script lang="ts"> | ||
/** | ||
* Signing in, as oneself, at one's own PDS: a handle, sent to the group | ||
* host's `/console/login`, which goes there and back to `back`. | ||
*/ | ||
let { back = '/' }: { back?: string } = $props(); | ||
import { SIGN_IN } from '#lib/signIn.ts'; | ||
/** The way in: a button opening the sign-in dialog, wherever it is wanted. */ | ||
</script> | ||
| ||
<form class="sign-in" method="get" action="/console/login"> | ||
<input type="hidden" name="back" value={back} /> | ||
<label> | ||
Your handle | ||
<input name="handle" required autocomplete="username" placeholder="you.bsky.social" /> | ||
</label> | ||
<button type="submit">Sign in</button> | ||
</form> | ||
<button type="button" popovertarget={SIGN_IN}>Sign in</button> | ||
web/src/lib/molecules/SignOut.svelte+1−1
| @@ -5,5 +5,5 @@ | ||
| ||
<form class="sign-out" method="post" action="/console/logout"> | ||
<span class="mute">Signed in as <span class="mono">{handle ? `@${handle}` : did}</span></span> | ||
<button type="submit">Sign out</button> | ||
<button class="quiet" type="submit">Sign out</button> | ||
</form> | ||
web/src/lib/molecules/Standing.svelte+2−2
| @@ -14,9 +14,9 @@ | ||
| ||
<div class="standing"> | ||
{#if member} | ||
<form method="post" action="?/leave"><span class="mute">You are a member.</span> <button type="submit">Leave</button></form> | ||
<form method="post" action="?/leave"><span class="mute">You are a member.</span> <button class="quiet" type="submit">Leave</button></form> | ||
{:else if asked} | ||
<form method="post" action="?/cancel"><span class="mute">You have asked to join.</span> <button type="submit">Take back the request</button></form> | ||
<form method="post" action="?/cancel"><span class="mute">You have asked to join.</span> <button class="quiet" type="submit">Take back the request</button></form> | ||
{:else if invited} | ||
<p class="mute">This group takes people by invitation.</p> | ||
{:else} | ||
web/src/lib/organisms/AccountMove.svelte+2−2
| @@ -26,7 +26,7 @@ | ||
Its address here | ||
<input name="address" value={plan.label} maxlength="63" pattern="[A-Za-z0-9\-]+" /> | ||
</label> | ||
<button type="submit">Check that address</button> | ||
<button class="quiet" type="submit">Check that address</button> | ||
</form> | ||
<form class="stack" method="post" action="?/start"> | ||
<input type="hidden" name="address" value={plan.label} /> | ||
| @@ -41,6 +41,6 @@ | ||
</form> | ||
{/if} | ||
<form method="post" action="?/cancel"> | ||
<button type="submit">Stop, and sign out of it</button> | ||
<button class="quiet" type="submit">Stop, and sign out of it</button> | ||
</form> | ||
</div> | ||
web/src/lib/organisms/AppPasswords.svelte+1−1
| @@ -17,7 +17,7 @@ | ||
{#each passwords as p (p.name)} | ||
<li> | ||
<strong>{p.name}</strong> <span class="mute">by {p.member}{p.privileged ? ', with chat' : ''}{p.lastUsedAt ? `, last used ${p.lastUsedAt}` : ''}</span> | ||
<form method="post" action="?/unpassword"><input type="hidden" name="name" value={p.name} /><button type="submit">Revoke “{p.name}”</button></form> | ||
<form method="post" action="?/unpassword"><input type="hidden" name="name" value={p.name} /><button class="quiet" type="submit">Revoke “{p.name}”</button></form> | ||
</li> | ||
{/each} | ||
</ul> | ||
web/src/lib/organisms/AuthorizeRequest.svelte+1−1
| @@ -59,6 +59,6 @@ | ||
{/if} | ||
<form method="post" action={action('decline')}> | ||
<input type="hidden" name="requestUri" value={requestUri} /> | ||
<button type="submit">Decline</button> | ||
<button class="quiet" type="submit">Decline</button> | ||
</form> | ||
</div> | ||
web/src/lib/organisms/ConnectedApps.svelte+1−1
| @@ -11,7 +11,7 @@ | ||
{#each apps as a (a.clientId)} | ||
<li> | ||
<strong>{a.name}</strong> <span class="mute">connected {a.connectedAt}, last used {a.usedAt}</span> | ||
<form method="post" action="?/disconnect"><input type="hidden" name="clientId" value={a.clientId} /><button type="submit">Disconnect {a.name}</button></form> | ||
<form method="post" action="?/disconnect"><input type="hidden" name="clientId" value={a.clientId} /><button class="quiet" type="submit">Disconnect {a.name}</button></form> | ||
</li> | ||
{/each} | ||
</ul> | ||