Browse Source

change to three prompts for an onboarding-method choice (first one doesn't work yet)

master
Trent Larson 6 days ago
parent
commit
51c8d8ac8b
  1. 2
      README.md
  2. 152
      src/components/ChoiceButtonDialog.vue
  3. 36
      src/views/HomeView.vue

2
README.md

@ -10,7 +10,7 @@ See [project.task.yaml](project.task.yaml) for current priorities.
## Setup
We like pkgx: `sh <(curl https://pkgx.sh) +npm sh`
We like pkgx: `sh <(curl https://pkgx.sh) +vite sh`
```
npm install

152
src/components/ChoiceButtonDialog.vue

@ -0,0 +1,152 @@
<template>
<NotificationGroup group="customModal">
<div class="fixed z-[100] top-0 inset-x-0 w-full">
<Notification
v-slot="{ notifications, close }"
enter="transform ease-out duration-300 transition"
enter-from="translate-y-2 opacity-0 sm:translate-y-4"
enter-to="translate-y-0 opacity-100 sm:translate-y-0"
leave="transition ease-in duration-500"
leave-from="opacity-100"
leave-to="opacity-0"
move="transition duration-500"
move-delay="delay-300"
>
<div
v-for="notification in notifications"
:key="notification.id"
class="w-full"
role="alert"
>
<div
class="absolute inset-0 h-screen flex flex-col items-center justify-center bg-slate-900/50"
>
<div
class="flex w-11/12 max-w-sm mx-auto mb-3 overflow-hidden bg-white rounded-lg shadow-lg"
>
<div class="w-full px-6 py-6 text-slate-900 text-center">
<span class="font-semibold text-lg">{{ title }}</span>
<p class="text-sm mb-2">{{ text }}</p>
<button
@click="handleOption1(close)"
class="block w-full text-center text-md font-bold capitalize bg-blue-800 text-white px-2 py-2 rounded-md mb-2"
>
{{ option1Text }}
</button>
<button
@click="handleOption2(close)"
class="block w-full text-center text-md font-bold capitalize bg-blue-700 text-white px-2 py-2 rounded-md mb-2"
>
{{ option2Text }}
</button>
<button
@click="handleOption3(close)"
class="block w-full text-center text-md font-bold capitalize bg-blue-600 text-white px-2 py-2 rounded-md mb-2"
>
{{ option3Text }}
</button>
<button
@click="handleCancel(close)"
class="block w-full text-center text-md font-bold capitalize bg-slate-600 text-white px-2 py-2 rounded-md"
>
Cancel
</button>
</div>
</div>
</div>
</div>
</Notification>
</div>
</NotificationGroup>
</template>
<script lang="ts">
import { Component, Vue } from "vue-facing-decorator";
import { NotificationIface } from "@/constants/app";
@Component
export default class PromptDialog extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void;
title = "";
text = "";
option1Text = "";
option2Text = "";
option3Text = "";
onOption1?: () => void;
onOption2?: () => void;
onOption3?: () => void;
onCancel?: () => Promise<void>;
open(options: {
title: string;
text: string;
option1Text?: string;
option2Text?: string;
option3Text?: string;
onOption1?: () => void;
onOption2?: () => void;
onOption3?: () => void;
onCancel?: () => Promise<void>;
}) {
this.title = options.title;
this.text = options.text;
this.option1Text = options.option1Text || "";
this.option2Text = options.option2Text || "";
this.option3Text = options.option3Text || "";
this.onOption1 = options.onOption1;
this.onOption2 = options.onOption2;
this.onOption3 = options.onOption3;
this.onCancel = options.onCancel;
this.$notify(
{
group: "customModal",
type: "confirm",
title: this.title,
text: this.text,
option1Text: this.option1Text,
option2Text: this.option2Text,
option3Text: this.option3Text,
onOption1: this.onOption1,
onOption2: this.onOption2,
onOption3: this.onOption3,
onCancel: this.onCancel,
} as NotificationIface,
-1
);
}
handleOption1(close: (id: string) => void) {
if (this.onOption1) {
this.onOption1();
}
close("string that does not matter");
}
handleOption2(close: (id: string) => void) {
if (this.onOption2) {
this.onOption2();
}
close("string that does not matter");
}
handleOption3(close: (id: string) => void) {
if (this.onOption3) {
this.onOption3();
}
close("string that does not matter");
}
handleCancel(close: (id: string) => void) {
if (this.onCancel) {
this.onCancel();
}
close("string that does not matter");
}
}
</script>

36
src/views/HomeView.vue

@ -366,6 +366,8 @@
</div>
</div>
</section>
<ChoiceButtonDialog ref="choiceButtonDialog" />
</template>
<script lang="ts">
@ -383,6 +385,7 @@ import OnboardingDialog from "@/components/OnboardingDialog.vue";
import QuickNav from "@/components/QuickNav.vue";
import TopMessage from "@/components/TopMessage.vue";
import UserNameDialog from "@/components/UserNameDialog.vue";
import ChoiceButtonDialog from "@/components/ChoiceButtonDialog.vue";
import {
AppString,
NotificationIface,
@ -448,6 +451,7 @@ interface GiveRecordWithContactInfo extends GiveSummaryRecord {
GiftedPrompts,
InfiniteScroll,
OnboardingDialog,
ChoiceButtonDialog,
QuickNav,
TopMessage,
UserNameDialog,
@ -949,24 +953,22 @@ export default class HomeView extends Vue {
}
promptForShareMethod() {
this.$notify(
{
group: "modal",
type: "confirm",
title: "Are you nearby with cameras?",
text: "If so, we'll use those with QR codes to share.",
onCancel: async () => {},
onNo: async () => {
(this.$router as Router).push({ name: "share-my-contact-info" });
},
onYes: async () => {
(this.$router as Router).push({ name: "contact-qr" });
},
noText: "we will share another way",
yesText: "we are nearby with cameras",
(this.$refs.choiceButtonDialog as ChoiceButtonDialog).open({
title: "How can you share your info?",
text: "",
option1Text: "We are in a meeting together",
option2Text: "We are nearby with cameras",
option3Text: "We will share some other way",
onOption1: () => {
(this.$router as Router).push({ name: "onboarding-meeting" });
},
-1,
);
onOption2: () => {
(this.$router as Router).push({ name: "contact-qr" });
},
onOption3: () => {
(this.$router as Router).push({ name: "share-my-contact-info" });
},
});
}
}
</script>

Loading…
Cancel
Save