Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Floating feedback button #39

Merged
merged 7 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable no-console */
import '~/styles/globals.scss';
import Providers from '../providers/Providers';
import { revalidatePath, revalidateTag } from 'next/cache';
import FeedbackButton from '~/components/FeedbackButton/FeedbackButton';
import RedirectWrapper from '~/components/RedirectWrapper';
import { getServerSession } from '~/utils/auth';
import { api } from '~/trpc/server';
import { Toaster } from '~/components/ui/toaster';
import { revalidatePath, revalidateTag } from 'next/cache';
import '~/styles/globals.scss';
import { api } from '~/trpc/server';
import { getServerSession } from '~/utils/auth';
import Providers from '../providers/Providers';

export const metadata = {
title: 'Network Canvas Fresco',
Expand Down Expand Up @@ -35,6 +35,7 @@ async function RootLayout({ children }: { children: React.ReactNode }) {
>
<Providers initialSession={session}>{children}</Providers>
<Toaster />
<FeedbackButton />
</RedirectWrapper>
</body>
</html>
Expand Down
17 changes: 17 additions & 0 deletions components/FeedbackButton/ButtonTooltip.tsx
buckhalt marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { motion } from 'framer-motion';

const ButtonTooltip = () => {
return (
<motion.p
initial={{ opacity: 0, y: 15 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 15 }}
transition={{ duration: 0.5, delay: 1, ease: 'easeInOut' }}
className="rounded-md bg-slate-200 px-3 py-2 text-base"
>
Click here to report bugs!
</motion.p>
);
};

export default ButtonTooltip;
45 changes: 45 additions & 0 deletions components/FeedbackButton/FeedbackButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use client';

import { AnimatePresence, motion } from 'framer-motion';
import ButtonTooltip from './ButtonTooltip';
import { useEffect, useState } from 'react';
import ClickUpFormModal from './FeedbackModal';

const FeedbackButton = () => {
const [showTooltip, setShowTooltip] = useState(true);
const [open, setOpen] = useState(false);

useEffect(() => {
const timeoutId = setTimeout(() => {
setShowTooltip(false);
}, 10000); // tooltip disappears after 10 seconds

return () => clearTimeout(timeoutId);
}, []);

return (
<>
<ClickUpFormModal open={open} setOpen={setOpen} />
<motion.div
initial={{ opacity: 1 }}
animate={{ x: '25px', rotate: -60 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion the rotated button here looks a bit odd. Is the idea just to move it out of the way after the tooltip disappears? I think it would be fine to animate it to the bottom corner without rotating.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks creepy, right? 😅 I'll fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put the feedback button in a top-level banner according to Joshua's suggestion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The top-level banner looks awesome!

transition={{ delay: 12 }}
className="fixed bottom-16 right-10 z-50 h-[115px]"
>
<AnimatePresence>{showTooltip && <ButtonTooltip />}</AnimatePresence>
<motion.button
initial={{ opacity: 0, scale: 0.5 }}
animate={{ opacity: 1, scale: 1 }}
whileHover={{ scale: 1.1 }}
whileTap={{ scale: 0.9 }}
className="absolute bottom-0 right-1.5 w-fit cursor-pointer rounded-full p-4 text-4xl text-white"
onClick={() => setOpen(true)}
>
🤖
</motion.button>
</motion.div>
</>
);
};

export default FeedbackButton;
31 changes: 31 additions & 0 deletions components/FeedbackButton/FeedbackModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { type Dispatch, type SetStateAction } from 'react';
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
} from '~/components/ui/dialog';

type FeedbackModalProps = {
open: boolean;
setOpen: Dispatch<SetStateAction<boolean>>;
};

const FeedbackModal = ({ open, setOpen }: FeedbackModalProps) => {
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent className="max-w-[700px]">
<DialogHeader>
<DialogTitle>Your feedback below</DialogTitle>
</DialogHeader>
<iframe
className="h-[450px] w-full border"
title="Feedback form"
src="https://forms.clickup.com/3464225/f/39q11-6131/OIJSIULQV2EUZFLUOA"
></iframe>
</DialogContent>
</Dialog>
);
};

export default FeedbackModal;