@pagopa/io-app-design-system 1.38.5 → 1.38.6
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/lib/commonjs/components/layout/HeaderSecondLevel.js +32 -20
- package/lib/commonjs/components/layout/HeaderSecondLevel.js.map +1 -1
- package/lib/module/components/layout/HeaderSecondLevel.js +34 -22
- package/lib/module/components/layout/HeaderSecondLevel.js.map +1 -1
- package/lib/typescript/components/layout/HeaderSecondLevel.d.ts +3 -1
- package/lib/typescript/components/layout/HeaderSecondLevel.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/layout/HeaderSecondLevel.tsx +58 -32
|
@@ -6,19 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = exports.HeaderSecondLevel = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
-
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
10
9
|
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
10
|
+
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
11
11
|
var _core = require("../../core");
|
|
12
|
-
var _spacer = require("../spacer");
|
|
13
|
-
var _IconButton = _interopRequireDefault(require("../buttons/IconButton"));
|
|
14
12
|
var _fonts = require("../../utils/fonts");
|
|
13
|
+
var _IconButton = _interopRequireDefault(require("../buttons/IconButton"));
|
|
14
|
+
var _spacer = require("../spacer");
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
18
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
19
|
-
const HEADER_BG_COLOR = "white";
|
|
20
|
-
const borderColorDisabled = (0, _core.hexToRgba)(_core.IOColors["grey-100"], 0);
|
|
21
|
-
const headerTransparent = (0, _core.hexToRgba)(_core.IOColors[HEADER_BG_COLOR], 0);
|
|
22
19
|
const titleHorizontalMargin = 16;
|
|
23
20
|
const styles = _reactNative.StyleSheet.create({
|
|
24
21
|
headerInner: {
|
|
@@ -59,6 +56,8 @@ const HeaderSecondLevel = _ref => {
|
|
|
59
56
|
backTestID,
|
|
60
57
|
title,
|
|
61
58
|
type,
|
|
59
|
+
variant = "neutral",
|
|
60
|
+
backgroundColor,
|
|
62
61
|
transparent = false,
|
|
63
62
|
isModal = false,
|
|
64
63
|
testID,
|
|
@@ -70,8 +69,18 @@ const HeaderSecondLevel = _ref => {
|
|
|
70
69
|
const {
|
|
71
70
|
isExperimental
|
|
72
71
|
} = (0, _core.useIOExperimentalDesign)();
|
|
72
|
+
const theme = (0, _core.useIOTheme)();
|
|
73
73
|
const insets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
74
74
|
const isTitleAccessible = React.useMemo(() => !!title.trim(), [title]);
|
|
75
|
+
const iconButtonColor = variant === "neutral" ? "neutral" : "contrast";
|
|
76
|
+
const titleColor = variant === "neutral" ? _core.IOColors[theme["textHeading-default"]] : _core.IOColors.white;
|
|
77
|
+
|
|
78
|
+
/* Visual attributes when there are transitions between states */
|
|
79
|
+
const HEADER_DEFAULT_BG_COLOR = "white";
|
|
80
|
+
const headerBgColorTransparentState = backgroundColor ? (0, _core.hexToRgba)(backgroundColor, 0) : (0, _core.hexToRgba)(_core.IOColors[HEADER_DEFAULT_BG_COLOR], 0);
|
|
81
|
+
const headerBgColorSolidState = backgroundColor ?? _core.IOColors[HEADER_DEFAULT_BG_COLOR];
|
|
82
|
+
const borderColorTransparentState = backgroundColor ? (0, _core.hexToRgba)(backgroundColor, 0) : (0, _core.hexToRgba)(_core.IOColors["grey-100"], 0);
|
|
83
|
+
const borderColorSolidState = backgroundColor ?? _core.IOColors["grey-100"];
|
|
75
84
|
React.useLayoutEffect(() => {
|
|
76
85
|
if (isTitleAccessible) {
|
|
77
86
|
const reactNode = (0, _reactNative.findNodeHandle)(titleRef.current);
|
|
@@ -81,21 +90,22 @@ const HeaderSecondLevel = _ref => {
|
|
|
81
90
|
}
|
|
82
91
|
});
|
|
83
92
|
const headerWrapperAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
84
|
-
backgroundColor:
|
|
85
|
-
borderColor: scrollValues ? (0, _reactNativeReanimated.interpolateColor)(scrollValues.contentOffsetY.value, [0, scrollValues.triggerOffset], [
|
|
93
|
+
backgroundColor: scrollValues ? (0, _reactNativeReanimated.interpolateColor)(scrollValues.contentOffsetY.value, [0, scrollValues.triggerOffset], [headerBgColorTransparentState, headerBgColorSolidState]) : headerBgColorSolidState,
|
|
94
|
+
borderColor: scrollValues ? (0, _reactNativeReanimated.interpolateColor)(scrollValues.contentOffsetY.value, [0, scrollValues.triggerOffset], [borderColorTransparentState, borderColorSolidState]) : "transparent"
|
|
86
95
|
}));
|
|
87
96
|
const titleAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
88
97
|
opacity: scrollValues ? (0, _reactNativeReanimated.interpolate)(scrollValues.contentOffsetY.value, [0, scrollValues.triggerOffset], [0, 1]) : 1
|
|
89
98
|
}));
|
|
90
99
|
return /*#__PURE__*/React.createElement(_reactNativeReanimated.default.View, {
|
|
91
100
|
accessibilityRole: "header",
|
|
92
|
-
style: [
|
|
93
|
-
borderBottomWidth:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
101
|
+
style: [{
|
|
102
|
+
borderBottomWidth: 1,
|
|
103
|
+
borderColor: borderColorTransparentState
|
|
104
|
+
}, isModal ? {
|
|
105
|
+
borderColor: borderColorSolidState
|
|
106
|
+
} : {}, transparent ? headerWrapperAnimatedStyle : {
|
|
107
|
+
backgroundColor: headerBgColorSolidState
|
|
108
|
+
}]
|
|
99
109
|
}, /*#__PURE__*/React.createElement(_reactNativeReanimated.default.View, {
|
|
100
110
|
testID: testID,
|
|
101
111
|
style: [isModal ? {} : {
|
|
@@ -106,7 +116,7 @@ const HeaderSecondLevel = _ref => {
|
|
|
106
116
|
android: "backAndroid",
|
|
107
117
|
default: "backiOS"
|
|
108
118
|
}),
|
|
109
|
-
color:
|
|
119
|
+
color: iconButtonColor,
|
|
110
120
|
onPress: goBack,
|
|
111
121
|
accessibilityLabel: backAccessibilityLabel,
|
|
112
122
|
testID: backTestID
|
|
@@ -123,21 +133,23 @@ const HeaderSecondLevel = _ref => {
|
|
|
123
133
|
}, /*#__PURE__*/React.createElement(_reactNativeReanimated.default.Text, {
|
|
124
134
|
numberOfLines: 1,
|
|
125
135
|
accessible: false,
|
|
126
|
-
style: [styles.headerTitle,
|
|
136
|
+
style: [styles.headerTitle, {
|
|
137
|
+
color: titleColor
|
|
138
|
+
}, isExperimental ? styles.headerTitleFont : styles.headerTitleLegacyFont, titleAnimatedStyle]
|
|
127
139
|
}, title)), /*#__PURE__*/React.createElement(_reactNative.View, {
|
|
128
140
|
style: [_core.IOStyles.row, {
|
|
129
141
|
flexShrink: 0
|
|
130
142
|
}]
|
|
131
143
|
}, type === "threeActions" && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_IconButton.default, _extends({}, thirdAction, {
|
|
132
|
-
color:
|
|
144
|
+
color: iconButtonColor
|
|
133
145
|
})), /*#__PURE__*/React.createElement(_spacer.HSpacer, {
|
|
134
146
|
size: 16
|
|
135
147
|
})), (type === "twoActions" || type === "threeActions") && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_IconButton.default, _extends({}, secondAction, {
|
|
136
|
-
color:
|
|
148
|
+
color: iconButtonColor
|
|
137
149
|
})), /*#__PURE__*/React.createElement(_spacer.HSpacer, {
|
|
138
150
|
size: 16
|
|
139
151
|
})), type !== "base" ? /*#__PURE__*/React.createElement(_IconButton.default, _extends({}, firstAction, {
|
|
140
|
-
color:
|
|
152
|
+
color: iconButtonColor
|
|
141
153
|
})) : /*#__PURE__*/React.createElement(_spacer.HSpacer, {
|
|
142
154
|
size: _core.iconBtnSizeSmall
|
|
143
155
|
}))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","_interopRequireWildcard","require","_reactNative","
|
|
1
|
+
{"version":3,"names":["React","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","_reactNativeSafeAreaContext","_core","_fonts","_IconButton","_interopRequireDefault","_spacer","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","_extends","assign","bind","target","i","arguments","length","source","apply","titleHorizontalMargin","styles","StyleSheet","create","headerInner","paddingHorizontal","IOVisualCostants","appMarginDefault","height","headerHeight","flexGrow","flexDirection","alignItems","justifyContent","titleContainer","flexShrink","marginHorizontal","headerTitle","fontSize","textAlign","headerTitleFont","makeFontStyleObject","headerTitleLegacyFont","HeaderSecondLevel","_ref","scrollValues","undefined","goBack","backAccessibilityLabel","backTestID","title","type","variant","backgroundColor","transparent","isModal","testID","firstAction","secondAction","thirdAction","titleRef","createRef","isExperimental","useIOExperimentalDesign","theme","useIOTheme","insets","useSafeAreaInsets","isTitleAccessible","useMemo","trim","iconButtonColor","titleColor","IOColors","white","HEADER_DEFAULT_BG_COLOR","headerBgColorTransparentState","hexToRgba","headerBgColorSolidState","borderColorTransparentState","borderColorSolidState","useLayoutEffect","reactNode","findNodeHandle","current","AccessibilityInfo","setAccessibilityFocus","headerWrapperAnimatedStyle","useAnimatedStyle","interpolateColor","contentOffsetY","value","triggerOffset","borderColor","titleAnimatedStyle","opacity","interpolate","createElement","View","accessibilityRole","style","borderBottomWidth","marginTop","top","icon","Platform","select","android","color","onPress","accessibilityLabel","HSpacer","size","ref","accessibilityElementsHidden","importantForAccessibility","accessible","Text","numberOfLines","IOStyles","row","Fragment","iconBtnSizeSmall","exports","_default"],"sourceRoot":"../../../../src","sources":["components/layout/HeaderSecondLevel.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAQA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAKA,IAAAG,2BAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AAUA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,WAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAAoC,SAAAO,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,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
|
1
1
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
import {
|
|
4
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
3
|
+
import { AccessibilityInfo, Platform, StyleSheet, View, findNodeHandle } from "react-native";
|
|
5
4
|
import Animated, { interpolate, interpolateColor, useAnimatedStyle } from "react-native-reanimated";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import IconButton from "../buttons/IconButton";
|
|
5
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
6
|
+
import { IOColors, IOStyles, IOVisualCostants, hexToRgba, iconBtnSizeSmall, useIOExperimentalDesign, useIOTheme } from "../../core";
|
|
9
7
|
import { makeFontStyleObject } from "../../utils/fonts";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const headerTransparent = hexToRgba(IOColors[HEADER_BG_COLOR], 0);
|
|
8
|
+
import IconButton from "../buttons/IconButton";
|
|
9
|
+
import { HSpacer } from "../spacer";
|
|
13
10
|
const titleHorizontalMargin = 16;
|
|
14
11
|
const styles = StyleSheet.create({
|
|
15
12
|
headerInner: {
|
|
@@ -50,6 +47,8 @@ export const HeaderSecondLevel = _ref => {
|
|
|
50
47
|
backTestID,
|
|
51
48
|
title,
|
|
52
49
|
type,
|
|
50
|
+
variant = "neutral",
|
|
51
|
+
backgroundColor,
|
|
53
52
|
transparent = false,
|
|
54
53
|
isModal = false,
|
|
55
54
|
testID,
|
|
@@ -61,8 +60,18 @@ export const HeaderSecondLevel = _ref => {
|
|
|
61
60
|
const {
|
|
62
61
|
isExperimental
|
|
63
62
|
} = useIOExperimentalDesign();
|
|
63
|
+
const theme = useIOTheme();
|
|
64
64
|
const insets = useSafeAreaInsets();
|
|
65
65
|
const isTitleAccessible = React.useMemo(() => !!title.trim(), [title]);
|
|
66
|
+
const iconButtonColor = variant === "neutral" ? "neutral" : "contrast";
|
|
67
|
+
const titleColor = variant === "neutral" ? IOColors[theme["textHeading-default"]] : IOColors.white;
|
|
68
|
+
|
|
69
|
+
/* Visual attributes when there are transitions between states */
|
|
70
|
+
const HEADER_DEFAULT_BG_COLOR = "white";
|
|
71
|
+
const headerBgColorTransparentState = backgroundColor ? hexToRgba(backgroundColor, 0) : hexToRgba(IOColors[HEADER_DEFAULT_BG_COLOR], 0);
|
|
72
|
+
const headerBgColorSolidState = backgroundColor ?? IOColors[HEADER_DEFAULT_BG_COLOR];
|
|
73
|
+
const borderColorTransparentState = backgroundColor ? hexToRgba(backgroundColor, 0) : hexToRgba(IOColors["grey-100"], 0);
|
|
74
|
+
const borderColorSolidState = backgroundColor ?? IOColors["grey-100"];
|
|
66
75
|
React.useLayoutEffect(() => {
|
|
67
76
|
if (isTitleAccessible) {
|
|
68
77
|
const reactNode = findNodeHandle(titleRef.current);
|
|
@@ -72,21 +81,22 @@ export const HeaderSecondLevel = _ref => {
|
|
|
72
81
|
}
|
|
73
82
|
});
|
|
74
83
|
const headerWrapperAnimatedStyle = useAnimatedStyle(() => ({
|
|
75
|
-
backgroundColor:
|
|
76
|
-
borderColor: scrollValues ? interpolateColor(scrollValues.contentOffsetY.value, [0, scrollValues.triggerOffset], [
|
|
84
|
+
backgroundColor: scrollValues ? interpolateColor(scrollValues.contentOffsetY.value, [0, scrollValues.triggerOffset], [headerBgColorTransparentState, headerBgColorSolidState]) : headerBgColorSolidState,
|
|
85
|
+
borderColor: scrollValues ? interpolateColor(scrollValues.contentOffsetY.value, [0, scrollValues.triggerOffset], [borderColorTransparentState, borderColorSolidState]) : "transparent"
|
|
77
86
|
}));
|
|
78
87
|
const titleAnimatedStyle = useAnimatedStyle(() => ({
|
|
79
88
|
opacity: scrollValues ? interpolate(scrollValues.contentOffsetY.value, [0, scrollValues.triggerOffset], [0, 1]) : 1
|
|
80
89
|
}));
|
|
81
90
|
return /*#__PURE__*/React.createElement(Animated.View, {
|
|
82
91
|
accessibilityRole: "header",
|
|
83
|
-
style: [
|
|
84
|
-
borderBottomWidth:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
92
|
+
style: [{
|
|
93
|
+
borderBottomWidth: 1,
|
|
94
|
+
borderColor: borderColorTransparentState
|
|
95
|
+
}, isModal ? {
|
|
96
|
+
borderColor: borderColorSolidState
|
|
97
|
+
} : {}, transparent ? headerWrapperAnimatedStyle : {
|
|
98
|
+
backgroundColor: headerBgColorSolidState
|
|
99
|
+
}]
|
|
90
100
|
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
91
101
|
testID: testID,
|
|
92
102
|
style: [isModal ? {} : {
|
|
@@ -97,7 +107,7 @@ export const HeaderSecondLevel = _ref => {
|
|
|
97
107
|
android: "backAndroid",
|
|
98
108
|
default: "backiOS"
|
|
99
109
|
}),
|
|
100
|
-
color:
|
|
110
|
+
color: iconButtonColor,
|
|
101
111
|
onPress: goBack,
|
|
102
112
|
accessibilityLabel: backAccessibilityLabel,
|
|
103
113
|
testID: backTestID
|
|
@@ -114,21 +124,23 @@ export const HeaderSecondLevel = _ref => {
|
|
|
114
124
|
}, /*#__PURE__*/React.createElement(Animated.Text, {
|
|
115
125
|
numberOfLines: 1,
|
|
116
126
|
accessible: false,
|
|
117
|
-
style: [styles.headerTitle,
|
|
127
|
+
style: [styles.headerTitle, {
|
|
128
|
+
color: titleColor
|
|
129
|
+
}, isExperimental ? styles.headerTitleFont : styles.headerTitleLegacyFont, titleAnimatedStyle]
|
|
118
130
|
}, title)), /*#__PURE__*/React.createElement(View, {
|
|
119
131
|
style: [IOStyles.row, {
|
|
120
132
|
flexShrink: 0
|
|
121
133
|
}]
|
|
122
134
|
}, type === "threeActions" && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconButton, _extends({}, thirdAction, {
|
|
123
|
-
color:
|
|
135
|
+
color: iconButtonColor
|
|
124
136
|
})), /*#__PURE__*/React.createElement(HSpacer, {
|
|
125
137
|
size: 16
|
|
126
138
|
})), (type === "twoActions" || type === "threeActions") && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconButton, _extends({}, secondAction, {
|
|
127
|
-
color:
|
|
139
|
+
color: iconButtonColor
|
|
128
140
|
})), /*#__PURE__*/React.createElement(HSpacer, {
|
|
129
141
|
size: 16
|
|
130
142
|
})), type !== "base" ? /*#__PURE__*/React.createElement(IconButton, _extends({}, firstAction, {
|
|
131
|
-
color:
|
|
143
|
+
color: iconButtonColor
|
|
132
144
|
})) : /*#__PURE__*/React.createElement(HSpacer, {
|
|
133
145
|
size: iconBtnSizeSmall
|
|
134
146
|
}))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","
|
|
1
|
+
{"version":3,"names":["React","AccessibilityInfo","Platform","StyleSheet","View","findNodeHandle","Animated","interpolate","interpolateColor","useAnimatedStyle","useSafeAreaInsets","IOColors","IOStyles","IOVisualCostants","hexToRgba","iconBtnSizeSmall","useIOExperimentalDesign","useIOTheme","makeFontStyleObject","IconButton","HSpacer","titleHorizontalMargin","styles","create","headerInner","paddingHorizontal","appMarginDefault","height","headerHeight","flexGrow","flexDirection","alignItems","justifyContent","titleContainer","flexShrink","marginHorizontal","headerTitle","fontSize","textAlign","headerTitleFont","headerTitleLegacyFont","HeaderSecondLevel","_ref","scrollValues","undefined","goBack","backAccessibilityLabel","backTestID","title","type","variant","backgroundColor","transparent","isModal","testID","firstAction","secondAction","thirdAction","titleRef","createRef","isExperimental","theme","insets","isTitleAccessible","useMemo","trim","iconButtonColor","titleColor","white","HEADER_DEFAULT_BG_COLOR","headerBgColorTransparentState","headerBgColorSolidState","borderColorTransparentState","borderColorSolidState","useLayoutEffect","reactNode","current","setAccessibilityFocus","headerWrapperAnimatedStyle","contentOffsetY","value","triggerOffset","borderColor","titleAnimatedStyle","opacity","createElement","accessibilityRole","style","borderBottomWidth","marginTop","top","icon","select","android","default","color","onPress","accessibilityLabel","size","ref","accessibilityElementsHidden","importantForAccessibility","accessible","Text","numberOfLines","row","Fragment","_extends"],"sourceRoot":"../../../../src","sources":["components/layout/HeaderSecondLevel.tsx"],"mappings":";AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SACEC,iBAAiB,EAEjBC,QAAQ,EACRC,UAAU,EACVC,IAAI,EACJC,cAAc,QACT,cAAc;AACrB,OAAOC,QAAQ,IACbC,WAAW,EACXC,gBAAgB,EAChBC,gBAAgB,QACX,yBAAyB;AAChC,SAASC,iBAAiB,QAAQ,gCAAgC;AAClE,SACEC,QAAQ,EACRC,QAAQ,EACRC,gBAAgB,EAChBC,SAAS,EACTC,gBAAgB,EAChBC,uBAAuB,EACvBC,UAAU,QACL,YAAY;AAEnB,SAASC,mBAAmB,QAAQ,mBAAmB;AAEvD,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SAASC,OAAO,QAAQ,WAAW;AA6DnC,MAAMC,qBAAqC,GAAG,EAAE;AAEhD,MAAMC,MAAM,GAAGnB,UAAU,CAACoB,MAAM,CAAC;EAC/BC,WAAW,EAAE;IACXC,iBAAiB,EAAEZ,gBAAgB,CAACa,gBAAgB;IACpDC,MAAM,EAAEd,gBAAgB,CAACe,YAAY;IACrCC,QAAQ,EAAE,CAAC;IACXC,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDC,cAAc,EAAE;IACdJ,QAAQ,EAAE,CAAC;IACXK,UAAU,EAAE,CAAC;IACbC,gBAAgB,EAAEd;EACpB,CAAC;EACDe,WAAW,EAAE;IACXC,QAAQ,EAAE,EAAE;IACZC,SAAS,EAAE;EACb,CAAC;EACDC,eAAe,EAAE;IACf,GAAGrB,mBAAmB,CAAC,SAAS,EAAE,KAAK,EAAE,WAAW;EACtD,CAAC;EACDsB,qBAAqB,EAAE;IACrB,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CACO,CACF,CAAC;AAEpB,CAAC;AAED,eAAe0B,iBAAiB"}
|
|
@@ -19,6 +19,8 @@ type CommonProps = WithTestID<{
|
|
|
19
19
|
scrollValues?: ScrollValues;
|
|
20
20
|
title: string;
|
|
21
21
|
transparent?: boolean;
|
|
22
|
+
variant?: "neutral" | "contrast";
|
|
23
|
+
backgroundColor?: string;
|
|
22
24
|
isModal?: boolean;
|
|
23
25
|
}>;
|
|
24
26
|
interface Base extends CommonProps {
|
|
@@ -51,6 +53,6 @@ export type HeaderSecondLevel = BackProps & (Base | OneAction | TwoActions | Thr
|
|
|
51
53
|
* @param {HeaderSecondLevel} props - The props of the component
|
|
52
54
|
* @returns React Element
|
|
53
55
|
*/
|
|
54
|
-
export declare const HeaderSecondLevel: ({ scrollValues, goBack, backAccessibilityLabel, backTestID, title, type, transparent, isModal, testID, firstAction, secondAction, thirdAction }: HeaderSecondLevel) => React.JSX.Element;
|
|
56
|
+
export declare const HeaderSecondLevel: ({ scrollValues, goBack, backAccessibilityLabel, backTestID, title, type, variant, backgroundColor, transparent, isModal, testID, firstAction, secondAction, thirdAction }: HeaderSecondLevel) => React.JSX.Element;
|
|
55
57
|
export default HeaderSecondLevel;
|
|
56
58
|
//# sourceMappingURL=HeaderSecondLevel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderSecondLevel.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/HeaderSecondLevel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"HeaderSecondLevel.d.ts","sourceRoot":"","sources":["../../../../src/components/layout/HeaderSecondLevel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,OAAO,QAIN,MAAM,yBAAyB,CAAC;AAajC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAA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AAE,cAAc,CAAC;IACrB,WAAW,EAAE,UAAU,CAAC;IACxB,YAAY,EAAE,UAAU,CAAC;IACzB,WAAW,EAAE,UAAU,CAAC;CACzB;AAED,MAAM,MAAM,iBAAiB,GAAG,SAAS,GACvC,CAAC,IAAI,GAAG,SAAS,GAAG,UAAU,GAAG,YAAY,CAAC,CAAC;AA8BjD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,8KAe3B,iBAAiB,sBAiJnB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { ComponentProps } from "react";
|
|
2
3
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
AccessibilityInfo,
|
|
5
|
+
ColorValue,
|
|
5
6
|
Platform,
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
StyleSheet,
|
|
8
|
+
View,
|
|
9
|
+
findNodeHandle
|
|
8
10
|
} from "react-native";
|
|
9
|
-
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
10
11
|
import Animated, {
|
|
11
12
|
interpolate,
|
|
12
13
|
interpolateColor,
|
|
13
14
|
useAnimatedStyle
|
|
14
15
|
} from "react-native-reanimated";
|
|
16
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
15
17
|
import {
|
|
18
|
+
IOColors,
|
|
16
19
|
IOStyles,
|
|
17
20
|
IOVisualCostants,
|
|
18
|
-
iconBtnSizeSmall,
|
|
19
|
-
IOColors,
|
|
20
21
|
hexToRgba,
|
|
21
|
-
|
|
22
|
+
iconBtnSizeSmall,
|
|
23
|
+
useIOExperimentalDesign,
|
|
24
|
+
useIOTheme
|
|
22
25
|
} from "../../core";
|
|
23
|
-
import {
|
|
24
|
-
import
|
|
26
|
+
import type { IOSpacer, IOSpacingScale } from "../../core/IOSpacing";
|
|
27
|
+
import { makeFontStyleObject } from "../../utils/fonts";
|
|
25
28
|
import { WithTestID } from "../../utils/types";
|
|
26
29
|
import IconButton from "../buttons/IconButton";
|
|
27
|
-
import {
|
|
30
|
+
import { HSpacer } from "../spacer";
|
|
28
31
|
import { ActionProp } from "./common";
|
|
29
32
|
|
|
30
33
|
type ScrollValues = {
|
|
@@ -49,6 +52,8 @@ type CommonProps = WithTestID<{
|
|
|
49
52
|
title: string;
|
|
50
53
|
// Visual attributes
|
|
51
54
|
transparent?: boolean;
|
|
55
|
+
variant?: "neutral" | "contrast";
|
|
56
|
+
backgroundColor?: string;
|
|
52
57
|
isModal?: boolean;
|
|
53
58
|
}>;
|
|
54
59
|
|
|
@@ -83,10 +88,7 @@ interface ThreeActions extends CommonProps {
|
|
|
83
88
|
export type HeaderSecondLevel = BackProps &
|
|
84
89
|
(Base | OneAction | TwoActions | ThreeActions);
|
|
85
90
|
|
|
86
|
-
const
|
|
87
|
-
const borderColorDisabled = hexToRgba(IOColors["grey-100"], 0);
|
|
88
|
-
const headerTransparent = hexToRgba(IOColors[HEADER_BG_COLOR], 0);
|
|
89
|
-
const titleHorizontalMargin: IOSpacer = 16;
|
|
91
|
+
const titleHorizontalMargin: IOSpacingScale = 16;
|
|
90
92
|
|
|
91
93
|
const styles = StyleSheet.create({
|
|
92
94
|
headerInner: {
|
|
@@ -126,6 +128,8 @@ export const HeaderSecondLevel = ({
|
|
|
126
128
|
backTestID,
|
|
127
129
|
title,
|
|
128
130
|
type,
|
|
131
|
+
variant = "neutral",
|
|
132
|
+
backgroundColor,
|
|
129
133
|
transparent = false,
|
|
130
134
|
isModal = false,
|
|
131
135
|
testID,
|
|
@@ -136,9 +140,31 @@ export const HeaderSecondLevel = ({
|
|
|
136
140
|
const titleRef = React.createRef<View>();
|
|
137
141
|
|
|
138
142
|
const { isExperimental } = useIOExperimentalDesign();
|
|
143
|
+
const theme = useIOTheme();
|
|
139
144
|
const insets = useSafeAreaInsets();
|
|
140
145
|
const isTitleAccessible = React.useMemo(() => !!title.trim(), [title]);
|
|
141
146
|
|
|
147
|
+
const iconButtonColor: ComponentProps<typeof IconButton>["color"] =
|
|
148
|
+
variant === "neutral" ? "neutral" : "contrast";
|
|
149
|
+
const titleColor: ColorValue =
|
|
150
|
+
variant === "neutral"
|
|
151
|
+
? IOColors[theme["textHeading-default"]]
|
|
152
|
+
: IOColors.white;
|
|
153
|
+
|
|
154
|
+
/* Visual attributes when there are transitions between states */
|
|
155
|
+
const HEADER_DEFAULT_BG_COLOR: IOColors = "white";
|
|
156
|
+
|
|
157
|
+
const headerBgColorTransparentState = backgroundColor
|
|
158
|
+
? hexToRgba(backgroundColor, 0)
|
|
159
|
+
: hexToRgba(IOColors[HEADER_DEFAULT_BG_COLOR], 0);
|
|
160
|
+
const headerBgColorSolidState =
|
|
161
|
+
backgroundColor ?? IOColors[HEADER_DEFAULT_BG_COLOR];
|
|
162
|
+
|
|
163
|
+
const borderColorTransparentState = backgroundColor
|
|
164
|
+
? hexToRgba(backgroundColor, 0)
|
|
165
|
+
: hexToRgba(IOColors["grey-100"], 0);
|
|
166
|
+
const borderColorSolidState = backgroundColor ?? IOColors["grey-100"];
|
|
167
|
+
|
|
142
168
|
React.useLayoutEffect(() => {
|
|
143
169
|
if (isTitleAccessible) {
|
|
144
170
|
const reactNode = findNodeHandle(titleRef.current);
|
|
@@ -149,19 +175,18 @@ export const HeaderSecondLevel = ({
|
|
|
149
175
|
});
|
|
150
176
|
|
|
151
177
|
const headerWrapperAnimatedStyle = useAnimatedStyle(() => ({
|
|
152
|
-
backgroundColor:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
: IOColors[HEADER_BG_COLOR],
|
|
178
|
+
backgroundColor: scrollValues
|
|
179
|
+
? interpolateColor(
|
|
180
|
+
scrollValues.contentOffsetY.value,
|
|
181
|
+
[0, scrollValues.triggerOffset],
|
|
182
|
+
[headerBgColorTransparentState, headerBgColorSolidState]
|
|
183
|
+
)
|
|
184
|
+
: headerBgColorSolidState,
|
|
160
185
|
borderColor: scrollValues
|
|
161
186
|
? interpolateColor(
|
|
162
187
|
scrollValues.contentOffsetY.value,
|
|
163
188
|
[0, scrollValues.triggerOffset],
|
|
164
|
-
[
|
|
189
|
+
[borderColorTransparentState, borderColorSolidState]
|
|
165
190
|
)
|
|
166
191
|
: "transparent"
|
|
167
192
|
}));
|
|
@@ -180,11 +205,11 @@ export const HeaderSecondLevel = ({
|
|
|
180
205
|
<Animated.View
|
|
181
206
|
accessibilityRole="header"
|
|
182
207
|
style={[
|
|
208
|
+
{ borderBottomWidth: 1, borderColor: borderColorTransparentState },
|
|
209
|
+
isModal ? { borderColor: borderColorSolidState } : {},
|
|
183
210
|
transparent
|
|
184
|
-
?
|
|
185
|
-
: { backgroundColor:
|
|
186
|
-
{ borderBottomWidth: 1 },
|
|
187
|
-
headerWrapperAnimatedStyle
|
|
211
|
+
? headerWrapperAnimatedStyle
|
|
212
|
+
: { backgroundColor: headerBgColorSolidState }
|
|
188
213
|
]}
|
|
189
214
|
>
|
|
190
215
|
<Animated.View
|
|
@@ -197,7 +222,7 @@ export const HeaderSecondLevel = ({
|
|
|
197
222
|
android: "backAndroid",
|
|
198
223
|
default: "backiOS"
|
|
199
224
|
})}
|
|
200
|
-
color=
|
|
225
|
+
color={iconButtonColor}
|
|
201
226
|
onPress={goBack}
|
|
202
227
|
accessibilityLabel={backAccessibilityLabel}
|
|
203
228
|
testID={backTestID}
|
|
@@ -221,6 +246,7 @@ export const HeaderSecondLevel = ({
|
|
|
221
246
|
accessible={false}
|
|
222
247
|
style={[
|
|
223
248
|
styles.headerTitle,
|
|
249
|
+
{ color: titleColor },
|
|
224
250
|
isExperimental
|
|
225
251
|
? styles.headerTitleFont
|
|
226
252
|
: styles.headerTitleLegacyFont,
|
|
@@ -233,21 +259,21 @@ export const HeaderSecondLevel = ({
|
|
|
233
259
|
<View style={[IOStyles.row, { flexShrink: 0 }]}>
|
|
234
260
|
{type === "threeActions" && (
|
|
235
261
|
<>
|
|
236
|
-
<IconButton {...thirdAction} color=
|
|
262
|
+
<IconButton {...thirdAction} color={iconButtonColor} />
|
|
237
263
|
{/* Same as above */}
|
|
238
264
|
<HSpacer size={16} />
|
|
239
265
|
</>
|
|
240
266
|
)}
|
|
241
267
|
{(type === "twoActions" || type === "threeActions") && (
|
|
242
268
|
<>
|
|
243
|
-
<IconButton {...secondAction} color=
|
|
269
|
+
<IconButton {...secondAction} color={iconButtonColor} />
|
|
244
270
|
{/* Ideally, with the "gap" flex property,
|
|
245
271
|
we can get rid of these ugly constructs */}
|
|
246
272
|
<HSpacer size={16} />
|
|
247
273
|
</>
|
|
248
274
|
)}
|
|
249
275
|
{type !== "base" ? (
|
|
250
|
-
<IconButton {...firstAction} color=
|
|
276
|
+
<IconButton {...firstAction} color={iconButtonColor} />
|
|
251
277
|
) : (
|
|
252
278
|
<HSpacer size={iconBtnSizeSmall as IOSpacer} />
|
|
253
279
|
)}
|