-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'razorpay:master' into master
- Loading branch information
Showing
322 changed files
with
13,052 additions
and
4,263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
...blade/codemods/migrate-motion-tokens/transformers/__tests__/migrate-motion-tokens.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import { applyTransform } from '@hypermod/utils'; | ||
import transformer from '..'; | ||
|
||
it('should update token for dashboard sidebar example', async () => { | ||
const result = await applyTransform( | ||
transformer, | ||
` | ||
export const SidebarContainer = styled.div<SidebarContainerProps>( | ||
({ theme, isRTUXHomepage, isVisible, isMobile }) => \` | ||
display: flex; | ||
flex-direction: column; | ||
position: fixed; | ||
top: 0; | ||
bottom: 0; | ||
background-color: \${ | ||
isRTUXHomepage | ||
? isMobile | ||
? theme.colors.surface.background.cloud.subtle | ||
: 'transparent' | ||
: '#2e3345' | ||
}; | ||
transform: translate(-100%,0); | ||
transition: transform \${makeMotionTime(theme.motion.delay.short)} \${ | ||
theme.motion.easing.standard.effective | ||
}; | ||
\`); | ||
`, | ||
{ parser: 'tsx' }, | ||
); | ||
|
||
expect(result).toMatchInlineSnapshot(` | ||
"export const SidebarContainer = styled.div<SidebarContainerProps>( | ||
({ theme, isRTUXHomepage, isVisible, isMobile }) => \` | ||
display: flex; | ||
flex-direction: column; | ||
position: fixed; | ||
top: 0; | ||
bottom: 0; | ||
background-color: \${ | ||
isRTUXHomepage | ||
? isMobile | ||
? theme.colors.surface.background.cloud.subtle | ||
: 'transparent' | ||
: '#2e3345' | ||
}; | ||
transform: translate(-100%,0); | ||
transition: transform \${makeMotionTime(theme.motion.delay.short)} \${ | ||
theme.motion.easing.standard | ||
}; | ||
\`);" | ||
`); | ||
}); | ||
|
||
it('should update token when used as prop', async () => { | ||
const result = await applyTransform( | ||
transformer, | ||
` | ||
function App() { | ||
const { theme } = useTheme(); | ||
return <Box easing={theme.motion.easing.standard.wary} /> | ||
} | ||
`, | ||
{ parser: 'tsx' }, | ||
); | ||
|
||
expect(result).toMatchInlineSnapshot(` | ||
"function App() { | ||
const { theme } = useTheme(); | ||
return <Box easing={theme.motion.easing.shake} /> | ||
}" | ||
`); | ||
}); | ||
|
||
it('should update token as used in X payroll', async () => { | ||
const result = await applyTransform( | ||
transformer, | ||
` | ||
export const AnimatedContainer = styled.div<{ delay?: number }>(({ theme, delay = 0 }) => { | ||
return css\` | ||
animation: \${entry} \${makeMotionTime(theme.motion.duration['2xgentle'])} | ||
\${theme.motion.easing.entrance.revealing} forwards; | ||
animation-delay: \${delay}ms; | ||
opacity: 0; | ||
\`; | ||
}); | ||
`, | ||
{ parser: 'tsx' }, | ||
); | ||
|
||
expect(result).toMatchInlineSnapshot(` | ||
"export const AnimatedContainer = styled.div<{ delay?: number }>(({ theme, delay = 0 }) => { | ||
return css\` | ||
animation: \${entry} \${makeMotionTime(theme.motion.duration['2xgentle'])} | ||
\${theme.motion.easing.entrance} forwards; | ||
animation-delay: \${delay}ms; | ||
opacity: 0; | ||
\`; | ||
});" | ||
`); | ||
}); | ||
|
||
it('should update token when variable name is not "theme"', async () => { | ||
const result = await applyTransform( | ||
transformer, | ||
` | ||
export const AnimatedContainer = styled.div<{ delay?: number }>(({ theme, delay = 0 }) => { | ||
return css\` | ||
animation: \${entry} \${makeMotionTime(paymentTheme.motion.duration['2xgentle'])} | ||
\${paymentTheme.motion.easing.exit.effective} forwards; | ||
animation-delay: \${delay}ms; | ||
opacity: 0; | ||
\`; | ||
}); | ||
`, | ||
{ parser: 'tsx' }, | ||
); | ||
|
||
expect(result).toMatchInlineSnapshot(` | ||
"export const AnimatedContainer = styled.div<{ delay?: number }>(({ theme, delay = 0 }) => { | ||
return css\` | ||
animation: \${entry} \${makeMotionTime(paymentTheme.motion.duration['2xgentle'])} | ||
\${paymentTheme.motion.easing.exit} forwards; | ||
animation-delay: \${delay}ms; | ||
opacity: 0; | ||
\`; | ||
});" | ||
`); | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/blade/codemods/migrate-motion-tokens/transformers/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './migrate-motion'; |
24 changes: 24 additions & 0 deletions
24
packages/blade/codemods/migrate-motion-tokens/transformers/migrate-motion.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { FileInfo } from 'jscodeshift'; | ||
// eslint-disable-next-line import/extensions | ||
import * as tokenMapping from './motionTokenMapping.json'; | ||
|
||
const transformer = (file: FileInfo): string => { | ||
// Fairly simple usecases of motion tokens in razorpay files so this works. | ||
// .replace has also worked well during rebranding | ||
// eslint-disable-next-line no-useless-escape | ||
const newSource = file.source.replace(/motion\.easing\.[\w\.]+/g, (matchingToken) => { | ||
const match = Object.entries(tokenMapping).find( | ||
([oldToken, _newToken]) => oldToken === matchingToken, | ||
); | ||
|
||
if (match) { | ||
return match[1]; | ||
} | ||
|
||
return matchingToken; | ||
}); | ||
|
||
return newSource; | ||
}; | ||
|
||
export default transformer; |
11 changes: 11 additions & 0 deletions
11
packages/blade/codemods/migrate-motion-tokens/transformers/motionTokenMapping.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"motion.easing.entrance.effective": "motion.easing.entrance", | ||
"motion.easing.standard.effective": "motion.easing.standard", | ||
"motion.easing.exit.effective": "motion.easing.exit", | ||
"motion.easing.entrance.revealing": "motion.easing.entrance", | ||
"motion.easing.standard.revealing": "motion.easing.emphasized", | ||
"motion.easing.exit.revealing": "motion.easing.exit", | ||
"motion.easing.entrance.attentive": "motion.easing.overshoot", | ||
"motion.easing.exit.attentive": "motion.easing.exit", | ||
"motion.easing.standard.wary": "motion.easing.shake" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ import { | |
Box, | ||
} from '../../src/components'; | ||
|
||
import MotionInstallation from '../../src/components/BaseMotion/docs/MotionInstallation.mdx'; | ||
|
||
<Meta title="Guides/Installation" /> | ||
|
||
# Installation | ||
|
@@ -77,7 +79,8 @@ Before you install the package, make sure that you have performed the following | |
<TabList> | ||
<TabItem value="basic">1. Basic Setup</TabItem> | ||
<TabItem value="fonts">2. Install Fonts</TabItem> | ||
<TabItem value="ts">3. TypeScript</TabItem> | ||
<TabItem value="motion">3. Setup Motion React</TabItem> | ||
<TabItem value="ts">4. TypeScript</TabItem> | ||
</TabList> | ||
</Box> | ||
<TabPanel value="basic"> | ||
|
@@ -90,7 +93,7 @@ Before you install the package, make sure that you have performed the following | |
<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> | ||
|
||
```shell | ||
yarn add @razorpay/blade [email protected] @razorpay/[email protected] @razorpay/[email protected] | ||
yarn add @razorpay/blade [email protected] @razorpay/[email protected] @razorpay/[email protected] [email protected] | ||
``` | ||
<List> | ||
<ListItem> | ||
|
@@ -248,6 +251,16 @@ Before you install the package, make sure that you have performed the following | |
``` | ||
|
||
</TabPanel> | ||
|
||
<TabPanel value="motion"> | ||
<Heading size="large" marginTop="spacing.7">Add motion to your application</Heading> | ||
|
||
Assuming you've followed the first step and installed `framer-motion` in your project, Here's how we recommend you to setup the project- | ||
|
||
<MotionInstallation /> | ||
|
||
</TabPanel> | ||
|
||
<TabPanel value="ts"> | ||
<Heading size="large" marginY="spacing.7">TypeScript Setup</Heading> | ||
|
||
|
Oops, something went wrong.