refactor: use the useAnimate hook (#5103)

Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
Nafees NazikandPeer Richelsen authored and GitHub committed 2022-10-20 05:09:52 +00:00
1 parent 7756b9c3a1
commit 2931f4f84a
13 files changed
+38 -83

No files matched your search

+2 -7
View File
@@ -1,6 +1,5 @@
import autoAnimate from "@formkit/auto-animate";
import { useAutoAnimate } from "@formkit/auto-animate/react";
import Link from "next/link";
import { useEffect, useRef } from "react";
import { inferQueryOutput } from "@calcom/trpc/react";
import { Switch } from "@calcom/ui/v2";
@@ -24,11 +23,7 @@ export default function AppCard({
children?: React.ReactNode;
setAppData: SetAppDataGeneric<typeof eventTypeAppCardZod>;
}) {
const animationRef = useRef(null);
useEffect(() => {
animationRef.current && autoAnimate(animationRef.current);
}, [animationRef]);
const [animationRef] = useAutoAnimate<HTMLDivElement>();
return (
<div ref={animationRef} className="mb-4 mt-2 rounded-md border border-gray-200 p-8 text-sm">
@@ -1,6 +1,6 @@
import autoAnimate from "@formkit/auto-animate";
import { useAutoAnimate } from "@formkit/auto-animate/react";
import { App_RoutingForms_Form } from "@prisma/client";
import { useEffect, useRef, useState } from "react";
import { useEffect, useState } from "react";
import { Controller, useFieldArray } from "react-hook-form";
import { UseFormReturn } from "react-hook-form";
import { v4 as uuidv4 } from "uuid";
@@ -197,11 +197,7 @@ const FormEdit = ({
name: fieldsNamespace,
});
const animationRef = useRef(null);
useEffect(() => {
animationRef.current && autoAnimate(animationRef.current);
}, [animationRef]);
const [animationRef] = useAutoAnimate<HTMLDivElement>();
const addField = () => {
appendHookFormField({
@@ -1,6 +1,6 @@
import autoAnimate from "@formkit/auto-animate";
import { useAutoAnimate } from "@formkit/auto-animate/react";
import { App_RoutingForms_Form } from "@prisma/client";
import React, { useState, useCallback, useRef, useEffect } from "react";
import React, { useState, useCallback } from "react";
import { Query, Config, Builder, Utils as QbUtils } from "react-awesome-query-builder";
// types
import { JsonTree, ImmutableTree, BuilderProps } from "react-awesome-query-builder";
@@ -326,11 +326,8 @@ const Routes = ({
return transformRoutes().map((route) => deserializeRoute(route, config));
});
const animationRef = useRef(null);
useEffect(() => {
animationRef.current && autoAnimate(animationRef.current);
}, [animationRef]);
const [animationRef] = useAutoAnimate<HTMLDivElement>();
const mainRoutes = routes.filter((route) => !route.isFallback);
let fallbackRoute = routes.find((route) => route.isFallback);
@@ -1,5 +1,4 @@
import autoAnimate from "@formkit/auto-animate";
import React, { useEffect, useRef } from "react";
import { useAutoAnimate } from "@formkit/auto-animate/react";
import { Props } from "react-select";
import { classNames } from "@calcom/lib";
@@ -24,11 +23,8 @@ export const CheckedTeamSelect = ({
onChange: (value: readonly CheckedSelectOption[]) => void;
}) => {
const { t } = useLocale();
const animationRef = useRef(null);
useEffect(() => {
animationRef.current && autoAnimate(animationRef.current);
}, [animationRef]);
const [animationRef] = useAutoAnimate<HTMLUListElement>();
return (
<>
@@ -1,5 +1,3 @@
import autoAnimate from "@formkit/auto-animate";
import React, { useEffect, useRef } from "react";
import { components, GroupBase, Props, ValueContainerProps } from "react-select";
import { Icon } from "@calcom/ui/Icon";
@@ -37,11 +35,6 @@ const LimitedChipsContainer = <Option, IsMulti extends boolean, Group extends Gr
export const MultiDropdownSelect = ({ options = [], value = [], ...props }: Props) => {
// const { t } = useLocale();
const animationRef = useRef(null);
useEffect(() => {
animationRef.current && autoAnimate(animationRef.current);
}, [animationRef]);
return (
<Select
+3 -7
View File
@@ -1,5 +1,5 @@
import autoAnimate from "@formkit/auto-animate";
import { useEffect, useState, useRef } from "react";
import { useAutoAnimate } from "@formkit/auto-animate/react";
import { useEffect, useState } from "react";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { localStorage } from "@calcom/lib/webstorage";
@@ -34,11 +34,7 @@ const tips = [
];
export default function Tips() {
const animationRef = useRef(null);
useEffect(() => {
animationRef.current && autoAnimate(animationRef.current, { duration: 250, easing: "ease-out" });
}, [animationRef]);
const [animationRef] = useAutoAnimate<HTMLDivElement>();
const { t } = useLocale();