@tecsinapse/react-core 1.12.1 → 1.12.5

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/dist/components/atoms/Badge/styled.d.ts +3 -2
  3. package/dist/components/atoms/Badge/styled.js +5 -3
  4. package/dist/components/atoms/Badge/styled.js.map +1 -1
  5. package/dist/components/atoms/Button/styled.js +4 -2
  6. package/dist/components/atoms/Button/styled.js.map +1 -1
  7. package/dist/components/atoms/GroupButton/styled.js +4 -2
  8. package/dist/components/atoms/GroupButton/styled.js.map +1 -1
  9. package/dist/components/atoms/Input/styled.js +3 -1
  10. package/dist/components/atoms/Input/styled.js.map +1 -1
  11. package/dist/components/atoms/ProgressBar/styled.d.ts +15 -3
  12. package/dist/components/atoms/ProgressBar/styled.js +3 -1
  13. package/dist/components/atoms/ProgressBar/styled.js.map +1 -1
  14. package/dist/components/atoms/Switch/styled.d.ts +15 -2
  15. package/dist/components/atoms/Switch/styled.js +6 -4
  16. package/dist/components/atoms/Switch/styled.js.map +1 -1
  17. package/dist/components/atoms/shared/PaperAndCard.js +0 -1
  18. package/dist/components/atoms/shared/PaperAndCard.js.map +1 -1
  19. package/dist/components/molecules/DatePicker/styled.d.ts +25 -4
  20. package/dist/components/molecules/DatePicker/styled.js +7 -5
  21. package/dist/components/molecules/DatePicker/styled.js.map +1 -1
  22. package/dist/components/molecules/DateTimePicker/styled.js +4 -2
  23. package/dist/components/molecules/DateTimePicker/styled.js.map +1 -1
  24. package/dist/components/molecules/DateTimeSelector/styled.js +3 -1
  25. package/dist/components/molecules/DateTimeSelector/styled.js.map +1 -1
  26. package/dist/components/molecules/Grid/Grid.d.ts +6 -1
  27. package/dist/components/molecules/Grid/Grid.js +1 -1
  28. package/dist/components/molecules/Grid/Grid.js.map +1 -1
  29. package/dist/components/molecules/Grid/Item/Item.d.ts +6 -1
  30. package/dist/components/molecules/Grid/Item/Item.js +12 -1
  31. package/dist/components/molecules/Grid/Item/Item.js.map +1 -1
  32. package/dist/components/molecules/Snackbar/styled.js +7 -5
  33. package/dist/components/molecules/Snackbar/styled.js.map +1 -1
  34. package/dist/components/molecules/TextArea/styled.d.ts +13 -6
  35. package/dist/components/molecules/TextArea/styled.js +8 -6
  36. package/dist/components/molecules/TextArea/styled.js.map +1 -1
  37. package/dist/styles/definitions.js +44 -41
  38. package/dist/styles/definitions.js.map +1 -1
  39. package/dist/utils/IPhoneXHelper.d.ts +4 -0
  40. package/dist/utils/IPhoneXHelper.js +38 -0
  41. package/dist/utils/IPhoneXHelper.js.map +1 -0
  42. package/dist/utils/ResponsiveFontSize.d.ts +3 -0
  43. package/dist/utils/ResponsiveFontSize.js +57 -0
  44. package/dist/utils/ResponsiveFontSize.js.map +1 -0
  45. package/dist/utils/extractNumbersFromString.js +2 -2
  46. package/dist/utils/extractNumbersFromString.js.map +1 -1
  47. package/dist/utils/index.d.ts +2 -0
  48. package/dist/utils/index.js +33 -0
  49. package/dist/utils/index.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/components/atoms/Badge/styled.ts +5 -4
  52. package/src/components/atoms/Button/styled.ts +3 -2
  53. package/src/components/atoms/GroupButton/styled.ts +3 -2
  54. package/src/components/atoms/Input/styled.ts +2 -1
  55. package/src/components/atoms/ProgressBar/styled.ts +3 -2
  56. package/src/components/atoms/Switch/styled.ts +7 -5
  57. package/src/components/atoms/shared/PaperAndCard.ts +0 -1
  58. package/src/components/molecules/DatePicker/styled.ts +4 -2
  59. package/src/components/molecules/DateTimePicker/styled.ts +4 -3
  60. package/src/components/molecules/DateTimeSelector/styled.ts +2 -1
  61. package/src/components/molecules/Grid/Grid.tsx +9 -2
  62. package/src/components/molecules/Grid/Item/Item.tsx +24 -2
  63. package/src/components/molecules/Snackbar/styled.ts +6 -5
  64. package/src/components/molecules/TextArea/styled.ts +6 -12
  65. package/src/styles/definitions.ts +43 -42
  66. package/src/utils/IPhoneXHelper.ts +34 -0
  67. package/src/utils/ResponsiveFontSize.ts +52 -0
  68. package/src/utils/extractNumbersFromString.ts +2 -4
  69. package/src/utils/index.ts +2 -0
