forked from ekzhang/sshx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a dialog for users to choose their name
- Loading branch information
Showing
7 changed files
with
163 additions
and
87 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { persisted } from "svelte-persisted-store"; | ||
|
||
export type SettingsStore = { | ||
name: string; | ||
}; | ||
|
||
/** A persisted store for settings of the current user. */ | ||
export const settings = persisted<SettingsStore>("sshx-settings-store", { | ||
name: "", | ||
}); |
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,33 @@ | ||
<script lang="ts"> | ||
import { browser } from "$app/environment"; | ||
import OverlayMenu from "./OverlayMenu.svelte"; | ||
import { settings } from "$lib/settings"; | ||
let value = ""; | ||
function handleSubmit() { | ||
settings.set({ ...settings, name: value }); | ||
} | ||
</script> | ||
|
||
<OverlayMenu | ||
title="Welcome!" | ||
description="Before you join — what should we call you?" | ||
maxWidth={640} | ||
open={browser && !$settings.name} | ||
> | ||
<form class="flex gap-2" on:submit|preventDefault={handleSubmit}> | ||
<input | ||
class="flex-1 w-full px-3 py-2 rounded outline-none text-gray-300 bg-zinc-800" | ||
placeholder="Your name" | ||
required | ||
minlength="2" | ||
bind:value | ||
/> | ||
<button | ||
class="flex-shrink-0 px-3 py-2 bg-pink-700 hover:bg-pink-600 active:ring-4 active:ring-pink-500/50 rounded font-medium" | ||
>Join</button | ||
> | ||
</form> | ||
</OverlayMenu> |
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,63 @@ | ||
<script lang="ts"> | ||
import { | ||
Dialog, | ||
DialogDescription, | ||
DialogOverlay, | ||
DialogTitle, | ||
Transition, | ||
TransitionChild, | ||
} from "@rgossiaux/svelte-headlessui"; | ||
import { XIcon } from "svelte-feather-icons"; | ||
import { createEventDispatcher } from "svelte"; | ||
const dispatch = createEventDispatcher<{ close: void }>(); | ||
export let title: string; | ||
export let description: string; | ||
export let showCloseButton = false; | ||
export let maxWidth: number = 768; // screen-md | ||
export let open: boolean; | ||
</script> | ||
|
||
<Transition show={open}> | ||
<Dialog on:close class="fixed inset-0 z-50 grid place-items-center"> | ||
<DialogOverlay class="fixed -z-10 inset-0 bg-black/20 backdrop-blur-sm" /> | ||
|
||
<TransitionChild | ||
enter="duration-300 ease-out" | ||
enterFrom="scale-95 opacity-0" | ||
enterTo="scale-100 opacity-100" | ||
leave="duration-75 ease-out" | ||
leaveFrom="scale-200 opacity-100" | ||
leaveTo="scale-95 opacity-0" | ||
class="w-full sm:w-[calc(100%-32px)]" | ||
style="max-width: {maxWidth}px" | ||
> | ||
<div | ||
class="relative bg-[#111] sm:border border-zinc-800 px-6 py-10 sm:py-6 | ||
h-screen sm:h-auto max-h-screen sm:rounded-lg overflow-y-auto" | ||
> | ||
{#if showCloseButton} | ||
<button | ||
class="absolute top-4 right-4 p-1 rounded hover:bg-zinc-700 active:bg-indigo-700 transition-colors" | ||
aria-label="Close settings" | ||
on:click={() => dispatch("close")} | ||
> | ||
<XIcon class="h-5 w-5" /> | ||
</button> | ||
{/if} | ||
|
||
<div class="mb-8 text-center"> | ||
<DialogTitle class="text-xl font-medium mb-2"> | ||
{title} | ||
</DialogTitle> | ||
<DialogDescription class="text-zinc-400"> | ||
{description} | ||
</DialogDescription> | ||
</div> | ||
|
||
<slot /> | ||
</div> | ||
</TransitionChild> | ||
</Dialog> | ||
</Transition> |
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