Skip to content

Commit

Permalink
fixed js css interaction
Browse files Browse the repository at this point in the history
  • Loading branch information
zarSou9 committed May 26, 2024
1 parent f38104c commit 9b394ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
5 changes: 0 additions & 5 deletions app/components/Feedback/feedback.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@
opacity: 1;
}

.thanks {
opacity: 0;
transition: opacity 0.25s ease-in-out; /* Transition effect */
}

.composite-button > .feedback-form {
position: absolute;
transform: translate(-9vw, var(--spacing-56));
Expand Down
29 changes: 15 additions & 14 deletions app/components/Feedback/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {useState, useRef} from 'react'
import {useEffect, useState, useRef} from 'react'
import {Action, ActionType} from '~/routes/questions.actions'
import './feedback.css'
import FeedbackForm from './Form'
Expand Down Expand Up @@ -43,18 +43,14 @@ const Feedback = ({
formClassName,
onSubmit,
}: FeedbackProps) => {
const [showThanks, setShowThanks] = useState(false)
const [showFeedbackForm, setShowFeedbackForm] = useState(false)
const [voted, setVoted]: any = useState(false)

const thanksRef = useRef<HTMLDivElement | null>(null)

function showThanks() {
if (thanksRef.current) thanksRef.current.style.opacity = '1'
const timeout = setInterval(() => {
if (thanksRef.current) thanksRef.current.style.opacity = '0'
}, 6000)
useEffect(() => {
const timeout = setTimeout(() => setShowThanks(false), 6000)
return () => clearInterval(timeout)
}
}, [showThanks])

return (
<div className="flex items-center">
Expand All @@ -67,7 +63,7 @@ const Feedback = ({
hint={upHint}
setVoted={setVoted}
onClick={() => {
showThanks()
setShowThanks(true)
}}
/>
<Action
Expand All @@ -78,20 +74,25 @@ const Feedback = ({
disabled={voted}
setVoted={setVoted}
onClick={() => {
if (!showForm) showThanks()
if (!showForm) setShowThanks(true)
setShowFeedbackForm(!!showForm)
}}
/>
</ButtonSecondaryWrapper>

<div ref={thanksRef} className="thanks ml-2 opacity-0 pointer-events-none">
<p
className={
'transition-opacity duration-200 ease-in-out ml-2 pointer-events-none ' +
(showThanks ? 'opacity-100' : 'opacity-0')
}
>
Thank you for your feedback!
</div>
</p>

{showFeedbackForm && (
<FeedbackForm
onSubmit={(att) => {
showThanks()
setShowThanks(true)
return onSubmit(att)
}}
onClose={() => {
Expand Down

0 comments on commit 9b394ea

Please sign in to comment.