Skip to content

Commit 663da58

Browse files
feat(Motion): motion integration branch (#2435)
* start integration branch * docs(motion-presets): Motion Refresh / Presets RFC 2024 (#2336) * feat: init motion presets rfc * docs: add poc video * docs: add comparison table and pocs * feat: add gsap poc * add layout animations poc with blade components * feat: add basic API decision * feat: add api decisions and memes * feat: add api decisions and memes * feat: remove unrelated changes * docs: add morph note * feat: add video example * docs: add note for previews * docs: add more videos * fix: images * fix: code alignments * docs: fix widths of cols * feat: add chat interface demo * typo * fix: width of previews * docs: update animationInteractions docs * feat: add view transitions API note * feat: add view transitions API note * feat: rename framer motion to motion/react * feat: add framer motion name change note in library table * docs: add new open questions and conclusions * fix: change misleading scale heading * feat: add videos locally * feat: revert to previous fade video * feat: rename transition prop to type * docs: update AnimateInteractions prop * remove unrelated changes * feat: add PR link * fix: PR link * feat: add breaking change note * feat(motion.ts): add refreshed tokens and internal components migration (#2356) * feat: init motion presets rfc * docs: add poc video * docs: add comparison table and pocs * feat: add gsap poc * add layout animations poc with blade components * feat: add basic API decision * feat: add api decisions and memes * feat: add api decisions and memes * feat: remove unrelated changes * docs: add morph note * feat: add video example * docs: add note for previews * docs: add more videos * fix: images * fix: code alignments * docs: fix widths of cols * feat: add chat interface demo * typo * fix: width of previews * feat: update all token values * feat: motion, migrate internal motion tokens * fix: ts check * fix: ts * fix: switch delay * fix: durations map * docs: update animationInteractions docs * feat: add view transitions API note * feat: add view transitions API note * feat: rename framer motion to motion/react * feat: add framer motion name change note in library table * docs: add new open questions and conclusions * fix: change misleading scale heading * feat(motion): add initial presets code (#2360) * feat: init motion presets rfc * docs: add poc video * docs: add comparison table and pocs * feat: add gsap poc * add layout animations poc with blade components * feat: add basic API decision * feat: add api decisions and memes * feat: add api decisions and memes * feat: remove unrelated changes * docs: add morph note * feat: add video example * docs: add note for previews * docs: add more videos * fix: images * fix: code alignments * docs: fix widths of cols * feat: add chat interface demo * typo * fix: width of previews * feat: update all token values * feat: motion, migrate internal motion tokens * fix: ts check * fix: ts * fix: switch delay * feat: add base entry exit presets * fix: example card alignment * feat: add stagger component * feat: add animateInteractions * refactor: use common BaseMotionBox * refactor: move stagger and animateinteraction check * fix: durations map * feat: add morph and scale preset * feat: add Slide * refactor: remove unused code add todo * docs: update animationInteractions docs * feat: add css bezier function * feat: add view transitions API note * feat: add view transitions API note * feat: add controled scale, enhancer animateinteraction * feat: replace framer-motion imports with motion/react * feat: rename framer motion to motion/react * feat: add framer motion name change note in library table * docs: add new open questions and conclusions * fix: change misleading scale heading * feat: add fade token values * fix(AnimateInteractions): a11y focus issues * feat: add token valyes for move * feat: add slide tokens * fix: stories * fix: typecheck * feat: add refs to components till checkbox * feat: add refs till radio * feat: migration to ref till typography * feat: add withRef story * fix: scale box * feat: add shouldUnmountWhenHidden * feat: handle no unmount transitions in stagger * feat: add slideFromOffset prop * refactor: simplify basemotion * feat: add memo for variants object * fix: focus on animate interactions * fix: resolve anurag's comments * feat: add comments for getOuterMotionRef * feat: add delay prop * fix: stagger type * feat: support framer-motion v4 * feat: add borderRadius and backgroundColor morph support * feat: remove reduced motion handling * docs(Motion Presets): add motion presets documentation (#2428) * feat: init motion presets rfc * docs: add poc video * docs: add comparison table and pocs * feat: add gsap poc * add layout animations poc with blade components * feat: add basic API decision * feat: add api decisions and memes * feat: add api decisions and memes * feat: remove unrelated changes * docs: add morph note * feat: add video example * docs: add note for previews * docs: add more videos * fix: images * fix: code alignments * docs: fix widths of cols * feat: add chat interface demo * typo * fix: width of previews * feat: update all token values * feat: motion, migrate internal motion tokens * fix: ts check * fix: ts * fix: switch delay * feat: add base entry exit presets * fix: example card alignment * feat: add stagger component * feat: add animateInteractions * refactor: use common BaseMotionBox * refactor: move stagger and animateinteraction check * fix: durations map * feat: add morph and scale preset * feat: add Slide * refactor: remove unused code add todo * docs: update animationInteractions docs * feat: add css bezier function * feat: add view transitions API note * feat: add view transitions API note * feat: add controled scale, enhancer animateinteraction * feat: replace framer-motion imports with motion/react * feat: rename framer motion to motion/react * feat: add framer motion name change note in library table * docs: add new open questions and conclusions * fix: change misleading scale heading * feat: add fade token values * fix(AnimateInteractions): a11y focus issues * feat: add token valyes for move * feat: add slide tokens * fix: stories * fix: typecheck * feat: add refs to components till checkbox * feat: add refs till radio * feat: migration to ref till typography * feat: add withRef story * fix: scale box * feat: add basic stories * refactor: docs * feat: add shouldUnmountWhenHidden * docs: add docs for other entry/exit presets * feat: add stagger documentation * feat: handle no unmount transitions in stagger * feat: add dashboard example * fix: workspace animation on dashboard recipe * feat: add slideFromOffset prop * feat: add loading screen to dashboard example * refactor: simplify basemotion * feat: add slide docs fix * docs: minor docs changes * feat: add memo for variants object * feat: add installation docs, expose overlay colors * fix: focus on animate interactions * docs: remove docs page of recipes * fix: scale performance * fix: ts * feat: add basic intro page for motion * docs: finish motion intro docs * feat: add basic upgrade guide info * fix: resolve anurag's comments * feat: add comments for getOuterMotionRef * feat: add delay prop * fix: types * fix: stagger type * feat: support framer-motion v4 * feat: add version upgrade guide * feat: add jsdoc, pass down boxProps to stagger * feat: reuse motion installation mdx * feat: add borderRadius and backgroundColor morph support * fix: button morph example * fix: morph showcase * feat: add lazy motion * test(Motion): add tests and codemod (#2436) * feat: init motion presets rfc * docs: add poc video * docs: add comparison table and pocs * feat: add gsap poc * add layout animations poc with blade components * feat: add basic API decision * feat: add api decisions and memes * feat: add api decisions and memes * feat: remove unrelated changes * docs: add morph note * feat: add video example * docs: add note for previews * docs: add more videos * fix: images * fix: code alignments * docs: fix widths of cols * feat: add chat interface demo * typo * fix: width of previews * feat: update all token values * feat: motion, migrate internal motion tokens * fix: ts check * fix: ts * fix: switch delay * feat: add base entry exit presets * fix: example card alignment * feat: add stagger component * feat: add animateInteractions * refactor: use common BaseMotionBox * refactor: move stagger and animateinteraction check * fix: durations map * feat: add morph and scale preset * feat: add Slide * refactor: remove unused code add todo * docs: update animationInteractions docs * feat: add css bezier function * feat: add view transitions API note * feat: add view transitions API note * feat: add controled scale, enhancer animateinteraction * feat: replace framer-motion imports with motion/react * feat: rename framer motion to motion/react * feat: add framer motion name change note in library table * docs: add new open questions and conclusions * fix: change misleading scale heading * feat: add fade token values * fix(AnimateInteractions): a11y focus issues * feat: add token valyes for move * feat: add slide tokens * fix: stories * fix: typecheck * feat: add refs to components till checkbox * feat: add refs till radio * feat: migration to ref till typography * feat: add withRef story * fix: scale box * feat: add basic stories * refactor: docs * feat: add shouldUnmountWhenHidden * docs: add docs for other entry/exit presets * feat: add stagger documentation * feat: handle no unmount transitions in stagger * feat: add dashboard example * fix: workspace animation on dashboard recipe * feat: add slideFromOffset prop * feat: add loading screen to dashboard example * refactor: simplify basemotion * feat: add slide docs fix * docs: minor docs changes * feat: add memo for variants object * feat: add installation docs, expose overlay colors * fix: focus on animate interactions * docs: remove docs page of recipes * fix: scale performance * fix: ts * feat: add basic intro page for motion * docs: finish motion intro docs * feat: add tests for basic components * tests: update snapshots * feat: add interaction tests * feat: add codemod * feat: add basic upgrade guide info * fix: resolve anurag's comments * feat: add comments for getOuterMotionRef * feat: add delay prop * fix: types * fix: stagger type * feat: support framer-motion v4 * feat: add version upgrade guide * feat: add jsdoc, pass down boxProps to stagger * feat: reuse motion installation mdx * fix: basemotion mock * fix: motion/react instances * fix: native test * fix: transitions on card * fix: snapshot for card * fix: lint issues * fix: typecheck * fix: lint * fix: regex lint * fix: text lint * feat: add borderRadius and backgroundColor morph support * fix: slide test * upgrade guide cleanup * heading level cleanup in upgrade guide * fix: button morph example * fix: morph showcase * feat: add lazy motion * fix: typecheck * fix: native snapshots * Create fluffy-bikes-drop.md * fix: conflicts * fix: features.js extension in PR preview sandbox * fix: GlobalStyles undefined * feat: add motion to peerDependency as well like framer-motion * fix: recommend `framer-motion` name installation instead of `motion/react` (#2443) * fix: mark motion as optional peer deps * feat: mark motion external * fix: check if its working without motion as external * fix: mark motion/react as external * feat: recommend framer-motion name instead * fix: stackblitz examples minor cleanup
1 parent 3532461 commit 663da58

File tree

313 files changed

+12700
-4256
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

313 files changed

+12700
-4256
lines changed

.changeset/fluffy-bikes-drop.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@razorpay/blade": major
3+
---
4+
5+
feat(Motion): Release Motion Presets
6+
7+
- Check out [Blade v12 Upgrade Guide](https://github.com/razorpay/blade/blob/master/packages/blade/docs/migration-docs/upgrade-v12.md) for codemod and migration steps

packages/blade/.storybook/react/preview.tsx

+35-18
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { DocsContainer } from '@storybook/addon-docs';
1111
import React from 'react';
1212
import { MINIMAL_VIEWPORTS } from '@storybook/addon-viewport';
1313
import './global.css';
14+
import { domMax, LazyMotion } from 'framer-motion';
1415

1516
export const parameters = {
1617
// disable snapshot by default and then enable it only for kitchen sink
@@ -73,6 +74,17 @@ export const parameters = {
7374
],
7475
'Components',
7576
['*', 'Interaction Tests', 'KitchenSink'],
77+
'Motion',
78+
[
79+
'Introduction to Motion',
80+
'Fade',
81+
'Move',
82+
'Slide',
83+
'*',
84+
'AnimateInteractions',
85+
'Stagger',
86+
'Recipes',
87+
],
7688
'Recipes',
7789
],
7890
},
@@ -95,13 +107,15 @@ export const parameters = {
95107
}
96108
return (
97109
<DocsContainer context={context}>
98-
<BladeProvider
99-
key={`${context.store.globals.globals.themeTokenName}-${context.store.globals.globals.colorScheme}`}
100-
themeTokens={getThemeTokens()}
101-
colorScheme={context.store.globals.globals.colorScheme}
102-
>
103-
{children}
104-
</BladeProvider>
110+
<LazyMotion strict features={domMax}>
111+
<BladeProvider
112+
key={`${context.store.globals.globals.themeTokenName}-${context.store.globals.globals.colorScheme}`}
113+
themeTokens={getThemeTokens()}
114+
colorScheme={context.store.globals.globals.colorScheme}
115+
>
116+
{children}
117+
</BladeProvider>
118+
</LazyMotion>
105119
</DocsContainer>
106120
);
107121
},
@@ -147,7 +161,8 @@ const StoryCanvas = styled.div<{ context }>(
147161
context.kind.includes('/Carousel') ||
148162
context.kind.includes('/TopNav') ||
149163
context.kind.includes('/Examples') ||
150-
context.kind.includes('/SideNav')
164+
context.kind.includes('/SideNav') ||
165+
context.kind.includes('/Recipes')
151166
? '0rem'
152167
: '2rem'
153168
};
@@ -180,15 +195,18 @@ export const decorators = [
180195
return (
181196
<ErrorBoundary>
182197
<GlobalStyle />
183-
<BladeProvider
184-
key={`${context.globals.themeTokenName}-${context.globals.colorScheme}`}
185-
themeTokens={getThemeTokens()}
186-
colorScheme={context.globals.colorScheme}
187-
>
188-
<StoryCanvas context={context}>
189-
<Story />
190-
</StoryCanvas>
191-
</BladeProvider>
198+
{/* strict in LazyMotion will make sure we don't use excessive `motion` component in blade components and instead use light weight `m` */}
199+
<LazyMotion strict features={domMax}>
200+
<BladeProvider
201+
key={`${context.globals.themeTokenName}-${context.globals.colorScheme}`}
202+
themeTokens={getThemeTokens()}
203+
colorScheme={context.globals.colorScheme}
204+
>
205+
<StoryCanvas context={context}>
206+
<Story />
207+
</StoryCanvas>
208+
</BladeProvider>
209+
</LazyMotion>
192210
</ErrorBoundary>
193211
);
194212
},
@@ -228,7 +246,6 @@ export const globalTypes = {
228246
showName: true,
229247
},
230248
},
231-
// TODO: Rebranding - Uncomment this when we fix white-labeling
232249
brandColor: {
233250
name: 'Brand Color',
234251
description: 'Brand Color (You can pass any valid color to BladeProvider)',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
import { applyTransform } from '@hypermod/utils';
2+
import transformer from '..';
3+
4+
it('should update token for dashboard sidebar example', async () => {
5+
const result = await applyTransform(
6+
transformer,
7+
`
8+
export const SidebarContainer = styled.div<SidebarContainerProps>(
9+
({ theme, isRTUXHomepage, isVisible, isMobile }) => \`
10+
display: flex;
11+
flex-direction: column;
12+
position: fixed;
13+
top: 0;
14+
bottom: 0;
15+
background-color: \${
16+
isRTUXHomepage
17+
? isMobile
18+
? theme.colors.surface.background.cloud.subtle
19+
: 'transparent'
20+
: '#2e3345'
21+
};
22+
transform: translate(-100%,0);
23+
transition: transform \${makeMotionTime(theme.motion.delay.short)} \${
24+
theme.motion.easing.standard.effective
25+
};
26+
\`);
27+
`,
28+
{ parser: 'tsx' },
29+
);
30+
31+
expect(result).toMatchInlineSnapshot(`
32+
"export const SidebarContainer = styled.div<SidebarContainerProps>(
33+
({ theme, isRTUXHomepage, isVisible, isMobile }) => \`
34+
display: flex;
35+
flex-direction: column;
36+
position: fixed;
37+
top: 0;
38+
bottom: 0;
39+
background-color: \${
40+
isRTUXHomepage
41+
? isMobile
42+
? theme.colors.surface.background.cloud.subtle
43+
: 'transparent'
44+
: '#2e3345'
45+
};
46+
transform: translate(-100%,0);
47+
transition: transform \${makeMotionTime(theme.motion.delay.short)} \${
48+
theme.motion.easing.standard
49+
};
50+
\`);"
51+
`);
52+
});
53+
54+
it('should update token when used as prop', async () => {
55+
const result = await applyTransform(
56+
transformer,
57+
`
58+
function App() {
59+
const { theme } = useTheme();
60+
61+
return <Box easing={theme.motion.easing.standard.wary} />
62+
}
63+
`,
64+
{ parser: 'tsx' },
65+
);
66+
67+
expect(result).toMatchInlineSnapshot(`
68+
"function App() {
69+
const { theme } = useTheme();
70+
71+
return <Box easing={theme.motion.easing.shake} />
72+
}"
73+
`);
74+
});
75+
76+
it('should update token as used in X payroll', async () => {
77+
const result = await applyTransform(
78+
transformer,
79+
`
80+
export const AnimatedContainer = styled.div<{ delay?: number }>(({ theme, delay = 0 }) => {
81+
return css\`
82+
animation: \${entry} \${makeMotionTime(theme.motion.duration['2xgentle'])}
83+
\${theme.motion.easing.entrance.revealing} forwards;
84+
animation-delay: \${delay}ms;
85+
opacity: 0;
86+
\`;
87+
});
88+
`,
89+
{ parser: 'tsx' },
90+
);
91+
92+
expect(result).toMatchInlineSnapshot(`
93+
"export const AnimatedContainer = styled.div<{ delay?: number }>(({ theme, delay = 0 }) => {
94+
return css\`
95+
animation: \${entry} \${makeMotionTime(theme.motion.duration['2xgentle'])}
96+
\${theme.motion.easing.entrance} forwards;
97+
animation-delay: \${delay}ms;
98+
opacity: 0;
99+
\`;
100+
});"
101+
`);
102+
});
103+
104+
it('should update token when variable name is not "theme"', async () => {
105+
const result = await applyTransform(
106+
transformer,
107+
`
108+
export const AnimatedContainer = styled.div<{ delay?: number }>(({ theme, delay = 0 }) => {
109+
return css\`
110+
animation: \${entry} \${makeMotionTime(paymentTheme.motion.duration['2xgentle'])}
111+
\${paymentTheme.motion.easing.exit.effective} forwards;
112+
animation-delay: \${delay}ms;
113+
opacity: 0;
114+
\`;
115+
});
116+
`,
117+
{ parser: 'tsx' },
118+
);
119+
120+
expect(result).toMatchInlineSnapshot(`
121+
"export const AnimatedContainer = styled.div<{ delay?: number }>(({ theme, delay = 0 }) => {
122+
return css\`
123+
animation: \${entry} \${makeMotionTime(paymentTheme.motion.duration['2xgentle'])}
124+
\${paymentTheme.motion.easing.exit} forwards;
125+
animation-delay: \${delay}ms;
126+
opacity: 0;
127+
\`;
128+
});"
129+
`);
130+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './migrate-motion';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { FileInfo } from 'jscodeshift';
2+
// eslint-disable-next-line import/extensions
3+
import * as tokenMapping from './motionTokenMapping.json';
4+
5+
const transformer = (file: FileInfo): string => {
6+
// Fairly simple usecases of motion tokens in razorpay files so this works.
7+
// .replace has also worked well during rebranding
8+
// eslint-disable-next-line no-useless-escape
9+
const newSource = file.source.replace(/motion\.easing\.[\w\.]+/g, (matchingToken) => {
10+
const match = Object.entries(tokenMapping).find(
11+
([oldToken, _newToken]) => oldToken === matchingToken,
12+
);
13+
14+
if (match) {
15+
return match[1];
16+
}
17+
18+
return matchingToken;
19+
});
20+
21+
return newSource;
22+
};
23+
24+
export default transformer;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"motion.easing.entrance.effective": "motion.easing.entrance",
3+
"motion.easing.standard.effective": "motion.easing.standard",
4+
"motion.easing.exit.effective": "motion.easing.exit",
5+
"motion.easing.entrance.revealing": "motion.easing.entrance",
6+
"motion.easing.standard.revealing": "motion.easing.emphasized",
7+
"motion.easing.exit.revealing": "motion.easing.exit",
8+
"motion.easing.entrance.attentive": "motion.easing.overshoot",
9+
"motion.easing.exit.attentive": "motion.easing.exit",
10+
"motion.easing.standard.wary": "motion.easing.shake"
11+
}

packages/blade/docs/guides/Installation.stories.mdx

+15-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import {
2222
Box,
2323
} from '../../src/components';
2424

25+
import MotionInstallation from '../../src/components/BaseMotion/docs/MotionInstallation.mdx';
26+
2527
<Meta title="Guides/Installation" />
2628

2729
# Installation
@@ -77,7 +79,8 @@ Before you install the package, make sure that you have performed the following
7779
<TabList>
7880
<TabItem value="basic">1. Basic Setup</TabItem>
7981
<TabItem value="fonts">2. Install Fonts</TabItem>
80-
<TabItem value="ts">3. TypeScript</TabItem>
82+
<TabItem value="motion">3. Setup Motion React</TabItem>
83+
<TabItem value="ts">4. TypeScript</TabItem>
8184
</TabList>
8285
</Box>
8386
<TabPanel value="basic">
@@ -90,7 +93,7 @@ Before you install the package, make sure that you have performed the following
9093
<Text>Blade has a few peer dependencies that you may already have installed in your project. If so, you can skip adding them again.</Text>
9194

9295
```shell
93-
yarn add @razorpay/blade [email protected] @razorpay/[email protected] @razorpay/[email protected]
96+
yarn add @razorpay/blade [email protected] @razorpay/[email protected] @razorpay/[email protected] [email protected]
9497
```
9598
<List>
9699
<ListItem>
@@ -248,6 +251,16 @@ Before you install the package, make sure that you have performed the following
248251
```
249252

250253
</TabPanel>
254+
255+
<TabPanel value="motion">
256+
<Heading size="large" marginTop="spacing.7">Add motion to your application</Heading>
257+
258+
Assuming you've followed the first step and installed `framer-motion` in your project, Here's how we recommend you to setup the project-
259+
260+
<MotionInstallation />
261+
262+
</TabPanel>
263+
251264
<TabPanel value="ts">
252265
<Heading size="large" marginY="spacing.7">TypeScript Setup</Heading>
253266

0 commit comments

Comments
 (0)