Framer Motion

Here you will find the information on how we used animations from this library.

Credits

All the base examples of the animations and overall how this work you can find on their official documentation here.

In this block we just briefly take a look how this animation set in our project.

Requirement

First of all we need to install package:

"framer-motion": "^11.3.2",

Example

In file we import:

import { AnimatePresence, motion } from 'framer-motion';

N.B. AnimatePresence not always necessary.

Base usage on example in Lead Statuses Settings:

<motion.div key="edit" {...statusesForm} className="tour-statuses-list">
        <DndContext sensors={sensors} collisionDetection={closestCorners} onDragEnd={handleDragEnd}>
                <StatusesList statuses={statuses} />
        </DndContext>
</motion.div>

or more complicated example just lower in the code:

<AnimatePresence mode="wait">
                {mode === 'edit' && (
                    <motion.div key="edit" {...statusesForm}>
                        <EditStatus
                            t={t}
                            statuses={statuses}
                            colors={colors}
                            handleUpdateStatus={handleUpdateStatus}
                            handleOpenDeleteModal={handleOpenDeleteModal}
                            loading={loading}
                        />
                    </motion.div>
                )}
                {mode === 'add' && (
                    <motion.div key="add" {...statusesForm}>
                        <AddStatus t={t} colors={colors} handleCreateStatus={handleCreateStatus} loading={loading} />
                    </motion.div>
                )}
</AnimatePresence>

From this example we can understand that render switches on display based on different conditions. Animation make experience of UI usage more smooth.

Helpers

You may notice this thing in component code:

{...statusesForm}

Such code you can find in .../ui/src/common/animationVariants/

As you can see, in that folder we stores other animation variants.

Just go there and try it!

Last updated