Read the curated photo feeds from wss://nostr.kosmos.org, verify events, cache originals and thumbnails, and let users pick a wallpaper from the Photos section. Nature is the default feed; City Nights is opt-in. Adds the manual publishing scripts, real event fixtures, protocol documentation, and tests with stubbed network connections.
80 lines
2.5 KiB
Plaintext
80 lines
2.5 KiB
Plaintext
import Component from '@glimmer/component';
|
|
import { action } from '@ember/object';
|
|
import { on } from '@ember/modifier';
|
|
import { service } from '@ember/service';
|
|
import Wallpaper from './wallpaper.gjs';
|
|
import { WELCOME_WALLPAPER_URL } from '../config/nostr';
|
|
import autofocus from '../modifiers/autofocus';
|
|
|
|
// First-run onboarding step: ask the user what to call them. Kept presentational
|
|
// so later steps can be sequenced from the route/service without touching this
|
|
// form.
|
|
export default class WelcomeComponent extends Component {
|
|
@service user;
|
|
@service router;
|
|
|
|
get welcomePhoto() {
|
|
return {
|
|
url: WELCOME_WALLPAPER_URL,
|
|
displayUrl: WELCOME_WALLPAPER_URL,
|
|
alt: '',
|
|
};
|
|
}
|
|
|
|
@action
|
|
handleSubmit(event) {
|
|
event.preventDefault();
|
|
|
|
const value = String(new FormData(event.target).get('name') ?? '').trim();
|
|
|
|
if (!value) {
|
|
return;
|
|
}
|
|
|
|
// setName updates the tracked name synchronously, so the index guard passes
|
|
// immediately; the disk write finishes in the background.
|
|
this.user.setName(value);
|
|
this.router.replaceWith('index');
|
|
}
|
|
|
|
<template>
|
|
<Wallpaper @photo={{this.welcomePhoto}} />
|
|
|
|
<div
|
|
class="col-span-3 row-span-3 flex flex-col items-center justify-center px-6 text-center text-white"
|
|
data-test-welcome
|
|
>
|
|
<form class="w-full max-w-xl" {{on "submit" this.handleSubmit}}>
|
|
<h1 class="text-3xl font-semibold sm:text-4xl">
|
|
Hello! What's your name?
|
|
</h1>
|
|
|
|
<label class="sr-only" for="welcome-name">Your name</label>
|
|
<input
|
|
id="welcome-name"
|
|
name="name"
|
|
type="text"
|
|
required
|
|
autocomplete="given-name"
|
|
placeholder="Your name"
|
|
data-test-welcome-input
|
|
class="mt-8 w-full border-0 border-b-2 border-white/70 bg-transparent px-1 pb-2 text-center text-3xl text-white placeholder-white/50 focus:border-white focus:outline-none"
|
|
{{autofocus}}
|
|
/>
|
|
|
|
<p class="mt-4 text-sm text-white/80 text-shadow-sm">
|
|
Please enter your first name or the name you prefer to be called.
|
|
</p>
|
|
|
|
<button
|
|
type="submit"
|
|
data-test-welcome-submit
|
|
class="mt-8 inline-flex cursor-pointer items-center gap-2 rounded-full border border-white/70 px-6 py-2 text-sm font-semibold text-white transition-colors hover:bg-white/10 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white/70"
|
|
>
|
|
Continue
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</template>
|
|
}
|