@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.
@@ -268,9 +268,9 @@ type Typography = {
268
268
  // letterSpacings: {};
269
269
  };
270
270
 
271
- type TypographyPlatforms$1 = 'onDesktop' | 'onMobile';
271
+ type TypographyPlatforms = 'onDesktop' | 'onMobile';
272
272
 
273
- type TypographyWithPlatforms = Record<TypographyPlatforms$1, Typography>;
273
+ type TypographyWithPlatforms = Record<TypographyPlatforms, Typography>;
274
274
 
275
275
  /**
276
276
  * When any of the values are changed here, do change the jsdoc comments in BaseBox/types/spacingTypes.ts as well
@@ -310,39 +310,19 @@ type ColorSchemeNamesInput = ColorSchemeNames | 'system';
310
310
 
311
311
  type ColorSchemeModes = 'onDark' | 'onLight';
312
312
 
313
- type ShadowLevels = 1 | 2 | 3 | 4 | 5;
314
-
315
313
  type TextTypes = 'muted' | 'normal' | 'placeholder' | 'subdued' | 'subtle';
316
314
 
317
315
  type ColorContrastTypes = 'low' | 'high';
318
316
 
319
- type Shadows = {
320
- offsetX: {
321
- level: Record<ShadowLevels, number>;
322
- };
323
- offsetY: {
324
- level: Record<ShadowLevels, number>;
325
- };
326
- blurRadius: {
327
- level: Record<ShadowLevels, number>;
328
- };
329
- color: Record<
330
- ColorSchemeModes,
331
- {
332
- level: Record<ShadowLevels, string>;
333
- }
334
- >;
335
- androidElevation: {
336
- level: Record<ShadowLevels, number>;
337
- };
338
- };
339
-
340
317
  type Feedback = 'information' | 'negative' | 'neutral' | 'notice' | 'positive';
341
318
 
342
319
  type ColorContrast = {
343
320
  [K in ColorContrastTypes as `${Extract<K, string>}Contrast`]: string;
344
321
  };
345
322
 
323
+ // @TODO: this shall rather be Surface = 'level1' | 'level2' | 'level3' to keep in sync with color tokens
324
+ type SurfaceLevels = 1 | 2 | 3;
325
+
346
326
  type ActionStates = {
347
327
  default: string;
348
328
  hover: string;
@@ -457,8 +437,8 @@ type ThemeTokens = {
457
437
  breakpoints: Breakpoints;
458
438
  colors: ColorsWithModes;
459
439
  motion: Motion;
440
+ elevation: ElevationWithColorModes;
460
441
  spacing: Spacing;
461
- shadows: Shadows;
462
442
  typography: TypographyWithPlatforms;
463
443
  };
464
444
 
@@ -904,6 +884,35 @@ type Motion = Readonly<{
904
884
  easing: Easing;
905
885
  }>;
906
886
 
887
+ type ElevationLevels = 'none' | 'lowRaised' | 'midRaised' | 'highRaised';
888
+
889
+ type ElevationStyles = Readonly<{
890
+ elevation: number;
891
+ shadowColor: string;
892
+ shadowOpacity: number;
893
+ shadowRadius: number;
894
+ shadowOffset: {
895
+ /**
896
+ * x-axis
897
+ */
898
+ width: number;
899
+ /**
900
+ * y-axis
901
+ */
902
+ height: number;
903
+ };
904
+ }>;
905
+
906
+ type Elevation = Record<
907
+ ElevationLevels,
908
+ Platform.Select<{
909
+ web: string;
910
+ native: ElevationStyles;
911
+ }>
912
+ >;
913
+
914
+ type ElevationWithColorModes = Record<ColorSchemeModes, Elevation>;
915
+
907
916
  /**
908
917
  * @template TokenType token type generic
909
918
  * @description Tokenises objects to dot notation strings, eg: `surface.text.normal.lowContrast`
@@ -1002,7 +1011,7 @@ declare type ActionListProps = {
1002
1011
  /**
1003
1012
  * Decides the backgroundColor of ActionList
1004
1013
  */
