Skip to content
Closed
Changes from all commits
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
17 changes: 15 additions & 2 deletions src/components/Layout/Feedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) Facebook, Inc. and its affiliates.
*/

import {useState} from 'react';
import {useEffect, useState} from 'react';
import {useRouter} from 'next/router';
import {ga} from '../../utils/analytics';

Expand Down Expand Up @@ -60,8 +60,21 @@ function sendGAEvent(isPositive: boolean) {

function SendFeedback({onSubmit}: {onSubmit: () => void}) {
const [isSubmitted, setIsSubmitted] = useState(false);
const [isVisible, setIsVisible] = useState(true);

useEffect(() => {
if (isSubmitted) {
setInterval(() => {
setIsVisible(false);
}, 2500);
}
}, [isSubmitted]);

return (
<div className="max-w-xs w-80 lg:w-auto py-3 shadow-lg rounded-lg m-4 bg-wash dark:bg-gray-95 px-4 flex">
<div
className={`max-w-xs w-80 lg:w-auto py-3 shadow-lg rounded-lg m-4 bg-wash dark:bg-gray-95 px-4 flex ${
!isVisible && 'hidden'
}`}>
<p className="w-full font-bold text-primary dark:text-primary-dark text-lg mr-4">
{isSubmitted ? 'Thank you for your feedback!' : 'Is this page useful?'}
</p>
Expand Down