Skip to content

Commit

Permalink
Merge pull request #96 from flowerpowerdao/feature/open-login-modal
Browse files Browse the repository at this point in the history
✨ added login modal popup when user trying to vote and not logged in
  • Loading branch information
letmejustputthishere authored May 5, 2022
2 parents 7a5daa9 + 3a5d082 commit a919ece
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
16 changes: 12 additions & 4 deletions src/frontend/components/CastVote.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import CastVoteModal from "./CastVoteModal.svelte";
import Card from "./Card.svelte";
import LoginModal from "./LoginModal.svelte";
let openModal = false;
let openLogin = false;
let confetti = false;
let selected;
Expand All @@ -22,6 +24,11 @@
function toggleModal() {
openModal = !openModal;
}
function toggleLogin() {
openLogin = !openLogin;
}
function handleEscape({ key }) {
if (key === "Escape") {
openModal = false;
Expand Down Expand Up @@ -74,10 +81,8 @@
<div class="flex justify-center flex-col items-center mt-12">
<button
class="max-w-md disabled:cursor-not-allowed bg-white dark:bg-black border-2 border-black dark:border-white dark:text-white rounded-3xl h-12 w-full font-mono"
disabled={selected === undefined ||
alreadyVoted ||
$store.votingPower < 1}
on:click={toggleModal}
disabled={selected === undefined || alreadyVoted}
on:click={$store.isAuthed ? toggleModal : toggleLogin}
>
submit vote →
</button>
Expand All @@ -96,4 +101,7 @@
bind:confetti
/>
{/if}
{#if openLogin}
<LoginModal toggleModal={toggleLogin} />
{/if}
{/if}
4 changes: 2 additions & 2 deletions src/frontend/components/CastVoteModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
<div class="flex gap-3 flex-col flex-1 justify-center items-center">
<Button
on:click={castVote}
disabled={loading}
style={"lg:h-16 2xl:h-20 lg:rounded-[55px]"}
disabled={loading || $store.votingPower < 1}
style={"lg:h-16 2xl:h-20 lg:rounded-[55px] disabled:cursor-not-allowed"}
>
{#if loading}
<img class="h-6" src={spinner} alt="loading animation" />
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/components/LoginModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<Modal title={"login with …"} {toggleModal}>
<div class="flex gap-3 flex-col flex-1 justify-center items-center">
<PlugButton bind:loading />
<StoicButton bind:loading />
<PlugButton bind:loading {toggleModal}/>
<StoicButton bind:loading {toggleModal}/>
</div>
</Modal>
2 changes: 2 additions & 0 deletions src/frontend/components/PlugButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import Button from "./Button.svelte";
export let loading;
export let toggleModal;
onMount(async () => {
const connected = await window.ic?.plug?.isConnected();
Expand All @@ -19,6 +20,7 @@
loading = "plug";
await store.plugConnect();
loading = "";
toggleModal();
}
</script>

Expand Down
2 changes: 2 additions & 0 deletions src/frontend/components/StoicButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import spinner from "../assets/loading.gif";
export let loading;
export let toggleModal;
onMount(async () => {
StoicIdentity.load().then(async (identity) => {
Expand All @@ -21,6 +22,7 @@
loading = "stoic";
await store.stoicConnect();
loading = "";
toggleModal();
}
</script>

Expand Down

0 comments on commit a919ece

Please sign in to comment.