@janiscommerce/ui-native 1.2.0 → 1.3.0

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 (81) hide show
  1. package/dist/env.json +1 -0
  2. package/dist/{components → src/components}/Avatar/index.js +14 -8
  3. package/dist/{components → src/components}/BaseButton/index.js +13 -6
  4. package/dist/{components → src/components}/CheckBox/index.js +16 -9
  5. package/dist/{components → src/components}/Icon/index.js +3 -1
  6. package/dist/{components → src/components}/Input/index.js +15 -8
  7. package/dist/{components → src/components}/Loading/index.js +7 -3
  8. package/dist/{components → src/components}/LoadingFullScreen/index.js +10 -4
  9. package/dist/{components → src/components}/ProgressBar/index.js +10 -5
  10. package/dist/{components → src/components}/RadioButton/index.js +9 -5
  11. package/dist/{components → src/components}/Select/Components/Dropdown/index.js +21 -9
  12. package/dist/{components → src/components}/Select/Components/Icons/Chevron/index.d.ts +0 -1
  13. package/dist/{components → src/components}/Select/Components/Icons/Chevron/index.js +4 -3
  14. package/dist/{components → src/components}/Select/Components/Icons/Delete/index.d.ts +0 -1
  15. package/dist/{components → src/components}/Select/Components/Icons/Delete/index.js +4 -3
  16. package/dist/{components → src/components}/Select/index.js +24 -12
  17. package/dist/{components → src/components}/StatusChip/index.js +14 -7
  18. package/dist/{components → src/components}/Svg/index.js +8 -1
  19. package/dist/{components → src/components}/Text/index.js +3 -1
  20. package/dist/{index.d.ts → src/index.d.ts} +2 -1
  21. package/dist/{index.js → src/index.js} +2 -1
  22. package/dist/src/scale/index.d.ts +8 -0
  23. package/dist/src/scale/index.js +13 -0
  24. package/dist/{theme → src/theme}/palette.js +2 -1
  25. package/dist/{ts → src/ts}/interfaces/colors.d.ts +3 -2
  26. package/package.json +3 -3
  27. /package/dist/{components → src/components}/Avatar/index.d.ts +0 -0
  28. /package/dist/{components → src/components}/Avatar/utils/formatPlaceholder/index.d.ts +0 -0
  29. /package/dist/{components → src/components}/Avatar/utils/formatPlaceholder/index.js +0 -0
  30. /package/dist/{components → src/components}/BaseButton/index.d.ts +0 -0
  31. /package/dist/{components → src/components}/Carousel/index.d.ts +0 -0
  32. /package/dist/{components → src/components}/Carousel/index.js +0 -0
  33. /package/dist/{components → src/components}/Carousel/utils/index.d.ts +0 -0
  34. /package/dist/{components → src/components}/Carousel/utils/index.js +0 -0
  35. /package/dist/{components → src/components}/CheckBox/icon/CheckedIcon.d.ts +0 -0
  36. /package/dist/{components → src/components}/CheckBox/icon/CheckedIcon.js +0 -0
  37. /package/dist/{components → src/components}/CheckBox/index.d.ts +0 -0
  38. /package/dist/{components → src/components}/Icon/assets/fonts/selection.json +0 -0
  39. /package/dist/{components → src/components}/Icon/index.d.ts +0 -0
  40. /package/dist/{components → src/components}/Image/index.d.ts +0 -0
  41. /package/dist/{components → src/components}/Image/index.js +0 -0
  42. /package/dist/{components → src/components}/Input/index.d.ts +0 -0
  43. /package/dist/{components → src/components}/Input/utils/index.d.ts +0 -0
  44. /package/dist/{components → src/components}/Input/utils/index.js +0 -0
  45. /package/dist/{components → src/components}/List/index.d.ts +0 -0
  46. /package/dist/{components → src/components}/List/index.js +0 -0
  47. /package/dist/{components → src/components}/Loading/LoadingSvg/index.d.ts +0 -0
  48. /package/dist/{components → src/components}/Loading/LoadingSvg/index.js +0 -0
  49. /package/dist/{components → src/components}/Loading/index.d.ts +0 -0
  50. /package/dist/{components → src/components}/LoadingFullScreen/index.d.ts +0 -0
  51. /package/dist/{components → src/components}/ProgressBar/index.d.ts +0 -0
  52. /package/dist/{components → src/components}/ProgressBar/utils/index.d.ts +0 -0
  53. /package/dist/{components → src/components}/ProgressBar/utils/index.js +0 -0
  54. /package/dist/{components → src/components}/RadioButton/index.d.ts +0 -0
  55. /package/dist/{components → src/components}/Select/Components/Dropdown/index.d.ts +0 -0
  56. /package/dist/{components → src/components}/Select/index.d.ts +0 -0
  57. /package/dist/{components → src/components}/Select/utils/index.d.ts +0 -0
  58. /package/dist/{components → src/components}/Select/utils/index.js +0 -0
  59. /package/dist/{components → src/components}/StatusChip/index.d.ts +0 -0
  60. /package/dist/{components → src/components}/Svg/index.d.ts +0 -0
  61. /package/dist/{components → src/components}/Svg/svgs/EmptyIllustration/index.d.ts +0 -0
  62. /package/dist/{components → src/components}/Svg/svgs/EmptyIllustration/index.js +0 -0
  63. /package/dist/{components → src/components}/Svg/svgs/EmptyListIllustration/index.d.ts +0 -0
  64. /package/dist/{components → src/components}/Svg/svgs/EmptyListIllustration/index.js +0 -0
  65. /package/dist/{components → src/components}/Svg/svgs/JanisLogo/index.d.ts +0 -0
  66. /package/dist/{components → src/components}/Svg/svgs/JanisLogo/index.js +0 -0
  67. /package/dist/{components → src/components}/Svg/svgs/JanisLogoColor/index.d.ts +0 -0
  68. /package/dist/{components → src/components}/Svg/svgs/JanisLogoColor/index.js +0 -0
  69. /package/dist/{components → src/components}/Svg/svgs/LoginIllustration/index.d.ts +0 -0
  70. /package/dist/{components → src/components}/Svg/svgs/LoginIllustration/index.js +0 -0
  71. /package/dist/{components → src/components}/Svg/svgs/NoNotifications/index.d.ts +0 -0
  72. /package/dist/{components → src/components}/Svg/svgs/NoNotifications/index.js +0 -0
  73. /package/dist/{components → src/components}/SwipeUp/childComponents/index.d.ts +0 -0
  74. /package/dist/{components → src/components}/SwipeUp/childComponents/index.js +0 -0
  75. /package/dist/{components → src/components}/SwipeUp/index.d.ts +0 -0
  76. /package/dist/{components → src/components}/SwipeUp/index.js +0 -0
  77. /package/dist/{components → src/components}/Text/index.d.ts +0 -0
  78. /package/dist/{theme → src/theme}/palette.d.ts +0 -0
  79. /package/dist/{ts → src/ts}/interfaces/colors.js +0 -0
  80. /package/dist/{ts → src/ts}/interfaces/svgs.d.ts +0 -0
  81. /package/dist/{ts → src/ts}/interfaces/svgs.js +0 -0
