@tecsinapse/react-core 1.12.3 → 1.12.7
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 +35 -0
- package/dist/components/atoms/Badge/styled.d.ts +3 -2
- package/dist/components/atoms/Badge/styled.js +5 -3
- package/dist/components/atoms/Badge/styled.js.map +1 -1
- package/dist/components/atoms/Button/styled.js +4 -2
- package/dist/components/atoms/Button/styled.js.map +1 -1
- package/dist/components/atoms/GroupButton/styled.js +4 -2
- package/dist/components/atoms/GroupButton/styled.js.map +1 -1
- package/dist/components/atoms/Input/styled.js +3 -1
- package/dist/components/atoms/Input/styled.js.map +1 -1
- package/dist/components/atoms/ProgressBar/styled.d.ts +15 -3
- package/dist/components/atoms/ProgressBar/styled.js +3 -1
- package/dist/components/atoms/ProgressBar/styled.js.map +1 -1
- package/dist/components/atoms/Switch/Switch.js +30 -22
- package/dist/components/atoms/Switch/Switch.js.map +1 -1
- package/dist/components/atoms/Switch/animation.d.ts +1 -1
- package/dist/components/atoms/Switch/animation.js +24 -16
- package/dist/components/atoms/Switch/animation.js.map +1 -1
- package/dist/components/atoms/Switch/styled.d.ts +16 -2
- package/dist/components/atoms/Switch/styled.js +11 -5
- package/dist/components/atoms/Switch/styled.js.map +1 -1
- package/dist/components/atoms/shared/PaperAndCard.js +3 -5
- package/dist/components/atoms/shared/PaperAndCard.js.map +1 -1
- package/dist/components/molecules/DatePicker/styled.d.ts +25 -4
- package/dist/components/molecules/DatePicker/styled.js +7 -5
- package/dist/components/molecules/DatePicker/styled.js.map +1 -1
- package/dist/components/molecules/DateTimePicker/styled.js +4 -2
- package/dist/components/molecules/DateTimePicker/styled.js.map +1 -1
- package/dist/components/molecules/DateTimeSelector/styled.js +3 -1
- package/dist/components/molecules/DateTimeSelector/styled.js.map +1 -1
- package/dist/components/molecules/Snackbar/styled.js +7 -5
- package/dist/components/molecules/Snackbar/styled.js.map +1 -1
- package/dist/components/molecules/TextArea/styled.d.ts +13 -6
- package/dist/components/molecules/TextArea/styled.js +8 -6
- package/dist/components/molecules/TextArea/styled.js.map +1 -1
- package/dist/styles/definitions.js +45 -42
- package/dist/styles/definitions.js.map +1 -1
- package/dist/utils/IPhoneXHelper.d.ts +4 -0
- package/dist/utils/IPhoneXHelper.js +38 -0
- package/dist/utils/IPhoneXHelper.js.map +1 -0
- package/dist/utils/ResponsiveFontSize.d.ts +3 -0
- package/dist/utils/ResponsiveFontSize.js +57 -0
- package/dist/utils/ResponsiveFontSize.js.map +1 -0
- package/dist/utils/extractNumbersFromString.js +2 -2
- package/dist/utils/extractNumbersFromString.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +33 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/atoms/Badge/styled.ts +5 -4
- package/src/components/atoms/Button/styled.ts +3 -2
- package/src/components/atoms/GroupButton/styled.ts +3 -2
- package/src/components/atoms/Input/styled.ts +2 -1
- package/src/components/atoms/ProgressBar/styled.ts +3 -2
- package/src/components/atoms/Switch/Switch.tsx +29 -32
- package/src/components/atoms/Switch/animation.ts +26 -16
- package/src/components/atoms/Switch/styled.ts +10 -6
- package/src/components/atoms/shared/PaperAndCard.ts +4 -6
- package/src/components/molecules/DatePicker/styled.ts +4 -2
- package/src/components/molecules/DateTimePicker/styled.ts +4 -3
- package/src/components/molecules/DateTimeSelector/styled.ts +2 -1
- package/src/components/molecules/Snackbar/styled.ts +6 -5
- package/src/components/molecules/TextArea/styled.ts +6 -12
- package/src/styles/definitions.ts +44 -43
- package/src/utils/IPhoneXHelper.ts +34 -0
- package/src/utils/ResponsiveFontSize.ts +52 -0
- package/src/utils/extractNumbersFromString.ts +2 -4
- package/src/utils/index.ts +2 -0
|
@@ -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: {
|
|
@@ -48,81 +49,81 @@ export const hex2rgba: (hex, alpha?: number) => string = (hex, alpha = 1) => {
|
|
|
48
49
|
};
|
|
49
50
|
|
|
50
51
|
export const miscellaneous: Miscellaneous = {
|
|
51
|
-
shadow: '#
|
|
52
|
+
shadow: '#000000', // black
|
|
52
53
|
overlay: '#282625', // rgba(40, 38, 37, 0.5)
|
|
53
54
|
bodyColor: '#f8f7f7',
|
|
54
55
|
surfaceColor: '#ffffff', //input, group button, cards
|
|
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, '');
|