From 3d018dae1830f4ac0bd8473b4c58455833c1064c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C5=ABdolfs=20O=C5=A1i=C5=86=C5=A1?= Date: Fri, 23 Dec 2022 14:47:54 +0100 Subject: [PATCH] Refactor modals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rūdolfs Ošiņš --- public/elevations.css | 8 +- public/index.css | 2 - public/typography.css | 8 +- src/App.svelte | 54 ++--- src/App/ColorPalette.svelte | 112 ++++------- src/App/Header.svelte | 29 +-- src/App/Header/Search.svelte | 142 ++------------ ...sults.svelte => SearchResultsModal.svelte} | 36 +--- src/App/HelpModal.svelte | 79 ++++++++ src/App/Hotkeys.svelte | 35 ++++ src/App/ModalPortal.svelte | 41 ++++ src/components/Button.svelte | 3 + src/components/Connect.svelte | 53 +++-- src/components/Connect/ConnectWallet.svelte | 93 --------- .../Connect/ConnectWalletModal.svelte | 72 +++++++ src/components/Emoji.svelte | 16 ++ src/components/Error.svelte | 35 ++++ src/components/ErrorModal.svelte | 112 +++++++---- src/components/Markdown.svelte | 2 +- src/components/Message.svelte | 2 +- src/components/Modal.svelte | 147 +++++++------- src/components/NotFound.svelte | 46 +++-- src/components/TextInput.svelte | 14 +- src/components/Toggle.svelte | 4 +- src/lib/modal.ts | 76 +++++++ src/lib/router.ts | 45 +---- src/lib/router/definitions.ts | 19 +- src/lib/search.ts | 124 ++++++++++++ src/lib/utils.ts | 13 -- src/lib/vesting.ts | 20 +- src/lib/wallet.ts | 2 +- .../faucet/{Form.svelte => Faucet.svelte} | 8 +- src/views/faucet/Routes.svelte | 16 -- src/views/faucet/Withdraw.svelte | 100 ---------- src/views/faucet/WithdrawModal.svelte | 85 ++++++++ src/views/profiles/Profile.svelte | 95 +++++---- src/views/profiles/SetName.svelte | 185 ------------------ src/views/profiles/SetNameModal.svelte | 145 ++++++++++++++ .../profiles/SetNameModal/SuccessModal.svelte | 17 ++ src/views/projects/Blob.svelte | 2 +- src/views/projects/ProjectMeta.svelte | 2 +- src/views/projects/View.svelte | 25 ++- src/views/registrations/CheckNameModal.svelte | 126 ++++++++++++ src/views/registrations/New.svelte | 133 ------------- .../registrations/RegisterNameModal.svelte | 142 ++++++++++++++ .../{ => RegisterNameModal}/BlockTimer.svelte | 0 .../{Index.svelte => RegistrationForm.svelte} | 16 +- src/views/registrations/Routes.svelte | 36 +--- src/views/registrations/Submit.svelte | 129 ------------ src/views/registrations/Update.svelte | 90 ++++----- src/views/registrations/View.svelte | 172 ++++++++-------- src/views/seeds/View.svelte | 8 +- src/views/vesting/Routes.svelte | 4 + src/views/vesting/Withdraw.svelte | 72 ------- src/views/vesting/WithdrawModal.svelte | 55 ++++++ tests/e2e/hotkeys.spec.ts | 36 ++++ tests/e2e/modal.spec.ts | 18 ++ tests/unit/router.test.ts | 73 +------ 58 files changed, 1684 insertions(+), 1550 deletions(-) rename src/App/Header/{SearchResults.svelte => SearchResultsModal.svelte} (64%) create mode 100644 src/App/HelpModal.svelte create mode 100644 src/App/Hotkeys.svelte create mode 100644 src/App/ModalPortal.svelte delete mode 100644 src/components/Connect/ConnectWallet.svelte create mode 100644 src/components/Connect/ConnectWalletModal.svelte create mode 100644 src/components/Emoji.svelte create mode 100644 src/components/Error.svelte create mode 100644 src/lib/modal.ts create mode 100644 src/lib/search.ts rename src/views/faucet/{Form.svelte => Faucet.svelte} (95%) delete mode 100644 src/views/faucet/Routes.svelte delete mode 100644 src/views/faucet/Withdraw.svelte create mode 100644 src/views/faucet/WithdrawModal.svelte delete mode 100644 src/views/profiles/SetName.svelte create mode 100644 src/views/profiles/SetNameModal.svelte create mode 100644 src/views/profiles/SetNameModal/SuccessModal.svelte create mode 100644 src/views/registrations/CheckNameModal.svelte delete mode 100644 src/views/registrations/New.svelte create mode 100644 src/views/registrations/RegisterNameModal.svelte rename src/views/registrations/{ => RegisterNameModal}/BlockTimer.svelte (100%) rename src/views/registrations/{Index.svelte => RegistrationForm.svelte} (90%) delete mode 100644 src/views/registrations/Submit.svelte delete mode 100644 src/views/vesting/Withdraw.svelte create mode 100644 src/views/vesting/WithdrawModal.svelte create mode 100644 tests/e2e/hotkeys.spec.ts create mode 100644 tests/e2e/modal.spec.ts diff --git a/public/elevations.css b/public/elevations.css index e7a3ab5f4..20e595bb2 100644 --- a/public/elevations.css +++ b/public/elevations.css @@ -1,11 +1,11 @@ :root { --elevation-low: 0px 16px 32px 32px #00000070; - --elevation-high: 0px 8px 64px var(--color-secondary-5); - --elevation-high-negative: 0px 8px 64px var(--color-negative-5); + --elevation-high: 0px 0px 1px var(--color-secondary), + 0px 8px 64px var(--color-secondary-5); } [data-theme="light"] { --elevation-low: 0px 16px 32px 16px #00000020; - --elevation-high: 0px 8px 64px var(--color-secondary-5); - --elevation-high-negative: 0px 8px 64px var(--color-negative-5); + --elevation-high: 0px 0px 1px var(--color-secondary), + 0px 8px 64px var(--color-secondary-3); } diff --git a/public/index.css b/public/index.css index 4227b2e07..0fd76dd35 100644 --- a/public/index.css +++ b/public/index.css @@ -17,8 +17,6 @@ --button-small-height: 2rem; --button-tiny-height: 1.5rem; - --glow: var(--color-secondary-3); - --glow-error: var(--color-negative-3); --header-gradient: linear-gradient( 180deg, var(--color-secondary-3) 0%, diff --git a/public/typography.css b/public/typography.css index 6b3ad54c7..06390ae71 100644 --- a/public/typography.css +++ b/public/typography.css @@ -77,7 +77,8 @@ --font-size-regular: 1rem; --font-size-medium: 1.25rem; --font-size-large: 1.75rem; - --font-size-huge: 2rem; + --font-size-x-large: 2rem; + --font-size-xx-large: 3rem; } [data-codefont="system"] { @@ -124,7 +125,10 @@ p { font-size: var(--font-size-large); } .txt-huge { - font-size: var(--font-size-huge); + font-size: var(--font-size-x-large); +} +.txt-humongous { + font-size: var(--font-size-xx-large); } .txt-monospace { diff --git a/src/App.svelte b/src/App.svelte index 0bdaf9b5e..ad819753c 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -4,16 +4,17 @@ import { Connection, state, session } from "@app/lib/session"; import { getWallet } from "@app/lib/wallet"; import { initialize, activeRouteStore } from "@app/lib/router"; - import { twemoji, unreachable } from "@app/lib/utils"; + import { unreachable } from "@app/lib/utils"; - import ColorPalette from "./App/ColorPalette.svelte"; import Header from "./App/Header.svelte"; + import ModalPortal from "./App/ModalPortal.svelte"; + import Hotkeys from "./App/Hotkeys.svelte"; import Loading from "@app/components/Loading.svelte"; - import Modal from "@app/components/Modal.svelte"; import NotFound from "@app/components/NotFound.svelte"; + import Error from "@app/components/Error.svelte"; - import Faucet from "@app/views/faucet/Routes.svelte"; + import Faucet from "@app/views/faucet/Faucet.svelte"; import Home from "@app/views/home/Index.svelte"; import Profile from "@app/views/profiles/Profile.svelte"; import Projects from "@app/views/projects/View.svelte"; @@ -46,16 +47,6 @@ } return wallet; }); - - function handleKeydown(event: KeyboardEvent) { - if (event.key === "Enter") { - const elems = document.querySelectorAll("button.primary"); - if (elems.length === 1) { - // We only allow this when there's one primary button. - elems[0].click(); - } - } - } - Radicle + + +
{#await loadWallet} -
{:then wallet} -
{#if $activeRouteStore.resource === "home"} {:else if $activeRouteStore.resource === "faucet"} - + {:else if $activeRouteStore.resource === "seeds"} {:else if $activeRouteStore.resource === "registrations"} - + {:else if $activeRouteStore.resource === "vesting"} {:else if $activeRouteStore.resource === "projects"} @@ -113,23 +98,18 @@ addressOrName={$activeRouteStore.params.addressOrName} {wallet} /> {:else if $activeRouteStore.resource === "404"} - +
+ +
{:else} {unreachable($activeRouteStore)} {/if}
{:catch err} -
- - -
👻
-
Error connecting to network
-
- - - {err.message ? err.message : JSON.stringify(err)} - -
+
+
{/await}
diff --git a/src/App/ColorPalette.svelte b/src/App/ColorPalette.svelte index 877e98671..968aeffa9 100644 --- a/src/App/ColorPalette.svelte +++ b/src/App/ColorPalette.svelte @@ -1,4 +1,6 @@ - - -{#if show} + -
(checkers = !checkers)}> -
- {#each colorGroups as colorGroup} -
- {#each colors.filter(color => { - return color.match(`--color-${colorGroup}`); - }) as color} -
-
-
- {/each} -
- {/each} +
+
(checkers = !checkers)}> +
+ {#each colorGroups as colorGroup} +
+ {#each colors.filter(color => { + return color.match(`--color-${colorGroup}`); + }) as color} +
+
+
+ {/each} +
+ {/each} +
-{/if} + diff --git a/src/App/Header.svelte b/src/App/Header.svelte index ff94198d1..f99a47d86 100644 --- a/src/App/Header.svelte +++ b/src/App/Header.svelte @@ -1,6 +1,5 @@ - - dispatch("close")} /> - - - ️🔍 - -

- - Results for {query} - -

-
- + + {#if results.projects.length > 0} -

Projects

+
Projects
    {#each results.projects as project}
  • {/if} {#if results.profiles.length > 0} -

    ENS names

    +
    ENS names
      {#each results.profiles as profile}
    • @@ -81,9 +70,4 @@
    {/if} - - - diff --git a/src/App/HelpModal.svelte b/src/App/HelpModal.svelte new file mode 100644 index 000000000..89faca922 --- /dev/null +++ b/src/App/HelpModal.svelte @@ -0,0 +1,79 @@ + + + + + +
    +
    +
    +
    +
    ?
    +
    Shortcuts
    +
    + +
    +
    /
    +
    Search
    +
    + + {#if import.meta.env.DEV} +
    +
    d
    +
    Color palette
    +
    + {/if} +
    + +
    +
    +
    enter
    +
    Submit
    +
    + +
    +
    esc
    +
    Close
    +
    +
    +
    +
    +
    diff --git a/src/App/Hotkeys.svelte b/src/App/Hotkeys.svelte new file mode 100644 index 000000000..2481cd768 --- /dev/null +++ b/src/App/Hotkeys.svelte @@ -0,0 +1,35 @@ + + + diff --git a/src/App/ModalPortal.svelte b/src/App/ModalPortal.svelte new file mode 100644 index 000000000..f38cadfa7 --- /dev/null +++ b/src/App/ModalPortal.svelte @@ -0,0 +1,41 @@ + + + + +{#if $modalStore} +
    + +
    +
    + +
    +
    +{/if} diff --git a/src/components/Button.svelte b/src/components/Button.svelte index 2652b6c0d..970fa270e 100644 --- a/src/components/Button.svelte +++ b/src/components/Button.svelte @@ -8,6 +8,7 @@ | "text"; export let size: "tiny" | "small" | "regular" = "regular"; + export let autofocus: boolean = false; export let disabled: boolean = false; export let waiting: boolean = false; export let style: string | undefined = undefined; @@ -112,10 +113,12 @@ } + - -
    - -
diff --git a/src/components/Connect/ConnectWalletModal.svelte b/src/components/Connect/ConnectWalletModal.svelte new file mode 100644 index 000000000..35f45c1c3 --- /dev/null +++ b/src/components/Connect/ConnectWalletModal.svelte @@ -0,0 +1,72 @@ + + + + + { + state.connectMetamask(wallet); + }, + props: { + variant: "secondary", + size: "small", + disabled: !wallet.metamask.signer, + }, + }} + closeAction={{ + callback: onClose, + props: { size: "small" }, + }}> +
+
+ Scan the QR code with WalletConnect + or use + Metamask + . +
+
+ +
+
+
+ {@html svgString} +
+
+
+
diff --git a/src/components/Emoji.svelte b/src/components/Emoji.svelte new file mode 100644 index 000000000..c6d4c2f8e --- /dev/null +++ b/src/components/Emoji.svelte @@ -0,0 +1,16 @@ + + +{@html twemoji.parse(emoji, { + base, + folder: "twemoji", + ext: ".svg", + className: "txt-emoji", +})} diff --git a/src/components/Error.svelte b/src/components/Error.svelte new file mode 100644 index 000000000..ddf89f8b6 --- /dev/null +++ b/src/components/Error.svelte @@ -0,0 +1,35 @@ + + + + +
+
{emoji}
+
{title}
+
{message}
+
diff --git a/src/components/ErrorModal.svelte b/src/components/ErrorModal.svelte index 1d6ee3752..c61347b67 100644 --- a/src/components/ErrorModal.svelte +++ b/src/components/ErrorModal.svelte @@ -1,51 +1,83 @@ - - - - {#if emoji} -
{emoji}
- {/if} - {title} -
+ - - - - - -
+{#if error} + +
{caption}
+
+
+ +
+ +
+
+ {error} +
+
+
+
+{:else} + +
{caption}
+
+{/if} diff --git a/src/components/Markdown.svelte b/src/components/Markdown.svelte index 84fc5af4a..77e2e7477 100644 --- a/src/components/Markdown.svelte +++ b/src/components/Markdown.svelte @@ -121,7 +121,7 @@ } .markdown :global(h1) { - font-size: calc(var(--font-size-huge) * 0.75); + font-size: calc(var(--font-size-x-large) * 0.75); font-weight: var(--font-weight-medium); padding: 1rem 0 0.5rem 0; margin: 0 0 0.75rem; diff --git a/src/components/Message.svelte b/src/components/Message.svelte index 9f1b35f22..1a702bfdd 100644 --- a/src/components/Message.svelte +++ b/src/components/Message.svelte @@ -9,7 +9,7 @@ .message-error { color: var(--color-negative); border-radius: var(--border-radius); - background-color: var(--glow-error); + background-color: var(--color-negative-3); } diff --git a/src/components/Modal.svelte b/src/components/Modal.svelte index 9a0528d71..77503100d 100644 --- a/src/components/Modal.svelte +++ b/src/components/Modal.svelte @@ -1,35 +1,47 @@ + + -{#if floating} -
-{/if} - -
-