This repository has been archived by the owner on Aug 1, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): navigate-to-project modal (#738)
*** * navigation modal * preliminary untracked page * update to new typography system <3 * fixup * touchup * ModalOverlay component * autofocus but still escapable * proper sidebar link styling * move local var under props * Update ui/DesignSystem/Component/SearchModal.svelte Co-authored-by: Rūdolfs Ošiņš <rudolfs@osins.org> * fix stray event.code * styling polish * urn in tracking info reflects value entered * fix circular dependency * emoji component * Update ui/src/modal.ts Co-authored-by: Alexander Simmerl <a.simmerl@gmail.com> * Apply suggestions from code review Co-authored-by: Alexander Simmerl <a.simmerl@gmail.com> * fix prettier Co-authored-by: Rūdolfs Ošiņš <rudolfs@osins.org> Co-authored-by: Alexander Simmerl <a.simmerl@gmail.com>
- Loading branch information
1 parent
72a7822
commit a3403e2
Showing
16 changed files
with
399 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<script> | ||
import * as modal from "../../src/modal"; | ||
export let store = null; | ||
let content; | ||
const clickOutside = ev => { | ||
if (content && ev.target !== content && !content.contains(ev.target)) | ||
modal.hide(); | ||
}; | ||
</script> | ||
|
||
<style> | ||
.modal { | ||
height: 100vh; | ||
width: 100vw; | ||
position: fixed; | ||
z-index: 100; | ||
} | ||
.overlay { | ||
background-color: black; | ||
opacity: 0.7; | ||
height: 100%; | ||
width: 100%; | ||
position: fixed; | ||
} | ||
.content { | ||
position: relative; | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
z-index: 200; | ||
} | ||
.hide { | ||
display: none; | ||
} | ||
</style> | ||
|
||
<svelte:window on:click={clickOutside} /> | ||
|
||
<div class="modal" class:hide={!$store.show}> | ||
<div class="overlay" on:click={clickOutside} /> | ||
<div class="content"> | ||
<svelte:component | ||
this={$store.component} | ||
bind:content | ||
on:hide={modal.hide} /> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
<script> | ||
import { push } from "svelte-spa-router"; | ||
import { createEventDispatcher } from "svelte"; | ||
import { Icon, Input } from "../Primitive"; | ||
import TrackToggle from "./TrackToggle.svelte"; | ||
import Urn from "./Urn.svelte"; | ||
import * as path from "../../src/path"; | ||
import { Status } from "../../src/remote"; | ||
import { updateUrn, validation } from "../../src/search"; | ||
import { ValidationStatus } from "../../src/validation"; | ||
export let content; | ||
let searchBar, value, hasExpanded, showTrackingInfo; | ||
const dispatch = createEventDispatcher(); | ||
const navigateToProject = () => { | ||
if ($validation.status !== ValidationStatus.Success) return; | ||
dispatch("hide"); | ||
push(path.projectUntracked(value)); | ||
}; | ||
const onKeydown = ev => { | ||
switch (ev.code) { | ||
case "Enter": | ||
navigateToProject(); | ||
break; | ||
case "Escape": | ||
dispatch("hide"); | ||
} | ||
}; | ||
$: if (value && value.length > 0) { | ||
updateUrn({ urn: value }); | ||
} | ||
// TODO(sos): animate & show/hide based on actual remote response | ||
$: { | ||
showTrackingInfo = hasExpanded | ||
? true | ||
: value && value.length > 0 && $validation.status === Status.Success; | ||
if (showTrackingInfo && !hasExpanded) hasExpanded = true; | ||
} | ||
</script> | ||
|
||
<style> | ||
.container { | ||
width: 26.25rem; | ||
} | ||
.search-bar { | ||
margin-bottom: 1rem; | ||
} | ||
.tracking-info { | ||
background: var(--color-background); | ||
cursor: pointer; | ||
border-radius: 0.5rem; | ||
height: 0; | ||
overflow: hidden; | ||
transition: height 0.5s linear; | ||
} | ||
.showTrackingInfo { | ||
height: 13.5rem; | ||
} | ||
.header { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: flex-start; | ||
margin-bottom: 0.25rem; | ||
} | ||
</style> | ||
|
||
<svelte:window on:keydown={onKeydown} /> | ||
|
||
<div class="container" bind:this={content}> | ||
<div class="search-bar" bind:this={searchBar}> | ||
<!-- TODO(sos): fix autofocus / hotkey conflict --> | ||
<Input.Text | ||
autofocus | ||
bind:value | ||
placeholder="Have a Radicle project ID? Paste it here..." | ||
showLeftItem | ||
style="height: 3rem;" | ||
inputStyle="border: none; border-radius: 0.5rem; height: 3rem;" | ||
validation={$validation}> | ||
<div slot="left" style="display: flex;"> | ||
<Icon.MagnifyingGlass /> | ||
</div> | ||
</Input.Text> | ||
</div> | ||
|
||
<!-- TODO(sos): Once we determine how searching works, make sure this looks right | ||
if user changes urn | ||
--> | ||
<div | ||
class="tracking-info" | ||
class:showTrackingInfo | ||
on:click={navigateToProject}> | ||
<div style="padding: 2rem;"> | ||
<div class="header"> | ||
<h3 style="color: var(--color-foreground-level-6);">my-new-project</h3> | ||
<TrackToggle variant="expanded" /> | ||
</div> | ||
|
||
<div style="display: flex; margin-bottom: 1rem;"> | ||
<Urn | ||
urn={value || ''} | ||
notificationText="The project ID was copied to your clipboard" | ||
showOnHover /> | ||
</div> | ||
|
||
<p style="color: var(--color-foreground-level-6);"> | ||
You’re not tracking this project yet, so there’s nothing to show here. | ||
Track it and you’ll be notified as soon as it’s available. | ||
</p> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.