Skip to content

Commit cb3cecc

Browse files
committed
chore: sync with master
2 parents 57a5f46 + db5c906 commit cb3cecc

File tree

764 files changed

+44044
-9136
lines changed

Some content is hidden

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

764 files changed

+44044
-9136
lines changed

CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
/packages/blade/ @chaitanyadeorukhkar @kamleshchandnani @anuraghazra @snitin315 @saurabhdaware
1+
/packages/blade/ @chaitanyadeorukhkar @kamleshchandnani @anuraghazra @snitin315 @saurabhdaware @tewarig
22

CONTRIBUTING.md

Lines changed: 93 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Contributing guidelines for `blade`
22

3-
## Development setup
3+
## Local Development Setup
44

55
These steps should get you up and started for local development setup. Please ensure you've NodeJS and Yarn installed on your machine before proceeding.
66

@@ -22,7 +22,16 @@ These steps should get you up and started for local development setup. Please en
2222
yarn start:web
2323
```
2424

25-
- That's it!
25+
- That's it! You can access storybook on http://localhost:9009
26+
27+
### Setting up React Native
28+
29+
If you're contributing to React Native parts, you can follow the following setup.
30+
31+
You can skip it if you're contributing to web only component. Our [Component Status Page in Documentation](https://blade.razorpay.com/?path=/docs/guides-component-status--docs) mentions which components are react native supported and which are web only
32+
33+
<details>
34+
<summary><h4>React Native Local Development Setup</h4></summary>
2635

2736
### Setting up iOS
2837

@@ -38,13 +47,13 @@ These steps should get you up and started for local development setup. Please en
3847

3948
- Install [Xcode](https://reactnative.dev/docs/environment-setup#xcode).
4049

41-
> **Note**
50+
> [!Note]
4251
>
4352
> Sometimes it can take a very long time for Xcode to install. Check [here](https://apple.stackexchange.com/questions/427640/mac-app-store-xcode-download-stuck-at-installing) for troubleshooting.
4453
4554
- Install an iOS 13 simulator in Xcode: Xcode > Preferences > Platforms.
4655

47-
> **Note**
56+
> [!Note]
4857
>
4958
> Sometimes this can get stuck or take a very long time. Check [here](https://stackoverflow.com/questions/29058229/download-xcode-simulator-directly) for troubleshooting.
5059
@@ -56,7 +65,7 @@ These steps should get you up and started for local development setup. Please en
5665

5766
- Install pods. This can be done by running `pod install` in the `ios/` directory for Intel machine. For M1, things might not work out of box.
5867

59-
> **Note**
68+
> [!Note]
6069
>
6170
> Follow the note [here](https://reactnative.dev/docs/environment-setup#cocoapods) if you're using M1
6271
@@ -70,9 +79,9 @@ These steps should get you up and started for local development setup. Please en
7079
>
7180
> You don't need to build the app everytime (only when you're changing native dependencies), once the app is built you can just start the storybook server and open the app directly on your simulator
7281
73-
- If the stars aligned correctly, the storybook app should get installed and up and running on the simulator. If not, please refer to the official [guide](https://reactnative.dev/docs/environment-setup) for any deviations.
82+
- If the stars aligned correctly, the storybook app should get installed and up and running on the simulator. If not, please refer to the official [guide](https://reactnative.dev/docs/environment-setup) for any deviations.
7483

75-
*The storybook can take some time to open after simulator starts. Don't worry, it will start after few minutes (hopefully 🤞).*
84+
_The storybook can take some time to open after simulator starts. Don't worry, it will start after few minutes (hopefully 🤞)._
7685

7786
### Setting up Android
7887

@@ -93,28 +102,99 @@ These steps should get you up and started for local development setup. Please en
93102
yarn start:android
94103
```
95104

96-
> **Note**
105+
> [!Note]
97106
>
98107
> If you already have `yarn start:ios` running, you might have to close it since `yarn start:android` will try to run react-native server on the same port and fail with port taken error.
99-
>
108+
>
100109
> If you want to run both, android and ios at the same time, you can use `yarn start:native` instead.
101110
102-
> **Note**
111+
> [!Note]
103112
>
104113
> Make sure `$ANDROID_SDK_ROOT` is added before running the above command, you can run `echo $ANDROID_SDK_ROOT` in same terminal to confirm. (You can run `source ~/.zshrc` or `source ~/.bash_profile` depending on where you added the variables)
105114
106115
- If the stars aligned correctly, the storybook app should get installed and up and running on the emulator 🎉
107116

108-
## Tips
117+
> [!TIP]
118+
>
119+
> You can use `yarn start:all` command to run storybooks on all platforms like web, android, and ios (better to not use it in development though to avoid stressing your laptop)
120+
121+
</details>
122+
123+
## Codebase Terminologies and Structure
109124

110-
- You can use `yarn start:all` command to run storybooks on all platforms like web, android, and ios (better to not use it in development though to avoid stressing your laptop)
125+
### Base Component Terminology in Code
111126