1005
- surfaceLevel?: 2 | 3;
1014
+ surfaceLevel?: Exclude<SurfaceLevels, 1>;
1006
1015
  } & TestID;
1007
1016
  declare const ActionList: React__default.MemoExoticComponent<({ children, surfaceLevel, testID }: ActionListProps) => JSX.Element>;
1008
1017
 
@@ -1013,11 +1022,7 @@ type Theme$1 = {
1013
1022
  colors: Colors;
1014
1023
  spacing: Spacing;
1015
1024
  motion: Motion;
1016
- shadows: Omit<Shadows, 'color'> & {
1017
- color: {
1018
- level: Record<ShadowLevels, string>;
1019
- };
1020
- };
1025
+ elevation: Elevation;
1021
1026
  typography: Typography;
1022
1027
  };
1023
1028
 
@@ -1663,8 +1668,6 @@ declare type UseColorScheme = {
1663
1668
  setColorScheme: (colorScheme: ColorSchemeNamesInput) => void;
1664
1669
  };
1665
1670
 
1666
- declare type TypographyPlatforms = 'onDesktop' | 'onMobile';
1667
-
1668
1671
  declare type ThemeContext = UseColorScheme & {
1669
1672
  theme: Theme;
1670
1673
  platform: TypographyPlatforms;
@@ -1679,11 +1682,7 @@ declare type Theme = {
1679
1682
  colors: Colors;
1680
1683
  spacing: Spacing;
1681
1684
  motion: Motion;
1682
- shadows: Omit<Shadows, 'color'> & {
1683
- color: {
1684
- level: Record<ShadowLevels, string>;
1685
- };
1686
- };
1685
+ elevation: Elevation;
1687
1686
  typography: Typography;
1688
1687
  };
1689
1688
 
@@ -2301,6 +2300,8 @@ declare type CardProps = {
2301
2300
  *
2302
2301
  * eg: `theme.colors.surface.background.level1`
2303
2302
  *
2303
+ * @default `2`
2304
+ *
2304
2305
  * **Description:**
2305
2306
  *
2306
2307
  * - 2: Used in layouts which are on top of the main background
@@ -2310,9 +2311,28 @@ declare type CardProps = {
2310
2311
  * - Docs: https://blade.razorpay.com/?path=/docs/tokens-colors--page#-theme-tokens
2311
2312
  * - Figma: https://shorturl.at/fsvwK
2312
2313
  */
2313
- surfaceLevel?: 2 | 3;
2314
+ surfaceLevel?: Exclude<SurfaceLevels, 1>;
2315
+ /**
2316
+ * Sets the elevation for Cards
2317
+ *
2318
+ * eg: `theme.elevation.midRaised`
2319
+ *
2320
+ * @default `theme.elevation.lowRaised`
2321
+ *
2322
+ * **Links:**
2323
+ * - Docs: https://blade.razorpay.com/?path=/docs/tokens-elevation--page
2324
+ */
2325
+ elevation?: keyof Elevation;
2326
+ /**
2327
+ * Sets the padding equally on all sides. Only few `spacing` tokens are allowed deliberately
2328
+ * @default `spacing.7`
2329
+ *
2330
+ * **Links:**
2331
+ * - Docs: https://blade.razorpay.com/?path=/docs/tokens-spacing--page
2332
+ */
2333
+ padding?: Extract<SpacingValueType$1, 'spacing.0' | 'spacing.3' | 'spacing.5' | 'spacing.7'>;
2314
2334
  } & TestID & StyledPropsBlade;
2315
- declare const Card: ({ children, surfaceLevel, testID, ...styledProps }: CardProps) => React__default.ReactElement;
2335
+ declare const Card: ({ children, surfaceLevel, elevation, testID, padding, ...styledProps }: CardProps) => React__default.ReactElement;
2316
2336
  declare type CardBodyProps = {
2317
2337
  children: React__default.ReactNode;
2318
2338
  } & TestID;
@@ -268,9 +268,9 @@ type Typography = {
268
268
  // letterSpacings: {};
269
269
  };
270
270
 
271
- type TypographyPlatforms$1 = 'onDesktop' | 'onMobile';
271
+ type TypographyPlatforms = 'onDesktop' | 'onMobile';
272
272
 
273
- type TypographyWithPlatforms = Record<TypographyPlatforms$1, Typography>;
273
+ type TypographyWithPlatforms = Record<TypographyPlatforms, Typography>;
274
274
 
275
275
  /**
276
276
  * When any of the values are changed here, do change the jsdoc comments in BaseBox/types/spacingTypes.ts as well
@@ -310,39 +310,19 @@ type ColorSchemeNamesInput = ColorSchemeNames | 'system';
310
310
 
311
311
  type ColorSchemeModes = 'onDark' | 'onLight';
312
312
 
313
- type ShadowLevels = 1 | 2 | 3 | 4 | 5;
314
-
315
313
  type TextTypes = 'muted' | 'normal' | 'placeholder' | 'subdued' | 'subtle';
316
314
 
317
315
  type ColorContrastTypes = 'low' | 'high';
318
316
 
319
- type Shadows = {
320
- offsetX: {
321
- level: Record<ShadowLevels, number>;
322
- };
323
- offsetY: {
324
- level: Record<ShadowLevels, number>;
325
- };
326
- blurRadius: {
327
- level: Record<ShadowLevels, number>;
328
- };
329
- color: Record<
330
- ColorSchemeModes,
331
- {
332
- level: Record<ShadowLevels, string>;
333
- }
334
- >;
335
- androidElevation: {
336
- level: Record<ShadowLevels, number>;
337
- };
338
- };
339
-
340
317
  type Feedback = 'information' | 'negative' | 'neutral' | 'notice' | 'positive';
341
318
 
342
319
  type ColorContrast = {
343
320
  [K in ColorContrastTypes as `${Extract<K, string>}Contrast`]: string;
344
321
  };
345
322
 
323
+ // @TODO: this shall rather be Surface = 'level1' | 'level2' | 'level3' to keep in sync with color tokens
324
+ type SurfaceLevels = 1 | 2 | 3;
325
+
346
326
  type ActionStates = {
347
327
  default: string;
348
328
  hover: string;
@@ -457,8 +437,8 @@ type ThemeTokens = {
457
437
  breakpoints: Breakpoints;
458
438
  colors: ColorsWithModes;
459
439
  motion: Motion;
440
+ elevation: ElevationWithColorModes;
460
441
  spacing: Spacing;
461
- shadows: Shadows;
462
442
  typography: TypographyWithPlatforms;
463
443
  };
464
444
 
@@ -904,6 +884,35 @@ type Motion = Readonly<{
904
884
  easing: Easing;
905
885
  }>;
906
886
 
887
+ type ElevationLevels = 'none' | 'lowRaised' | 'midRaised' | 'highRaised';
888
+
889
+ type ElevationStyles = Readonly<{
890
+ elevation: number;
891
+ shadowColor: string;
892
+ shadowOpacity: number;
893
+ shadowRadius: number;
894
+ shadowOffset: {
895
+ /**
896
+ * x-axis
897
+ */
898
+ width: number;
899
+ /**
900
+ * y-axis
901
+ */
902
+ height: number;
903
+ };
904
+ }>;
905
+
906
+ type Elevation = Record<
907
+ ElevationLevels,
908
+ Platform.Select<{
909
+ web: string;
910
+ native: ElevationStyles;
911
+ }>
912
+ >;
913
+
914
+ type ElevationWithColorModes = Record<ColorSchemeModes, Elevation>;
915
+
907
916
  /**
908
917
  * @template TokenType token type generic
909
918
  * @description Tokenises objects to dot notation strings, eg: `surface.text.normal.lowContrast`
@@ -1002,7 +1011,7 @@ declare type ActionListProps = {
1002
1011
  /**
1003
1012
  * Decides the backgroundColor of ActionList
1004
1013
  */
