Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

AP-1222 Add option to disable Modal animations #142

Merged
merged 4 commits into from
Nov 21, 2019

Conversation

justinanastos
Copy link
Contributor

@justinanastos justinanastos commented Nov 21, 2019

Contributes to issue https://apollographql.atlassian.net/browse/AP-1222

The context implementation is inspired by Kent C. Dodds's "Using Context Effectively" blog post. I suggest you read it!


Problem

We use framer motion to animate our Modal component. This looks awesome! Unfortunately, Chromatic can't automatically disable JavaScript based animations (see the docs https://docs.chromaticqa.com/animations); this can lead to Chromatic snapshots being taken mid-animation, causing unacceptable flake in our visual tests. Even worse, this behavior is non-deterministic, so if we take a snapshot on master and that snapshot is taken mid-animation, that change will be auto-accepted and that will become the new baseline. See this example: https://www.chromaticqa.com/snapshot?appId=5a77a6d38a9e3c002045d20d&id=5dd5a7093b1d9300209972b2

Solution

Per @cheapsteak 's suggestion, create an optional SpaceKitProvider that accepts props to disable animations across all space kit components. We can wrap our application with this or use it as a Storybook decorator to wrap it around all our stories.

// storybook/config.js
import { addDecorator } from '@storybook/react';
import isChromatic from 'storybook-chromatic/isChromatic';
import { SpaceKitProvider } from '@apollo/space-kit/SpaceKitProvider';
import React from 'react';

addDecorator((story) => (
  <SpaceKitProvider disableAnimations={isChromatic()}>
    {story()}
  </SpaceKitProvider>
));

This will prevent us from having to add isChromatic to our exported components (great catch on this @trevorblades !), and will prevent us from having to remember to conditionally disable animations in our stories or components if we're rendering inside Chromatic.

I've tested this in AGM; it works as expected 😃

@justinanastos justinanastos added the minor Increment the minor version when merged label Nov 21, 2019
@justinanastos justinanastos force-pushed the justin/AP-1222/disable-modal-animations branch from dbb035f to 091ebb1 Compare November 21, 2019 16:53
@justinanastos justinanastos marked this pull request as ready for review November 21, 2019 17:02
@justinanastos
Copy link
Contributor Author

@jgzuke I propose we use this solution for LoadingSpinner as well! #141

Copy link
Member

@cheapsteak cheapsteak left a comment

Choose a reason for hiding this comment

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

Love the considerate ergonomics!

What do you think about package-wide setting? Would be convenient if we could set this once, either via something like

spaceKitSettings.disableAnimations = true;
// similar to _.templateSettings

or

<SpaceKitProvider disableAnimations={true}>
  ...
</SpaceKitProvider>

@justinanastos
Copy link
Contributor Author

@cheapsteak I love

Love the considerate ergonomics!

What do you think about package-wide setting? Would be convenient if we could set this once, either via something like

spaceKitSettings.disableAnimations = true;
// similar to _.templateSettings

or

<SpaceKitProvider disableAnimations={true}>
  ...
</SpaceKitProvider>

Those are great ideas! Let me take a look at how quickly I can create SpaceKitProvider.

@justinanastos justinanastos changed the title AP-1222 Add option to disable Modal animations [WIP] AP-1222 Add option to disable Modal animations Nov 21, 2019
@justinanastos justinanastos force-pushed the justin/AP-1222/disable-modal-animations branch from 091ebb1 to c988123 Compare November 21, 2019 18:19
@justinanastos justinanastos changed the title [WIP] AP-1222 Add option to disable Modal animations AP-1222 Add option to disable Modal animations Nov 21, 2019
@justinanastos justinanastos force-pushed the justin/AP-1222/disable-modal-animations branch from c988123 to c5a12f7 Compare November 21, 2019 18:32
Copy link
Member

@cheapsteak cheapsteak left a comment

Choose a reason for hiding this comment

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

very nice!

@justinanastos justinanastos force-pushed the justin/AP-1222/disable-modal-animations branch from c5a12f7 to dbefab7 Compare November 21, 2019 19:03
@justinanastos justinanastos force-pushed the justin/AP-1222/disable-modal-animations branch from dbefab7 to a5f5180 Compare November 21, 2019 19:08
@justinanastos justinanastos merged commit cd55590 into master Nov 21, 2019
@justinanastos justinanastos deleted the justin/AP-1222/disable-modal-animations branch November 21, 2019 19:20
@apollo-bot2
Copy link
Collaborator

🚀 PR was released in v2.18.0 🚀

@apollo-bot2 apollo-bot2 added the released This issue/pull request has been released. label Nov 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
minor Increment the minor version when merged released This issue/pull request has been released.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants