Files
radicle-explorer/src/App.svelte
T
Sebastian Martinez baa77d4269 Add User View Route
Signed-off-by: Sebastian Martinez <sebastinez@me.com>
2021-06-16 11:16:34 -03:00

85 lines
2.2 KiB
Svelte

<script lang="typescript">
import { Router, Route } from "svelte-routing";
import { getConfig } from '@app/config';
import { state, session } from '@app/session';
import Home from '@app/base/home/Index.svelte';
import Vesting from '@app/base/vesting/Index.svelte';
import Registrations from '@app/base/registrations/Routes.svelte';
import Orgs from '@app/base/orgs/Routes.svelte';
import Users from '@app/base/users/Routes.svelte';
import Projects from '@app/base/projects/Routes.svelte';
import Resolver from '@app/base/resolver/Routes.svelte';
import Header from '@app/Header.svelte';
import Loading from '@app/Loading.svelte';
import Modal from '@app/Modal.svelte';
const loadConfig = getConfig().then(cfg => {
state.refreshBalance(cfg);
return cfg;
});
function handleKeydown(event: KeyboardEvent) {
if (event.key === 'Enter') {
let elems = document.querySelectorAll<HTMLElement>('button.primary');
if (elems.length == 1) { // We only allow this when there's one primary button.
elems[0].click();
}
}
}
</script>
<style>
.app {
height: 100%;
display: flex;
flex-direction: column;
}
.wrapper {
display: flex;
align-items: center;
flex-direction: column;
height: 100%;
}
</style>
<svelte:window on:keydown={handleKeydown} />
<div class="app">
{#await loadConfig}
<!-- Loading wallet -->
<div class="wrapper">
<Loading center />
</div>
{:then config}
<Header session={$session} {config} />
<div class="wrapper">
<Router>
<Route path="/">
<Home />
</Route>
<Route path="vesting">
<Vesting {config} session={$session} />
</Route>
<Registrations {config} session={$session} />
<Orgs {config} />
<Users {config} />
<Projects {config} />
<Resolver {config} />
</Router>
</div>
{:catch err}
<div class="wrapper">
<Modal error subtle>
<span slot="title">
<h3>👻</h3>
<div>Error connecting to network</div>
</span>
<span slot="body">
{err}
</span>
</Modal>
</div>
{/await}
</div>