@razorpay/blade 11.6.1 → 11.6.2

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.
@@ -1,13 +1,18 @@
1
1
  import { applyTransform } from '@hypermod/utils';
2
2
  import * as transformer from '..';
3
3
 
4
- it('should update the lineHeight & fontSize tokens', async () => {
4
+ it('should update the color tokens', async () => {
5
5
  const result = await applyTransform(
6
6
  transformer,
7
7
  `
8
8
  const CustomBox = styled(Box)\`
9
9
  color: \${theme.colors.feedback.notice.action.background.primary.default.lowContrast};
10
10
  backgroundColor: \${getIn(theme.colors, 'surface.background.level3.lowContrast')};
11
+
12
+ span {
13
+ color: \${theme.colors.brand.primary[500]};
14
+ backgroundColor: \${theme.colors.brand.gray[200].lowContrast};
15
+ }
11
16
  \`
12
17
  const App = () => (
13
18
  <>
@@ -24,6 +29,11 @@ it('should update the lineHeight & fontSize tokens', async () => {
24
29
  "const CustomBox = styled(Box)\`
25
30
  color: \${theme.colors.interactive.background.notice.faded};
26
31
  backgroundColor: \${getIn(theme.colors, 'surface.background.gray.moderate')};
32
+
33
+ span {
34
+ color: \${theme.colors.surface.background.primary.intense};
35
+ backgroundColor: \${theme.colors.surface.background.gray.moderate};
36
+ }
27
37
  \`
28
38
  const App = () => (
29
39
  <>
@@ -37,6 +37,8 @@ it('should remove the "variant" prop from Heading', async () => {
37
37
  const result = await applyTransform(
38
38
  transformer,
39
39
  `
40
+ import { Heading } from '@razorpay/blade/components';
41
+
40
42
  const App = () => (
41
43
  <>
42
44
  <Heading type="subtle" weight="bold" variant="subheading" marginTop="spacing.2"> Lorem ipsum </Heading>
@@ -47,7 +49,9 @@ it('should remove the "variant" prop from Heading', async () => {
47
49
  );
48
50
 
49
51
  expect(result).toMatchInlineSnapshot(`
50
- "const App = () => (
52
+ "import { Heading, Text } from '@razorpay/blade/components';
53
+
54
+ const App = () => (
51
55
  <>
52
56
  <Text weight="semibold" marginTop="spacing.2" size="small" color="surface.text.gray.subtle"> Lorem ipsum </Text>
53
57
  </>
@@ -46,7 +46,9 @@ const transformer: Transform = (file, api, options) => {
46
46
  return 'UPDATE_THIS_VALUE_WITH_A_NEW_COLOR_TOKEN';
47
47
  }
48
48
 
49
- const replacement = colorTokensMapping[originalString];
49
+ // Get the token from the original string, e.g. "brand.primary[500]" -> "brand.primary.500"
50
+ const token = originalString.replace('[', '.').replace(/\]|'|"/g, '');
51
+ const replacement = colorTokensMapping[token];
50
52
 
51
53
  if (!replacement) {
52
54
  return originalString;
@@ -89,6 +89,28 @@ function migrateTypographyComponents({ root, j, file }): void {
89
89
  ) {
90
90
  node.openingElement.name.name = 'Text';
91
91
  node.closingElement.name.name = 'Text';
92
+
93
+ // Add 'Text' import if not present
94
+ // Note that we don't remove the 'Heading' import as it might be used elsewhere
95
+ root
96
+ .find(j.ImportDeclaration, {
97
+ source: {
98
+ value: '@razorpay/blade/components',
99
+ },
100
+ })
101
+ .replaceWith((path) => {
102
+ // Check if Heading import is already present
103
+ const isTextImportPresent = path.node.specifiers.some(
104
+ (node) => node.imported.name === 'Text',
105
+ );
106
+
107
+ // If Heading import is not present, update the "Title" import to use "Heading"
108
+ if (!isTextImportPresent) {
109
+ path.node.specifiers.push(j.importSpecifier(j.identifier('Text')));
110
+ }
111
+
112
+ return path.node;
113
+ });
92
114
  }
93
115
 
94
116
  if (
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@razorpay/blade",
3
3
  "description": "The Design System that powers Razorpay",
4
- "version": "11.6.1",
4
+ "version": "11.6.2",
5
5
  "license": "MIT",
6
6
  "engines": {
7
7
  "node": ">=18.12.1"
@@ -274,7 +274,7 @@
274
274
  "typescript-transform-paths": "3.4.6",
275
275
  "@types/body-scroll-lock": "3.1.0",
276
276
  "ramda": "0.29.1",
277
- "@razorpay/i18nify-js": "1.4.0",
277
+ "@razorpay/i18nify-js": "1.4.4",
278
278
  "@razorpay/i18nify-react": "4.0.0"
279
279
  },
280
280
  "peerDependencies": {
@@ -291,7 +291,7 @@
291
291
  "react-hot-toast": "2.4.1",
292
292
  "@gorhom/bottom-sheet": "^4.4.6",
293
293
  "@gorhom/portal": "^1.0.14",
294
- "@razorpay/i18nify-js": "^1.4.0"
294
+ "@razorpay/i18nify-js": "^1.4.4"
295
295
  },
296
296
  "peerDependenciesMeta": {
297
297
  "react-native": {