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

Feat/cards animation #22

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
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
20 changes: 16 additions & 4 deletions src/components/pages/game/game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ const ORACLE_NEEDS_TIME = 'images/tarot-game/oracle-needs-time.png';
const THANKS_ORACLE = 'images/tarot-game/thanks-oracle.png';

const LOADING_IMAGES = [SHUFFLE_DECK, ORACLE_NEEDS_TIME] as const;
const CARD_ANIMATIONS = [
'firstCardAppearance 1s linear forwards',
'secondCardAppearance 2s linear forwards',
'thirdCardAppearance 3s linear forwards',
] as const;

type TarotRequestSchemaType = z.infer<typeof TarotRequestSchema>;

Expand Down Expand Up @@ -75,7 +80,13 @@ export const GameSection = () => {

useEffect(() => {
if (predictionAnswer) {
setValue('question', predictionAnswer.answer);
const timer = setTimeout(() => {
setValue('question', predictionAnswer.answer);
}, 3200);

return () => {
clearTimeout(timer);
};
}
}, [isSuccess, predictionAnswer, setValue, watch]);

Expand Down Expand Up @@ -117,17 +128,18 @@ export const GameSection = () => {

return (
<div className="container flex flex-col gap-[20px] py-[20px] font-inknut">
<div className="text-center font-bona-nova-sc text-[30px] sm:text-[50px]">Your Future In One Bet</div>
<div className="text-center font-bona-nova-sc text-[30px] sm:text-[50px]">Your Future In One Forecast</div>

<div className="w-[90vw] overflow-x-auto sm:w-auto">
<div className="relative -z-50 h-[444px] w-[888px] sm:h-auto sm:w-auto">
{predictionAnswer && currentMainImage === DEFAULT_IMAGE && (
<div className="absolute flex h-[93%] w-full flex-row justify-around py-4 sm:h-full sm:justify-evenly">
{predictionAnswer.tarots.map((e) => {
{predictionAnswer.tarots.map((e, idx) => {
return (
<img
key={e.id}
className={cn('rounded-[8px]', e.reverted && 'rotate-180')}
style={{ animation: CARD_ANIMATIONS[idx] }}
src={`images/cards/${e.id}.jpg`}
alt="card"
/>
Expand Down Expand Up @@ -160,7 +172,7 @@ export const GameSection = () => {
<div className="text-red-700"> {errors.question?.message ? errors.question.message : '⠀'} </div>
<textarea
{...register('question')}
className="rounded-[8px] border border-[#3A3939] bg-transparent p-4 placeholder-[#3A3939] outline-none"
className="min-h-[150px] rounded-[8px] border border-[#3A3939] bg-transparent p-4 placeholder-[#3A3939] outline-none"
placeholder="Type your question here"
disabled={isPending}
rows={7}
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/home/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PredictFutureBtn } from '@/components/common/PredictFutureBtn';

export const Hero = () => {
return (
<div className="relative flex min-h-[812px] flex-col items-center justify-between pb-[52px] pt-20 md:min-h-[988px] md:pb-[72px] md:pt-24">
<div className="relative flex min-h-[812px] flex-col items-center justify-between pb-[52px] pt-20 md:min-h-[865px] md:pb-[72px] md:pt-20">
<h1 className="text-center font-bona-nova-sc text-[40px] md:text-[60px]">TarotSol AI</h1>
<div className="flex flex-col gap-6 md:flex-row md:gap-10">
<GoToTwitterBtn />
Expand Down
33 changes: 33 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,36 @@ body {
@apply bg-background text-foreground;
}
}

@keyframes firstCardAppearance {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tailwind generate keyFrames from tailwind.config during build (in case they are used in code)
So that's why, i moved keyFrames to style.css, because i use thm dynamically

0% {
transform: translateY(-50%);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}

@keyframes secondCardAppearance {
0% {
transform: translateY(-180%);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}

@keyframes thirdCardAppearance {
0% {
transform: translateY(-300%);
opacity: 0;
}
100% {
transform: translateY(0);
opacity: 1;
}
}
Loading