mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 02:47:06 +00:00
Fix modal history
This commit is contained in:
@@ -18,8 +18,8 @@
|
||||
as a user.
|
||||
</p>
|
||||
<div class="card flex-row justify-between">
|
||||
relay.whatever.com
|
||||
<button on:click={() => clip('relay.whatever.com')}>
|
||||
devrelay.highlighter.com
|
||||
<button on:click={() => clip('devrelay.highlighter.com')}>
|
||||
<Icon icon="copy" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
</style>
|
||||
|
||||
<script lang="ts">
|
||||
import {goto} from '$app/navigation'
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import PrimaryNavItem from "@lib/components/PrimaryNavItem.svelte"
|
||||
import SpaceAdd from '@app/components/SpaceAdd.svelte'
|
||||
@@ -14,6 +15,8 @@
|
||||
import {pushModal} from "@app/modal"
|
||||
|
||||
export const addSpace = () => pushModal(SpaceAdd)
|
||||
|
||||
export const browseSpaces = () => goto("/browse")
|
||||
</script>
|
||||
|
||||
<div class="relative w-14 bg-base-100">
|
||||
@@ -41,7 +44,7 @@
|
||||
<Icon size={7} icon="add-circle" />
|
||||
</div>
|
||||
</PrimaryNavItem>
|
||||
<PrimaryNavItem title="Browse Spaces">
|
||||
<PrimaryNavItem title="Browse Spaces" on:click={browseSpaces}>
|
||||
<div class="!flex w-10 items-center justify-center">
|
||||
<Icon size={6} icon="compass-big" />
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
<script lang="ts">
|
||||
import CardButton from '@lib/components/CardButton.svelte'
|
||||
import SpaceCreate from '@app/components/SpaceCreate.svelte'
|
||||
import SpaceJoin from '@app/components/SpaceJoin.svelte'
|
||||
import {pushModal} from '@app/modal'
|
||||
|
||||
const startCreate = () => pushModal(SpaceCreate)
|
||||
|
||||
const startJoin = () => pushModal(SpaceJoin)
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
@@ -14,7 +17,7 @@
|
||||
</CardButton>
|
||||
<div class="card column gap-4">
|
||||
<h2 class="subheading">Have an invite?</h2>
|
||||
<button class="btn btn-primary">
|
||||
<button class="btn btn-primary" on:click={startJoin}>
|
||||
Join a Space
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
import Field from '@lib/components/Field.svelte'
|
||||
import Icon from '@lib/components/Icon.svelte'
|
||||
import InfoNip29 from '@app/components/InfoNip29.svelte'
|
||||
import SpaceCreateFinish from '@app/components/SpaceCreateFinish.svelte'
|
||||
import {pushModal} from '@app/modal'
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const next = () => pushModal()
|
||||
const next = () => pushModal(SpaceCreateFinish)
|
||||
|
||||
const showNip29Info = () => pushModal(InfoNip29)
|
||||
|
||||
|
||||
1
src/app/components/SpaceCreateFinish.svelte
Normal file
1
src/app/components/SpaceCreateFinish.svelte
Normal file
@@ -0,0 +1 @@
|
||||
hi
|
||||
45
src/app/components/SpaceJoin.svelte
Normal file
45
src/app/components/SpaceJoin.svelte
Normal file
@@ -0,0 +1,45 @@
|
||||
<script lang="ts">
|
||||
import {goto} from '$app/navigation'
|
||||
import CardButton from '@lib/components/CardButton.svelte'
|
||||
import Field from '@lib/components/Field.svelte'
|
||||
import Icon from '@lib/components/Icon.svelte'
|
||||
import SpaceCreateFinish from '@app/components/SpaceCreateFinish.svelte'
|
||||
import {pushModal} from '@app/modal'
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const browse = () => goto("/browse", {state: {}})
|
||||
|
||||
const join = () => {}
|
||||
|
||||
let link = ""
|
||||
|
||||
$: linkIsValid = Boolean(link.match(/.+\..+'.+/))
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<h1 class="heading">Join a Space</h1>
|
||||
<p class="text-center">
|
||||
Enter an invite link below to join an existing space.
|
||||
</p>
|
||||
<Field>
|
||||
<p slot="label">Invite Link*</p>
|
||||
<label class="input input-bordered w-full flex items-center gap-2" slot="input">
|
||||
<Icon icon="link-round" />
|
||||
<input bind:value={link} class="grow" type="text" />
|
||||
</label>
|
||||
</Field>
|
||||
<CardButton icon="compass" title="Don't have an invite?" on:click={browse}>
|
||||
Browse other spaces on the discover page.
|
||||
</CardButton>
|
||||
<div class="flex flex-row justify-between items-center gap-4">
|
||||
<button class="btn btn-link" on:click={back}>
|
||||
<Icon icon="alt-arrow-left" />
|
||||
Go back
|
||||
</button>
|
||||
<button class="btn btn-primary" on:click={join} disabled={!linkIsValid}>
|
||||
Join Space
|
||||
<Icon icon="alt-arrow-right" class="!bg-base-300" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
import type {ComponentType} from "svelte"
|
||||
import {randomId} from "@welshman/lib"
|
||||
import {pushState} from "$app/navigation"
|
||||
import {goto} from "$app/navigation"
|
||||
|
||||
export const modals = new Map()
|
||||
|
||||
@@ -9,12 +9,9 @@ export const pushModal = (component: ComponentType, props: Record<string, any> =
|
||||
|
||||
// TODO: fix memory leak here by listening to history somehow
|
||||
modals.set(id, {component, props})
|
||||
pushState("", {modal: id})
|
||||
goto("#" + id)
|
||||
|
||||
return id
|
||||
}
|
||||
|
||||
export const popModal = (id: string) => {
|
||||
modals.delete(id)
|
||||
history.back()
|
||||
}
|
||||
export const clearModal = () => goto('#')
|
||||
|
||||
3
src/assets/icons/Link Round.svg
Normal file
3
src/assets/icons/Link Round.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M10 15H12C15.3137 15 18 12.3137 18 9C18 5.68629 15.3137 3 12 3H8C4.68629 3 2 5.68629 2 9C2 10.5367 2.57771 11.9385 3.52779 13M14 9H12C8.68629 9 6 11.6863 6 15C6 18.3137 8.68629 21 12 21H16C19.3137 21 22 18.3137 22 15C22 13.4633 21.4223 12.0615 20.4722 11" stroke="#1C274C" stroke-width="1.5" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 429 B |
@@ -22,6 +22,7 @@
|
||||
import HandPills from "@assets/icons/Hand Pills.svg?dataurl"
|
||||
import HomeSmile from "@assets/icons/Home Smile.svg?dataurl"
|
||||
import InfoCircle from "@assets/icons/Info Circle.svg?dataurl"
|
||||
import LinkRound from "@assets/icons/Link Round.svg?dataurl"
|
||||
import Plain from "@assets/icons/Plain.svg?dataurl"
|
||||
import RemoteControllerMinimalistic from "@assets/icons/Remote Controller Minimalistic.svg?dataurl"
|
||||
import Settings from "@assets/icons/Settings.svg?dataurl"
|
||||
@@ -49,6 +50,7 @@
|
||||
"hand-pills": HandPills,
|
||||
"home-smile": HomeSmile,
|
||||
"info-circle": InfoCircle,
|
||||
"link-round": LinkRound,
|
||||
plain: Plain,
|
||||
'remote-controller-minimalistic': RemoteControllerMinimalistic,
|
||||
settings: Settings,
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<script lang="ts">
|
||||
import "@src/app.css"
|
||||
import {onMount} from 'svelte'
|
||||
import {page} from "$app/stores"
|
||||
import {fly} from "@lib/transition"
|
||||
import ModalBox from "@lib/components/ModalBox.svelte"
|
||||
import Toast from "@app/components/Toast.svelte"
|
||||
import PrimaryNav from "@app/components/PrimaryNav.svelte"
|
||||
import SecondaryNav from "@app/components/SecondaryNav.svelte"
|
||||
import {modals} from "@app/modal"
|
||||
import {modals, clearModal} from "@app/modal"
|
||||
|
||||
const login = async () => {
|
||||
const nl = await import("nostr-login")
|
||||
@@ -24,15 +25,25 @@
|
||||
nl.launch()
|
||||
}
|
||||
|
||||
let modal: HTMLDialogElement
|
||||
let dialog: HTMLDialogElement
|
||||
|
||||
$: modal = $page.url.hash.slice(1)
|
||||
|
||||
$: {
|
||||
if ($page.state.modal) {
|
||||
modal?.showModal()
|
||||
if (modal) {
|
||||
dialog?.showModal()
|
||||
} else {
|
||||
modal?.close()
|
||||
dialog?.close()
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
dialog.addEventListener('close', () => {
|
||||
if (modal) {
|
||||
clearModal()
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<div data-theme="dark">
|
||||
@@ -43,10 +54,10 @@
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
<dialog bind:this={modal} class="modal modal-bottom sm:modal-middle !z-modal">
|
||||
{#if $page.state.modal}
|
||||
{#key $page.state.modal}
|
||||
<ModalBox {...modals.get($page.state.modal)} />
|
||||
<dialog bind:this={dialog} class="modal modal-bottom sm:modal-middle !z-modal">
|
||||
{#if modal}
|
||||
{#key modal}
|
||||
<ModalBox {...modals.get(modal)} />
|
||||
{/key}
|
||||
<Toast />
|
||||
{/if}
|
||||
|
||||
0
src/routes/browse/+page.svelte
Normal file
0
src/routes/browse/+page.svelte
Normal file
Reference in New Issue
Block a user