react-native-system-ui 0.0.4 → 0.0.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.
|
@@ -51,20 +51,21 @@ const Notify = props => {
|
|
|
51
51
|
const tokens = (0, _tokens.useNotifyTokens)(tokensOverride);
|
|
52
52
|
const paddingVertical = tokens.spacing.paddingVertical;
|
|
53
53
|
const safeAreaPadding = (0, _hooks.useSafeAreaPadding)({
|
|
54
|
-
top:
|
|
55
|
-
bottom:
|
|
54
|
+
top: 0,
|
|
55
|
+
bottom: 0
|
|
56
56
|
});
|
|
57
57
|
const type = typeProp ?? tokens.defaults.type;
|
|
58
58
|
const position = positionProp ?? tokens.defaults.position;
|
|
59
59
|
const closeOnClick = closeOnClickProp ?? tokens.defaults.closeOnClick;
|
|
60
60
|
const safeAreaInsetTop = props.safeAreaInsetTop ?? (position === 'top' ? tokens.defaults.safeAreaInsetTop : false);
|
|
61
61
|
const safeAreaInsetBottom = props.safeAreaInsetBottom ?? (position === 'bottom' ? tokens.defaults.safeAreaInsetBottom : false);
|
|
62
|
-
const safeTop = safeAreaInsetTop && position === 'top' ? safeAreaPadding.paddingTop :
|
|
63
|
-
const safeBottom = safeAreaInsetBottom && position === 'bottom' ? safeAreaPadding.paddingBottom :
|
|
62
|
+
const safeTop = safeAreaInsetTop && position === 'top' ? safeAreaPadding.paddingTop : 0;
|
|
63
|
+
const safeBottom = safeAreaInsetBottom && position === 'bottom' ? safeAreaPadding.paddingBottom : 0;
|
|
64
64
|
const offset = typeof offsetProp === 'number' && Number.isFinite(offsetProp) ? Math.max(0, offsetProp) : 0;
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
65
|
+
const addOffset = (value, delta) => typeof value === 'string' ? `calc(${value} + ${delta}px)` : value + delta;
|
|
66
|
+
const safeBottomInset = safeAreaInsetBottom && position === 'bottom' && typeof safeBottom === 'number' ? safeBottom + offset : offset;
|
|
67
|
+
const webTopPadding = _reactNative().Platform.OS === 'web' && position === 'top' ? addOffset(safeTop, offset) : undefined;
|
|
68
|
+
const webBottomPadding = _reactNative().Platform.OS === 'web' && safeAreaInsetBottom && position === 'bottom' ? addOffset(safeBottom, offset) : undefined;
|
|
68
69
|
const variant = tokens.colors.variants[type];
|
|
69
70
|
const resolvedBackground = background ?? variant.background;
|
|
70
71
|
const resolvedTextColor = color ?? variant.text;
|
|
@@ -155,7 +156,7 @@ const Notify = props => {
|
|
|
155
156
|
if (!mounted) return null;
|
|
156
157
|
const bar = /*#__PURE__*/_react().default.createElement(_reactNative().View, {
|
|
157
158
|
style: [tokens.layout.container, position === 'top' ? {
|
|
158
|
-
paddingTop: webTopPadding ?? (
|
|
159
|
+
paddingTop: webTopPadding ?? addOffset(safeTop, offset)
|
|
159
160
|
} : null, webBottomPadding !== undefined ? {
|
|
160
161
|
paddingBottom: webBottomPadding
|
|
161
162
|
} : null]
|
|
@@ -31,20 +31,21 @@ export const Notify = props => {
|
|
|
31
31
|
const tokens = useNotifyTokens(tokensOverride);
|
|
32
32
|
const paddingVertical = tokens.spacing.paddingVertical;
|
|
33
33
|
const safeAreaPadding = useSafeAreaPadding({
|
|
34
|
-
top:
|
|
35
|
-
bottom:
|
|
34
|
+
top: 0,
|
|
35
|
+
bottom: 0
|
|
36
36
|
});
|
|
37
37
|
const type = typeProp ?? tokens.defaults.type;
|
|
38
38
|
const position = positionProp ?? tokens.defaults.position;
|
|
39
39
|
const closeOnClick = closeOnClickProp ?? tokens.defaults.closeOnClick;
|
|
40
40
|
const safeAreaInsetTop = props.safeAreaInsetTop ?? (position === 'top' ? tokens.defaults.safeAreaInsetTop : false);
|
|
41
41
|
const safeAreaInsetBottom = props.safeAreaInsetBottom ?? (position === 'bottom' ? tokens.defaults.safeAreaInsetBottom : false);
|
|
42
|
-
const safeTop = safeAreaInsetTop && position === 'top' ? safeAreaPadding.paddingTop :
|
|
43
|
-
const safeBottom = safeAreaInsetBottom && position === 'bottom' ? safeAreaPadding.paddingBottom :
|
|
42
|
+
const safeTop = safeAreaInsetTop && position === 'top' ? safeAreaPadding.paddingTop : 0;
|
|
43
|
+
const safeBottom = safeAreaInsetBottom && position === 'bottom' ? safeAreaPadding.paddingBottom : 0;
|
|
44
44
|
const offset = typeof offsetProp === 'number' && Number.isFinite(offsetProp) ? Math.max(0, offsetProp) : 0;
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
45
|
+
const addOffset = (value, delta) => typeof value === 'string' ? `calc(${value} + ${delta}px)` : value + delta;
|
|
46
|
+
const safeBottomInset = safeAreaInsetBottom && position === 'bottom' && typeof safeBottom === 'number' ? safeBottom + offset : offset;
|
|
47
|
+
const webTopPadding = Platform.OS === 'web' && position === 'top' ? addOffset(safeTop, offset) : undefined;
|
|
48
|
+
const webBottomPadding = Platform.OS === 'web' && safeAreaInsetBottom && position === 'bottom' ? addOffset(safeBottom, offset) : undefined;
|
|
48
49
|
const variant = tokens.colors.variants[type];
|
|
49
50
|
const resolvedBackground = background ?? variant.background;
|
|
50
51
|
const resolvedTextColor = color ?? variant.text;
|
|
@@ -135,7 +136,7 @@ export const Notify = props => {
|
|
|
135
136
|
if (!mounted) return null;
|
|
136
137
|
const bar = /*#__PURE__*/React.createElement(View, {
|
|
137
138
|
style: [tokens.layout.container, position === 'top' ? {
|
|
138
|
-
paddingTop: webTopPadding ?? (
|
|
139
|
+
paddingTop: webTopPadding ?? addOffset(safeTop, offset)
|
|
139
140
|
} : null, webBottomPadding !== undefined ? {
|
|
140
141
|
paddingBottom: webBottomPadding
|
|
141
142
|
} : null]
|
package/package.json
CHANGED