112-
## TypeScript Guide
127+
We have some base components defined internally such as BaseInput, BaseButton, BaseText which act as a base for multiple exposed components.
128+
129+
E.g.
130+
131+
- Heading, Display, Text all use BaseText internally
132+
- TextInput, PasswordInput, SelectInput all use BaseInput internally
133+
- Majority of our components use BaseBox internally which is a more flexible version of the exposed Box component.
134+
135+
### Cross Platform Guide
136+
137+
You will see files with `.web.tsx` or `.native.tsx` syntax. The `.web.tsx` files end up in web bundle and `.native.tsx` files end up in react native bundle. You can define common logic in normal `.tsx` files which can be imported in both web and native files.
138+
139+
#### Cross Platform TypeScript Guide
113140

114141
[Writing Cross-Platform TypeScript In Blade](./rfcs/writing-cross-platform-typescript.md)
115142

143+
## Testing Changes
144+
145+
### Unit Tests
146+
147+
We have unit tests which you can run by running following commands
148+
149+
```sh
150+
cd packages/blade
151+
yarn test:react # web tests
152+
yarn test:react-native # native tests
153+
```
154+
155+
### Visual Tests
156+
157+
We also have visual tests that run on every PR. So if your PR changes / breaks a certain component, the diff will show up on chromatic checks of PR
158+
159+
<img width="822" alt="image" src="https://github.com/user-attachments/assets/35f6dfd8-ba64-4bc8-a15d-39a3476b6ae8">
160+
161+
### Interaction Tests
162+
163+
We support writing interaction tests using playwright. You can check example interaction tests of toast at [Toast.test.stories.tsx](./packages/blade/src/components/Toast/__tests__/Toast.test.stories.tsx). You can run these tests by visiting the Interaction Tests section in blade documentation E.g. [Toast Stacking Interaction Test on Documentation](https://blade.razorpay.com/?path=/story/components-interaction-tests-toast--toast-stacking)
164+
165+
## Editor Setup
166+
167+
- Make sure you have [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) installed and setup on your VSCode. This will guide you and autofix errors to keep the code consistent with this project's guidelines
168+
- Make sure you have [VSCode MDX](https://marketplace.visualstudio.com/items?itemName=JounQin.vscode-mdx) installed on your VSCode. This will help you with linting the markdown files if you're modifying or adding any `mdx` files for documentation purpose.
169+
- After installing this plugin navigate to your settings and add `mdx` extension to your `eslint` config. Below is how your settings will look after configuring `mdx` to work with eslint
170+
```json
171+
// .vscode/settings.json
172+
{
173+
"editor.codeActionsOnSave": {
174+
"source.fixAll.eslint": true
175+
},
176+
"eslint.options": {
177+
"extensions": [".js", ".jsx", ".md", ".mdx", ".ts", ".tsx"]
178+
},
179+
"eslint.validate": [
180+
"markdown",
181+
"mdx",
182+
"javascript",
183+
"javascriptreact",
184+
"typescript",
185+
"typescriptreact"
186+
]
187+
}
188+
```
189+
116190
## Troubleshooting guidelines
117191

118192
- VSCode auto imports can sometimes mess things up due to import aliases and `.web` / `.native` extensions. If something is breaking weirdly after adding / importing a new module this might be related
119193
- Ensure you're not using any `.web`, `.native` files directly in respective imports in `.web` / `.native` modules. For example, if you end up importing a `.web` module accidentally in a `.native` module, you might see a blank component being rendered or module not found error
120194
- If you forget to import types inside a `.d.ts` file, sometimes TS won't complain and it can throw the typecheck logic in other modules off
195+
196+
- `Blade requires "FRAMEWORK" environment variable to be set. Valid values are "REACT" and "REACT_NATIVE". Instead, received: undefined`
197+
198+
**Issue:** This is an issue that happens mostly if you run `yarn android` directly. For some reason `FRAMEWORK` doesn't gets passed to React Native application
199+
200+
**Fix:** If you come across this issue then you first run `yarn start` and then run `yarn android`.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
"publish-npm": "lerna run --scope @razorpay/blade publish-npm",
2222
"release": "lerna run --scope @razorpay/blade generate-github-npmrc && changeset publish",
2323
"build": "lerna run --scope @razorpay/blade build",
24-
"postinstall": "lerna run --scope eslint-plugin-blade build"
24+
"postinstall": "lerna run --scope eslint-plugin-blade build",
25+
"aicodemod:serve": "node packages/blade/codemods/aicodemod/server.mjs",
26+
"aicodemod:host": "npx localtunnel --port 3000 --subdomain blade-ds"
2527
},
2628
"dependencies": {},
2729
"devDependencies": {

packages/blade/.storybook/react-native/Storybook.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import './storybook.requires';
88

99
import { name as appName } from '../../app.json';
1010

11-
const App = (): React.ReactElement => {
11+
const App = () => {
1212
const Storybook = getStorybookUI({
1313
shouldPersistSelection: true,
1414
// keeping in comments becuase this is not documented properly in the docs

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

Lines changed: 36 additions & 19 deletions
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
@@ -50,7 +51,7 @@ export const parameters = {
5051
method: 'alphabetical',
5152
order: [
5253
'Guides',
53-
['Intro', 'Installation', 'Local Development', 'How to use?'],
54+
['Intro', 'Installation', 'Contributing', 'How to use?'],
5455
'Tokens',
5556
[
5657
'Colors',
@@ -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)',

0 commit comments

Comments
 (0)