@razorpay/blade 8.1.0 → 8.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md DELETED
@@ -1,1648 +0,0 @@
1
- # @razorpay/blade
2
-
3
- ## 8.1.0
4
-
5
- ### Minor Changes
6
-
7
- - 9f2dabfd: feat: add border support to Box component
8
-
9
- ## 8.0.0
10
-
11
- ### Major Changes
12
-
13
- - 9917a5cd: feat(Dropdown): Controlled Dropdown and Button Trigger
14
-
15
- - Adds API to seamlessly build controlled dropdown
16
- - Add DropdownButton component to trigger dropdown using Button
17
- - Removes `isDefaultSelected` from `ActionListItem` _(see migration guide below)_
18
-
19
- > **Warning**
20
- >
21
- > **Breaking change** for consumers who -
22
- >
23
- > - Use `isDefaultSelected` on `ActionListItem` component
24
- > - Use `onChange` on `SelectInput` (under some scenarios. Check migration guide below)
25
- >
26
- > Rest of the consumers can safely upgrade without any migration
27
-
28
- ### Migration Guide
29
-
30
- #### `isDefaultSelected` Migration
31
-
32
- We have removed `isDefaultSelected` from `<ActionListItem />` component. [Check out API decision](https://github.com/razorpay/blade/blob/master/packages/blade/src/components/Dropdown/_decisions/controlled-dropdown.md) for reasoning
33
-
34
- If you were using it as a workaround for controlled selection,
35
-
36
- - We now have a first class controlled selection support with `value` and `onChange` prop on `SelectInput`.
37
-
38
- Checkout CodeSandbox Example for new API - https://codesandbox.io/s/blade-controlled-select-vxg30b
39
-
40
- If you were using `isDefaultSelected` for default selections, you can now use `defaultValue` on SelectInput
41
-
42
- - Remove `isDefaultSelected` and use `defaultValue` on SelectInput. You can pass array of values to `defaultValue` in case of multiselect
43
- ```diff
44
- <Dropdown>
45
- <SelectInput
46
- label="Select City"
47
- + defaultValue="mumbai"
48
- />
49
- <DropdownOverlay>
50
- <ActionListItem
51
- title="Mumbai"
52
- value="mumbai"
53
- - isDefaultSelected
54
- />
55
- <ActionListItem title="Bangalore" value="bangalore" />
56
- </DropdownOverlay>
57
- </Dropdown>
58
- ```
59
-
60
- #### `onChange` on SelectInput Migration
61
-
62
- As a part of [bug fix](https://github.com/razorpay/blade/issues/1102), `onChange` will now **NOT** be called on initial render
63
- like it previously did. This will only require migration if you were earlier relying on `onChange` to set initial value.
64
-
65
- If you were relying on `onChange` to set initial value, you can now move those values to your `useState`'s initial value.
66
-
67
- ```tsx
68
- const Example = (): JSX.Element => {
69
- const [cities, setCities] = React.useState();
70
- return (
71
- <>
72
- <Dropdown>
73
- <SelectInput label="Cities" onChange={({values}) => setCities(values) } />
74
- <DropdownOverlay>
75
- <ActionListItem title="Mumbai" value="mumbai" />
76
- <ActionListItem title="Pune" value="pune" />
77
- </DropdownOverlay>
78
- </Dropdown>
79
- <Text>{cities}</Text>
80
- {/*
81
- In earlier versions, value of `cities` would've been `['']`
82
- (because onChange would've been called initially to set array with empty string value)
83
-
84
- Now it will output undefined (anything you pass in your useState) as the onChange wouldn't be called on initial render
85
- */}
86
- <>
87
- )
88
- }
89
- ```
90
-
91
- ## 7.2.2
92
-
93
- ### Patch Changes
94
-
95
- - 2a6b8c89: chore: add meta attribute `data-component-from-blade='true'` to native components
96
-
97
- ## 7.2.1
98
-
99
- ### Patch Changes
100
-
101
- - 40a16da7: fix(blade): BottomSheet body dynamic height
102
- - e0f80522: feat(blade): added bottomsheet component ids
103
-
104
- ## 7.2.0
105
-
106
- ### Minor Changes
107
-
108
- - 1333e756: feat(blade): added bottomsheet component
109
-
110
- > For react-native consumers make sure to [go through the installation guide](https://blade.razorpay.com/?path=/docs/guides-installation--page#-add-blade-to-your-application) on how to setup the peer dependencies
111
-
112
- <details>
113
- <summary>⚠️ Migration guide from prerelease version</summary>
114
-
115
- Update the imports:
116
-
117
- ```diff
118
- import {
119
- - BottomSheet_PRE_RELEASE,
120
- + BottomSheet,
121
- BottomSheetHeader,
122
- BottomSheetBody,
123
- BottomSheetFooter
124
- } from "@razorpay/blade/components"
125
- ```
126
-
127
- Changed Header Footer API:
128
-
129
- **Header**
130
-
131
- Prop changes:
132
-
133
- - Removed prefix/suffix props and added new props
134
-
135
- ```diff
136
- - title: string;
137
- + title?: string;
138
- subtitle?: string;
139
- - prefix?: React.ReactNode;
140
- - suffix?: React.ReactNode;
141
- + leading?: React.ReactNode;
142
- + trailing?: React.ReactNode;
143
- + titleSuffix?: React.ReactNode;
144
- + showBackButton?: boolean;
145
- + onBackButtonClick?: () => void;
146
- + closeButtonRef: React.MutableRefObject<any>;
147
- ```
148
-
149
- **Footer**
150
-
151
- Footer component now accepts JSX content
152
-
153
- Before:
154
-
155
- ```jsx
156
- <BottomSheetFooter
157
- trailing={{
158
- primary: {
159
- text: 'Hello',
160
- onClick: () => {},
161
- },
162
- secondary: {
163
- text: 'World',
164
- onClick: () => {},
165
- },
166
- }}
167
- />
168
- ```
169
-
170
- After:
171
-
172
- ```jsx
173
- <BottomSheetFooter>
174
- <Button isFullWidth variant="secondary" onClick={() => {}}>
175
- Hello
176
- </Button>
177
- <Button isFullWidth marginTop="spacing.5" onClick={() => {}}>
178
- World
179
- </Button>
180
- </BottomSheetFooter>
181
- ```
182
-
183
- </details>
184
-
185
- ## 7.1.3
186
-
187
- ### Patch Changes
188
-
189
- - 73011827: fix(BottomSheet): ensure that the BottomSheet's lower snappoint will have a buffer
190
- - f2130469: fix(blade): bottomsheet isOpen state, simplify isOpen logic & glue code
191
-
192
- Previously if users did not changed the isOpen state to false inside `onDismiss` the bottomsheet's internal state will still remain "open", but the bottomsheet would visually be hidden and the backdrop will still remain, this fixes the bug so that internally we won't modify the bottomsheet's position instead we will just call the `onDismiss`. [Check the loom](https://www.loom.com/share/f24fcb51b245431fbf1a0aeb53cea287) video here for more info.
193
-
194
- - 24d2a0b0: fix(cardFooter): alignment issue
195
-
196
- ## 7.1.2
197
-
198
- ### Patch Changes
199
-
200
- - 69ef5042: fix(blade): BottomSheet unable to scroll content
201
-
202
- ## 7.1.1
203
-
204
- ### Patch Changes
205
-
206
- - 85737340: fix(SelectInput): dropdown without label takes up margin space
207
-
208
- A dropdown without any label will now correctly take no extra space for the margin
209
-
210
- ## 7.1.0
211
-
212
- ### Minor Changes
213
-
214
- - 85289118: feat(blade): BottomSheet prerelease
215
-
216
- > **Warning**
217
- >
218
- > The final `BottomSheet` API isn't final and subjected to change as we work on stabilizing the component.
219
-
220
- ## 7.0.4
221
-
222
- ### Patch Changes
223
-
224
- - e3d5321c: perf(blade): integrate SectionList in ActionList
225
-
226
- ## 7.0.3
227
-
228
- ### Patch Changes
229
-
230
- - 6f7ec83f: fix(Box): add correct prop types in react native Box
231
- - abc4c156: fix(colors): incorrect value of ashGrayLight.1200
232
-
233
- There was a typo earlier in the value of the token.
234
-
235
- - fce1c767: feat(TextInput): add note on `type="number"` attribute
236
- - c0701725: fix: remove internal BaseBox export (no change for consumers)
237
-
238
- ## 7.0.2
239
-
240
- ### Patch Changes
241
-
242
- - 71b4a85b: feat: add `htmlTitle` prop support for Link component on web
243
-
244
- ## 7.0.1
245
-
246
- ### Patch Changes
247
-
248
- - 0f6e2ad7: fix: ref breakage on react native
249
- - 9963a7be: feat(package.json): add "main" field to package.json
250
-
251
- ## 7.0.0
252
-
253
- ### Major Changes
254
-
255
- - 5248ea66: feat(Typography): streamline typography scale
256
-
257
- > **Warning**
258
- >
259
- > Breaking Change!
260
- > This is a breaking change for typography components and lineHeight scale
261
- >
262
- > We have written codemod to ease this process so please follow the [migration guide thoroughly](#breaking-changes)
263
-
264
- ### Component Changes:
265
-
266
- - Title:
267
- - Added `xlarge` size
268
- - Text:
269
- - Added `large` size
270
- - Link:
271
- - Added `large` size
272
- - Code:
273
- - Added `weight=bold`
274
-
275
- ### Breaking Changes:
276
-
277
- - Title:
278
- - Replace all `large` size variants to `xlarge`
279
-
280
- ```diff
281
- - <Title size="large">hello world</Title>
282
- + <Title size="xlarge">hello world</Title>
283
- ```
284
-
285
- ***
286
-
287
- ### Line-height scale changes
288
-
289
- New scale has been changed to use numbered values for more flexibility, to read more about the changes [check this doc](https://docs.google.com/document/d/16j8dIKuQF9GjDgkhkZwnokVGNeoK7R-7zzIXHCgvveA/edit).
290
-
291
- #### **Migration guide:**
292
-
293
- Replace old named tokens to corresponding numbered values:
294
-
295
- For example:
296
-
297
- ```diff
298
- - theme.typography.lineHeights.s
299
- + theme.typography.lineHeights[50]
300
- ```
301
-
302
- **Old vs New mappings:**
303
-
304
- | old | new |
305
- | --- | --- |
306
- | s | 50 |
307
- | m | 50 |
308
- | l | 100 |
309
- | xl | 200 |
310
- | 2xl | 300 |
311
- | 3xl | 400 |
312
- | 4xl | 600 |
313
- | 5xl | 700 |
314
- | 6xl | 800 |
315
-
316
- #### **Migrate with Codemod:**
317
-
318
- To change all instances of `theme.typography.lineHeights` to the new scale automatically use this codemod:
319
-
320
- **Step1:** Install this version of blade
321
-
322
- **Step2:** Run the codemod with the following command
323
-
324
- > Checkout [jscodeshift docs](https://github.com/facebook/jscodeshift) for further cli usage help.
325
-
326
- ```sh
327
- npx jscodeshift ./YOUR_DIR --extensions=tsx,ts,jsx,js -t ./node_modules/@razorpay/blade/codemods/migrate-typography/transformers/migrate-typography.ts --ignore-pattern="**/node_modules/**"
328
- ```
329
-
330
- > **Note**
331
- >
332
- > This codemod will cover 80% of the usecases, but it might miss certain edge cases, it is advised to thoroughly test & check the code to ensure nothing is missed.
333
-
334
- ## 6.7.0
335
-
336
- ### Minor Changes
337
-
338
- - 0c8e5f1b: feat: add `Amount` component
339
-
340
- ### Usage
341
-
342
- ```tsx
343
- <Amount value={10000} />
344
- ```
345
-
346
- ## 6.6.3
347
-
348
- ### Patch Changes
349
-
350
- - 0d7bb723: fix(blade): FileTextIcon alignment
351
- - b62358cb: perf: improve dropdown/actionlist performance
352
-
353
- ## 6.6.2
354
-
355
- ### Patch Changes
356
-
357
- - c7c66051: fix: ListItemLink alignment
358
-
359
- ## 6.6.1
360
-
361
- ### Patch Changes
362
-
363
- - fe89e6f6: fix: tree-shaking in blade components
364
- - 7817c9e3: feat(Box): add different types for `display` on react native
365
- - c6512ba0: fix(Alert, Card): set `box-sizing` as `border-box` for Alert and Card
366
-
367
- ## 6.6.0
368
-
369
- ### Minor Changes
370
-
371
- - 5863f939: feat(OTPInput): add `onFocus` & `onBlur` props
372
- - 75daaa3c: feat(theme): add `name` property in `theme` to watch on theme changes
373
-
374
- ### Patch Changes
375
-
376
- - 6a8524ab: feat(Link): add `hitSlop` support for native
377
-
378
- ## 6.5.2
379
-
380
- ### Patch Changes
381
-
382
- - 2700667f: fix(SelectInput): call user passed onBlur callback
383
- - 3855a583: fix(Card): CardHeader title alignment when subtitle is not present
384
-
385
- ## 6.5.1
386
-
387
- ### Patch Changes
388
-
389
- - 86cd05a6: chore(blade): update meta constant of Box
390
-
391
- ## 6.5.0
392
-
393
- ### Minor Changes
394
-
395
- - a4be1b06: feat(Layout Primitives): Add `Box` Component and Styled Props to Blade Components
396
-
397
- Documentation: https://blade.razorpay.com/?path=/docs/components-layout-primitives-box-layout-primitives-tutorial--page
398
-
399
- **Breakpoint Token Changes**
400
-
401
- `max` breakpoint is removed as it wasn't used and had same value as `xl`.
402
- Through our audit, we didn't find any usage of this token. If you happen to use this somewhere, you can rename `breakpoints.max` to `breakpoints.xl`
403
-
404
- - 2c7034b7: feat(Input): add onSubmit prop on BaseInput, TextInput, TextArea, & PasswordInput for react-native
405
-
406
- ## 6.4.0
407
-
408
- ### Minor Changes
409
-
410
- - 4145d553: feat: add `testID` prop to all components
411
- - a7826b0b: feat(Input): add `autoCapitalize` support to `BaseInput`, `TextInput` & `PasswordInput`
412
- - bdd74d7a: feat(Text): add `textAlign` prop
413
-
414
- ### Patch Changes
415
-
416
- - da4489b3: fix: lodash tree shaking to reduce effective bundle-size.
417
-
418
- ## 6.3.0
419
-
420
- ### Minor Changes
421
-
422
- - a2518742: feat(icons): add BulkPayoutsIcon
423
-
424
- ## 6.2.3
425
-
426
- ### Patch Changes
427
-
428
- - cbb1424b: fix: change import to default in package exports
429
-
430
- Jest does not support the "import" condition in exports. This was causing tests to fail for Blade consumers. Changed "import" to "default" which is supported by all tools. Since Blade is not exporting a dual package, we don't need the "import" condition.
431
-
432
- ## 6.2.2
433
-
434
- ### Patch Changes
435
-
436
- - 559d97d9: feat: support string array in children
437
-
438
- Users can now use dynamic variables inside children and don't have to wrap it around with string literals
439
-
440
- ```jsx
441
- <Button onClick={}>{someVariable} hello</Button>
442
- ```
443
-
444
- ## 6.2.1
445
-
446
- ### Patch Changes
447
-
448
- - 7016c215: fix(Dropdown): infinite render onChange, positioning in flex container
449
-
450
- ## 6.2.0
451
-
452
- ### Minor Changes
453
-
454
- - bb2f1561: feat(Dropdown): Add `Dropdown`, `Select`, `ActionList`.
455
-
456
- Check out [Dropdown Story](https://blade.razorpay.com/?path=/docs/components-dropdown-with-select) for usage
457
-
458
- ### Patch Changes
459
-
460
- - 505ca975: fix(checkbox): fixed screen reader styles
461
-
462
- Fixed a bug where if we have lots of checkboxes in a small overflowed container the browser is trying to jump to the hidden inputs which is causing unexpected jumps in the scroll.
463
-
464
- ## 6.1.0
465
-
466
- ### Minor Changes
467
-
468
- - aff735ba: feat: add `List`, `ListItem`, `ListItemLink` & `ListItemCode` components
469
-
470
- ## 6.0.5
471
-
472
- ### Patch Changes
473
-
474
- - 38e8e6d0: chore(OTPInput): add `autoCompleteSuggestionType` prop and disable password manager with `isMasked`
475
-
476
- We wanted to disable the password managers for OTPInput when `isMasked` is set. The straightforward way to do this is set autocomplete='off' (i.e autoCompleteSuggestionType='none'). The issue with autocomplete is that its not an enforcement but a suggestion to the browser to follow. Safari mostly adheres to it but Chrome and Firefox ignores it and shows the password managers anyway. We decided on a workaround to unset `type` on first render and set it to `password` once a value is entered. This way the password managers won't make any suggestions when the user is on an empty OTP input field.
477
-
478
- ## 6.0.4
479
-
480
- ### Patch Changes
481
-
482
- - 26ffc564: fix: add types field to package exports for ESM TypeScript projects
483
-
484
- ## 6.0.3
485
-
486
- ### Patch Changes
487
-
488
- - c95e814a: chore(blade): fix dependabot alerts
489
- - d2cfab2d: fix(blade): checkbox icon wrapper position
490
-
491
- Fixed a bug in checkbox where the checkbox icon was flaoting outside it's wrapper because we've added `position: absolute` in the FadeIn animation component but forgot to add `position: relative` in the parent wrapper.
492
-
493
- ## 6.0.2
494
-
495
- ### Patch Changes
496
-
497
- - ba5ec1ac: fix: mark react-native peerDependencies as optional
498
- - 4a178a79: fix(Alert): color of title and description
499
-
500
- - The color of title and description will look slightly subtle now to match the current designs.
501
- - Internally uses the `subtle` type correctly now to fix a discrepancy in color for title and description.
502
-
503
- ## 6.0.1
504
-
505
- ### Patch Changes
506
-
507
- - 62a98bb1: fix(blade): update BaseInput background color
508
-
509
- ## 6.0.0
510
-
511
- ### Major Changes
512
-
513
- - 980bc038: fix(Alert)!: fix typo in prop `isDismissible`
514
-
515
- > **Warning**
516
- >
517
- > Breaking change. Update prop `isDismissable` to `isDismissible`.
518
-
519
- ### Migration guide
520
-
521
- Find and replace:
522
-
523
- ```diff
524
- <Alert
525
- - isDismissable
526
- + isDismissible
527
- />
528
- ```
529
-
530
- - 5f7e4876: feat(blade): added all icons from figma
531
-
532
- **Breaking Changes:**
533
-
534
- - Renamed `RefreshLeft` icon to `Refresh`
535
-
536
- ### Minor Changes
537
-
538
- - 82d75b71: chore(blade): added new icons
539
- - 29238f1e: feat(blade): added ref support for input components
540
-
541
- ## 5.5.1
542
-
543
- ### Patch Changes
544
-
545
- - 735e370: fix(blade): update peerDependencies to support react v18
546
-
547
- ## 5.5.0
548
-
549
- ### Minor Changes
550
-
551
- - a094736: feat: expose `onFocus` on `TextInput` and `TextArea`
552
- - 2c2841a: added transaction icon
553
- - 46425d3: feat(blade): add ClockIcon
554
- - 1dd920e: feat(Icons): add BankIcon
555
- - 227be3d: added tag, shuffle, user, book, and settlements icons
556
- - e64d7cc: chore: design changes for Badge, Counter, Spinner
557
-
558
- ### Patch Changes
559
-
560
- - ba16503: fix(blade): TextInput clear button state on initial render
561
-
562
- ## 5.4.3
563
-
564
- ### Patch Changes
565
-
566
- - e6c3ea9: fix(blade): restrict childrens in Card component
567
-
568
- ## 5.4.2
569
-
570
- ### Patch Changes
571
-
572
- - da470b0: fix: remove `maxWidth` from Badge
573
-
574
- ## 5.4.1
575
-
576
- ### Patch Changes
577
-
578
- - 7eb6e4c: feat(Code): Use alpha 50 token in Code component's background
579
-
580
- ## 5.4.0
581
-
582
- ### Minor Changes
583
-
584
- - 5c8005f: feat: add `ProgressBar` component
585
-
586
- ## 5.3.0
587
-
588
- ### Minor Changes
589
-
590
- - 26baa81: feat(blade): added Card component
591
-
592
- ## 5.2.1
593
-
594
- ### Patch Changes
595
-
596
- - 9966931: chore: fix dom nesting in form label component
597
- - e660831: fix: change acceptable BaseInput `type` from `numeric` to `number`
598
-
599
- ## 5.2.0
600
-
601
- ### Minor Changes
602
-
603
- - d03de10: feat(Alert): update `isFullWidth` to make inline borderless alerts on desktop
604
-
605
- > **Warning**
606
- >
607
- > `isBorderless` prop is removed and its usage is now replaced by `isFullWidth`. The layout is updated to match the designs and is now centered on desktop resolutions.
608
-
609
- ### Steps for migration:
610
-
611
- ```diff
612
- <Alert
613
- - isBorderless
614
- + isFullWidth
615
- />
616
- ```
617
-
618
- ## 5.1.5
619
-
620
- ### Patch Changes
621
-
622
- - 756f4b4: feat: allow masked otp input
623
-
624
- `OTPInput` now supports an `isMasked` prop
625
-
626
- ## 5.1.4
627
-
628
- ### Patch Changes
629
-
630
- - 71f274e: fix(Checkbox): allow Checkbox to accept `childern` prop of type `React.ReactNode`
631
-
632
- ## 5.1.3
633
-
634
- ### Patch Changes
635
-
636
- - af9bdc9: fix(Alert): responsive design alignment
637
-
638
- ## 5.1.2
639
-
640
- ### Patch Changes
641
-
642
- - bd0b675: chore(blade): added blade component data attributes
643
-
644
- ## 5.1.1
645
-
646
- ### Patch Changes
647
-
648
- - 5a6b980: feat: add Mail icon
649
-
650
- ## 5.1.0
651
-
652
- ### Minor Changes
653
-
654
- - d4b981e: fix: show `Spinner` on `TextInput` when `isLoading=true`
655
- - Adds spinner when `isLoading: true` is passed to `TextInput`. This was a long pending TODO
656
- - Update Spinner sizes after the design was updated \* This doesn't need any code mod since there are 9 instances of spinner being used with default variant i.e medium
657
-
658
- ## 5.0.1
659
-
660
- ### Patch Changes
661
-
662
- - 96cf25f: feat: add new icons (lock, settings, file-text, users, slash)
663
-
664
- ## 5.0.0
665
-
666
- ### Major Changes
667
-
668
- - fc2a3bf:
669
-
670
- > **Warning**
671
- >
672
- > This is a breaking change for `Alert` component. The UI is updated to match the designs.
673
-
674
- feat(Alert): design revamp
675
-
676
- - `Alert` is updated to match the new designs
677
- - Bordered variant is now more compact and smaller in size
678
- - A new `neutral` intent is added. This is the new default if you haven't passed any `intent` explicitly.
679
-
680
- ### Migration guide for consumers
681
-
682
- - Earlier the default `intent` was `information`, this is now updated to `neutral`. If you were earlier using alerts without explicitly passing `intent` you should update that to continue using `information` as intent:
683
-
684
- ```diff
685
- <Alert
686
- + intent="information"
687
- />
688
- ```
689
-
690
- ### Patch Changes
691
-
692
- - bb170bb: fix: set input type='text' when type='search' passed
693
-
694
- ## 4.0.0
695
-
696
- ### Major Changes
697
-
698
- - d747de4: chore: Badge design changes
699
-
700
- - Adds a new small size
701
- - Bumps existing small & medium to medium & large respectively
702
- - Horizontal padding changes in the large size
703
-
704
- ### Migration Guide for Badge Consumers
705
-
706
- 1. For existing `small` size badge, bump the size from `small` to `medium`
707
-
708
- ```diff
709
- - <Badge size='small'>...</Badge>
710
- + <Badge size='medium'>...</Badge>
711
- ```
712
-
713
- 2. For existing `medium` size badge, bump the size from `medium` to `large`
714
-
715
- ```diff
716
- - <Badge size='medium'>...</Badge>
717
- + <Badge size='large'>...</Badge>
718
- ```
719
-
720
- 3. For existing badge with no `size` specified, add `size='large'` since default size is `medium`
721
- > Note: The horizontal padding is changed from `8px` to `12px` for the new `large` size which makes it visually bigger than the existing `medium` size
722
-
723
- ```diff
724
- - <Badge>...</Badge>
725
- + <Badge size='large'>...</Badge>
726
- ```
727
-
728
- ## 3.8.0
729
-
730
- ### Minor Changes
731
-
732
- - 32c1f05: feat(Counter): design changes
733
-
734
- - Added small variant in Counter
735
- - Fixed italic font
736
-
737
- ## 3.7.1
738
-
739
- ### Patch Changes
740
-
741
- - 03bb818: feat(tokens): add new tokens
742
- - updates color tokens of banking theme to match the designs
743
- - 002e0a2: feat(tokens): add new tokens
744
- - Updates tokens for payment theme to match the designs
745
- - 66f473e: fix: remove aria-hidden for checkbox and radio
746
-
747
- ## 3.7.0
748
-
749
- ### Minor Changes
750
-
751
- - 67e5059: feat(Indicator): add Indicator component
752
-
753
- ## 3.6.2
754
-
755
- ### Patch Changes
756
-
757
- - 63c950a: feat(IconButton): export IconButton
758
- - Adds a new `IconButton` component useful for making transparent icon only buttons
759
-
760
- ## 3.6.1
761
-
762
- ### Patch Changes
763
-
764
- - add9b3e: fix(Typography): inherit `text-align` property from parent in Typography components
765
-
766
- ## 3.6.0
767
-
768
- ### Minor Changes
769
-
770
- - 0f4df3a: feat(blade): added counter component
771
- - c5b28bc: feat(tokens): add new tokens to neutral palette
772
-
773
- ## 3.5.3
774
-
775
- ### Patch Changes
776
-
777
- - 92cfa80: fix(Alert): throw error if `secondaryAction` is defined without `primaryAction`
778
-
779
- ## 3.5.2
780
-
781
- ### Patch Changes
782
-
783
- - ffe9872: fix: `@babel-runtime` issues when importing in codesandbox and vite
784
-
785
- ## 3.5.1
786
-
787
- ### Patch Changes
788
-
789
- - dea879d: fix(IconButton): add `type="button"` to stop form submission
790
-
791
- ## 3.5.0
792
-
793
- ### Minor Changes
794
-
795
- - 8dc131d: feat(blade): added `small` variant in Checkbox/Radio
796
-
797
- ## 3.4.2
798
-
799
- ### Patch Changes
800
-
801
- - 48c36af: feat: add README to npm
802
-
803
- ## 3.4.1
804
-
805
- ### Patch Changes
806
-
807
- - 49894f2: feat: adding Link icon
808
-
809
- ## 3.4.0
810
-
811
- ### Minor Changes
812
-
813
- - 6429d93: feat(Link): add `size` prop and support for `small` size
814
-
815
- > **Note**
816
- >
817
- > Icons in links are slightly bumped up now to match the designs
818
-
819
- <img width="379" alt="image" src="https://user-images.githubusercontent.com/6682655/196698626-e73dcc07-3d35-49e1-8ead-95c5826f3c41.png">
820
-
821
- ## 3.3.0
822
-
823
- ### Minor Changes
824
-
825
- - 37c00c0: feat: publish `@razorpay/blade` package on NPM
826
-
827
- _No changes are required for consumer. We will be publishing on both, github package registry and npm._
828
-
829
- ## 3.2.0
830
-
831
- ### Minor Changes
832
-
833
- - f7e8941: added RotateCounterClockWiseIcon, TrendingUpIcon, TrendingDownIcon, ExternalLinkIcon, HelpCircleIcon
834
-
835
- ## 3.1.6
836
-
837
- ### Patch Changes
838
-
839
- - 66d3184: Update few tokens value which was typo on figma
840
-
841
- ## 3.1.5
842
-
843
- ### Patch Changes
844
-
845
- - a539fe5: feat(tokens): add new tokens
846
-
847
- ## 3.1.4
848
-
849
- ### Patch Changes
850
-
851
- - f0b901d: chore: remove border from Badge component
852
-
853
- ## 3.1.3
854
-
855
- ### Patch Changes
856
-
857
- - 2576ce3: fix(link): add type prop for button variant
858
-
859
- ## 3.1.2
860
-
861
- ### Patch Changes
862
-
863
- - ba0c74d: fix: use the correct maxWidth for OTPInput
864
-
865
- ## 3.1.1
866
-
867
- ### Patch Changes
868
-
869
- - aee7e57: feat(Icons): add MinusIcon
870
-
871
- ## 3.1.0
872
-
873
- ### Minor Changes
874
-
875
- - c3d9d2f: feat: add OTPInput component
876
-
877
- ## 3.0.0
878
-
879
- ### Major Changes
880
-
881
- - 3aebc58: feat(Typography): make `size` prop consistent for `Heading`, `Title`, and `Text`
882
-
883
- > **Warning**
884
- >
885
- > Breaking Change!
886
- > This is a breaking change for apps that are using `Title` or `Heading` component from blade. Rest of the apps can upgrade without any migrations.
887
-
888
- #### Migration
889
-
890
- _**Tip:** If you're using TypeScript, run `yarn tsc` and that should throw errors wherever a change is required._
891
-
892
- 1. **`<Title />`:** Rename `variant` prop to `size` in Title
893
-
894
- ```diff
895
- - <Title variant="small">Some Title</Title>
896
- + <Title size="small">Some Title</Title>
897
- ```
898
-
899
- 2. **`<Heading />`:** Rename `variant` prop to `size` if the value is `small`, `medium,` or `large`. No change is required on `variant="subheading"`.
900
-
901
- ```diff
902
- <Heading variant="subheading">Nothing changes here</Heading> // No change here
903
-
904
- - <Heading variant="medium">Medium Heading</Heading>
905
- + <Heading size="medium">Medium Heading</Heading>
906
- ```
907
-
908
- ##### Edge Cases
909
-
910
- Make sure to follow migration on new component if `Title` or `Heading` from blade is overriden with styled-components.
911
-
912
- ```diff
913
- const MyTitle = styled(Title)`
914
- // some styles
915
- `
916
-
917
- - <MyTitle variant="large" />
918
- + <MyTitle size="large" />
919
- ```
920
-
921
- - e16c154: feat(PasswordInput)!: rename from `PasswordField` to `PasswordInput`
922
-
923
- #### Migration
924
-
925
- > **Warning**
926
- >
927
- > Breaking change!
928
-
929
- Rename occurences of `PasswordField` to `PasswordInput`, no changes in the API.
930
-
931
- ```diff
932
- - PasswordField
933
- + PasswordInput
934
- ```
935
-
936
- ### Minor Changes
937
-
938
- - eeba339: feat(Code): add `<Code />` component :shipit:
939
-
940
- ## 2.5.1
941
-
942
- ### Patch Changes
943
-
944
- - 0ce8390: fix(BaseInput): use cursor not-allowed for disabled inputs
945
-
946
- ## 2.5.0
947
-
948
- ### Minor Changes
949
-
950
- - d0017cd: feat(PasswordField): add final export :tada:
951
- - adds a new `PasswordField` component
952
-
953
- ## 2.4.0
954
-
955
- ### Minor Changes
956
-
957
- - bf92637: feat(blade): Improve platform types with TS 4.7
958
-
959
- ### Added support for platform dependant types
960
-
961
- Migration Steps
962
-
963
- 1. Upgrade to TypeScript 4.7+
964
- 2. In `tsconfig.json` add `moduleSuffix: ['.web', '']` or `moduleSuffix: ['.native', '']` (depending on the platform)
965
-
966
- ```js
967
- {
968
- "compilerOptions": {
969
- // For react-native use `.native`
970
- // For web use `.web` extension
971
- "moduleSuffixes": [".web", ""]
972
- }
973
- }
974
- ```
975
-
976
- > **Note**:
977
- > if you are on <TS 4.7 or don't specify the `moduleSuffixes` blade will fallback to resolving `web` types
978
-
979
- ## 2.3.0
980
-
981
- ### Minor Changes
982
-
983
- - 887cd11: feat(blade): added TextArea component
984
-
985
- ## 2.2.2
986
-
987
- ### Patch Changes
988
-
989
- - a8c5c08: tests: add tests for `TextInput`
990
- fix: render clear button on mount when the `defaultValue` or `value` is passed
991
-
992
- ## 2.2.1
993
-
994
- ### Patch Changes
995
-
996
- - 4b6bfda: fix: update spinner easing
997
-
998
- ## 2.2.0
999
-
1000
- ### Minor Changes
1001
-
1002
- - 7c272be: feat: add `Spinner` component
1003
- - Also adds an internal `BaseSpinner` component
1004
-
1005
- ## 2.1.0
1006
-
1007
- ### Minor Changes
1008
-
1009
- - a6bf780: feat(TextInput): add TextInput Field
1010
-
1011
- ### This release publishes **`TextField`** Input
1012
-
1013
- #### [Figma Link](https://www.figma.com/file/jubmQL9Z8V7881ayUD95ps/Blade---Payment-Light?node-id=10953%3A210737)
1014
-
1015
- #### Capabilities
1016
-
1017
- - Support for various `type` of TextInput i.e `'text' | 'telephone' | 'email' | 'url' | 'numeric' | 'search'`
1018
- - Automatically decide `keyboardType`, `keyboardReturnKeyType`, `autoCompleteSuggestionType` based on `type` attribute alone
1019
-
1020
- ![image](https://user-images.githubusercontent.com/11384858/188391913-d45e40b4-1b92-4fab-8bf8-8d49891929f8.png)
1021
-
1022
- - Max characters to be accepted by the input field which will in turn also render a counter
1023
- ![image](https://user-images.githubusercontent.com/11384858/188390436-2854807d-5fb0-42de-8171-3ba61be4b9f6.png)
1024
-
1025
- - Clear the content of the input field with the help of a clear button
1026
- ![image](https://user-images.githubusercontent.com/11384858/188391183-8e262200-7424-4a80-a5fe-1c7166be26ce.png)
1027
-
1028
- - Attach `prefix` and `suffix` to the input field
1029
- - Fully Accessible
1030
-
1031
- ### Patch Changes
1032
-
1033
- - a8c7620: ## Internal changes
1034
-
1035
- tests(BaseInput): add web tests and fix onBlur
1036
-
1037
- - Adds `onBlur`
1038
-
1039
- - 1417e90: changed native text-input helptext color
1040
-
1041
- ## 2.0.0
1042
-
1043
- ### Major Changes
1044
-
1045
- - cc4355a: feat(blade): added 2px spacing token
1046
-
1047
- #### Breaking changes
1048
-
1049
- > **Note**
1050
- >
1051
- > This breaking change affects you only if you're using the tokens directly somewhere. If you're only using the components then nothing needs to be updated at your end.
1052
-
1053
- - Added 2px token, thus all spacing tokens have shifted by 1 step.
1054
-
1055
- #### Migration steps
1056
-
1057
- Shift every spacing token other than the first one (`0th` index) by +1
1058
-
1059
- ```diff
1060
- - <div style={{ margin: theme.spacing[1] }} />
1061
- + <div style={{ margin: theme.spacing[2] }} />
1062
- ```
1063
-
1064
- ### Patch Changes
1065
-
1066
- - a402ef1: feat(icons): add `RefreshLeft` icon
1067
-
1068
- ## 1.1.0
1069
-
1070
- ### Minor Changes
1071
-
1072
- - 5f1033c: feat: add `Alert` component :tada:
1073
-
1074
- ### Patch Changes
1075
-
1076
- - cd5f61f: feat(tokens): add new tokens
1077
- - e8d932a: feat: add `blue` variant to `Badge`
1078
- - acfd566: feat(icons): arrow up and arrow left
1079
-
1080
- ## 1.0.2
1081
-
1082
- ### Patch Changes
1083
-
1084
- - 771981c: fix(blade): radio & checkbox icon alignment
1085
-
1086
- ## 1.0.1
1087
-
1088
- ### Patch Changes
1089
-
1090
- - ef7f459: fix: font weight of `Link` component
1091
-
1092
- ## 1.0.0
1093
-
1094
- ### Major Changes
1095
-
1096
- - 51a6787: feat: add `Radio` & `RadioGroup` component
1097
-
1098
- ## ⚠️ Breaking change for `Checkbox`
1099
-
1100
- - We've renamed the `neccessityIndicator` prop to `necessityIndicator` to fix a spelling error
1101
-
1102
- - 65834be: fix: icon sizes for `Icon`, `IconButton`, `Button`, `Link` & `Spinner` components
1103
-
1104
- ## ⚠️ Breaking changes for `Icon`
1105
-
1106
- **❗️This version introduces a breaking change for the `Icon` component's `size` prop**
1107
-
1108
- Earlier, the `size` prop had the following size to pixel mapping:
1109
-
1110
- - **xxsmall:** 10px
1111
- - **xsmall**: 12px
1112
- - **small**: 16px
1113
- - **medium**: 20px
1114
- - **large**: 24px
1115
- - **xlarge**: 32px
1116
-
1117
- Now, the correct `size` prop will have the following size to pixel mapping:
1118
-
1119
- - **xsmall**: 8px
1120
- - **small**: 12px
1121
- - **medium**: 16px
1122
- - **large**: 20px
1123
- - **xlarge**: 24px
1124
- - **2xlarge**: 32px
1125
-
1126
- > ⚠️ `xxsmall` is not an accepted value anymore. Instead, we have a new acceptable value of `2xlarge`.
1127
-
1128
- ### Minor Changes
1129
-
1130
- - 61a17fe: feat: add `Badge` component
1131
-
1132
- ## 0.13.6
1133
-
1134
- ### Patch Changes
1135
-
1136
- - b365464: fix: button spinner layout
1137
- - f3abfbe: feat(Icons): add new icons
1138
-
1139
- ## 0.13.5
1140
-
1141
- ### Patch Changes
1142
-
1143
- - 7909d7c: fix(blade): Checkbox design changes
1144
-
1145
- ## 0.13.4
1146
-
1147
- ### Patch Changes
1148
-
1149
- - 2778973: chore: add appropriate types for onClick of Button & BaseButton
1150
-
1151
- ## 0.13.3
1152
-
1153
- ### Patch Changes
1154
-
1155
- - 3ea6d6c: fix(blade): fixes checkbox helptext and errortext alignment for individual checkboxes
1156
-
1157
- ## 0.13.2
1158
-
1159
- ### Patch Changes
1160
-
1161
- - 17b2c71: fix: button styling for native
1162
-
1163
- ## 0.13.1
1164
-
1165
- ### Patch Changes
1166
-
1167
- - 985f82a: refactor: use Box component on BaseButton
1168
-
1169
- ## 0.13.0
1170
-
1171
- ### Minor Changes
1172
-
1173
- - b8cc7df: feat: add checkbox component
1174
- - eb65c30: feat: add support for css theme variables
1175
- - f61675e: feat: add `Link` & `BaseLink` components
1176
-
1177
- ## 0.12.0
1178
-
1179
- ### Minor Changes
1180
-
1181
- - 381e9c7: fix(Blade): add `size` prop to Text component and update tokens
1182
-
1183
- This PR updates the typography tokens scale for mobile devices to create better visual hierarchy which we received as feedback from other teams as well.
1184
-
1185
- It also adds a new `size` prop to `Text` component for `variant='body'`
1186
-
1187
- ## 0.11.4
1188
-
1189
- ### Patch Changes
1190
-
1191
- - 66f9b24: feat(tokens): add new tokens
1192
-
1193
- ## 0.11.3
1194
-
1195
- ### Patch Changes
1196
-
1197
- - e0a2631: feat: add Download, Edit, History, Plus, Pause, & Trash icons
1198
-
1199
- ## 0.11.2
1200
-
1201
- ### Patch Changes
1202
-
1203
- - b2b86b4: fix: SkipNav export
1204
-
1205
- ## 0.11.1
1206
-
1207
- ### Patch Changes
1208
-
1209
- - 873676f: fix: button export to components
1210
-
1211
- ## 0.11.0
1212
-
1213
- ### Minor Changes
1214
-
1215
- - 5d022f4: feat: add `Button` component
1216
-
1217
- ### Patch Changes
1218
-
1219
- - cddd298: chore: update currency icons
1220
-
1221
- ## 0.10.1
1222
-
1223
- ### Patch Changes
1224
-
1225
- - 7b9baf7: fix(blade): broken gray color types in theme.d.ts file
1226
-
1227
- ## 0.10.0
1228
-
1229
- ### Minor Changes
1230
-
1231
- - a800a96: feat(blade): added makeAccessible function
1232
-
1233
- makeAccessible function is a compatibility layer between web & native for accessibility props
1234
- More [info in RFC](https://github.com/razorpay/blade/blob/master/rfcs/2022-04-09-accessibility.md#platform-specific-implementation--5)
1235
-
1236
- ### Patch Changes
1237
-
1238
- - a800a96: fix(blade): added aria hidden in icons
1239
-
1240
- ## 0.9.0
1241
-
1242
- ### Minor Changes
1243
-
1244
- - 0c3a951: feat(blade): Added SkipNav component
1245
-
1246
- Learn more about [Skip Navigations in Accessibility RFC](https://github.com/razorpay/blade/blob/master/rfcs/2022-04-09-accessibility.md#skip-navigations)
1247
-
1248
- - 5c750bb: feat(blade): add VisuallyHidden component
1249
-
1250
- This component is used specifically when you want to hide certain things visually for people who are not visually impaired but also want to make your content is accessible to visually impaired people via assistive technologies.
1251
-
1252
- You can play around with it on [Storybook](https://master--61c19ee8d3d282003ac1d81c.chromatic.com/?path=/docs/components-accessibility-visuallyhidden--visually-hidden)
1253
-
1254
- ## 0.8.0
1255
-
1256
- ### Minor Changes
1257
-
1258
- - 002fce2: fix: icon colors & remove `surface.action.icon.link.*` colors from `theme`
1259
-
1260
- ## Breaking Changes
1261
-
1262
- - Remove the following tokens from `paymentTheme` & `bankingTheme` theme of Blade:
1263
-
1264
- - `colors.surface.action.icon.link.default.lowContrast`
1265
- - `colors.surface.action.icon.link.default.highContrast`
1266
- - `colors.surface.action.icon.link.hover.lowContrast`
1267
- - `colors.surface.action.icon.link.hover.highContrast`
1268
- - `colors.surface.action.icon.link.focus.lowContrast`
1269
- - `colors.surface.action.icon.link.focus.highContrast`
1270
- - `colors.surface.action.icon.link.active.lowContrast`
1271
- - `colors.surface.action.icon.link.active.highContrast`
1272
- - `colors.surface.action.icon.link.disabled.lowContrast`
1273
- - `colors.surface.action.icon.link.disabled.highContrast`
1274
-
1275
- If you are using any of these tokens, they will no longer be available in your `theme`. Make sure you remove usage of these tokens from your codebase.
1276
-
1277
- ## Fixes
1278
-
1279
- 1. Fix incorrect Icon colors that were supported & suggested by TypeScript
1280
-
1281
- ## 0.7.2
1282
-
1283
- ### Patch Changes
1284
-
1285
- - 9f0bb83: feat: add Dollar, ChevronUp, ChevronDown, ChevronLeft, ChevronRight, Eye, EyeOff, Close icons
1286
-
1287
- ## 0.7.1
1288
-
1289
- ### Patch Changes
1290
-
1291
- - 25a7b89: fix(blade): add contrast prop to Typography components
1292
-
1293
- Add `contrast` prop to all the Typography components so that consumers can change the intent to grab the attention towards the text. The possible values for `contrast` are `high` or `low` and accordingly the color token will be used to set the color of the Typography components
1294
-
1295
- ## 0.7.0
1296
-
1297
- ### Minor Changes
1298
-
1299
- - 52efedb: fix(blade): set defaults for all typography components
1300
-
1301
- Make all the props optional to have a better DX and add default values for all the important props
1302
-
1303
- ## 0.6.0
1304
-
1305
- ### Minor Changes
1306
-
1307
- - e352eef: fix(blade): add `Heading` component
1308
-
1309
- ## 0.5.0
1310
-
1311
- ### Minor Changes
1312
-
1313
- - 75882a7: feat(Blade): add `Title`component
1314
-
1315
- The API for `Title` component can be found under [Typography/Text/\_decisions](https://github.com/razorpay/blade/blob/master/packages/blade/src/components/Typography/_decisions/decisions.md)
1316
-
1317
- ## 0.4.0
1318
-
1319
- ### Minor Changes
1320
-
1321
- - 294173e: - Add the following components that would act as building blocks for our icons:
1322
- 1. `Svg`
1323
- 2. `Path`
1324
- 3. `Rect`
1325
- 4. `Defs`
1326
- 5. `ClipPath`
1327
- 6. `G`
1328
- - Add `CreditCardIcon` component
1329
- - Add `RupeeIcon` component
1330
-
1331
- ### Patch Changes
1332
-
1333
- - e76cd01: feat/add-text-component
1334
-
1335
- ## 0.3.0
1336
-
1337
- ### Minor Changes
1338
-
1339
- - a20b608: feat(blade): add motion tokens
1340
-
1341
- ### Motion tokens
1342
-
1343
- We have added tokens for
1344
-
1345
- 1. Delay
1346
- 2. Duration
1347
- 3. Easing
1348
-
1349
- You can find a detailed RFC for motion here: [View Formatted RFC](https://github.com/razorpay/blade/blob/rfc/2022-03-22-motion-rfc/rfcs/2022-03-22-motion-rfc.md)
1350
-
1351
- ## 0.2.0
1352
-
1353
- ### Minor Changes
1354
-
1355
- - 6885ac3: feat(blade): add BaseText component
1356
-
1357
- ## 0.1.6
1358
-
1359
- ### Patch Changes
1360
-
1361
- - 33e3930: feat(blade): add listener for toggling breakpoints
1362
-
1363
- **Updates**
1364
-
1365
- - Add `breakpoints` token to the themes.
1366
- - Out of the box responsiveness support for typography tokens.
1367
- - Publish `useBreakpoint` hook.
1368
- - Following breakpoints are supported as of today.
1369
- ```
1370
- /** max width: 320px */
1371
- xs: 320;
1372
- /** min width: 321px and max width: 480px */
1373
- s: 480;
1374
- /** min width: 481px and max width: 768px */
1375
- m: 768;
1376
- /** min width: 769 and max width: 1024px */
1377
- l: 1024;
1378
- /** min width: 1025 and max width: 1200px */
1379
- xl: 1200;
1380
- /** min width: 1201px */
1381
- max: 1201;
1382
- ```
1383
- - For web the typography scale will toggle between mobile and desktop
1384
- - `xs, s, m` are considered as mobile
1385
- - `l, xl, xl` are considered as desktop
1386
- - For react native we always default to mobile typography scale
1387
-
1388
- **What does it mean for me(as a developer)?**
1389
-
1390
- - If you’re already using Blade tokens then you can leverage this by just running `yarn upgrade @razorpay/blade@0.1.6` and that’s it you are set 🚀
1391
- - You can use the typography tokens as you were doing previously. Refer the [usage guideline here](https://61c19ee8d3d282003ac1d81c-jukcfyruls.chromatic.com/?path=/story/guides-usage--page&globals=measureEnabled:false#tokens)
1392
- - You can use these `breakpoints` as a base reference to build your next set of features by just following the [usage guidelines here](https://61c19ee8d3d282003ac1d81c-jukcfyruls.chromatic.com/?path=/story/tokens-breakpoints--page&globals=measureEnabled:false).
1393
-
1394
- This is our first step towards building responsive and adaptive applications. We’ll be publishing Typography Components next which will be built on top of these tokens and you can use them directly for your projects. Meanwhile, [read more about our responsive and adaptive strategy in this RFC](https://github.com/razorpay/blade/blob/master/rfcs/2022-02-11-responsive-and-adaptive-layout-strategy.md)
1395
-
1396
- ## 0.1.5
1397
-
1398
- ### Patch Changes
1399
-
1400
- - 04677a3: fix(blade): add lineheight tokens
1401
-
1402
- ## 0.1.4
1403
-
1404
- ### Patch Changes
1405
-
1406
- - f992f77: fix(blade): typo in exports field
1407
-
1408
- ## 0.1.3
1409
-
1410
- ### Patch Changes
1411
-
1412
- - d32dd9d: fix(blade): add overlay color token
1413
-
1414
- ## 0.1.2
1415
-
1416
- ### Patch Changes
1417
-
1418
- - 8cddfad: fix(blade): update desktop typography scale
1419
-
1420
- ## 0.1.1
1421
-
1422
- ### Patch Changes
1423
-
1424
- - 6c69a4d: fix(blade): update imports and exports
1425
-
1426
- ## 0.1.0
1427
-
1428
- ### Minor Changes
1429
-
1430
- - de4124f: ### ⚠️ **Breaking Change** ⚠️
1431
- This PR introduces a major breaking change on how we access tokens.
1432
-
1433
- ### Why did we want to change the way we access tokens?
1434
-
1435
- So, previously if you had to start consuming tokens from the new version of Blade you start with importing the theme provider:
1436
-
1437
- ```jsx
1438
- // App entry point
1439
- import { ThemeProvider } from '@razorpay/blade/components';
1440
- import { paymentTheme } from '@razorpay/blade/tokens';
1441
-
1442
- function App(): JSX.Element {
1443
- return (
1444
- <React.Fragment>
1445
- <GlobalStyle />
1446
- <ThemeProvider theme={paymentTheme}>
1447
- <Card />
1448
- </ThemeProvider>
1449
- </React.Fragment>
1450
- );
1451
- }
1452
-
1453
- export default App;
1454
- ```
1455
-
1456
- And then in one of our components, we'll use the `useTheme()` hook to get the theme and the mode like following 👇
1457
-
1458
- ```jsx
1459
- const StyledCard = styled.div(
1460
- ({ theme }: { theme: Theme }) => `
1461
- width: 368px;
1462
- background-color: ${theme.colors.surface.background.level2.lowContrast.onLight};
1463
- border-radius: ${theme.border.radius.medium}px;
1464
- box-shadow: ${theme.shadows.offsetX.level[1]}px ${theme.shadows.offsetY.level[1]}px ${theme.shadows.blurRadius.level[1]}px ${theme.shadows.color.level[1].onLight}, ${theme.shadows.offsetX.level[1]}px ${theme.shadows.offsetY.level[1]}px ${theme.shadows.blurRadius.level[1]}px ${theme.shadows.color.level[1].onLight};
1465
- padding: ${theme.spacing[5]}px;
1466
- display: flex;
1467
- flex-direction: column;
1468
- `,
1469
- );
1470
-
1471
- const Card = (): React.ReactElement => {
1472
- const { theme } = useTheme();
1473
- return (
1474
- <React.Fragment>
1475
- <DisplayLarge theme={theme}>Cash Advance </DisplayLarge>
1476
- <StyledCard theme={theme}>
1477
- <AlertInformation theme={theme}>
1478
- The interest charged will be deposited back into your bank account within a day of
1479
- repayment.
1480
- </AlertInformation>
1481
- <Divider theme={theme} />
1482
- <CaptionRegular theme={theme}>
1483
- This amount will be deducted in 3 installments from your settlement balance between Feb
1484
- 18-20 on a daily basis.
1485
- </CaptionRegular>
1486
- </StyledCard>
1487
- </React.Fragment>
1488
- );
1489
- };
1490
- ```
1491
-
1492
- #### Problem with the existing implementation:
1493
-
1494
- So we pass the raw theme tokens which have everything light mode colors, dark mode colors. Different typography scales for desktop, mobile, etc. But as a consumer look at how do we access the tokens from the above file
1495
-
1496
- ```jsx
1497
-
1498
- const { theme } = useTheme();
1499
-
1500
- background-color: ${theme.colors.surface.background.level2.lowContrast.onLight};
1501
- font-size: ${theme.typography.desktop.fonts.size[200]}px;
1502
- ```
1503
-
1504
- - Isn't it weird to explicitly write `onLight`/`onDark` by hand while accessing color tokens?
1505
- - Isn't it weird to explicitly write `desktop` to access the typography scale for desktop?
1506
- - How would you as a developer change things let's say if the user toggles the color mode?
1507
- - How would you as a developer change the typography scale if the user switches from desktop to mobile or vice-versa?
1508
-
1509
- You can't! Because we have **hardcoded** the object properties and which means we lost the power of dynamically changing these things based on the user's behavior which is incorrect.
1510
-
1511
- #### What is the root cause of this issue?
1512
-
1513
- The root cause is the mental model of how we store tokens and how do we consume them. Typically our tokens are nothing but our design decisions. So this means we need to store every decision in our token file, for eg: light mode colors, dark mode colors, typography scale for desktop, typography scale for mobile but when we consume them we want the system to take care of these things and give us single value for the modes and the platform.
1514
-
1515
- So we want something like this 👇
1516
-
1517
- ```diff
1518
-
1519
- const { theme } = useTheme();
1520
-
1521
- -background-color: ${theme.colors.surface.background.level2.lowContrast.onLight};
1522
- +background-color: ${theme.colors.surface.background.level2.lowContrast};
1523
- -font-size: ${theme.typography.desktop.fonts.size[200]}px;
1524
- +font-size: ${theme.typography.fonts.size[200]}px;
1525
- ```
1526
-
1527
- Notice the removal of **`onLight`** and **`desktop`** keys from the theme object.
1528
-
1529
- So we want our system to behave in such a manner that:
1530
-
1531
- - We input the raw theme(which has color modes and platform types)
1532
- - It will output the flat theme which will have color mode and platform type selected, so we don't have to hardcode `onLight`/`onDark` or `desktop`/`mobile`.
1533
-
1534
- ### What is the solution?
1535
-
1536
- The system we spoke about is nothing but our `BladeProvider`(previously known as `ThemeProvider`). It'll accept the raw theme as a prop and then based on the device type and color mode pick those values from `themeTokens` and set it in the context as `theme`. We can then use `useTheme()` hook to get the theme from the context which will be flattened.
1537
-
1538
- This is how things will look after this change 👇
1539
-
1540
- ```diff
1541
- // App entry point
1542
- -import { ThemeProvider } from '@razorpay/blade/components';
1543
- +import { BladeProvider } from '@razorpay/blade/components';
1544
- import { paymentTheme } from '@razorpay/blade/tokens';
1545
-
1546
- function App(): JSX.Element {
1547
- return (
1548
- <React.Fragment>
1549
- <GlobalStyle />
1550
- - <ThemeProvider theme={paymentTheme}>
1551
- + <BladeProvider themeTokens={paymentTheme}>
1552
- <Card />
1553
- - </ThemeProvider>
1554
- + </BladeProvider>
1555
- </React.Fragment>
1556
- );
1557
- }
1558
-
1559
- export default App;
1560
-
1561
- // somewhere in the app
1562
- const { theme } = useTheme();
1563
-
1564
- -background-color: ${theme.colors.surface.background.level2.lowContrast.onLight};
1565
- +background-color: ${theme.colors.surface.background.level2.lowContrast};
1566
- -font-size: ${theme.typography.desktop.fonts.size[200]}px;
1567
- +font-size: ${theme.typography.fonts.size[200]}px;
1568
- ```
1569
-
1570
- ### Migration guide for apps using the older version
1571
-
1572
- 1. Rename **ThemeProvider** to **BladeProvider**
1573
-
1574
- ```diff
1575
- -import { ThemeProvider } from '@razorpay/blade/components';
1576
- +import { BladeProvider } from '@razorpay/blade/components';
1577
- ```
1578
-
1579
- 2. Rename `theme` prop on provider to `themeTokens`
1580
-
1581
- ```diff
1582
- -<BladeProvider theme={paymentTheme}>
1583
- +<BladeProvider themeTokens={paymentTheme}>
1584
- ```
1585
-
1586
- 3. import `Theme` type to be imported from `@razorpay/blade/components` instead of `@razorpay/blade/tokens`
1587
-
1588
- ```diff
1589
- -import type { Theme } from '@razorpay/blade/tokens';
1590
- +import type { Theme } from '@razorpay/blade/components';
1591
- ```
1592
-
1593
- 4. Remove all the `onLight`/`onDark` keywords from the theme colors object
1594
-
1595
- ```diff
1596
- -background-color: ${theme.colors.surface.background.level2.lowContrast.onLight};
1597
- +background-color: ${theme.colors.surface.background.level2.lowContrast};
1598
- ```
1599
-
1600
- 5. Remove all the `desktop`/`mobile` keywords from the theme typography object
1601
-
1602
- ```diff
1603
- -background-color: ${theme.colors.surface.background.level2.lowContrast.onLight};
1604
- +background-color: ${theme.colors.surface.background.level2.lowContrast};
1605
- ```
1606
-
1607
- ## 0.0.8
1608
-
1609
- ### Patch Changes
1610
-
1611
- - 7a09800: fix(blade): add description in token types
1612
-
1613
- ## 0.0.7
1614
-
1615
- ### Patch Changes
1616
-
1617
- - 1aa2961: fix(blade): export all the types of global tokens for consumers
1618
- - d8d8027: fix(blade): typo in color tokens
1619
-
1620
- ## 0.0.6
1621
-
1622
- ### Patch Changes
1623
-
1624
- - 8374dc1: build(blade): generate root `.d.ts`
1625
-
1626
- ## 0.0.5
1627
-
1628
- ### Patch Changes
1629
-
1630
- - 057cf66: build(blade): add re-exports to `.ts` instead of `.js`
1631
-
1632
- ## 0.0.4
1633
-
1634
- ### Patch Changes
1635
-
1636
- - efb59d9: feat(blade): add type generation scripts
1637
-
1638
- ## 0.0.3
1639
-
1640
- ### Patch Changes
1641
-
1642
- - f0b2b01: fix(blade): typo in exports field
1643
-
1644
- ## 0.0.2
1645
-
1646
- ### Patch Changes
1647
-
1648
- - 55ac5d3: feat(blade): add rollup to build blade