package/dist/env.json ADDED
@@ -0,0 +1 @@
1
+ { "LOAD_STORYBOOK": true, "WEB_MODE": false }
@@ -3,6 +3,7 @@ import { StyleSheet, View } from 'react-native';
3
3
  import Image from '../Image';
4
4
  import Text from '../Text';
5
5
  import { formatPlaceholder } from './utils/formatPlaceholder/index';
6
+ import { horizontalScale, moderateScale, scaledForDevice } from '../../scale';
6
7
  export const sizeValues = {
7
8
  sm: 24,
8
9
  md: 36,
@@ -25,6 +26,13 @@ const Avatar = ({ size = 'sm', textColor = '#FFFFFF', bgColor = '#E8EAF6', image
25
26
  return null;
26
27
  }
27
28
  const initials = formatPlaceholder(String(placeholder));
29
+ const calculateBorderRadius = getSize(size, customSize) / 2;
30
+ const calculateSize = getSize(size, customSize);
31
+ const calculateFontSize = getSize(size, customSize) * 0.4;
32
+ const validBorderRadius = scaledForDevice(calculateBorderRadius, moderateScale);
33
+ const validWidth = scaledForDevice(calculateSize, horizontalScale);
34
+ const validHeight = scaledForDevice(calculateSize, moderateScale);
35
+ const validFontSize = scaledForDevice(calculateFontSize, moderateScale);
28
36
  const handleOnErrorImage = () => {
29
37
  setShowInitials(true);
30
38
  if (onErrorImg) {
@@ -35,22 +43,20 @@ const Avatar = ({ size = 'sm', textColor = '#FFFFFF', bgColor = '#E8EAF6', image
35
43
  styles.container,
36
44
  {
37
45
  backgroundColor: bgColor,
38
- borderRadius: getSize(size, customSize) / 2,
39
- height: getSize(size, customSize),
40
- width: getSize(size, customSize),
46
+ borderRadius: validBorderRadius,
47
+ height: validHeight,
48
+ width: validWidth,
41
49
  },
42
50
  style,
43
51
  ]} {...props}>
44
52
  {!!imageUrl && !showInitials && (<Image accessibilityRole="image" onError={handleOnErrorImage} onLoad={() => setShowInitials(false)} source={{
45
53
  uri: imageUrl,
46
54
  }} style={{
47
- height: getSize(size, customSize),
48
- width: getSize(size, customSize),
55
+ height: validHeight,
56
+ width: validWidth,
49
57
  }}/>)}
50
58
 
51
- {(showInitials || !imageUrl) && !!initials.length && (<Text style={[styles.text, { color: textColor, fontSize: getSize(size, customSize) * 0.4 }]}>
52
- {initials}
53
- </Text>)}
59
+ {(showInitials || !imageUrl) && !!initials.length && (<Text style={[styles.text, { color: textColor, fontSize: validFontSize }]}>{initials}</Text>)}
54
60
  </View>);
55
61
  };
56
62
  export default Avatar;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Pressable, StyleSheet } from 'react-native';
3
+ import { moderateScale, horizontalScale, scaledForDevice } from '../../scale';
3
4
  import { palette } from '../../theme/palette';
4
5
  import Text from '../Text';
5
6
  import Icon from '../Icon';
@@ -10,24 +11,30 @@ const BaseButton = ({ title = null, icon = null, iconRight = false, disabled = f
10
11
  const bgColor = !disabled ? palette.primary.main : palette.grey[200];
11
12
  const iconPaddingLeft = iconRight && title ? 8 : 0;
12
13
  const iconPaddingRight = !iconRight && title ? 8 : 0;
14
+ const validatePaddingVertical = scaledForDevice(10, moderateScale);
15
+ const validatePaddingHorizontal = scaledForDevice(16, horizontalScale);
16
+ const validateFontSize = scaledForDevice(14, moderateScale);
17
+ const validateBorderRadius = scaledForDevice(borderRadius, moderateScale);
18
+ const validatePaddingRightIcon = scaledForDevice(iconPaddingRight, horizontalScale);
19
+ const validatePaddingLeftIcon = scaledForDevice(iconPaddingLeft, horizontalScale);
13
20
  const styles = StyleSheet.create({
14
21
  container: {
15
22
  display: 'flex',
16
23
  flexDirection: 'row',
17
24
  alignItems: 'center',
18
25
  justifyContent: 'center',
19
- paddingHorizontal: 16,
20
- paddingVertical: 10,
21
- borderRadius,
26
+ paddingHorizontal: validatePaddingHorizontal,
27
+ paddingVertical: validatePaddingVertical,
28
+ borderRadius: validateBorderRadius,
22
29
  backgroundColor: bgColor,
23
30
  },
24
31
  icon: {
25
32
  color: palette.base.white,
26
- paddingRight: iconPaddingRight,
27
- paddingLeft: iconPaddingLeft,
33
+ paddingRight: validatePaddingRightIcon,
34
+ paddingLeft: validatePaddingLeftIcon,
28
35
  },
29
36
  title: {
30
- fontSize: 14,
37
+ fontSize: validateFontSize,
31
38
  fontWeight: '500',
32
39
  textAlign: 'center',
33
40
  color: palette.base.white,
@@ -1,36 +1,43 @@
1
1
  import React from 'react';
2
2
  import { View, TouchableOpacity, StyleSheet } from 'react-native';
3
3
  import { base, grey, primary } from '../../theme/palette';
4
+ import { moderateScale, horizontalScale, scaledForDevice } from '../../scale';
4
5
  import Icon from './icon/CheckedIcon';
5
6
  const getCheckBoxScale = (size, divisor) => size / divisor;
6
7
  const CheckBox = ({ checked, customSize = 16, checkOnColor = primary.main, checkOffColor = grey[500], iconCheckColor = base.white, borderRadius, disabled = false, style, ...props }) => {
7
8
  const hasBorderRadius = !borderRadius ? getCheckBoxScale(customSize, 4) : borderRadius;
9
+ const validateIconSize = scaledForDevice(customSize, moderateScale);
10
+ const validWidth = scaledForDevice(customSize, horizontalScale);
11
+ const validHeight = scaledForDevice(customSize, moderateScale);
12
+ const validBorderRadius = scaledForDevice(hasBorderRadius, moderateScale);
8
13
  const styles = StyleSheet.create({
9
14
  touchableOpacity: {
10
- width: customSize,
11
- height: customSize,
12
- borderRadius: hasBorderRadius,
15
+ width: validWidth,
16
+ height: validHeight,
17
+ borderRadius: validBorderRadius,
13
18
  },
14
19
  checkOn: {
15
20
  display: 'flex',
16
21
  justifyContent: 'center',
17
22
  alignItems: 'center',
18
23
  backgroundColor: !disabled ? checkOnColor : grey[200],
19
- width: customSize,
20
- height: customSize,
21
- borderRadius: hasBorderRadius,
24
+ width: validWidth,
25
+ height: validHeight,
26
+ borderRadius: validBorderRadius,
22
27
  },
23
28
  checkOff: {
24
29
  borderWidth: getCheckBoxScale(customSize, 16),
25
30
  borderColor: !disabled ? checkOffColor : grey[200],
26
- width: customSize,
27
- height: customSize,
31
+ width: validWidth,
32
+ height: validHeight,
28
33
  borderRadius: hasBorderRadius,
29
34
  },
30
35
  });
31
36
  const isChecked = checked ? styles.checkOn : styles.checkOff;
32
37
  return (<TouchableOpacity disabled={disabled} activeOpacity={0.6} style={[styles.touchableOpacity, style]} {...props}>
33
- <View style={isChecked}>{checked && <Icon color={iconCheckColor} size={customSize}/>}</View>
38
+ <View style={isChecked}>
39
+ {checked && <Icon color={iconCheckColor} size={validateIconSize}/>}
40
+ </View>
34
41
  </TouchableOpacity>);
35
42
  };
36
43
  export default CheckBox;
@@ -2,11 +2,13 @@ import React from 'react';
2
2
  import { createIconSetFromIcoMoon } from 'react-native-vector-icons';
3
3
  import icoMoonConfig from './assets/fonts/selection.json';
4
4
  import { primary } from '../../theme/palette';
5
+ import { moderateScale, scaledForDevice } from '../../scale';
5
6
  const IconComponent = createIconSetFromIcoMoon(icoMoonConfig, 'janis-font-icon', 'janis-font-icon.ttf');
6
7
  const Icon = ({ name, color = primary.main, size = 16, ...props }) => {
7
8
  if (!name) {
8
9
  return null;
9
10
  }
10
- return <IconComponent name={name} color={color} size={size} {...props}/>;
11
+ const validateSize = scaledForDevice(size, moderateScale);
12
+ return <IconComponent name={name} color={color} size={validateSize} {...props}/>;
11
13
  };
12
14
  export default Icon;
@@ -1,6 +1,7 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { TextInput, StyleSheet, View, Text, } from 'react-native';
3
3
  import { getBorderColor, getInputInitialState, getLabelColor, getStatusMessageColor, raiseLabel, showStatusMessage, } from './utils';
4
+ import { moderateScale, horizontalScale, scaledForDevice } from '../../scale';
4
5
  export var keyboardTypes;
5
6
  (function (keyboardTypes) {
6
7
  keyboardTypes["default"] = "default";
@@ -44,34 +45,40 @@ const Input = React.forwardRef(({ disabled = false, readOnly = false, label, pla
44
45
  status,
45
46
  });
46
47
  const validStatusMessageColor = getStatusMessageColor(status);
48
+ const validBottom = scaledForDevice(25, moderateScale);
49
+ const validHeight = scaledForDevice(50, moderateScale);
50
+ const validBorderBottomWidth = scaledForDevice(1, horizontalScale);
51
+ const validLineHeight = scaledForDevice(19, moderateScale);
52
+ const validFontSize = scaledForDevice(16, moderateScale);
53
+ const validateMarginTop = scaledForDevice(5, moderateScale);
47
54
  const styles = StyleSheet.create({
48
55
  container: {
49
56
  width: '100%',
50
57
  },
51
58
  inputWrapper: {
52
- height: 50,
59
+ height: validHeight,
53
60
  borderBottomColor: validBorderColor,
54
- borderBottomWidth: 1,
61
+ borderBottomWidth: validBorderBottomWidth,
55
62
  justifyContent: 'flex-end',
56
63
  },
57
64
  label: {
58
65
  color: validLabelColor,
59
- fontSize: 16,
66
+ fontSize: validFontSize,
60
67
  letterSpacing: 0,
61
- lineHeight: 19,
68
+ lineHeight: validLineHeight,
62
69
  position: 'absolute',
63
- bottom: raiseLabel({ disabled, hasMessage, inputState }) ? 25 : 0,
70
+ bottom: raiseLabel({ disabled, hasMessage, inputState }) ? validBottom : 0,
64
71
  },
65
72
  input: {
66
73
  color: valueColor,
67
- fontSize: 16,
74
+ fontSize: validFontSize,
68
75
  letterSpacing: 0,
69
- lineHeight: 19,
76
+ lineHeight: validLineHeight,
70
77
  padding: 0,
71
78
  },
72
79
  statusMessage: {
73
80
  color: validStatusMessageColor,
74
- marginTop: 5,
81
+ marginTop: validateMarginTop,
75
82
  },
76
83
  });
77
84
  return (<View style={styles.container}>
@@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react';
2
2
  import { StyleSheet, View, Animated, Easing } from 'react-native';
3
3
  import LoadingSvg from './LoadingSvg';
4
4
  import { primary } from '../../theme/palette';
5
+ import { horizontalScale, moderateScale, scaledForDevice } from '../../scale';
5
6
  const startRotationAnimation = ({ duration, rotationDegree, timingAnimation }) => Animated.loop(Animated.timing(rotationDegree, {
6
7
  duration,
7
8
  toValue: 360,
@@ -10,13 +11,16 @@ const startRotationAnimation = ({ duration, rotationDegree, timingAnimation }) =
10
11
  })).start();
11
12
  const Loading = ({ isLoading, color = primary.main, size = 64, duration = 1000, children = null, style, ...props }) => {
12
13
  const rotationDegree = useRef(new Animated.Value(0)).current;
14
+ const validWidth = scaledForDevice(size, horizontalScale);
15
+ const validHeight = scaledForDevice(size, moderateScale);
16
+ const validSize = scaledForDevice(size, moderateScale);
13
17
  const styles = StyleSheet.create({
14
18
  container: {
15
19
  position: 'relative',
16
20
  justifyContent: 'center',
17
21
  alignItems: 'center',
18
- width: size,
19
- height: size,
22
+ width: validWidth,
23
+ height: validHeight,
20
24
  },
21
25
  spinner: {
22
26
  position: 'absolute',
@@ -49,7 +53,7 @@ const Loading = ({ isLoading, color = primary.main, size = 64, duration = 1000,
49
53
  return <></>;
50
54
  }
51
55
  return (<View style={[styles.container, style]} {...props}>
52
- <LoadingSvg style={[styles.spinner, { ...animationSpinnerStyle }]} size={size} color={color}/>
56
+ <LoadingSvg style={[styles.spinner, { ...animationSpinnerStyle }]} size={validSize} color={color}/>
53
57
  {children}
54
58
  </View>);
55
59
  };
@@ -3,6 +3,12 @@ import { StyleSheet, Modal, Text, View } from 'react-native';
3
3
  import Loading from '../Loading';
4
4
  import Svg from '../Svg';
5
5
  import { grey, white } from '../../theme/palette';
6
+ import { moderateScale, horizontalScale, scaledForDevice } from '../../scale';
7
+ const validFontSize = scaledForDevice(16, moderateScale);
8
+ const validLineHeight = scaledForDevice(24, moderateScale);
9
+ const validMarginTop = scaledForDevice(25, moderateScale);
10
+ const validWidth = scaledForDevice(36, horizontalScale);
11
+ const validHeight = scaledForDevice(25, moderateScale);
6
12
  const styles = StyleSheet.create({
7
13
  ContainerStyles: {
8
14
  flex: 1,
@@ -11,14 +17,14 @@ const styles = StyleSheet.create({
11
17
  backgroundColor: white.semiTransparent,
12
18
  },
13
19
  TextStyles: {
14
- fontSize: 16,
15
- lineHeight: 24,
20
+ fontSize: validFontSize,
21
+ lineHeight: validLineHeight,
16
22
  fontFamily: 'Roboto',
17
23
  color: grey[700],
18
24
  textAlign: 'center',
19
25
  fontWeight: '500',
20
26
  width: '50%',
21
- marginTop: 25,
27
+ marginTop: validMarginTop,
22
28
  },
23
29
  });
24
30
  const LoadingFullScreen = ({ text, isLoading, svgName = 'janis-logo', spinnerDuration = 2000, style, ...props }) => {
@@ -26,7 +32,7 @@ const LoadingFullScreen = ({ text, isLoading, svgName = 'janis-logo', spinnerDur
26
32
  return (<Modal visible={isLoading} transparent animationType="fade" testID="loading modal" {...props}>
27
33
  <View style={[styles.ContainerStyles, style]}>
28
34
  <Loading isLoading={isLoading} duration={spinnerDuration}>
29
- <Svg name={svgName} width={36} height={25}/>
35
+ <Svg name={svgName} width={validWidth} height={validHeight}/>
30
36
  </Loading>
31
37
  {hasTextPassed && <Text style={styles.TextStyles}>{text}</Text>}
32
38
  </View>
@@ -1,7 +1,9 @@
1
+ /* istanbul ignore file */
1
2
  import React, { useEffect, useRef } from 'react';
2
3
  import { View, StyleSheet, Animated, Easing } from 'react-native';
3
4
  import { palette } from '../../theme/palette';
4
5
  import { getBarColor, getPercentage } from './utils';
6
+ import { moderateScale, scaledForDevice } from '../../scale';
5
7
  const ProgressBar = ({ value, totalValue, isAnimated = false, duration = 300, style, ...props }) => {
6
8
  const { white } = palette;
7
9
  const widthAnimation = useRef(new Animated.Value(0)).current;
@@ -22,20 +24,23 @@ const ProgressBar = ({ value, totalValue, isAnimated = false, duration = 300, st
22
24
  widthAnimation.setValue(percentValue);
23
25
  }
24
26
  }, [isAnimated, percentValue, timeDuration, widthAnimation]);
27
+ const validHeight = scaledForDevice(4, moderateScale);
28
+ const validBorderRadius = scaledForDevice(2, moderateScale);
29
+ const validMarginTop = scaledForDevice(12, moderateScale);
25
30
  const styles = StyleSheet.create({
26
31
  container: {
27
32
  position: 'relative',
28
33
  width: '100%',
29
- height: 4,
30
- marginTop: 12,
31
- borderRadius: 2,
34
+ height: validHeight,
35
+ marginTop: validMarginTop,
36
+ borderRadius: validBorderRadius,
32
37
  backgroundColor: white.main,
33
38
  },
34
39
  fill: {
35
40
  position: 'absolute',
36
41
  left: 0,
37
- height: 4,
38
- borderRadius: 2,
42
+ height: validHeight,
43
+ borderRadius: validBorderRadius,
39
44
  zIndex: 10,
40
45
  backgroundColor: colorValue,
41
46
  },
@@ -2,17 +2,21 @@ import React from 'react';
2
2
  import { View, TouchableOpacity, StyleSheet } from 'react-native';
3
3
  import Text from '../Text';
4
4
  import CheckBox from '../CheckBox';
5
+ import { horizontalScale, moderateScale, scaledForDevice } from '../../scale';
5
6
  const checkLocation = ['left', 'right'];
6
7
  const CheckSizeValues = {
7
8
  sm: 16,
8
9
  md: 24,
9
10
  lg: 32,
10
11
  };
12
+ const validPaddingHorizontal = scaledForDevice(16, horizontalScale);
13
+ const validMarginVertical = scaledForDevice(10, moderateScale);
14
+ const validMarginHorizontal = scaledForDevice(15, horizontalScale);
11
15
  const styles = StyleSheet.create({
12
16
  container: {
13
17
  alignItems: 'center',
14
- paddingHorizontal: 16,
15
- marginVertical: 10,
18
+ paddingHorizontal: validPaddingHorizontal,
19
+ marginVertical: validMarginVertical,
16
20
  height: 'auto',
17
21
  },
18
22
  row: {
@@ -24,10 +28,10 @@ const styles = StyleSheet.create({
24
28
  justifyContent: 'space-between',
25
29
  },
26
30
  checkToLeft: {
27
- marginLeft: 15,
31
+ marginLeft: validMarginHorizontal,
28
32
  },
29
33
  checkToRight: {
30
- marginRight: 15,
34
+ marginRight: validMarginHorizontal,
31
35
  },
32
36
  });
33
37
  const RadioButton = ({ children, onPress, selected = false, checkPosition = 'left', checkSize = 'sm', disabled = false, style, ...props }) => {
@@ -39,7 +43,7 @@ const RadioButton = ({ children, onPress, selected = false, checkPosition = 'lef
39
43
  const checkLeft = checkPosition === 'left';
40
44
  const customSize = CheckSizeValues[checkSize];
41
45
  return (<TouchableOpacity style={[container, checkLeft ? row : reverseRow, style]} disabled={disabled} onPress={onPress} {...props}>
42
- <CheckBox checked={selected} disabled={disabled} customSize={customSize} borderRadius={customSize / 2}/>
46
+ <CheckBox checked={selected} disabled={disabled} customSize={customSize} borderRadius={customSize / 2} onPress={onPress}/>
43
47
  <View style={checkLeft ? checkToLeft : checkToRight}>
44
48
  {isStringChild ? <Text>{children}</Text> : children}
45
49
  </View>
@@ -1,45 +1,57 @@
1
1
  import React from 'react';
2
2
  import { View, StyleSheet, TouchableOpacity, ScrollView, Text } from 'react-native';
3
3
  import { base, black, grey, primary, white } from '../../../../theme/palette';
4
+ import { horizontalScale, moderateScale, scaledForDevice } from '../../../../scale';
4
5
  const Dropdown = (props) => {
5
6
  const { isShowedDropdown, filteredOptions, callbackOption, selectedOptions, noOptionsMessage, optionStyles, customOptionComponent = null, } = props;
6
7
  if (!isShowedDropdown) {
7
8
  return null;
8
9
  }
9
10
  const handleSelectedOption = (option) => callbackOption(option);
11
+ const validPadding = scaledForDevice(8, moderateScale);
12
+ const validMaxHeight = scaledForDevice(168, moderateScale);
13
+ const validTop = scaledForDevice(60, moderateScale);
14
+ const validMarginBottom = scaledForDevice(20, moderateScale);
15
+ const validElevation = scaledForDevice(5, moderateScale);
16
+ const validHeight = scaledForDevice(42, moderateScale);
17
+ const validLeft = scaledForDevice(8, horizontalScale);
18
+ const validFontSize = scaledForDevice(14, moderateScale);
19
+ const validPaddingVertical = scaledForDevice(10, moderateScale);
10
20
  const styles = StyleSheet.create({
11
21
  container: {
12
22
  width: '100%',
13
- padding: 8,
23
+ padding: validPadding,
14
24
  },
15
25
  optionWrapper: {
16
26
  position: 'absolute',
17
- maxHeight: 168,
27
+ maxHeight: validMaxHeight,
18
28
  borderColor: grey[200],
19
29
  backgroundColor: base.white,
20
30
  width: '100%',
21
- top: 60,
22
- marginBottom: 20,
23
- elevation: 5,
31
+ top: validTop,
32
+ marginBottom: validMarginBottom,
33
+ elevation: validElevation,
24
34
  zIndex: 10,
25
35
  flex: 1,
26
36
  },
27
37
  option: {
28
38
  width: '100%',
29
- height: 42,
39
+ height: validHeight,
30
40
  justifyContent: 'center',
31
41
  alignItems: 'stretch',
32
- paddingLeft: 8,
42
+ paddingLeft: validLeft,
33
43
  },
34
44
  optionText: {
45
+ fontSize: validFontSize,
35
46
  color: black.main,
36
47
  fontWeight: '400',
37
48
  },
38
49
  noOptionText: {
50
+ fontSize: validFontSize,
39
51
  color: grey[500],
40
52
  fontWeight: '400',
41
- paddingLeft: 8,
42
- paddingVertical: 10,
53
+ paddingLeft: validLeft,
54
+ paddingVertical: validPaddingVertical,
43
55
  },
44
56
  });
45
57
  const renderOptions = filteredOptions?.length &&
@@ -11,7 +11,6 @@ declare const Chevron: {
11
11
  ({ style, color, size, onPress, ...props }: IconProps): React.JSX.Element;
12
12
  defaultProps: {
13
13
  color: string;
14
- size: number;
15
14
  onPress: () => void;
16
15
  };
17
16
  };
@@ -2,10 +2,12 @@ import React from 'react';
2
2
  import { Pressable, View } from 'react-native';
3
3
  import { primary } from '../../../../../theme/palette';
4
4
  import Svg, { Path } from 'react-native-svg';
5
- const Chevron = ({ style, color, size, onPress, ...props }) => {
5
+ import { moderateScale, scaledForDevice } from '../../../../../scale';
6
+ const Chevron = ({ style, color, size = 21, onPress, ...props }) => {
7
+ const validSize = scaledForDevice(size, moderateScale);
6
8
  return (<Pressable onPress={onPress} style={style} {...props}>
7
9
  <View>
8
- <Svg width={size} height={size} viewBox="0 0 16 16">
10
+ <Svg width={validSize} height={validSize} viewBox="0 0 16 16">
9
11
  <Path d="M8.17432 11.1055L3 6.49316L4.33106 5L8.17627 8.42773L12.0132 5.01904L13.3413 6.51416L8.17432 11.1055Z" fill={color}/>
10
12
  </Svg>
11
13
  </View>
@@ -13,7 +15,6 @@ const Chevron = ({ style, color, size, onPress, ...props }) => {
13
15
  };
14
16
  Chevron.defaultProps = {
15
17
  color: primary.main,
16
- size: 21,
17
18
  onPress: () => { },
18
19
  };
19
20
  export default Chevron;
@@ -11,7 +11,6 @@ declare const Delete: {
11
11
  ({ style, color, size, onPress, ...props }: IconProps): React.JSX.Element;
12
12
  defaultProps: {
13
13
  color: string;
14
- size: number;
15
14
  onPress: () => void;
16
15
  };
17
16
  };
@@ -2,10 +2,12 @@ import React from 'react';
2
2
  import { Pressable, View } from 'react-native';
3
3
  import { black } from '../../../../../theme/palette';
4
4
  import Svg, { Path } from 'react-native-svg';
5
- const Delete = ({ style, color, size, onPress, ...props }) => {
5
+ import { moderateScale, scaledForDevice } from '../../../../../scale';
6
+ const Delete = ({ style, color, size = 21, onPress, ...props }) => {
7
+ const validSize = scaledForDevice(size, moderateScale);
6
8
  return (<Pressable onPress={onPress} style={style} {...props}>
7
9
  <View>
8
- <Svg width={size} height={size} viewBox="0 0 16 16">
10
+ <Svg width={validSize} height={validSize} viewBox="0 0 16 16">
9
11
  <Path fill-rule="evenodd" clip-rule="evenodd" d="M1 8C1 4.13403 4.13397 1 8 1C11.866 1 15 4.13403 15 8C15 11.866 11.866 15 8 15C4.13397 15 1 11.866 1 8ZM10.03 11.4441L11.4441 10.03L9.41406 8L11.4441 5.96997L10.03 4.55591L8 6.58594L5.96997 4.55591L4.55591 5.96997L6.58594 8L4.55591 10.03L5.96997 11.4441L8 9.41406L10.03 11.4441Z" fill={color}/>
10
12
  </Svg>
11
13
  </View>
@@ -13,7 +15,6 @@ const Delete = ({ style, color, size, onPress, ...props }) => {
13
15
  };
14
16
  Delete.defaultProps = {
15
17
  color: black.main,
16
- size: 21,
17
18
  onPress: () => { },
18
19
  };
19
20
  export default Delete;
@@ -1,3 +1,4 @@
1
+ /* istanbul ignore file */
1
2
  import React, { useState, useEffect, useRef, useCallback } from 'react';
2
3
  import { Keyboard, StyleSheet, Text, TextInput, View } from 'react-native';
3
4
  import { black, grey, primary } from '../../theme/palette';
@@ -5,6 +6,7 @@ import { formatPlaceholderMulti } from './utils';
5
6
  import ChevronIcon from './Components/Icons/Chevron';
6
7
  import DeleteIcon from './Components/Icons/Delete';
7
8
  import Dropdown from './Components/Dropdown';
9
+ import { horizontalScale, moderateScale, scaledForDevice } from '../../scale';
8
10
  var KeyboardTypes;
9
11
  (function (KeyboardTypes) {
10
12
  KeyboardTypes["Default"] = "default";
@@ -83,10 +85,20 @@ const Select = ({ options, label, value = null, placeholder = '', optionStyles =
83
85
  setInputValue(value);
84
86
  }
85
87
  }, [hasDefaultValue, value]);
88
+ const moveLabel = isMoveLabel ? 38 : 10;
89
+ const validFontSize = scaledForDevice(16, moderateScale);
90
+ const validMarginBottom = scaledForDevice(10, moderateScale);
91
+ const validMarginTop = scaledForDevice(18, moderateScale);
92
+ const validHeightLabel = scaledForDevice(19, moderateScale);
93
+ const validPadding = scaledForDevice(8, moderateScale);
94
+ const validBottomLabel = scaledForDevice(moveLabel, moderateScale);
95
+ const validHeightInput = scaledForDevice(38, moderateScale);
96
+ const validRight = scaledForDevice(30, horizontalScale);
97
+ const validBorderBottomWidth = scaledForDevice(1, moderateScale);
86
98
  const styles = StyleSheet.create({
87
99
  wrapper: {
88
100
  width: '100%',
89
- marginBottom: 10,
101
+ marginBottom: validMarginBottom,
90
102
  position: 'relative',
91
103
  zIndex: isShowedDropdown ? 10 : 0,
92
104
  },
@@ -94,32 +106,32 @@ const Select = ({ options, label, value = null, placeholder = '', optionStyles =
94
106
  position: 'relative',
95
107
  width: '100%',
96
108
  marginBottom: 0,
97
- marginTop: 18,
109
+ marginTop: validMarginTop,
98
110
  },
99
111
  label: {
100
112
  position: 'absolute',
101
113
  color: isMoveLabel && !isDisabled ? primary.main : black.main,
102
- fontSize: 16,
103
- lineHeight: 19,
114
+ fontSize: validFontSize,
115
+ lineHeight: validHeightLabel,
104
116
  letterSpacing: 0,
105
117
  left: 0,
106
118
  fontWeight: isMoveLabel ? '600' : '400',
107
- bottom: isMoveLabel ? 38 : 10,
119
+ bottom: validBottomLabel,
108
120
  },
109
121
  input: {
110
122
  width: '100%',
111
- height: 38,
123
+ height: validHeightInput,
112
124
  padding: 0,
113
- fontSize: 16,
114
- lineHeight: 19,
125
+ fontSize: validFontSize,
126
+ lineHeight: validHeightLabel,
115
127
  letterSpacing: 0,
116
- borderBottomWidth: 1,
128
+ borderBottomWidth: validBorderBottomWidth,
117
129
  color: black.main,
118
130
  borderBottomColor: isShowedDropdown ? primary.main : grey[200],
119
131
  },
120
132
  arrowIcon: {
121
133
  position: 'absolute',
122
- padding: 8,
134
+ padding: validPadding,
123
135
  right: 0,
124
136
  bottom: 0,
125
137
  zIndex: 1,
@@ -127,8 +139,8 @@ const Select = ({ options, label, value = null, placeholder = '', optionStyles =
127
139
  },
128
140
  deleteIcon: {
129
141
  position: 'absolute',
130
- padding: 8,
131
- right: 30,
142
+ padding: validPadding,
143
+ right: validRight,
132
144
  bottom: 0,
133
145
  zIndex: 1,
134
146
  },
@@ -2,21 +2,28 @@ import React, { isValidElement } from 'react';
2
2
  import { StyleSheet, View } from 'react-native';
3
3
  import { base, grey, primary } from '../../theme/palette';
4
4
  import Text from '../Text';
5
+ import { horizontalScale, moderateScale, scaledForDevice } from '../../scale';
6
+ const validHeight = scaledForDevice(24, moderateScale);
7
+ const validPadding = scaledForDevice(12, horizontalScale);
8
+ const validBorderRadius = scaledForDevice(12, moderateScale);
9
+ const validBorderWidth = scaledForDevice(1, moderateScale);
10
+ const validFontSize = scaledForDevice(13, moderateScale);
11
+ const validLineHeight = scaledForDevice(18, moderateScale);
5
12
  const styles = ({ background }) => StyleSheet.create({
6
13
  ViewStyles: {
7
- height: 24,
14
+ height: validHeight,
8
15
  flexDirection: 'row',
9
16
  alignItems: 'center',
10
- paddingLeft: 12,
11
- paddingRight: 12,
12
- borderRadius: 12,
17
+ paddingLeft: validPadding,
18
+ paddingRight: validPadding,
19
+ borderRadius: validBorderRadius,
13
20
  backgroundColor: background ?? base.white,
14
- borderWidth: 1,
21
+ borderWidth: validBorderWidth,
15
22
  borderColor: background ?? grey['300'],
16
23
  },
17
24
  TextStyles: {
18
- fontSize: 13,
19
- lineHeight: 18,
25
+ fontSize: validFontSize,
26
+ lineHeight: validLineHeight,
20
27
  fontFamily: 'Roboto',
21
28
  fontWeight: '900',
22
29
  textAlign: 'center',
@@ -7,6 +7,7 @@ import JanisLogo from './svgs/JanisLogo';
7
7
  import JanisLogoColor from './svgs/JanisLogoColor';
8
8
  import LoginIllustration from './svgs/LoginIllustration';
9
9
  import NoNotifications from './svgs/NoNotifications';
10
+ import { horizontalScale, moderateScale, scaledForDevice } from '../../scale';
10
11
  const svgs = {
11
12
  'empty-illustration': EmptyIllustration,
12
13
  'empty-list-illustration': EmptyListIllustration,
@@ -20,8 +21,14 @@ const Svg = ({ name, width, height, size, ...props }) => {
20
21
  return null;
21
22
  }
22
23
  const SvgSelected = svgs[name];
24
+ const selectedWidth = size ?? width;
25
+ const selectedHeight = size ?? height;
26
+ const parseSelectedWidth = selectedWidth || 0;
27
+ const parseSelectedHeight = selectedHeight || 0;
28
+ const validateWidth = scaledForDevice(parseSelectedWidth, horizontalScale);
29
+ const validateHeight = scaledForDevice(parseSelectedHeight, moderateScale);
23
30
  return (<View {...props}>
24
- <SvgSelected width={size ?? width} height={size ?? height} {...props}/>
31
+ <SvgSelected width={validateWidth} height={validateHeight} {...props}/>
25
32
  </View>);
26
33
  };
27
34
  export default Svg;
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
2
  import { StyleSheet, Text as TextComponent, } from 'react-native';
3
+ import { moderateScale, scaledForDevice } from '../../scale';
3
4
  const Text = ({ children, style, ...props }) => {
4
5
  if (!children) {
5
6
  return null;
6
7
  }
8
+ const validFontSize = scaledForDevice(13, moderateScale);
7
9
  const styles = StyleSheet.create({
8
10
  TextStyles: {
9
- fontSize: 13,
11
+ fontSize: validFontSize,
10
12
  fontFamily: 'Roboto',
11
13
  },
12
14
  });
@@ -17,4 +17,5 @@ import Carousel from './components/Carousel';
17
17
  import ProgressBar from './components/ProgressBar';
18
18
  import List from './components/List';
19
19
  import BaseButton from './components/BaseButton';
20
- export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, };
20
+ import * as getScale from './scale';
21
+ export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, getScale, };
@@ -17,4 +17,5 @@ import Carousel from './components/Carousel';
17
17
  import ProgressBar from './components/ProgressBar';
18
18
  import List from './components/List';
19
19
  import BaseButton from './components/BaseButton';
20
- export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, };
20
+ import * as getScale from './scale';
21
+ export { Text, Avatar, CheckBox, Icon, Image, Loading, Svg, StatusChip, Input, palette, LoadingFullScreen, RadioButton, Select, SwipeUp, SwipeUpFlatList, SwipeUpScrollView, SwipeUpView, Carousel, ProgressBar, List, BaseButton, getScale, };
@@ -0,0 +1,8 @@
1
+ declare const isIOS: boolean;
2
+ declare const viewportWidth: number, viewportHeight: number;
3
+ declare const isSmallDevice: (minWidth?: number) => boolean;
4
+ declare const horizontalScale: (size: number) => number;
5
+ declare const verticalScale: (size: number) => number;
6
+ declare const moderateScale: (size: number, factor?: number) => number;
7
+ declare const scaledForDevice: (size: number, scaleCallback: (size: number) => number) => number;
8
+ export { isIOS, viewportWidth, viewportHeight, isSmallDevice, horizontalScale, verticalScale, moderateScale, scaledForDevice, };
@@ -0,0 +1,13 @@
1
+ import { Dimensions, PixelRatio, Platform } from 'react-native';
2
+ import { WEB_MODE } from '../../env.json';
3
+ const guidelineBaseWidth = 360;
4
+ const guidelineBaseHeight = 720;
5
+ const isIOS = Platform.OS === 'ios';
6
+ const { width: viewportWidth, height: viewportHeight } = Dimensions.get('window');
7
+ const isSmallDevice = (minWidth = 365) => viewportWidth <= minWidth;
8
+ const horizontalScale = (size) => PixelRatio.roundToNearestPixel((viewportWidth / guidelineBaseWidth) * size);
9
+ const verticalScale = (size) => PixelRatio.roundToNearestPixel((viewportHeight / guidelineBaseHeight) * size);
10
+ const moderateScale = (size, factor = 1) => size + (horizontalScale(size) - size) * factor;
11
+ /* istanbul ignore next */
12
+ const scaledForDevice = (size, scaleCallback) => WEB_MODE ? size : scaleCallback(size);
13
+ export { isIOS, viewportWidth, viewportHeight, isSmallDevice, horizontalScale, verticalScale, moderateScale, scaledForDevice, };
@@ -6,12 +6,13 @@ const primary = {
6
6
  const black = {
7
7
  main: '#2F2F2F',
8
8
  dark: '#050505',
9
+ semiTransparent: '#0000001a',
9
10
  };
10
11
  const white = {
11
12
  main: '#E8EAF6',
12
13
  dark: '#D0D3E3',
13
14
  light: '#F4F5FB',
14
- semiTransparent: 'rgba(255, 255, 255, 0.75)',
15
+ semiTransparent: '#ffffffbf',
15
16
  };
16
17
  const grey = {
17
18
  100: '#DDDFE2',
@@ -19,8 +19,6 @@ export interface gamaColor {
19
19
  main: string;
20
20
  dark: string;
21
21
  }
22
- export interface Black extends gamaColor {
23
- }
24
22
  export interface Success extends gamaColor {
25
23
  }
26
24
  export interface Error extends gamaColor {
@@ -35,3 +33,6 @@ export interface Primary extends gamaColor {
35
33
  export interface White extends Primary {
36
34
  semiTransparent: string;
37
35
  }
36
+ export interface Black extends gamaColor {
37
+ semiTransparent: string;
38
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janiscommerce/ui-native",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "components library for Janis app",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -23,8 +23,8 @@
23
23
  "storybook-server": "react-native-storybook-server",
24
24
  "storybook-watcher": "sb-rn-watcher --config-path .ondevice",
25
25
  "update-stories": "sb-rn-get-stories --config-path .ondevice",
26
- "storybook-web": " npm run storybook-web-build && start-storybook -p 6006 --config-dir ./.storybook",
27
- "storybook-web-build": "build-storybook --config-dir ./.storybook --output-dir ./.storybook_static",
26
+ "storybook-web": "node scripts/set-app-mode.js web && npm run storybook-web-build && start-storybook -p 6006 --config-dir ./.storybook",
27
+ "storybook-web-build": "node scripts/set-app-mode.js web && build-storybook --config-dir ./.storybook --output-dir ./.storybook_static",
28
28
  "storybook-web-docs": "build-storybook --config-dir ./.storybook --output-dir ./docs"
29
29
  },
30
30
  "repository": {
File without changes
File without changes
File without changes
File without changes