Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splash #743

Closed
wants to merge 5 commits into from
Closed
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
28 changes: 4 additions & 24 deletions web/src/routes/(app)/Login.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { Login } from '$lib/Login';
import { loginType } from '../../stores/Author';
import { page } from '$app/stores';
import { afterNavigate } from '$app/navigation';
import { afterNavigate, goto } from '$app/navigation';
import { authorProfile } from '../../stores/Author';
import { WebStorage } from '$lib/WebStorage';
import ModalDialog from '$lib/components/ModalDialog.svelte';
Expand Down Expand Up @@ -35,7 +35,7 @@
}

async function loginWithDemo() {
location.pathname = '/home';
await goto('/home');
}

function createAccount(): void {
Expand Down Expand Up @@ -66,10 +66,6 @@
const { waitNostr } = await import('nip07-awaiter');
waitNostr(10000).then((n) => (nostr = n));
}

if ($authorProfile) {
gotoHome();
}
});

async function gotoHome() {
Expand All @@ -81,7 +77,7 @@

const url = '/home';
console.log(`Redirect to ${url}`);
location.pathname = url;
await goto(url);
}

afterNavigate(async () => {
Expand All @@ -99,7 +95,7 @@

<div class="login-wrapper">
<div class="login">
<img src="/nostter-logo.svg" alt="nostter-logo" />
<img src="/nostter-logo.svg" alt="nostter" />
<div class="messages-and-actions">
<p class="hero-message">
{$_('login.hero-message')}
Expand Down Expand Up @@ -227,22 +223,6 @@
</footer>

<style>
:global(header) {
display: none;
}

:global(.app) {
max-width: 100% !important;
margin: 0 !important;
padding: 0 !important;
display: block !important;
}

:global(main) {
margin: 0 !important;
max-width: 100% !important;
}

h2 {
font-size: 2rem;
}
Expand Down
4 changes: 2 additions & 2 deletions web/src/routes/(app)/editor/EmojiPickerSlide.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import { customEmojiTags } from '../../../stores/CustomEmojis';
import IconMoodSmile from '@tabler/icons-svelte/dist/svelte/icons/IconMoodSmile.svelte';

let emojiPicker: HTMLElement | undefined;
let emojiPicker: HTMLElement | null = null;
let hidden = true;

const dispatch = createEventDispatcher();
Expand All @@ -19,7 +19,7 @@
}

function updatePicker() {
if (emojiPicker === undefined) {
if (emojiPicker === null) {
return;
}

Expand Down
9 changes: 7 additions & 2 deletions web/src/routes/+layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ import { defaultRelays } from '$lib/Constants';

export const load = async () => {
console.log('[layout load]');
let authenticated = false;
if (browser) {
locale.set(window.navigator.language);
const success = await tryLogin();
if (!success) {
authenticated = await tryLogin();
if (!authenticated) {
await rxNostr.switchRelays(defaultRelays);
}
}
await waitLocale();
return {
splash: !browser || authenticated,
authenticated
};
};

async function tryLogin(): Promise<boolean> {
Expand Down
15 changes: 14 additions & 1 deletion web/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
<script lang="ts">
import { goto } from '$app/navigation';
import type { LayoutData } from './$types';
import SplashScreen from './SplashScreen.svelte';
import Login from './(app)/Login.svelte';
import '../app.css';

export let data: LayoutData;

$: if (data.authenticated) {
goto('/home');
}
</script>

<svelte:head>
<title>nostter</title>
</svelte:head>

<Login />
{#if data.splash}
<SplashScreen />
{:else}
<Login />
{/if}
21 changes: 21 additions & 0 deletions web/src/routes/SplashScreen.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<main>
<img src="/nostter-logo.svg" alt="nostter" />
</main>

<style>
:global(html, body) {
width: 100vw;
height: 100vh;
}

main {
height: 100vh;
display: flex;
justify-content: center;
}

img {
width: 90vw;
max-width: 360px;
}
</style>
4 changes: 2 additions & 2 deletions web/tests/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect, test } from '@playwright/test';

test('index page has expected h1', async ({ page }) => {
test('index page has expected logo', async ({ page }) => {
await page.goto('/');
await expect(page.getByRole('heading', { name: 'nostter' })).toBeVisible();
await expect(page.getByRole('img', { name: 'nostter' })).toBeVisible();
});