Skip to content

Commit

Permalink
Simple animations (#4378)
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-brydon committed Sep 12, 2022
1 parent 9557c18 commit ef7863a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
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

0 comments on commit ef7863a

Please sign in to comment.