@@ -3,6 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ var _exportNames = {
7
+ lightenDarkenColor: true,
8
+ extractNumbersFromString: true,
9
+ extractDigitsFromString: true
10
+ };
6
11
  Object.defineProperty(exports, "lightenDarkenColor", {
7
12
  enumerable: true,
8
13
  get: function () {
@@ -25,4 +30,32 @@ Object.defineProperty(exports, "extractDigitsFromString", {
25
30
  var _lightenDarkenColor = require("./lightenDarkenColor");
26
31
 
27
32
  var _extractNumbersFromString = require("./extractNumbersFromString");
33
+
34
+ var _IPhoneXHelper = require("./IPhoneXHelper");
35
+
36
+ Object.keys(_IPhoneXHelper).forEach(function (key) {
37
+ if (key === "default" || key === "__esModule") return;
38
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
39
+ if (key in exports && exports[key] === _IPhoneXHelper[key]) return;
40
+ Object.defineProperty(exports, key, {
41
+ enumerable: true,
42
+ get: function () {
43
+ return _IPhoneXHelper[key];
44
+ }
45
+ });
46
+ });
47
+
48
+ var _ResponsiveFontSize = require("./ResponsiveFontSize");
49
+
50
+ Object.keys(_ResponsiveFontSize).forEach(function (key) {
51
+ if (key === "default" || key === "__esModule") return;
52
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
53
+ if (key in exports && exports[key] === _ResponsiveFontSize[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _ResponsiveFontSize[key];
58
+ }
59
+ });
60
+ });
28
61
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA","sourcesContent":["export { lightenDarkenColor } from './lightenDarkenColor';\nexport {\n extractNumbersFromString,\n extractDigitsFromString,\n} from './extractNumbersFromString';\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAIA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export { lightenDarkenColor } from './lightenDarkenColor';\nexport {\n extractNumbersFromString,\n extractDigitsFromString,\n} from './extractNumbersFromString';\nexport * from './IPhoneXHelper'\nexport * from './ResponsiveFontSize'"],"file":"index.js"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tecsinapse/react-core",
3
3
  "description": "TecSinapse hybrid React components",
4
- "version": "1.12.1",
4
+ "version": "1.12.5",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -31,5 +31,5 @@
31
31
  "react-native": ">=0.64.0",
32
32
  "react-native-vector-icons": ">=8.1.0"
33
33
  },
34
- "gitHead": "50b3fc522e7726e43f9dd16d9681faf0a1e5a4d6"
34
+ "gitHead": "ce86b8c8b3e7c09e0fd86689418b540010f1419b"
35
35
  }
@@ -1,6 +1,7 @@
1
- import { View } from 'react-native';
2
1
  import styled, { css } from '@emotion/native';
3
- import { StyleProps } from '@tecsinapse/react-core';
2
+ import { View } from 'react-native';
3
+ import { StyleProps } from '../../../types/defaults';
4
+ import { RFValueStr } from '../../../utils';
4
5
  import { BadgeProps } from './Badge';
5
6
 
6
7
  const baseStyle = ({
@@ -17,8 +18,8 @@ const baseStyle = ({
17
18
  justify-content: center;
18
19
  height: ${theme.iconSize.centi};
19
20
  width: ${theme.iconSize.centi};
20
- top: -4px;
21
- right: -4px;
21
+ top: ${RFValueStr('-4px')};
22
+ right: ${RFValueStr('-4px')};
22
23
  `;
23
24
  };
24
25
 
@@ -1,5 +1,6 @@
1
1
  import styled, { css } from '@emotion/native';
2
2
  import { StyleProps } from '../../../types/defaults';
3
+ import { RFValueStr } from '../../../utils';
3
4
  import { PressableSurface } from '../PressableSurface';
4
5
  import { ButtonProps } from './Button';
5
6
 
@@ -20,12 +21,12 @@ const sizeStyles = ({ theme, size = 'default' }: StyleProps & ButtonProps) => {
20
21
  case 'small':
21
22
  return css`
22
23
  padding: ${theme.spacing.mili} ${theme.spacing.deca};
23
- min-height: 34px;
24
+ min-height: ${RFValueStr('34px')};
24
25
  `;
25
26
  default:
26
27
  return css`
27
28
  padding: ${theme.spacing.mili} ${theme.spacing.kilo};
28
- min-height: 44px;
29
+ min-height: ${RFValueStr('44px')};
29
30
  `;
30
31
  }
31
32
  };
@@ -1,6 +1,7 @@
1
1
  import styled, { css } from '@emotion/native';
2
2
  import { FC } from 'react';
3
3
  import { StyleProps } from '../../../types/defaults';
4
+ import { RFValueStr } from '../../../utils';
4
5
  import { ButtonSizeType } from '../Button';
5
6
  import { PressableSurface } from '../PressableSurface';
6
7
  import { TextProps } from '../Text';
@@ -104,12 +105,12 @@ const sizeStyles = ({
104
105
  case 'small':
105
106
  return css`
106
107
  padding: ${theme?.spacing.mili} ${theme?.spacing.deca};
107
- min-height: 34px;
108
+ min-height: ${RFValueStr('34px')};
108
109
  `;
109
110
  default:
110
111
  return css`
111
112
  padding: ${theme?.spacing.mili} ${theme?.spacing.kilo};
112
- min-height: 44px;
113
+ min-height: ${RFValueStr('44px')};
113
114
  `;
114
115
  }
115
116
  };
@@ -2,6 +2,7 @@ import styled, { css } from '@emotion/native';
2
2
  import { TextInput } from 'react-native';
3
3
  import { InputElementProps } from '.';
4
4
  import { StyleProps } from '../../../types/defaults';
5
+ import { RFValueStr } from '../../../utils';
5
6
  import { Icon } from '../Icon';
6
7
  import { InputContainerProps } from './InputContainer/InputContainer';
7
8
 
@@ -62,7 +63,7 @@ export const StyledInputContainer = styled.View<
62
63
  >`
63
64
  flex-direction: row;
64
65
  align-items: center;
65
- min-height: 44px;
66
+ min-height: ${RFValueStr('44px')};
66
67
  `;
67
68
 
68
69
  export const StyledInputElementBase = styled(TextInput)<
@@ -1,6 +1,7 @@
1
1
  import styled from '@emotion/native';
2
- import { StyleProps } from '@tecsinapse/react-core';
3
2
  import { Animated } from 'react-native';
3
+ import { StyleProps } from '../../../types/defaults';
4
+ import { RFValueStr } from '../../../utils';
4
5
 
5
6
  export const Container = styled.View<Partial<StyleProps>>`
6
7
  display: flex;
@@ -14,7 +15,7 @@ export const Container = styled.View<Partial<StyleProps>>`
14
15
  export const Segment = styled.View<Partial<StyleProps>>`
15
16
  flex: 1;
16
17
  background-color: ${({ theme }) => theme.color.secondary.light};
17
- border-right-width: 2px;
18
+ border-right-width: ${RFValueStr('2px')};
18
19
  border-color: ${({ theme }) => theme.color.secondary.xlight};
19
20
  `;
20
21
 
@@ -1,6 +1,8 @@
1
1
  import styled from '@emotion/native';
2
- import { StyleProps, SwitchProps } from '@tecsinapse/react-core';
3
2
  import { Animated } from 'react-native';
3
+ import { StyleProps } from '../../../types/defaults';
4
+ import { RFValueStr } from '../../../utils';
5
+ import { SwitchProps } from './Switch';
4
6
 
5
7
  export const StyledSwitchContent = styled(Animated.View)<
6
8
  Partial<SwitchProps> & Partial<StyleProps>
@@ -8,13 +10,13 @@ export const StyledSwitchContent = styled(Animated.View)<
8
10
  border-radius: ${({ theme }) => theme.borderRadius.pill};
9
11
  padding: 0 ${({ theme }) => theme.spacing.micro};
10
12
  justify-content: center;
11
- width: 40px;
12
- height: 22px;
13
+ width: ${RFValueStr('40px')};
14
+ height: ${RFValueStr('22px')};
13
15
  `;
14
16
 
15
17
  export const StyledSwitch = styled(Animated.View)<Partial<StyleProps>>`
16
18
  border-radius: ${({ theme }) => theme.borderRadius.pill};
17
19
  background-color: ${({ theme }) => theme.miscellaneous.surfaceColor};
18
- width: 16px;
19
- height: 16px;
20
+ width: ${RFValueStr('16px')};
21
+ height: ${RFValueStr('16px')};
20
22
  `;
@@ -3,7 +3,6 @@ import { StyleProps } from '@tecsinapse/react-core';
3
3
 
4
4
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
5
  export const baseStyles = ({ theme }: StyleProps): any => css`
6
- padding: ${theme.spacing.deca};
7
6
  border-radius: ${theme.borderRadius.mili};
8
7
  background-color: ${theme.miscellaneous.surfaceColor};
9
8
  overflow: hidden;
@@ -1,11 +1,13 @@
1
1
  import styled, { css } from '@emotion/native';
2
2
  import { FC } from 'react';
3
3
  import { Platform } from 'react-native';
4
+ import { hex2rgba } from '../../../styles/definitions';
5
+ import { StyleProps } from '../../../types/defaults';
6
+ import { RFValue } from '../../../utils';
4
7
  import { Icon } from '../../atoms/Icon';
5
8
  import { disabledInputStyles, InputContainerProps } from '../../atoms/Input';
6
9
  import { PressableSurface } from '../../atoms/PressableSurface';
7
10
  import { TextProps } from '../../atoms/Text';
8
- import { hex2rgba, StyleProps } from '@tecsinapse/react-core';
9
11
 
10
12
  const isWeb = Platform.OS === 'web';
11
13
 
@@ -29,7 +31,7 @@ export const ModalContent = styled.View<
29
31
  { offset: number } & Partial<StyleProps>
30
32
  >`
31
33
  background-color: transparent;
32
- padding-bottom: ${({ offset }) => `${offset}px`};
34
+ padding-bottom: ${({ offset }) => `${RFValue(offset)}px`};
33
35
  ${({ theme: { borderRadius } }) => css`
34
36
  ${isWeb
35
37
  ? `
@@ -2,9 +2,10 @@ import styled, { css } from '@emotion/native';
2
2
  import { FC } from 'react';
3
3
  import { Platform } from 'react-native';
4
4
  import { StyleProps } from '../../../types/defaults';
5
+ import { RFValue, RFValueStr } from '../../../utils';
5
6
  import {
6
7
  PressableSurface,
7
- PressableSurfaceProps,
8
+ PressableSurfaceProps
8
9
  } from '../../atoms/PressableSurface';
9
10
  import { DateTimeSelectorProps } from '../DateTimeSelector';
10
11
 
@@ -35,11 +36,11 @@ export const ModalContent = styled.View<
35
36
  { offset: number } & Partial<StyleProps>
36
37
  >`
37
38
  background-color: transparent;
38
- padding-bottom: ${({ offset }) => `${offset}px`};
39
+ padding-bottom: ${({ offset }) => `${RFValue(offset)}px`};
39
40
  ${({ theme: { borderRadius } }) => css`
40
41
  ${isWeb
41
42
  ? `
42
- width: 375px;
43
+ width: ${RFValueStr('375px')};
43
44
  border-radius: ${borderRadius.micro};
44
45
  `
45
46
  : `
@@ -1,5 +1,6 @@
1
1
  import styled from '@emotion/native';
2
2
  import { StyleProps } from '../../../types/defaults';
3
+ import { RFValueStr } from '../../../utils';
3
4
  import { PressableSurface } from '../../atoms/PressableSurface';
4
5
 
5
6
  export const Root = styled.View<Partial<StyleProps>>`
@@ -14,7 +15,7 @@ export const Content = styled.View<Partial<StyleProps>>`
14
15
  `;
15
16
 
16
17
  export const SelectorRoot = styled.View<Partial<StyleProps>>`
17
- border-width: 1px;
18
+ border-width: ${RFValueStr('1px')};
18
19
  border-color: ${({ theme }) => theme.color.secondary.xlight};
19
20
  border-radius: ${({ theme }) => theme.borderRadius.mili};
20
21
  `;
@@ -16,7 +16,14 @@ export interface IGrid extends ViewProps {
16
16
  layout?: number[][];
17
17
  /** Number of grid columns to be considered (not the number of elements per row) */
18
18
  columns?: number;
19
- spacing?: SpacingType;
19
+ spacing?:
20
+ | SpacingType
21
+ | {
22
+ top?: SpacingType;
23
+ right?: SpacingType;
24
+ bottom?: SpacingType;
25
+ left?: SpacingType;
26
+ };
20
27
  }
21
28
 
22
29
  const Grid = ({
@@ -70,7 +77,7 @@ const Grid = ({
70
77
  return React.cloneElement(child, {
71
78
  ...child?.props,
72
79
  columns,
73
- spacing,
80
+ spacing: child?.props.spacing ?? spacing,
74
81
  });
75
82
  })}
76
83
  </View>
@@ -11,6 +11,8 @@ type FlexAlignBase = FlexPositioning | 'stretch';
11
11
  type FlexAlignType = FlexAlignBase | 'baseline';
12
12
  type FlexSpacing = 'space-between' | 'space-around';
13
13
 
14
+ type PaddingPosition = 'top' | 'right' | 'bottom' | 'left';
15
+
14
16
  export interface IGridItem {
15
17
  children: React.ReactElement;
16
18
  /** Number of columns to fill */
@@ -30,7 +32,14 @@ export interface IGridItem {
30
32
  flexShrink?: number;
31
33
  justifyContent?: FlexPositioning | FlexSpacing | 'space-evenly';
32
34
  /** You don't have to give this property since is inherited from Grid */
33
- spacing?: SpacingType;
35
+ spacing?:
36
+ | SpacingType
37
+ | {
38
+ top?: SpacingType;
39
+ right?: SpacingType;
40
+ bottom?: SpacingType;
41
+ left?: SpacingType;
42
+ };
34
43
  /** Used to wrap children in a View when its style extrapolates the dimensions*/
35
44
  wrapper?: boolean;
36
45
  }
@@ -53,11 +62,24 @@ const GridItem = ({
53
62
  return loadingComponent;
54
63
  }
55
64
 
65
+ const getPadding = (pos: PaddingPosition) => {
66
+ if (_spacing) {
67
+ if (typeof _spacing === 'string')
68
+ return extractNumbersFromString(spacing[_spacing]);
69
+ else if (typeof _spacing === 'object' && _spacing[pos]) {
70
+ return extractNumbersFromString(spacing[_spacing[pos]!]);
71
+ } else return undefined;
72
+ } else return undefined;
73
+ };
74
+
56
75
  const style = {
57
76
  ...rest,
58
77
  boxSizing: 'border-box',
59
78
  flexBasis: `${100 / (columns / span)}%`,
60
- padding: _spacing ? extractNumbersFromString(spacing[_spacing]) : undefined,
79
+ paddingTop: getPadding('top'),
80
+ paddingBottom: getPadding('bottom'),
81
+ paddingRight: getPadding('right'),
82
+ paddingLeft: getPadding('left'),
61
83
  };
62
84
 
63
85
  const clone = React.cloneElement(children, {
@@ -1,10 +1,11 @@
1
- import { View } from 'react-native';
2
1
  import styled, { css } from '@emotion/native';
3
- import { SnackbarProps } from './Snackbar';
2
+ import { View } from 'react-native';
4
3
  import { StyleProps } from '../../../types/defaults';
5
- import { ProgressBar } from '../../atoms/ProgressBar';
4
+ import { RFValue } from '../../../utils';
6
5
  import { Paper } from '../../atoms/Paper';
7
6
  import { PressableSurface } from '../../atoms/PressableSurface';
7
+ import { ProgressBar } from '../../atoms/ProgressBar';
8
+ import { SnackbarProps } from './Snackbar';
8
9
 
9
10
  const baseStyles = ({
10
11
  theme,
@@ -31,7 +32,7 @@ const anchorTop = ({
31
32
  return (
32
33
  anchor === 'top' &&
33
34
  css`
34
- top: ${anchorDistance ? `${anchorDistance}px` : theme.spacing.deca};
35
+ top: ${anchorDistance ? `${RFValue(anchorDistance)}px` : theme.spacing.deca};
35
36
  `
36
37
  );
37
38
  };
@@ -44,7 +45,7 @@ const anchorBottom = ({
44
45
  return (
45
46
  anchor === 'bottom' &&
46
47
  css`
47
- bottom: ${anchorDistance ? `${anchorDistance}px` : theme.spacing.deca};
48
+ bottom: ${anchorDistance ? `${RFValue(anchorDistance)}px` : theme.spacing.deca};
48
49
  `
49
50
  );
50
51
  };
@@ -1,25 +1,19 @@
1
1
  import styled from '@emotion/native';
2
- import {
3
- extractNumbersFromString,
4
- InputContainer,
5
- InputElement,
6
- StyleProps,
7
- } from '@tecsinapse/react-core';
2
+ import { StyleProps } from '../../../types/defaults';
3
+ import { extractNumbersFromString, RFValue, RFValueStr } from '../../../utils';
4
+ import { InputContainer, InputElement } from '../../atoms/Input';
8
5
  import { TextAreaProps } from './TextArea';
9
6
 
10
7
  export const StyledInputContainer = styled(InputContainer)<Partial<StyleProps>>`
11
- min-height: 50px;
8
+ min-height: ${RFValueStr('50px')};
12
9
  `;
13
10
 
14
11
  export const TextAreaInputBase = styled(InputElement)<
15
12
  Partial<TextAreaProps> & Partial<StyleProps>
16
13
  >`
17
14
  max-height: ${({ theme, numberOfLines }) =>
18
- `${
19
- extractNumbersFromString(theme.typography.h5.lineHeight) *
20
- (numberOfLines || 1)
21
- }px`};
15
+ `${RFValue(extractNumbersFromString(theme.typography.h5.lineHeight) * (numberOfLines || 1))}px`};
22
16
  width: 100%;
23
17
  padding: 0;
24
- margin: 3px 0;
18
+ margin: ${RFValueStr('3px')} 0;
25
19
  `;
@@ -8,8 +8,9 @@ import {
8
8
  Miscellaneous,
9
9
  Spacing,
10
10
  TypographyVariation,
11
- ZIndex,
11
+ ZIndex
12
12
  } from '../types/defaults';
13
+ import { RFValueStr } from '../utils';
13
14
 
14
15
  export const statusColor = {
15
16
  error: {
@@ -55,74 +56,74 @@ export const miscellaneous: Miscellaneous = {
55
56
  };
56
57
 
57
58
  export const spacing: Spacing = {
58
- nano: '2px',
59
- micro: '4px',
60
- mili: '8px',
61
- centi: '12px',
62
- deca: '16px',
63
- kilo: '24px',
64
- mega: '32px',
65
- giga: '40px',
66
- tera: '48px',
67
- peta: '56px',
68
- hexa: '64px',
59
+ nano: RFValueStr('2px'),
60
+ micro: RFValueStr('4px'),
61
+ mili: RFValueStr('8px'),
62
+ centi: RFValueStr('12px'),
63
+ deca: RFValueStr('16px'),
64
+ kilo: RFValueStr('24px'),
65
+ mega: RFValueStr('32px'),
66
+ giga: RFValueStr('40px'),
67
+ tera: RFValueStr('48px'),
68
+ peta: RFValueStr('56px'),
69
+ hexa: RFValueStr('64px'),
69
70
  };
70
71
 
71
72
  export const iconSize: IconSize = {
72
- micro: '12px',
73
- mili: '14px',
74
- centi: '16px', // '1rem'
75
- deca: '18px', // '1.5rem'
76
- kilo: '24px', // '1.6rem'
77
- mega: '32px', // '2rem'
73
+ micro: RFValueStr('12px'),
74
+ mili: RFValueStr('14px'),
75
+ centi: RFValueStr('16px'), // '1rem'
76
+ deca: RFValueStr('18px'), // '1.5rem'
77
+ kilo: RFValueStr('24px'), // '1.6rem'
78
+ mega: RFValueStr('32px'), // '2rem'
78
79
  };
79
80
 
80
81
  export const borderRadius: BorderRadius = {
81
- nano: '2px',
82
- micro: '4px',
83
- mili: '8px',
84
- centi: '16px',
85
- deca: '24px',
86
- pill: '999999px', // also circle
82
+ nano: RFValueStr('2px'),
83
+ micro: RFValueStr('4px'),
84
+ mili: RFValueStr('8px'),
85
+ centi: RFValueStr('16px'),
86
+ deca: RFValueStr('24px'),
87
+ pill: RFValueStr('999999px'), // also circle
87
88
  };
88
89
 
89
90
  export const borderWidth: BorderWidth = {
90
- pico: '1px',
91
- nano: '2px',
91
+ pico: RFValueStr('1px'),
92
+ nano: RFValueStr('2px'),
92
93
  };
93
94
 
94
95
  export const typography: TypographyVariation = {
95
96
  h5: {
96
- fontSize: '16px', // '1rem'
97
- lineHeight: '24px', // '1.5rem'
97
+ fontSize: RFValueStr('16px'), // '1rem'
98
+ lineHeight: RFValueStr('24px'), // '1.5rem'
98
99
  },
99
100
  h4: {
100
- fontSize: '18px', // '1.125rem'
101
- lineHeight: '27px', // '1.688rem'
101
+ fontSize: RFValueStr('18px'), // '1.125rem'
102
+ lineHeight: RFValueStr('27px'), // '1.688rem'
102
103
  },
103
104
  h3: {
104
- fontSize: '20px', // '1.25rem'
105
- lineHeight: '32px', // '2rem'
105
+ fontSize: RFValueStr('20px'), // '1.25rem'
106
+ lineHeight: RFValueStr('32px'), // '2rem'
106
107
  },
107
108
  h2: {
108
- fontSize: '26px', // '1.625rem'
109
- lineHeight: '38px', // '2.375rem'
109
+ fontSize: RFValueStr('26px'), // '1.625rem'
110
+ lineHeight: RFValueStr('38px'), // '2.375rem'
110
111
  },
111
112
  h1: {
112
- fontSize: '32px', // '2rem'
113
- lineHeight: '42px', // '2.625rem'
113
+ fontSize: RFValueStr('32px'), // '2rem'
114
+ lineHeight: RFValueStr('42px'), // '2.625rem'
114
115
  },
115
116
  base: {
116
- fontSize: '14px', // '0.875rem'
117
- lineHeight: '21px', // '1.313rem'
117
+ fontSize: RFValueStr('14px'), // '0.875rem'
118
+ lineHeight: RFValueStr('21px'), // '1.313rem'
118
119
  },
119
120
  sub: {
120
- fontSize: '12px', // '0.75rem'
121
- lineHeight: '18px', // '1.125rem'
121
+ fontSize: RFValueStr('12px'), // '0.75rem'
122
+ lineHeight: RFValueStr('18px'), // '1.125rem'
122
123
  },
123
124
  label: {
124
- fontSize: '10px',
125
- lineHeight: '12px',
125
+ fontSize: RFValueStr('10px'),
126
+ lineHeight: RFValueStr('12px'),
126
127
  },
127
128
  };
128
129
 
@@ -0,0 +1,34 @@
1
+ import { Dimensions, Platform, StatusBar } from 'react-native';
2
+
3
+ export function isIphoneX() {
4
+ const dimen = Dimensions.get('window');
5
+ return (
6
+ Platform.OS === 'ios' &&
7
+ !Platform.isPad &&
8
+ !Platform.isTVOS &&
9
+ ((dimen.height === 780 || dimen.width === 780)
10
+ || (dimen.height === 812 || dimen.width === 812)
11
+ || (dimen.height === 844 || dimen.width === 844)
12
+ || (dimen.height === 896 || dimen.width === 896)
13
+ || (dimen.height === 926 || dimen.width === 926))
14
+ );
15
+ }
16
+
17
+ export function ifIphoneX(iphoneXStyle, regularStyle) {
18
+ if (isIphoneX()) {
19
+ return iphoneXStyle;
20
+ }
21
+ return regularStyle;
22
+ }
23
+
24
+ export function getStatusBarHeight(safe) {
25
+ return Platform.select({
26
+ ios: ifIphoneX(safe ? 44 : 30, 20),
27
+ android: StatusBar.currentHeight,
28
+ default: 0
29
+ });
30
+ }
31
+
32
+ export function getBottomSpace() {
33
+ return isIphoneX() ? 34 : 0;
34
+ }
@@ -0,0 +1,52 @@
1
+ import { Dimensions, Platform, StatusBar } from "react-native";
2
+ import { extractNumbersFromString } from "./extractNumbersFromString";
3
+ import { isIphoneX } from "./IPhoneXHelper";
4
+
5
+ const STANDARD_SCREEN_HEIGHT = 640
6
+
7
+ /**
8
+ * Use this function when you want to scale a percentage number
9
+ * to a reasonable value that will fit better on most of devices.
10
+ *
11
+ * @param percent
12
+ * @returns
13
+ */
14
+ export const RFPercentage = (percent: number) => {
15
+ if (Platform.OS === 'web') return percent
16
+ const { height, width } = Dimensions.get("window");
17
+ const standardLength = width > height ? width : height;
18
+ const offset = width > height ? 0 : Platform.OS === "ios" ? 78 : StatusBar.currentHeight || 0 // iPhone X style SafeAreaView size in portrait
19
+ const deviceHeight = isIphoneX() || Platform.OS === "android" ? standardLength - offset : standardLength;
20
+ const heightPercent = (percent * deviceHeight) / 100;
21
+ return Math.round(heightPercent);
22
+ }
23
+
24
+ /**
25
+ * Use this function when you want to scale a font size based on pixel unit
26
+ * to a reasonable value that will fit better on most of devices.
27
+ *
28
+ * @param fontSize
29
+ * @param standardScreenHeight
30
+ * @returns
31
+ */
32
+ export const RFValue = (fontSize: number, standardScreenHeight: number = STANDARD_SCREEN_HEIGHT) => {
33
+ if (Platform.OS === 'web') return fontSize
34
+ const { height, width } = Dimensions.get("window");
35
+ const standardLength = width > height ? width : height;
36
+ const offset = width > height ? 0 : Platform.OS === "ios" ? 78 : StatusBar.currentHeight || 0 // iPhone X style SafeAreaView size in portrait
37
+ const deviceHeight = isIphoneX() || Platform.OS === "android" ? standardLength - offset : standardLength;
38
+ const heightPercent = (fontSize * deviceHeight) / standardScreenHeight;
39
+ return Math.round(heightPercent);
40
+ }
41
+
42
+ /**
43
+ * Same of RFValue, however you can provide string values. E.g: '10px', '-5px'.
44
+ *
45
+ * @param fontSize
46
+ * @param standardScreenHeight
47
+ * @returns
48
+ */
49
+ export const RFValueStr = (fontSize: string, standardScreenHeight?: number) => {
50
+ const _fontSize = extractNumbersFromString(fontSize)
51
+ return `${RFValue(_fontSize, standardScreenHeight)}px`
52
+ }
@@ -1,8 +1,6 @@
1
- export const extractNumbersFromString = (value: string): number =>
2
- Number(value.replace(/[^0-9]/g, ''));
1
+ export const extractNumbersFromString = (value: string): number => Number(extractDigitsFromString(value));
3
2
 
4
3
  /*
5
4
  * implemented for the case: string numbers start with 0. Example: 012.345.678-91 Example: 012.345.678-91
6
5
  * */
7
- export const extractDigitsFromString = (value: string): string =>
8
- value.replace(/[^0-9]/g, '');
6
+ export const extractDigitsFromString = (value: string): string => value.replace(/[^-0-9]/g, '');
@@ -3,3 +3,5 @@ export {
3
3
  extractNumbersFromString,
4
4
  extractDigitsFromString,
5
5
  } from './extractNumbersFromString';
6
+ export * from './IPhoneXHelper'
7
+ export * from './ResponsiveFontSize'