@twreporter/universal-header 2.2.0-rc.6 → 2.2.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.
- package/CHANGELOG.md +74 -0
- package/lib/components/action-button.js +5 -3
- package/lib/components/channels.js +50 -50
- package/lib/components/drop-down-menu.js +14 -5
- package/lib/components/hamburger-icons.js +1 -1
- package/lib/components/hamburger-menu.js +0 -4
- package/lib/components/header.js +63 -33
- package/lib/components/icons.js +0 -2
- package/lib/components/mobile-header.js +17 -10
- package/lib/components/slogan.js +2 -2
- package/lib/constants/fonts.js +3 -0
- package/lib/containers/header.js +11 -4
- package/lib/utils/theme.js +18 -6
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,80 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.2.0](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.0-rc.12...@twreporter/universal-header@2.2.0) (2021-10-12)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @twreporter/universal-header
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [2.2.0-rc.12](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.0-rc.11...@twreporter/universal-header@2.2.0-rc.12) (2021-10-12)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **universal-header:** remove channel underline active UI ([87dfdb8](https://github.com/twreporter/twreporter-npm-packages/commit/87dfdb80f02807ac24b7781a6b9459127d31817e))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [2.2.0-rc.11](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.0-rc.10...@twreporter/universal-header@2.2.0-rc.11) (2021-10-08)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **universal-header:** fix ui defect ([a1592da](https://github.com/twreporter/twreporter-npm-packages/commit/a1592da85a0f3f9e38fe86b0f5ef86a8a1c83ba6))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# [2.2.0-rc.10](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.0-rc.9...@twreporter/universal-header@2.2.0-rc.10) (2021-10-07)
|
|
37
|
+
|
|
38
|
+
**Note:** Version bump only for package @twreporter/universal-header
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# [2.2.0-rc.9](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.0-rc.8...@twreporter/universal-header@2.2.0-rc.9) (2021-10-06)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Bug Fixes
|
|
48
|
+
|
|
49
|
+
* **universal-header:** fix tablet slogan animation delay & duration ([50027da](https://github.com/twreporter/twreporter-npm-packages/commit/50027da20ea34bfc656412803d6b772d25e7f3d7))
|
|
50
|
+
* **universal-header:** fix ui defect ([8d8c20a](https://github.com/twreporter/twreporter-npm-packages/commit/8d8c20a558f4bdcf4f76480125bd0b2426ed53be))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# [2.2.0-rc.8](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.0-rc.7...@twreporter/universal-header@2.2.0-rc.8) (2021-10-05)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Bug Fixes
|
|
60
|
+
|
|
61
|
+
* fix ui defect ([2ab85e2](https://github.com/twreporter/twreporter-npm-packages/commit/2ab85e2eabd9ae33b857353712358777b50a9f9a))
|
|
62
|
+
* **universal-header:** fix ui defect ([c1be79f](https://github.com/twreporter/twreporter-npm-packages/commit/c1be79f6ab811b0c44d9a8753230f73486be57cc))
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# [2.2.0-rc.7](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.0-rc.6...@twreporter/universal-header@2.2.0-rc.7) (2021-09-29)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
### Bug Fixes
|
|
72
|
+
|
|
73
|
+
* **universal-header:** fix active state should remain after transforming & eslint error ([f942be7](https://github.com/twreporter/twreporter-npm-packages/commit/f942be7f4d4c1b9a5d84ed4dd96dbff16cf4ca10))
|
|
74
|
+
* **universal-header:** refactor function assignment ([0629392](https://github.com/twreporter/twreporter-npm-packages/commit/062939250aaaab2ffaf70c839d2893a508122d4c))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
6
80
|
# [2.2.0-rc.6](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.0-rc.5...@twreporter/universal-header@2.2.0-rc.6) (2021-09-28)
|
|
7
81
|
|
|
8
82
|
|
|
@@ -105,15 +105,17 @@ var ActionsContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig(
|
|
|
105
105
|
var ActionContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
106
106
|
displayName: "action-button__ActionContainer",
|
|
107
107
|
componentId: "sc-4wc24t-1"
|
|
108
|
-
})(["transition:opacity 0.
|
|
108
|
+
})(["transition:opacity 0.1s;transition-delay:300ms;opacity:", ";pointer-events:", ";margin:", ";width:100%;&:first-child{margin-top:0;margin-left:0;}a,a:link,a:visited{color:", ";font-size:", ";font-weight:", ";", " ", "}"], function (props) {
|
|
109
109
|
return props.isActive ? 1 : 0;
|
|
110
|
+
}, function (props) {
|
|
111
|
+
return props.isActive ? 'auto' : 'none';
|
|
110
112
|
}, function (props) {
|
|
111
113
|
return (0, _css.arrayToCssShorthand)(styles.itemMargin[props.direction]);
|
|
112
114
|
}, function (props) {
|
|
113
115
|
return props.color || _colors["default"].white;
|
|
114
|
-
}, styles.fontSize.desktop, _fonts["default"].weight.bold, _mediaQuery["default"].tabletOnly(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-size: ", ";\n "])), function (props) {
|
|
116
|
+
}, styles.fontSize.desktop, _fonts["default"].weight.bold, _mediaQuery["default"].tabletOnly(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: default;\n font-size: ", ";\n "])), function (props) {
|
|
115
117
|
return styles.fontSize.tablet[props.direction];
|
|
116
|
-
}), _mediaQuery["default"].mobileOnly(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-size: ", ";\n "])), function (props) {
|
|
118
|
+
}), _mediaQuery["default"].mobileOnly(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n cursor: default;\n font-size: ", ";\n "])), function (props) {
|
|
117
119
|
return styles.fontSize.mobile[props.direction];
|
|
118
120
|
}));
|
|
119
121
|
|
|
@@ -19,8 +19,6 @@ var _headerContext = _interopRequireDefault(require("../contexts/header-context"
|
|
|
19
19
|
|
|
20
20
|
var _theme = _interopRequireDefault(require("../utils/theme"));
|
|
21
21
|
|
|
22
|
-
var _animations = _interopRequireDefault(require("../utils/animations"));
|
|
23
|
-
|
|
24
22
|
var _propTypes2 = _interopRequireDefault(require("../constants/prop-types"));
|
|
25
23
|
|
|
26
24
|
var _channels = _interopRequireDefault(require("../constants/channels"));
|
|
@@ -33,14 +31,16 @@ var _dropDownMenu = _interopRequireDefault(require("./drop-down-menu"));
|
|
|
33
31
|
|
|
34
32
|
var _customizedLink = _interopRequireDefault(require("./customized-link"));
|
|
35
33
|
|
|
36
|
-
var _css = require("@twreporter/core/lib/utils/css");
|
|
37
|
-
|
|
38
34
|
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
39
35
|
|
|
36
|
+
var _css = require("@twreporter/core/lib/utils/css");
|
|
37
|
+
|
|
40
38
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
41
39
|
|
|
42
40
|
var _map = _interopRequireDefault(require("lodash/map"));
|
|
43
41
|
|
|
42
|
+
var _templateObject;
|
|
43
|
+
|
|
44
44
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
45
45
|
|
|
46
46
|
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; }
|
|
@@ -83,6 +83,8 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
83
83
|
|
|
84
84
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
85
85
|
|
|
86
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
87
|
+
|
|
86
88
|
var _ = {
|
|
87
89
|
get: _get["default"],
|
|
88
90
|
map: _map["default"]
|
|
@@ -114,19 +116,16 @@ var styles = {
|
|
|
114
116
|
column: 'relative'
|
|
115
117
|
},
|
|
116
118
|
dropdownTop: {
|
|
117
|
-
row:
|
|
118
|
-
|
|
119
|
-
column: 0 //px
|
|
120
|
-
|
|
119
|
+
row: "calc(100% + 1px)",
|
|
120
|
+
column: 0
|
|
121
121
|
}
|
|
122
122
|
};
|
|
123
123
|
var dropDownMenuEffectCSS = /*#__PURE__*/(0, _styledComponents.css)([".effect-enter{max-height:0;}.effect-enter-active{max-height:400px;transition:max-height 400ms ease-in 100ms;}"]);
|
|
124
|
-
var linkUnderline = /*#__PURE__*/(0, _styledComponents.css)(["animation:", " 0.5s linear;position:absolute;left:0;bottom:-1px;display:block;content:'';width:100%;height:4px;background-color:#A67A44;"], _animations["default"].changeOpacity('0', '1'));
|
|
125
124
|
|
|
126
125
|
var DropDownMenuWrapper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
127
126
|
displayName: "channels__DropDownMenuWrapper",
|
|
128
127
|
componentId: "nu2llv-0"
|
|
129
|
-
})(["position:", ";z-index:999;width:100%;left:0;top:", "
|
|
128
|
+
})(["position:", ";z-index:999;width:100%;left:0;top:", ";", ""], function (props) {
|
|
130
129
|
return styles.dropdownPosition[props.direction];
|
|
131
130
|
}, function (props) {
|
|
132
131
|
return styles.dropdownTop[props.direction];
|
|
@@ -135,12 +134,12 @@ var DropDownMenuWrapper = /*#__PURE__*/_styledComponents["default"].div.withConf
|
|
|
135
134
|
var Box = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
136
135
|
displayName: "channels__Box",
|
|
137
136
|
componentId: "nu2llv-1"
|
|
138
|
-
})(["width:100%;"]);
|
|
137
|
+
})(["width:100%;height:100%;"]);
|
|
139
138
|
|
|
140
139
|
var List = /*#__PURE__*/_styledComponents["default"].ul.withConfig({
|
|
141
140
|
displayName: "channels__List",
|
|
142
141
|
componentId: "nu2llv-2"
|
|
143
|
-
})(["justify-content:space-between;background-color:", ";user-select:none;box-sizing:border-box;display:flex;flex-direction:", ";flex-wrap:nowrap;align-items:center;list-style-type:none;margin:auto;padding-inline-start:0;border-color:", ";border-width:", ";border-style:solid;"], function (props) {
|
|
142
|
+
})(["height:100%;justify-content:space-between;background-color:", ";user-select:none;box-sizing:border-box;display:flex;flex-direction:", ";flex-wrap:nowrap;align-items:center;list-style-type:none;margin:auto;padding-inline-start:0;border-color:", ";border-width:", ";border-style:solid;"], function (props) {
|
|
144
143
|
return props.bgColor || _colors["default"].white;
|
|
145
144
|
}, function (props) {
|
|
146
145
|
return props.direction;
|
|
@@ -153,7 +152,7 @@ var List = /*#__PURE__*/_styledComponents["default"].ul.withConfig({
|
|
|
153
152
|
var ListItem = /*#__PURE__*/_styledComponents["default"].li.withConfig({
|
|
154
153
|
displayName: "channels__ListItem",
|
|
155
154
|
componentId: "nu2llv-3"
|
|
156
|
-
})(["display:flex;flex-direction:", ";position:relative;width:", ";font-size:", ";letter-spacing:0.5px;
|
|
155
|
+
})(["display:flex;flex-direction:", ";position:relative;width:", ";height:100%;font-size:", ";letter-spacing:0.5px;margin:", ";flex:1;text-shadow:", ";border-style:solid;border-color:inherit;border-width:", ";&:first-child{border-width:", ";}a,a:link,a:visited{display:flex;justify-content:space-between;align-items:center;font-size:", ";font-weight:", ";padding:", ";width:100%;color:", ";border:0;line-height:18px;&:hover{background-color:", ";color:", ";}", "}"], function (props) {
|
|
157
156
|
return props.direction;
|
|
158
157
|
}, function (props) {
|
|
159
158
|
return styles.itemWidth[props.direction];
|
|
@@ -163,8 +162,6 @@ var ListItem = /*#__PURE__*/_styledComponents["default"].li.withConfig({
|
|
|
163
162
|
return (0, _css.arrayToCssShorthand)(styles.itemBorderWidth[props.direction]);
|
|
164
163
|
}, function (props) {
|
|
165
164
|
return (0, _css.arrayToCssShorthand)(styles.itemBorderWidthFirstChild[props.direction]);
|
|
166
|
-
}, function (props) {
|
|
167
|
-
return props.isActive && props.direction === 'row' ? linkUnderline : '';
|
|
168
165
|
}, _fonts["default"].size.base, _fonts["default"].weight.bold, function (props) {
|
|
169
166
|
return (0, _css.arrayToCssShorthand)(styles.itemPadding[props.direction]);
|
|
170
167
|
}, function (props) {
|
|
@@ -173,7 +170,7 @@ var ListItem = /*#__PURE__*/_styledComponents["default"].li.withConfig({
|
|
|
173
170
|
return props.hoverBgColor;
|
|
174
171
|
}, function (props) {
|
|
175
172
|
return props.hoverFontColor;
|
|
176
|
-
});
|
|
173
|
+
}, _mediaQuery["default"].tabletAndBelow(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: default;\n "]))));
|
|
177
174
|
|
|
178
175
|
var ShowOnHover = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
179
176
|
displayName: "channels__ShowOnHover",
|
|
@@ -200,18 +197,26 @@ var Channels = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
200
197
|
|
|
201
198
|
_this = _super.call(this, props);
|
|
202
199
|
_this.state = {
|
|
203
|
-
activeDataIndex: _this._checkWhichChannelActive(props.currentPathname)
|
|
200
|
+
activeDataIndex: _this._checkWhichChannelActive(props.currentPathname),
|
|
201
|
+
activeDropdownIndex: invalidDataIndex
|
|
204
202
|
};
|
|
205
203
|
_this.handleDropDownChannelClick = _this._handleDropDownChannelClick.bind(_assertThisInitialized(_this));
|
|
206
204
|
_this.handleNormalChannelClick = _this._handleNormalChannelClick.bind(_assertThisInitialized(_this));
|
|
207
205
|
_this.handleDropDownMenuClick = _this._handleDropDownMenuClick.bind(_assertThisInitialized(_this));
|
|
208
|
-
_this.setActiveData = _this._setActiveData.bind(_assertThisInitialized(_this));
|
|
209
|
-
_this.resetActiveData = _this._resetActiveDataIndex.bind(_assertThisInitialized(_this));
|
|
210
206
|
_this.callback = _this._callback.bind(_assertThisInitialized(_this));
|
|
211
207
|
return _this;
|
|
212
208
|
}
|
|
213
209
|
|
|
214
210
|
_createClass(Channels, [{
|
|
211
|
+
key: "componentDidUpdate",
|
|
212
|
+
value: function componentDidUpdate() {
|
|
213
|
+
if (this.context.hideHeader) {
|
|
214
|
+
this.setState({
|
|
215
|
+
activeDropdownIndex: invalidDataIndex
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}, {
|
|
215
220
|
key: "_checkWhichChannelActive",
|
|
216
221
|
value: function _checkWhichChannelActive(currentPathname) {
|
|
217
222
|
var data = this.props.data;
|
|
@@ -247,38 +252,35 @@ var Channels = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
247
252
|
key: "_handleDropDownChannelClick",
|
|
248
253
|
value: function _handleDropDownChannelClick(e, channelIndex) {
|
|
249
254
|
e.preventDefault();
|
|
250
|
-
this.
|
|
255
|
+
var activeDropdownIndex = this.state.activeDropdownIndex;
|
|
256
|
+
var nextActiveDropdownIndex = channelIndex === activeDropdownIndex ? invalidDataIndex : channelIndex;
|
|
257
|
+
this.setState({
|
|
258
|
+
activeDropdownIndex: nextActiveDropdownIndex
|
|
259
|
+
});
|
|
251
260
|
}
|
|
252
261
|
}, {
|
|
253
262
|
key: "_handleNormalChannelClick",
|
|
254
263
|
value: function _handleNormalChannelClick(channelIndex) {
|
|
255
|
-
this.
|
|
256
|
-
|
|
264
|
+
this.setState({
|
|
265
|
+
activeDataIndex: channelIndex,
|
|
266
|
+
activeDropdownIndex: invalidDataIndex
|
|
267
|
+
});
|
|
268
|
+
this.callback(channelIndex);
|
|
257
269
|
}
|
|
258
270
|
}, {
|
|
259
271
|
key: "_handleDropDownMenuClick",
|
|
260
|
-
value: function _handleDropDownMenuClick() {
|
|
261
|
-
this.resetActiveData(invalidDataIndex);
|
|
262
|
-
this.callback();
|
|
263
|
-
}
|
|
264
|
-
}, {
|
|
265
|
-
key: "_setActiveData",
|
|
266
|
-
value: function _setActiveData(dataIndex, clickTwiceInactive) {
|
|
267
|
-
var activeDataIndex = this.state.activeDataIndex;
|
|
268
|
-
var nextActiveIndex = clickTwiceInactive && activeDataIndex === dataIndex ? invalidDataIndex : dataIndex;
|
|
272
|
+
value: function _handleDropDownMenuClick(parentIndex) {
|
|
269
273
|
this.setState({
|
|
270
|
-
activeDataIndex:
|
|
274
|
+
activeDataIndex: parentIndex,
|
|
275
|
+
activeDropdownIndex: invalidDataIndex
|
|
271
276
|
});
|
|
272
|
-
|
|
273
|
-
}, {
|
|
274
|
-
key: "_resetActiveDataIndex",
|
|
275
|
-
value: function _resetActiveDataIndex() {
|
|
276
|
-
this.setActiveData(invalidDataIndex);
|
|
277
|
+
this.callback(parentIndex);
|
|
277
278
|
}
|
|
278
279
|
}, {
|
|
279
280
|
key: "_callback",
|
|
280
|
-
value: function _callback() {
|
|
281
|
-
this.props.
|
|
281
|
+
value: function _callback(dataIndex) {
|
|
282
|
+
var currentActivePathname = dataIndex === invalidDataIndex ? '' : this.props.data[dataIndex].pathname;
|
|
283
|
+
this.props.callback(currentActivePathname);
|
|
282
284
|
}
|
|
283
285
|
}, {
|
|
284
286
|
key: "_prepareChannelItemJSX",
|
|
@@ -293,8 +295,8 @@ var Channels = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
293
295
|
var _this$props = this.props,
|
|
294
296
|
data = _this$props.data,
|
|
295
297
|
direction = _this$props.direction;
|
|
296
|
-
var
|
|
297
|
-
var toShowDropdownMenu =
|
|
298
|
+
var activeDropdownIndex = this.state.activeDropdownIndex;
|
|
299
|
+
var toShowDropdownMenu = activeDropdownIndex === dataIndex;
|
|
298
300
|
|
|
299
301
|
var dropdownMenuData = _.get(data, [dataIndex, dropDownMenuKey], []);
|
|
300
302
|
|
|
@@ -309,11 +311,12 @@ var Channels = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
309
311
|
unmountOnExit: true
|
|
310
312
|
}, /*#__PURE__*/_react["default"].createElement(_dropDownMenu["default"], {
|
|
311
313
|
data: dropdownMenuData,
|
|
312
|
-
onClick:
|
|
314
|
+
onClick: function onClick(e) {
|
|
315
|
+
return _this2.handleDropDownMenuClick(dataIndex);
|
|
316
|
+
}
|
|
313
317
|
})));
|
|
314
318
|
|
|
315
|
-
var
|
|
316
|
-
var status = isActive ? 'collapse' : 'expand';
|
|
319
|
+
var status = toShowDropdownMenu ? 'collapse' : 'expand';
|
|
317
320
|
|
|
318
321
|
var _themeUtils$selectIco = _slicedToArray(_theme["default"].selectIcons(theme)[status], 2),
|
|
319
322
|
StatusIcon = _themeUtils$selectIco[0],
|
|
@@ -340,15 +343,12 @@ var Channels = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
340
343
|
var _this3 = this;
|
|
341
344
|
|
|
342
345
|
var _this$props2 = this.props,
|
|
343
|
-
currentPathname = _this$props2.currentPathname,
|
|
344
346
|
data = _this$props2.data,
|
|
345
347
|
direction = _this$props2.direction,
|
|
346
348
|
borderWidth = _this$props2.borderWidth,
|
|
347
349
|
themeFunction = _this$props2.themeFunction;
|
|
348
|
-
var activeDataIndex = this.state.activeDataIndex;
|
|
349
350
|
|
|
350
351
|
var channelsJSX = _.map(data, function (channelItem, dataIndex) {
|
|
351
|
-
var isActive = activeDataIndex === dataIndex;
|
|
352
352
|
return /*#__PURE__*/_react["default"].createElement(_headerContext["default"].Consumer, {
|
|
353
353
|
key: channelItem.key
|
|
354
354
|
}, function (_ref) {
|
|
@@ -357,14 +357,12 @@ var Channels = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
357
357
|
var _themeFunction = themeFunction(theme),
|
|
358
358
|
fontColor = _themeFunction.fontColor,
|
|
359
359
|
hoverFontColor = _themeFunction.hoverFontColor,
|
|
360
|
-
hoverBgColor = _themeFunction.hoverBgColor
|
|
361
|
-
borderColor = _themeFunction.borderColor;
|
|
360
|
+
hoverBgColor = _themeFunction.hoverBgColor;
|
|
362
361
|
|
|
363
362
|
var channelItemJSX = _this3._prepareChannelItemJSX(channelItem, dataIndex, theme);
|
|
364
363
|
|
|
365
364
|
return /*#__PURE__*/_react["default"].createElement(ListItem, {
|
|
366
365
|
direction: direction,
|
|
367
|
-
isActive: isActive,
|
|
368
366
|
onClick: _this3.handleClickChannel,
|
|
369
367
|
fontColor: fontColor,
|
|
370
368
|
hoverFontColor: hoverFontColor,
|
|
@@ -416,5 +414,7 @@ _defineProperty(Channels, "defaultProps", {
|
|
|
416
414
|
callback: function callback() {}
|
|
417
415
|
});
|
|
418
416
|
|
|
417
|
+
_defineProperty(Channels, "contextType", _headerContext["default"]);
|
|
418
|
+
|
|
419
419
|
var _default = Channels;
|
|
420
420
|
exports["default"] = _default;
|
|
@@ -21,14 +21,14 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
21
21
|
|
|
22
22
|
var _propTypes2 = _interopRequireDefault(require("../constants/prop-types"));
|
|
23
23
|
|
|
24
|
-
var _css = require("@twreporter/core/lib/utils/css");
|
|
25
|
-
|
|
26
24
|
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
27
25
|
|
|
28
26
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
29
27
|
|
|
30
28
|
var _map = _interopRequireDefault(require("lodash/map"));
|
|
31
29
|
|
|
30
|
+
var _templateObject;
|
|
31
|
+
|
|
32
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
33
33
|
|
|
34
34
|
function _extends() { _extends = Object.assign || 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); }
|
|
@@ -55,10 +55,20 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
55
55
|
|
|
56
56
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
57
57
|
|
|
58
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
59
|
+
|
|
58
60
|
var _ = {
|
|
59
61
|
get: _get["default"],
|
|
60
62
|
map: _map["default"]
|
|
61
63
|
};
|
|
64
|
+
var styles = {
|
|
65
|
+
subMenuHeight: {
|
|
66
|
+
mobile: 58,
|
|
67
|
+
// px
|
|
68
|
+
desktop: 46 // px
|
|
69
|
+
|
|
70
|
+
}
|
|
71
|
+
};
|
|
62
72
|
|
|
63
73
|
var ViewPort = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
64
74
|
displayName: "drop-down-menu__ViewPort",
|
|
@@ -78,12 +88,12 @@ var MenuContent = /*#__PURE__*/_styledComponents["default"].ul.withConfig({
|
|
|
78
88
|
var SubMenuBox = /*#__PURE__*/_styledComponents["default"].li.withConfig({
|
|
79
89
|
displayName: "drop-down-menu__SubMenuBox",
|
|
80
90
|
componentId: "sc-8es5ea-3"
|
|
81
|
-
})(["display:flex;box-sizing:border-box;white-space:nowrap;position:relative;margin:0;border-bottom:1px solid #e2e2e2;width:100%;a,a:link,a:visited{width:100%;border:0;color:#808080;&:hover{color:", ";background-color:rgba(0,0,0,0.1);}}"], _colors["default"].grayDark);
|
|
91
|
+
})(["display:flex;box-sizing:border-box;white-space:nowrap;position:relative;margin:0;border-bottom:1px solid #e2e2e2;width:100%;height:", "px;", " a,a:link,a:visited{width:100%;border:0;color:#808080;&:hover{color:", ";background-color:rgba(0,0,0,0.1);}}"], styles.subMenuHeight.mobile, _mediaQuery["default"].desktopAndAbove(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: ", "px;\n "])), styles.subMenuHeight.desktop), _colors["default"].grayDark);
|
|
82
92
|
|
|
83
93
|
var SubMenuContent = /*#__PURE__*/_styledComponents["default"].span.withConfig({
|
|
84
94
|
displayName: "drop-down-menu__SubMenuContent",
|
|
85
95
|
componentId: "sc-8es5ea-4"
|
|
86
|
-
})(["font-size:", ";font-weight:", ";cursor:pointer;"], _fonts["default"].size.base, _fonts["default"].weight.
|
|
96
|
+
})(["font-size:", ";font-weight:", ";cursor:pointer;"], _fonts["default"].size.base, _fonts["default"].weight.bold);
|
|
87
97
|
|
|
88
98
|
var DropDownMenu = /*#__PURE__*/function (_React$PureComponent) {
|
|
89
99
|
_inherits(DropDownMenu, _React$PureComponent);
|
|
@@ -102,7 +112,6 @@ var DropDownMenu = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
102
112
|
var _this$props = this.props,
|
|
103
113
|
data = _this$props.data,
|
|
104
114
|
onClick = _this$props.onClick;
|
|
105
|
-
var subMenuCount = data.length;
|
|
106
115
|
|
|
107
116
|
var menuJSX = _.map(data, function (subMenuItem, index) {
|
|
108
117
|
return /*#__PURE__*/_react["default"].createElement(SubMenuBox, {
|
|
@@ -66,7 +66,7 @@ var styles = {
|
|
|
66
66
|
var IconContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
67
67
|
displayName: "hamburger-icons__IconContainer",
|
|
68
68
|
componentId: "sc-11ma9zq-0"
|
|
69
|
-
})(["height:", "px;width:", "px;display:flex;justify-content:center;align-items:center;margin-right:17px;a{display:flex;}", ""], styles.iconHeight.mobile, styles.iconWidth.mobile, _mediaQuery["default"].tabletOnly(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: ", "px;\n width: ", "px;\n margin-right: 25px;\n "])), styles.iconHeight.tablet, styles.iconWidth.tablet));
|
|
69
|
+
})(["height:", "px;width:", "px;display:flex;justify-content:center;align-items:center;margin-right:17px;a{display:flex;cursor:default;}", ""], styles.iconHeight.mobile, styles.iconWidth.mobile, _mediaQuery["default"].tabletOnly(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: ", "px;\n width: ", "px;\n margin-right: 25px;\n "])), styles.iconHeight.tablet, styles.iconWidth.tablet));
|
|
70
70
|
|
|
71
71
|
var IconsContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
72
72
|
displayName: "hamburger-icons__IconsContainer",
|
|
@@ -19,14 +19,10 @@ var _headerContext = _interopRequireDefault(require("../contexts/header-context"
|
|
|
19
19
|
|
|
20
20
|
var _theme = _interopRequireDefault(require("../utils/theme"));
|
|
21
21
|
|
|
22
|
-
var _colors = _interopRequireDefault(require("../constants/colors"));
|
|
23
|
-
|
|
24
22
|
var _actionButton = _interopRequireDefault(require("./action-button"));
|
|
25
23
|
|
|
26
24
|
var _slogan = _interopRequireDefault(require("./slogan"));
|
|
27
25
|
|
|
28
|
-
var _customizedLink = _interopRequireDefault(require("./customized-link"));
|
|
29
|
-
|
|
30
26
|
var _hamburgerIcons = _interopRequireDefault(require("./hamburger-icons"));
|
|
31
27
|
|
|
32
28
|
var _channels = _interopRequireDefault(require("./channels.js"));
|
package/lib/components/header.js
CHANGED
|
@@ -23,8 +23,6 @@ var _theme = _interopRequireDefault(require("../utils/theme"));
|
|
|
23
23
|
|
|
24
24
|
var _animations = _interopRequireDefault(require("../utils/animations"));
|
|
25
25
|
|
|
26
|
-
var _colors = _interopRequireDefault(require("../constants/colors"));
|
|
27
|
-
|
|
28
26
|
var _channels = _interopRequireDefault(require("./channels"));
|
|
29
27
|
|
|
30
28
|
var _actionButton = _interopRequireDefault(require("./action-button"));
|
|
@@ -35,9 +33,11 @@ var _customizedLink = _interopRequireDefault(require("./customized-link"));
|
|
|
35
33
|
|
|
36
34
|
var _slogan = _interopRequireDefault(require("./slogan"));
|
|
37
35
|
|
|
36
|
+
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
37
|
+
|
|
38
38
|
var _css = require("@twreporter/core/lib/utils/css");
|
|
39
39
|
|
|
40
|
-
var
|
|
40
|
+
var _templateObject;
|
|
41
41
|
|
|
42
42
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
43
|
|
|
@@ -45,8 +45,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
45
45
|
|
|
46
46
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
49
|
+
|
|
50
|
+
var CHANNEL_HEIGHT = 36; // px
|
|
50
51
|
|
|
51
52
|
var styles = {
|
|
52
53
|
headerHeight: {
|
|
@@ -68,26 +69,40 @@ var styles = {
|
|
|
68
69
|
hd: 1320 // px
|
|
69
70
|
|
|
70
71
|
},
|
|
71
|
-
|
|
72
|
+
channelTopBorderWidth: [0, 1, 1, 0],
|
|
73
|
+
// px
|
|
74
|
+
channelBottomBorderWidth: [1, 0, 1, 0],
|
|
75
|
+
// px
|
|
76
|
+
iconBorderWidth: {
|
|
77
|
+
wide: [0, 0, 0, 0],
|
|
78
|
+
// px
|
|
79
|
+
narrow: [0, 0, 1, 0] // px
|
|
72
80
|
|
|
81
|
+
},
|
|
82
|
+
zIndex: {
|
|
83
|
+
topRow: 3,
|
|
84
|
+
channelBottom: 1,
|
|
85
|
+
channelTop: 4,
|
|
86
|
+
actionButton: 5
|
|
87
|
+
}
|
|
73
88
|
};
|
|
74
89
|
|
|
75
90
|
var headerWide = _animations["default"].changeHeight("".concat(styles.headerHeight.narrow, "px"), "".concat(styles.headerHeight.wide, "px"));
|
|
76
91
|
|
|
77
92
|
var headerNarrow = _animations["default"].changeHeight("".concat(styles.headerHeight.wide, "px"), "".concat(styles.headerHeight.narrow, "px"));
|
|
78
93
|
|
|
79
|
-
var HeaderEffect = /*#__PURE__*/(0, _styledComponents.css)([".header-effect-enter{height:", "px;}.header-effect-enter-active{animation:", " 0.
|
|
80
|
-
var ActionEffect = /*#__PURE__*/(0, _styledComponents.css)([".action-effect-enter{transform:translateX(-40px);}.action-effect-enter-active{animation:", " 0.
|
|
81
|
-
var SloganEffect = /*#__PURE__*/(0, _styledComponents.css)([".slogan-effect-enter{opacity:0;}.slogagn-effect-enter-active{animation:", " 0.
|
|
94
|
+
var HeaderEffect = /*#__PURE__*/(0, _styledComponents.css)([".header-effect-enter{height:", "px;}.header-effect-enter-active{animation:", " 0.2s linear;animation-delay:300ms;}.header-effect-exit-active{animation:", " 0.2s linear;animation-delay:300ms;}.header-effect-exit-done{height:", "px;}"], styles.headerHeight.narrow, headerWide, headerNarrow, styles.headerHeight.narrow);
|
|
95
|
+
var ActionEffect = /*#__PURE__*/(0, _styledComponents.css)([".action-effect-enter{transform:translateX(-40px);}.action-effect-enter-active{animation:", " 0.2s;animation-delay:300ms;}.action-effect-exit-active{animation:", " 0.2s;animation-delay:300ms;}.action-effect-exit-done{transform:translateX(-40px);}"], _animations["default"].changeTranslateX('-40px', 0), _animations["default"].changeTranslateX(0, '-40px'));
|
|
96
|
+
var SloganEffect = /*#__PURE__*/(0, _styledComponents.css)([".slogan-effect-enter{opacity:0;}.slogagn-effect-enter-active{animation:", " 0.2s;animation-delay:300ms;}.slogan-effect-exit-active{animation:", " 0.2s;animation-delay:300ms;}.slogan-effect-exit-done{opacity:0;}"], _animations["default"].changeOpacity('0', '1'), _animations["default"].changeOpacity('1', '0'));
|
|
82
97
|
var channelSlideIn = /*#__PURE__*/(0, _styledComponents.keyframes)(["from{transform:translateY(", "px);opacity:0;}to{transform:translateY(0);opacity:1;}"], -CHANNEL_HEIGHT);
|
|
83
98
|
var channelSlideOut = /*#__PURE__*/(0, _styledComponents.keyframes)(["from{transform:translateY(0);}to{transform:translateY(", "px);}"], -CHANNEL_HEIGHT);
|
|
84
|
-
var ChannelEffect = /*#__PURE__*/(0, _styledComponents.css)([".channel-effect-enter{opacity:0;}.channel-effect-enter-active{animation:", " 0.2s linear;animation-delay:
|
|
85
|
-
var LogoEffect = /*#__PURE__*/(0, _styledComponents.css)([".logo-effect-enter{width:80%;}.logo-effect-enter-active{animation:", " 0.
|
|
99
|
+
var ChannelEffect = /*#__PURE__*/(0, _styledComponents.css)([".channel-effect-enter{opacity:0;}.channel-effect-enter-active{animation:", " 0.2s linear;animation-delay:400ms;}.channel-effect-exit-active{animation:", " 0.1s linear;animation-delay:100ms;}"], channelSlideIn, channelSlideOut);
|
|
100
|
+
var LogoEffect = /*#__PURE__*/(0, _styledComponents.css)([".logo-effect-enter{width:80%;}.logo-effect-enter-active{animation:", " 0.2s linear;animation-delay:300ms;}.logo-effect-exit-active{animation:", " 0.2s linear;animation-delay:300ms;}.logo-effect-exit-done{width:80%;}"], _animations["default"].changeWidth('80%', '100%'), _animations["default"].changeWidth('100%', '80%'));
|
|
86
101
|
|
|
87
102
|
var Box = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
88
103
|
displayName: "header__Box",
|
|
89
104
|
componentId: "sc-1krza7i-0"
|
|
90
|
-
})(["transform:translateY(", ");transition:transform 0.3s linear;background-color:", ";box-sizing:border-box;position:relative;width:100%;display:flex;flex-direction:column;align-items:center;a:link,a:visited,a:hover,a:active{text-decoration:none;}", ""], function (props) {
|
|
105
|
+
})(["transform:translateY( ", " );transition:transform 0.3s linear;background-color:", ";box-sizing:border-box;position:relative;width:100%;display:flex;flex-direction:column;align-items:center;a:link,a:visited,a:hover,a:active{text-decoration:none;}", ""], function (props) {
|
|
91
106
|
return props.isHide ? "".concat(-styles.headerHeight.narrow, "px") : 0;
|
|
92
107
|
}, function (props) {
|
|
93
108
|
return props.bgColor;
|
|
@@ -96,12 +111,12 @@ var Box = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
96
111
|
var TopRow = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
97
112
|
displayName: "header__TopRow",
|
|
98
113
|
componentId: "sc-1krza7i-1"
|
|
99
|
-
})(["height:", "px;padding:", ";max-width:", "px;width:100%;box-sizing:border-box;display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between;align-items:center;z-index:
|
|
114
|
+
})(["height:", "px;padding:", ";max-width:", "px;width:100%;box-sizing:border-box;display:flex;flex-direction:row;flex-wrap:nowrap;justify-content:space-between;align-items:center;z-index:", ";"], styles.headerHeight.wide, (0, _css.arrayToCssShorthand)(styles.topRowPadding.desktop), styles.topRowMaxWidth.hd, styles.zIndex.topRow);
|
|
100
115
|
|
|
101
116
|
var ChannelContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
102
117
|
displayName: "header__ChannelContainer",
|
|
103
118
|
componentId: "sc-1krza7i-2"
|
|
104
|
-
})(["width:calc(100% - 120px);max-width:", "px;z-index:
|
|
119
|
+
})(["width:calc(100% - 120px);max-width:", "px;z-index:", ";", ""], styles.channelMaxWidth.hd, styles.zIndex.channelBottom, ChannelEffect);
|
|
105
120
|
|
|
106
121
|
var FlexGroup = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
107
122
|
displayName: "header__FlexGroup",
|
|
@@ -123,12 +138,21 @@ var SloganContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
123
138
|
var ActionContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
124
139
|
displayName: "header__ActionContainer",
|
|
125
140
|
componentId: "sc-1krza7i-6"
|
|
126
|
-
})(["", " ", ""], FlexItem, ActionEffect);
|
|
141
|
+
})(["z-index:", ";", " ", ""], styles.zIndex.actionButton, FlexItem, ActionEffect);
|
|
142
|
+
|
|
143
|
+
var IconContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
144
|
+
displayName: "header__IconContainer",
|
|
145
|
+
componentId: "sc-1krza7i-7"
|
|
146
|
+
})(["", " height:", "px;margin:0;padding-left:14px;border-color:", ";border-style:solid;border-width:", ";transition:border-width 0.1s linear 0.2s;"], FlexItem, styles.headerHeight.narrow, function (props) {
|
|
147
|
+
return props.borderColor;
|
|
148
|
+
}, function (props) {
|
|
149
|
+
return (0, _css.arrayToCssShorthand)(styles.iconBorderWidth[props.headerType]);
|
|
150
|
+
});
|
|
127
151
|
|
|
128
152
|
var ChannelTopContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
129
153
|
displayName: "header__ChannelTopContainer",
|
|
130
|
-
componentId: "sc-1krza7i-
|
|
131
|
-
})(["position:absolute;width:calc(100% - 530px);min-width:480px;max-width:910px;right:
|
|
154
|
+
componentId: "sc-1krza7i-8"
|
|
155
|
+
})(["position:absolute;width:calc(100% - 530px);min-width:480px;max-width:910px;height:", "px;right:186px;z-index:", ";", " ", " ", ""], styles.headerHeight.narrow, styles.zIndex.channelTop, FlexItem, ChannelEffect, _mediaQuery["default"].hdOnly(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n right: calc(50% - 540px);\n "]))));
|
|
132
156
|
|
|
133
157
|
var Header = function Header(_ref) {
|
|
134
158
|
var pathname = _ref.pathname,
|
|
@@ -143,7 +167,9 @@ var Header = function Header(_ref) {
|
|
|
143
167
|
toUseNarrow = _ref2.toUseNarrow,
|
|
144
168
|
hideHeader = _ref2.hideHeader;
|
|
145
169
|
|
|
146
|
-
var
|
|
170
|
+
var _themeUtils$selectHea = _theme["default"].selectHeaderTheme(theme),
|
|
171
|
+
bgColor = _themeUtils$selectHea.bgColor,
|
|
172
|
+
borderColor = _themeUtils$selectHea.borderColor;
|
|
147
173
|
|
|
148
174
|
var Logo = _theme["default"].selectLogoComponent(theme);
|
|
149
175
|
|
|
@@ -155,24 +181,24 @@ var Header = function Header(_ref) {
|
|
|
155
181
|
classNames: "header-effect",
|
|
156
182
|
timeout: {
|
|
157
183
|
appear: 0,
|
|
158
|
-
enter:
|
|
159
|
-
exit:
|
|
184
|
+
enter: 500,
|
|
185
|
+
exit: 500
|
|
160
186
|
}
|
|
161
187
|
}, /*#__PURE__*/_react["default"].createElement(TopRow, null, /*#__PURE__*/_react["default"].createElement(FlexGroup, null, /*#__PURE__*/_react["default"].createElement(LogoContainer, null, /*#__PURE__*/_react["default"].createElement(_customizedLink["default"], _links["default"].getLogoLink(isLinkExternal, releaseBranch), /*#__PURE__*/_react["default"].createElement(_CSSTransition["default"], {
|
|
162
188
|
"in": !toUseNarrow,
|
|
163
189
|
classNames: "logo-effect",
|
|
164
190
|
timeout: {
|
|
165
191
|
appear: 0,
|
|
166
|
-
enter:
|
|
167
|
-
exit:
|
|
192
|
+
enter: 500,
|
|
193
|
+
exit: 500
|
|
168
194
|
}
|
|
169
195
|
}, /*#__PURE__*/_react["default"].createElement(Logo, null)))), /*#__PURE__*/_react["default"].createElement(ActionContainer, null, /*#__PURE__*/_react["default"].createElement(_CSSTransition["default"], {
|
|
170
196
|
"in": !toUseNarrow,
|
|
171
197
|
classNames: "action-effect",
|
|
172
198
|
timeout: {
|
|
173
199
|
appear: 0,
|
|
174
|
-
enter:
|
|
175
|
-
exit:
|
|
200
|
+
enter: 500,
|
|
201
|
+
exit: 500
|
|
176
202
|
}
|
|
177
203
|
}, /*#__PURE__*/_react["default"].createElement(_actionButton["default"], {
|
|
178
204
|
actions: toUseNarrow ? narrowActions : actions
|
|
@@ -181,30 +207,34 @@ var Header = function Header(_ref) {
|
|
|
181
207
|
classNames: "slogan-effect",
|
|
182
208
|
timeout: {
|
|
183
209
|
appear: 0,
|
|
184
|
-
enter:
|
|
185
|
-
exit:
|
|
210
|
+
enter: 500,
|
|
211
|
+
exit: 500
|
|
186
212
|
}
|
|
187
213
|
}, /*#__PURE__*/_react["default"].createElement(_slogan["default"], null)))), /*#__PURE__*/_react["default"].createElement(ChannelTopContainer, null, /*#__PURE__*/_react["default"].createElement(_CSSTransition["default"], {
|
|
188
214
|
"in": toUseNarrow,
|
|
189
215
|
classNames: "channel-effect",
|
|
190
216
|
timeout: {
|
|
191
217
|
appear: 0,
|
|
192
|
-
enter:
|
|
193
|
-
exit:
|
|
218
|
+
enter: 600,
|
|
219
|
+
exit: 200
|
|
194
220
|
},
|
|
195
221
|
unmountOnExit: true
|
|
196
222
|
}, /*#__PURE__*/_react["default"].createElement(_channels["default"], {
|
|
197
223
|
currentPathname: pathname,
|
|
198
|
-
data: channels
|
|
199
|
-
|
|
224
|
+
data: channels,
|
|
225
|
+
borderWidth: styles.channelTopBorderWidth
|
|
226
|
+
}))), /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
227
|
+
headerType: toUseNarrow ? 'narrow' : 'wide',
|
|
228
|
+
borderColor: borderColor
|
|
229
|
+
}, /*#__PURE__*/_react["default"].createElement(_icons["default"], {
|
|
200
230
|
services: services
|
|
201
|
-
}))), /*#__PURE__*/_react["default"].createElement(ChannelContainer, null, /*#__PURE__*/_react["default"].createElement(_CSSTransition["default"], {
|
|
231
|
+
})))), /*#__PURE__*/_react["default"].createElement(ChannelContainer, null, /*#__PURE__*/_react["default"].createElement(_CSSTransition["default"], {
|
|
202
232
|
"in": !toUseNarrow,
|
|
203
233
|
classNames: "channel-effect",
|
|
204
234
|
timeout: {
|
|
205
235
|
appear: 0,
|
|
206
|
-
enter:
|
|
207
|
-
exit:
|
|
236
|
+
enter: 600,
|
|
237
|
+
exit: 200
|
|
208
238
|
},
|
|
209
239
|
unmountOnExit: true
|
|
210
240
|
}, /*#__PURE__*/_react["default"].createElement(_channels["default"], {
|
package/lib/components/icons.js
CHANGED
|
@@ -23,8 +23,6 @@ var _links = _interopRequireDefault(require("../utils/links"));
|
|
|
23
23
|
|
|
24
24
|
var _querystring = _interopRequireDefault(require("querystring"));
|
|
25
25
|
|
|
26
|
-
var _services = _interopRequireDefault(require("../constants/services"));
|
|
27
|
-
|
|
28
26
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
29
27
|
|
|
30
28
|
var _theme = _interopRequireDefault(require("../utils/theme"));
|
|
@@ -23,8 +23,6 @@ var _theme = _interopRequireDefault(require("../utils/theme"));
|
|
|
23
23
|
|
|
24
24
|
var _animations = _interopRequireDefault(require("../utils/animations"));
|
|
25
25
|
|
|
26
|
-
var _colors = _interopRequireDefault(require("../constants/colors"));
|
|
27
|
-
|
|
28
26
|
var _customizedLink = _interopRequireDefault(require("./customized-link"));
|
|
29
27
|
|
|
30
28
|
var _hamburgerMenu = _interopRequireDefault(require("./hamburger-menu"));
|
|
@@ -37,7 +35,7 @@ var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/med
|
|
|
37
35
|
|
|
38
36
|
var _css = require("@twreporter/core/lib/utils/css");
|
|
39
37
|
|
|
40
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
38
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
|
|
41
39
|
|
|
42
40
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
41
|
|
|
@@ -81,7 +79,13 @@ var styles = {
|
|
|
81
79
|
headerPadding: {
|
|
82
80
|
mobile: [24],
|
|
83
81
|
// px
|
|
84
|
-
tablet: [24, 30, 24, 50] //px
|
|
82
|
+
tablet: [24, 30, 24, 50] // px
|
|
83
|
+
|
|
84
|
+
},
|
|
85
|
+
hamburgerPadding: {
|
|
86
|
+
mobile: [24],
|
|
87
|
+
// px
|
|
88
|
+
tablet: [24, 30] // px
|
|
85
89
|
|
|
86
90
|
},
|
|
87
91
|
logoHeight: {
|
|
@@ -107,7 +111,7 @@ var styles = {
|
|
|
107
111
|
|
|
108
112
|
}
|
|
109
113
|
};
|
|
110
|
-
var SloganEffect = /*#__PURE__*/(0, _styledComponents.css)([".slogan-effect-enter{opacity:0;}.slogagn-effect-enter-active{animation:", " 0.
|
|
114
|
+
var SloganEffect = /*#__PURE__*/(0, _styledComponents.css)([".slogan-effect-enter{opacity:0;}.slogagn-effect-enter-active{animation:", " 0.1s;animation-delay:300ms;}.slogan-effect-exit-active{animation:", " 0.1s;animation-delay:300ms;}.slogan-effect-exit-done{opacity:0;}"], _animations["default"].changeOpacity('0', '1'), _animations["default"].changeOpacity('1', '0'));
|
|
111
115
|
|
|
112
116
|
var TabletOnly = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
113
117
|
displayName: "mobile-header__TabletOnly",
|
|
@@ -117,7 +121,7 @@ var TabletOnly = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
117
121
|
var FlexBox = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
118
122
|
displayName: "mobile-header__FlexBox",
|
|
119
123
|
componentId: "sc-1vxvz2u-1"
|
|
120
|
-
})(["transform:translateY(", ");transition:transform 0.3s linear;background-color:", ";display:flex;box-sizing:border-box;flex-direction:row;flex-wrap:nowrap;justify-content:space-between;align-items:center;padding:", ";", ""], function (props) {
|
|
124
|
+
})(["transform:translateY( ", " );transition:transform 0.3s linear;background-color:", ";display:flex;box-sizing:border-box;flex-direction:row;flex-wrap:nowrap;justify-content:space-between;align-items:center;padding:", ";", ""], function (props) {
|
|
121
125
|
return props.isHide ? "".concat(-styles.headerHeight.mobile, "px") : 0;
|
|
122
126
|
}, function (props) {
|
|
123
127
|
return props.bgColor;
|
|
@@ -153,7 +157,7 @@ var HamburgerContainer = /*#__PURE__*/_styledComponents["default"].div.withConfi
|
|
|
153
157
|
var Hamburger = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
154
158
|
displayName: "mobile-header__Hamburger",
|
|
155
159
|
componentId: "sc-1vxvz2u-7"
|
|
156
|
-
})(["display:flex;
|
|
160
|
+
})(["display:flex;position:absolute;right:0;padding:", ";", ""], (0, _css.arrayToCssShorthand)(styles.hamburgerPadding.mobile), _mediaQuery["default"].tabletOnly(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding: ", ";\n "])), (0, _css.arrayToCssShorthand)(styles.hamburgerPadding.tablet)));
|
|
157
161
|
|
|
158
162
|
var MobileHeader = /*#__PURE__*/function (_React$PureComponent) {
|
|
159
163
|
_inherits(MobileHeader, _React$PureComponent);
|
|
@@ -218,7 +222,8 @@ var MobileHeader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
218
222
|
|
|
219
223
|
var Logo = _theme["default"].selectLogoComponent(theme);
|
|
220
224
|
|
|
221
|
-
var
|
|
225
|
+
var _themeUtils$selectHea = _theme["default"].selectHeaderTheme(theme),
|
|
226
|
+
bgColor = _themeUtils$selectHea.bgColor;
|
|
222
227
|
|
|
223
228
|
var MenuIcon = _theme["default"].selectIcons(theme).menu;
|
|
224
229
|
|
|
@@ -234,8 +239,8 @@ var MobileHeader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
234
239
|
classNames: "slogan-effect",
|
|
235
240
|
timeout: {
|
|
236
241
|
appear: 0,
|
|
237
|
-
enter:
|
|
238
|
-
exit:
|
|
242
|
+
enter: 400,
|
|
243
|
+
exit: 400
|
|
239
244
|
}
|
|
240
245
|
}, /*#__PURE__*/_react["default"].createElement(_slogan["default"], null))))), /*#__PURE__*/_react["default"].createElement(Hamburger, {
|
|
241
246
|
onClick: _this2.handleOnHamburgerClick
|
|
@@ -251,6 +256,7 @@ exports["default"] = MobileHeader;
|
|
|
251
256
|
|
|
252
257
|
_defineProperty(MobileHeader, "propTypes", {
|
|
253
258
|
actions: _propTypes["default"].array,
|
|
259
|
+
narrowActions: _propTypes["default"].array,
|
|
254
260
|
menuChannels: _propTypes["default"].array,
|
|
255
261
|
menuServices: _propTypes["default"].array,
|
|
256
262
|
menuActions: _propTypes["default"].array
|
|
@@ -258,6 +264,7 @@ _defineProperty(MobileHeader, "propTypes", {
|
|
|
258
264
|
|
|
259
265
|
_defineProperty(MobileHeader, "defaultProps", {
|
|
260
266
|
actions: [],
|
|
267
|
+
narrowActions: [],
|
|
261
268
|
menuChannels: [],
|
|
262
269
|
menuServices: [],
|
|
263
270
|
menuActions: []
|
package/lib/components/slogan.js
CHANGED
|
@@ -32,9 +32,9 @@ var style = {
|
|
|
32
32
|
var SloganContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
33
33
|
displayName: "slogan__SloganContainer",
|
|
34
34
|
componentId: "sc-1eoofl8-0"
|
|
35
|
-
})(["color:", ";font-size:", ";font-family:
|
|
35
|
+
})(["color:", ";font-size:", ";font-family:", ";display:flex;align-items:center;cursor:default;"], function (props) {
|
|
36
36
|
return props.color || _colors["default"].grayDark;
|
|
37
|
-
}, style.fontSize.desktop);
|
|
37
|
+
}, style.fontSize.desktop, _fonts["default"].family.serif);
|
|
38
38
|
|
|
39
39
|
var Slogan = function Slogan(_ref) {
|
|
40
40
|
var themeFunction = _ref.themeFunction;
|
package/lib/constants/fonts.js
CHANGED
package/lib/containers/header.js
CHANGED
|
@@ -91,9 +91,9 @@ var _ = {
|
|
|
91
91
|
throttle: _throttle["default"]
|
|
92
92
|
};
|
|
93
93
|
var HIDE_HEADER_THRESHOLD = 46;
|
|
94
|
-
var TRANSFORM_HEADER_THRESHOLD =
|
|
94
|
+
var TRANSFORM_HEADER_THRESHOLD = 40;
|
|
95
95
|
var TRANSFORM_TIMEOUT = 800;
|
|
96
|
-
var stickyTop = /*#__PURE__*/(0, _styledComponents.css)(["position:sticky;top:0;z-index:
|
|
96
|
+
var stickyTop = /*#__PURE__*/(0, _styledComponents.css)(["position:sticky;top:0;z-index:1000;"]);
|
|
97
97
|
|
|
98
98
|
var MobileOnly = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
99
99
|
displayName: "header__MobileOnly",
|
|
@@ -168,14 +168,13 @@ var Container = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
168
168
|
var _this2 = this;
|
|
169
169
|
|
|
170
170
|
var isCurrentNarrow = this.state.toUseNarrow;
|
|
171
|
+
var nextToUseNarrow = scrollTop > TRANSFORM_HEADER_THRESHOLD;
|
|
171
172
|
var scrollState = {};
|
|
172
173
|
|
|
173
174
|
if (this.isTransforming) {
|
|
174
175
|
return scrollState;
|
|
175
176
|
}
|
|
176
177
|
|
|
177
|
-
scrollState.toUseNarrow = scrollTop > TRANSFORM_HEADER_THRESHOLD;
|
|
178
|
-
|
|
179
178
|
if (scrollDirection === 'up') {
|
|
180
179
|
this.readyY = scrollTop;
|
|
181
180
|
scrollState.hideHeader = false;
|
|
@@ -186,6 +185,14 @@ var Container = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
186
185
|
if (isCurrentNarrow && scrollTop - this.readyY > HIDE_HEADER_THRESHOLD) {
|
|
187
186
|
scrollState.hideHeader = true;
|
|
188
187
|
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (isCurrentNarrow) {
|
|
191
|
+
// after transforming to narrow header, always remain narrow when scroll down
|
|
192
|
+
scrollState.toUseNarrow = scrollDirection === 'down' ? true : nextToUseNarrow;
|
|
193
|
+
} else {
|
|
194
|
+
// after transfroming to wide header, always remain wide when scroll up
|
|
195
|
+
scrollState.toUseNarrow = scrollDirection === 'up' ? false : nextToUseNarrow;
|
|
189
196
|
} // register transform timer to mark header transform status
|
|
190
197
|
|
|
191
198
|
|
package/lib/utils/theme.js
CHANGED
|
@@ -220,27 +220,39 @@ function selectChannelTheme(theme) {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
function
|
|
223
|
+
function selectHeaderTheme(theme) {
|
|
224
224
|
switch (theme) {
|
|
225
225
|
case _theme["default"].photography:
|
|
226
226
|
{
|
|
227
|
-
return
|
|
227
|
+
return {
|
|
228
|
+
bgColor: _colors["default"].photography,
|
|
229
|
+
borderColor: 'rgba(128, 128, 128, 0.2)'
|
|
230
|
+
};
|
|
228
231
|
}
|
|
229
232
|
|
|
230
233
|
case _theme["default"].transparent:
|
|
231
234
|
{
|
|
232
|
-
return
|
|
235
|
+
return {
|
|
236
|
+
bgColor: 'rgba(0, 0, 0, 0.1)',
|
|
237
|
+
borderColor: 'rgba(128, 128, 128, 0.2)'
|
|
238
|
+
};
|
|
233
239
|
}
|
|
234
240
|
|
|
235
241
|
case _theme["default"].index:
|
|
236
242
|
{
|
|
237
|
-
return
|
|
243
|
+
return {
|
|
244
|
+
bgColor: _colors["default"].white,
|
|
245
|
+
borderColor: _colors["default"].gray
|
|
246
|
+
};
|
|
238
247
|
}
|
|
239
248
|
|
|
240
249
|
case _theme["default"].normal:
|
|
241
250
|
default:
|
|
242
251
|
{
|
|
243
|
-
return
|
|
252
|
+
return {
|
|
253
|
+
bgColor: _colors["default"].grayLight,
|
|
254
|
+
borderColor: _colors["default"].gray
|
|
255
|
+
};
|
|
244
256
|
}
|
|
245
257
|
}
|
|
246
258
|
}
|
|
@@ -398,11 +410,11 @@ function selectSloganHBTheme(theme) {
|
|
|
398
410
|
}
|
|
399
411
|
|
|
400
412
|
var _default = {
|
|
401
|
-
selectBgColor: selectBgColor,
|
|
402
413
|
selectLogoComponent: selectLogoComponent,
|
|
403
414
|
selectServiceIcons: selectServiceIcons,
|
|
404
415
|
selectHamburgerServiceIcons: selectHamburgerServiceIcons,
|
|
405
416
|
selectIcons: selectIcons,
|
|
417
|
+
selectHeaderTheme: selectHeaderTheme,
|
|
406
418
|
selectChannelTheme: selectChannelTheme,
|
|
407
419
|
selectActionButtonTheme: selectActionButtonTheme,
|
|
408
420
|
selectSloganTheme: selectSloganTheme,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twreporter/universal-header",
|
|
3
|
-
"version": "2.2.0
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Universal header of TWReporter sites",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@twreporter/core": "^1.2.1",
|
|
22
|
-
"@twreporter/react-components": "8.5.0
|
|
22
|
+
"@twreporter/react-components": "^8.5.0",
|
|
23
23
|
"lodash": "^4.17.11",
|
|
24
24
|
"prop-types": "^15.6.2",
|
|
25
25
|
"querystring": "^0.2.0",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"files": [
|
|
35
35
|
"lib"
|
|
36
36
|
],
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "b482beff13f1826cc6698022aff715194d6a4b4f"
|
|
38
38
|
}
|