1005
- surfaceLevel?: 2 | 3;
1014
+ surfaceLevel?: Exclude<SurfaceLevels, 1>;
1006
1015
  } & TestID;
1007
1016
  declare const ActionList: React__default.MemoExoticComponent<({ children, surfaceLevel, testID }: ActionListProps) => JSX.Element>;
1008
1017
 
@@ -1013,11 +1022,7 @@ type Theme$1 = {
1013
1022
  colors: Colors;
1014
1023
  spacing: Spacing;
1015
1024
  motion: Motion;
1016
- shadows: Omit<Shadows, 'color'> & {
1017
- color: {
1018
- level: Record<ShadowLevels, string>;
1019
- };
1020
- };
1025
+ elevation: Elevation;
1021
1026
  typography: Typography;
1022
1027
  };
1023
1028
 
@@ -1665,8 +1670,6 @@ declare type UseColorScheme = {
1665
1670
  setColorScheme: (colorScheme: ColorSchemeNamesInput) => void;
1666
1671
  };
1667
1672
 
1668
- declare type TypographyPlatforms = 'onDesktop' | 'onMobile';
1669
-
1670
1673
  declare type ThemeContext = UseColorScheme & {
1671
1674
  theme: Theme;
1672
1675
  platform: TypographyPlatforms;
@@ -1681,11 +1684,7 @@ declare type Theme = {
1681
1684
  colors: Colors;
1682
1685
  spacing: Spacing;
1683
1686
  motion: Motion;
1684
- shadows: Omit<Shadows, 'color'> & {
1685
- color: {
1686
- level: Record<ShadowLevels, string>;
1687
- };
1688
- };
1687
+ elevation: Elevation;
1689
1688
  typography: Typography;
1690
1689
  };
1691
1690
 
@@ -2303,6 +2302,8 @@ declare type CardProps = {
2303
2302
  *
2304
2303
  * eg: `theme.colors.surface.background.level1`
2305
2304
  *
2305
+ * @default `2`
2306
+ *
2306
2307
  * **Description:**
2307
2308
  *
2308
2309
  * - 2: Used in layouts which are on top of the main background
@@ -2312,9 +2313,28 @@ declare type CardProps = {
2312
2313
  * - Docs: https://blade.razorpay.com/?path=/docs/tokens-colors--page#-theme-tokens
2313
2314
  * - Figma: https://shorturl.at/fsvwK
2314
2315
  */
2315
- surfaceLevel?: 2 | 3;
2316
+ surfaceLevel?: Exclude<SurfaceLevels, 1>;
2317
+ /**
2318
+ * Sets the elevation for Cards
2319
+ *
2320
+ * eg: `theme.elevation.midRaised`
2321
+ *
2322
+ * @default `theme.elevation.lowRaised`
2323
+ *
2324
+ * **Links:**
2325
+ * - Docs: https://blade.razorpay.com/?path=/docs/tokens-elevation--page
2326
+ */
2327
+ elevation?: keyof Elevation;
2328
+ /**
2329
+ * Sets the padding equally on all sides. Only few `spacing` tokens are allowed deliberately
2330
+ * @default `spacing.7`
2331
+ *
2332
+ * **Links:**
2333
+ * - Docs: https://blade.razorpay.com/?path=/docs/tokens-spacing--page
2334
+ */
2335
+ padding?: Extract<SpacingValueType$1, 'spacing.0' | 'spacing.3' | 'spacing.5' | 'spacing.7'>;
2316
2336
  } & TestID & StyledPropsBlade;
2317
- declare const Card: ({ children, surfaceLevel, testID, ...styledProps }: CardProps) => React__default.ReactElement;
2337
+ declare const Card: ({ children, surfaceLevel, elevation, testID, padding, ...styledProps }: CardProps) => React__default.ReactElement;
2318
2338
  declare type CardBodyProps = {
2319
2339
  children: React__default.ReactNode;
2320
2340
  } & TestID;