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

Simple animations #4378

Merged
merged 3 commits into from
Sep 12, 2022
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
12 changes: 11 additions & 1 deletion apps/web/pages/v2/availability/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import autoAnimate from "@formkit/auto-animate";
import { useRef, useEffect } from "react";

import { NewScheduleButton, ScheduleListItem } from "@calcom/features/schedules";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { inferQueryOutput, trpc } from "@calcom/trpc/react";
Expand All @@ -13,6 +16,7 @@ import SkeletonLoader from "@components/availability/SkeletonLoader";
export function AvailabilityList({ schedules }: inferQueryOutput<"viewer.availability.list">) {
const { t } = useLocale();
const utils = trpc.useContext();
const animationParentRef = useRef(null);

const meQuery = trpc.useQuery(["viewer.me"]);

Expand All @@ -28,6 +32,12 @@ export function AvailabilityList({ schedules }: inferQueryOutput<"viewer.availab
}
},
});

// Adds smooth delete button - item fades and old item slides into place
useEffect(() => {
animationParentRef.current && autoAnimate(animationParentRef.current);
}, [animationParentRef]);

return (
<>
{schedules.length === 0 ? (
Expand All @@ -41,7 +51,7 @@ export function AvailabilityList({ schedules }: inferQueryOutput<"viewer.availab
</div>
) : (
<div className="mb-16 overflow-hidden rounded-md border border-gray-200 bg-white">
<ul className="divide-y divide-neutral-200" data-testid="schedules">
<ul className="divide-y divide-neutral-200" data-testid="schedules" ref={animationParentRef}>
{schedules.map((schedule) => (
<ScheduleListItem
displayOptions={{
Expand Down
12 changes: 10 additions & 2 deletions apps/web/pages/v2/bookings/[status].tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import autoAnimate from "@formkit/auto-animate";
import { GetStaticPaths, GetStaticProps } from "next";
import { useRouter } from "next/router";
import { Fragment } from "react";
import { Fragment, useEffect, useRef } from "react";
import { z } from "zod";

import { WipeMyCalActionButton } from "@calcom/app-store/wipemycalother/components";
Expand Down Expand Up @@ -43,6 +44,8 @@ export default function Bookings() {
getNextPageParam: (lastPage) => lastPage.nextCursor,
});

// Animate page (tab) tranistions to look smoothing
const animationParentRef = useRef(null);
const buttonInView = useInViewObserver(() => {
if (!query.isFetching && query.hasNextPage && query.status === "success") {
query.fetchNextPage();
Expand Down Expand Up @@ -79,9 +82,14 @@ export default function Bookings() {
}
return true;
};

useEffect(() => {
animationParentRef.current && autoAnimate(animationParentRef.current);
}, [animationParentRef]);

return (
<BookingLayout heading={t("bookings")} subtitle={t("bookings_description")}>
<div className="flex w-full flex-1 flex-col">
<div className="flex w-full flex-1 flex-col" ref={animationParentRef}>
{query.status === "error" && (
<Alert severity="error" title={t("something_went_wrong")} message={query.error.message} />
)}
Expand Down