Skip to content

Commit

Permalink
feat: onboarding (#2)
Browse files Browse the repository at this point in the history
* wip

* onboarding

* better onboarding
  • Loading branch information
lmiller1990 authored Jul 2, 2024
1 parent 6169424 commit fbfcbe5
Show file tree
Hide file tree
Showing 23 changed files with 10,415 additions and 13,693 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# StudyHQ

AI powered revision, exam generator and grader.
AI powered revision, exam generator and grader.

https://studyhq.app

Expand All @@ -12,7 +12,6 @@ https://studyhq.app
- Receive useful feedback
- Retake exams to practice


## Coming soon

- More customizable exams
Expand All @@ -21,7 +20,7 @@ https://studyhq.app

## TODO

- Figure out how to price this!
- Figure out how to price this!
- Allow bring your own API key

# Screenshots
Expand Down
18 changes: 16 additions & 2 deletions components/NewButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ const emits = defineEmits<{
(e: "newThread"): void;
(e: "newExam"): void;
}>();
const { guestMode, setShowSignUpModal } = useAuth();
function maybeEmit(event: "newThread" | "newExam") {
if (guestMode.value) {
setShowSignUpModal(true);
} else {
if (event === "newExam") {
emits("newExam");
} else if (event === "newThread") {
emits("newThread");
}
}
}
</script>

<template>
Expand All @@ -16,15 +30,15 @@ const emits = defineEmits<{
size="xs"
:disabled="disabled"
:loading="disabled"
@click="emits('newThread')"
@click="maybeEmit('newThread')"
>
New Chat</UButton
>
<UButton
size="xs"
:disabled="disabled"
:loading="disabled"
@click="emits('newThread')"
@click="maybeEmit('newThread')"
>New Exam</UButton
>
</div>
Expand Down
20 changes: 18 additions & 2 deletions components/SidebarLinks.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang="ts">
import SignUpModal from "./SignUpModal.vue";
type NavLink = {
label: string;
icon: string;
Expand All @@ -15,6 +17,20 @@ const emits = defineEmits<{
(e: "newThread"): void;
(e: "newExam"): void;
}>();
const { guestMode, setShowSignUpModal } = useAuth();
function maybeEmit(event: "newThread" | "newExam") {
if (guestMode.value) {
setShowSignUpModal(true);
} else {
if (event === "newExam") {
emits("newExam");
} else if (event === "newThread") {
emits("newThread");
}
}
}
</script>

<template>
Expand All @@ -25,7 +41,7 @@ const emits = defineEmits<{
size="xs"
:disabled="disabled"
:loading="disabled"
@click="emits('newThread')"
@click="maybeEmit('newThread')"
>
New Chat</UButton
>
Expand All @@ -49,7 +65,7 @@ const emits = defineEmits<{
size="xs"
:disabled="disabled"
:loading="disabled"
@click="emits('newExam')"
@click="maybeEmit('newExam')"
>New Exam</UButton
>
</div>
Expand Down
25 changes: 25 additions & 0 deletions components/SignUpModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script lang="ts" setup>
defineProps<{
modelValue: boolean;
}>();
const emits = defineEmits<{
(e: "update:modelValue", payload: boolean): void;
}>();
</script>

<template>
<UModal
:modelValue="modelValue"
@update:modelValue="(val) => emits('update:modelValue', val)"
>
<div class="p-8 text-center">
<p class="my-4 mb-10">Please sign up to continue using StudyHQ.</p>
<div class="flex justify-center mt-8 mb-4">
<SignInGoogle class="mr-2" />

<SignInGithub />
</div>
</div>
</UModal>
</template>
16 changes: 16 additions & 0 deletions composables/useAuth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ref } from "vue";

const guestMode = ref(true);
const showSignUpModal = ref(false);

export function useAuth() {
const setGuest = () => (guestMode.value = true);
return {
setShowSignUpModal: (val: boolean) => {
showSignUpModal.value = val;
},
showSignUpModal,
guestMode,
setGuest,
};
}
34 changes: 23 additions & 11 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
import { emitter } from "~/src/emitter";
import { useIntervalFn, useMagicKeys } from "@vueuse/core";
import SidebarLinks from "~/components/SidebarLinks.vue";
import { useAuth } from "~/composables/useAuth";
import SignUpModal from "~/components/SignUpModal.vue";
const { ctrl, n } = useMagicKeys();
const { clear, loggedIn } = useUserSession();
const { guestMode, setShowSignUpModal, showSignUpModal } = useAuth();
if (!loggedIn.value && !guestMode.value) {
await navigateTo("/");
}
const { data: threads, refresh: refreshThreads } =
await useFetch("/api/threads");
Expand All @@ -15,17 +24,11 @@ declare global {
const isOpen = ref(false);
const { clear, loggedIn } = useUserSession();
const { loading: signingOut, run: handleSignOut } = useLoading(async () => {
await clear();
await navigateTo("/");
});
if (!loggedIn.value) {
await navigateTo("/");
}
const { data: user, refresh: refreshUserData } = await useFetch("/api/user");
// useIntervalFn(() => {
Expand Down Expand Up @@ -69,13 +72,21 @@ const examLinks = computed(() =>
const { run: _handleNewThread, loading: creatingNewThread } = useCreateThread();
async function handleNewThread() {
await _handleNewThread();
isOpen.value = false;
if (guestMode.value) {
setShowSignUpModal(true);
} else {
await _handleNewThread();
isOpen.value = false;
}
}
async function handleNewExam() {
isOpen.value = false;
await navigateTo(`/exams/new`);
if (guestMode.value) {
setShowSignUpModal(true);
} else {
isOpen.value = false;
await navigateTo(`/exams/new`);
}
}
watchEffect(() => {
Expand All @@ -96,6 +107,7 @@ const credit = computed(() => {

<template>
<UContainer class="pt-4">
<SignUpModal v-model="showSignUpModal" />
<div class="flex justify-between items-center w-full mb-4 mx-2">
<NuxtLink
class="font-mono mr-4"
Expand All @@ -122,7 +134,7 @@ const credit = computed(() => {
@click="() => (isOpen = true)"
/>
<USlideover v-model="isOpen">
<div>
<div class="overflow-scroll">
<div class="flex items-center justify-between mt-4 mx-2">
<UButton
@click="handleSignOut"
Expand Down
Empty file added mydb.sqlite
Empty file.
Loading

0 comments on commit fbfcbe5

Please sign in to comment.