@twreporter/universal-header 2.2.0-rc.5 → 2.2.0-rc.9
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 +47 -0
- package/lib/components/action-button.js +1 -1
- package/lib/components/channels.js +44 -42
- package/lib/components/drop-down-menu.js +14 -5
- package/lib/components/hamburger-menu.js +0 -4
- package/lib/components/header.js +88 -38
- package/lib/components/icons.js +0 -2
- package/lib/components/mobile-header.js +9 -8
- package/lib/components/slogan.js +2 -2
- package/lib/constants/fonts.js +3 -0
- package/lib/containers/header.js +17 -24
- package/lib/utils/theme.js +18 -6
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,53 @@
|
|
|
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-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)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **universal-header:** fix tablet slogan animation delay & duration ([50027da](https://github.com/twreporter/twreporter-npm-packages/commit/50027da20ea34bfc656412803d6b772d25e7f3d7))
|
|
12
|
+
* **universal-header:** fix ui defect ([8d8c20a](https://github.com/twreporter/twreporter-npm-packages/commit/8d8c20a558f4bdcf4f76480125bd0b2426ed53be))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# [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)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* fix ui defect ([2ab85e2](https://github.com/twreporter/twreporter-npm-packages/commit/2ab85e2eabd9ae33b857353712358777b50a9f9a))
|
|
24
|
+
* **universal-header:** fix ui defect ([c1be79f](https://github.com/twreporter/twreporter-npm-packages/commit/c1be79f6ab811b0c44d9a8753230f73486be57cc))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
# [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)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
|
|
35
|
+
* **universal-header:** fix active state should remain after transforming & eslint error ([f942be7](https://github.com/twreporter/twreporter-npm-packages/commit/f942be7f4d4c1b9a5d84ed4dd96dbff16cf4ca10))
|
|
36
|
+
* **universal-header:** refactor function assignment ([0629392](https://github.com/twreporter/twreporter-npm-packages/commit/062939250aaaab2ffaf70c839d2893a508122d4c))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# [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)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Bug Fixes
|
|
46
|
+
|
|
47
|
+
* address review comment & lint error ([#212](https://github.com/twreporter/twreporter-npm-packages/issues/212)) ([c02800d](https://github.com/twreporter/twreporter-npm-packages/commit/c02800dd410ae08abbe617d31509ad18ba7cd3aa))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
6
53
|
# [2.2.0-rc.5](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.2.0-rc.4...@twreporter/universal-header@2.2.0-rc.5) (2021-09-28)
|
|
7
54
|
|
|
8
55
|
|
|
@@ -105,7 +105,7 @@ 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:", ";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
110
|
}, function (props) {
|
|
111
111
|
return (0, _css.arrayToCssShorthand)(styles.itemMargin[props.direction]);
|
|
@@ -35,8 +35,6 @@ var _customizedLink = _interopRequireDefault(require("./customized-link"));
|
|
|
35
35
|
|
|
36
36
|
var _css = require("@twreporter/core/lib/utils/css");
|
|
37
37
|
|
|
38
|
-
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
39
|
-
|
|
40
38
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
41
39
|
|
|
42
40
|
var _map = _interopRequireDefault(require("lodash/map"));
|
|
@@ -114,19 +112,17 @@ var styles = {
|
|
|
114
112
|
column: 'relative'
|
|
115
113
|
},
|
|
116
114
|
dropdownTop: {
|
|
117
|
-
row:
|
|
118
|
-
|
|
119
|
-
column: 0 //px
|
|
120
|
-
|
|
115
|
+
row: "calc(100% + 1px)",
|
|
116
|
+
column: 0
|
|
121
117
|
}
|
|
122
118
|
};
|
|
123
119
|
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:#
|
|
120
|
+
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
121
|
|
|
126
122
|
var DropDownMenuWrapper = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
127
123
|
displayName: "channels__DropDownMenuWrapper",
|
|
128
124
|
componentId: "nu2llv-0"
|
|
129
|
-
})(["position:", ";z-index:999;width:100%;left:0;top:", "
|
|
125
|
+
})(["position:", ";z-index:999;width:100%;left:0;top:", ";", ""], function (props) {
|
|
130
126
|
return styles.dropdownPosition[props.direction];
|
|
131
127
|
}, function (props) {
|
|
132
128
|
return styles.dropdownTop[props.direction];
|
|
@@ -135,12 +131,12 @@ var DropDownMenuWrapper = /*#__PURE__*/_styledComponents["default"].div.withConf
|
|
|
135
131
|
var Box = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
136
132
|
displayName: "channels__Box",
|
|
137
133
|
componentId: "nu2llv-1"
|
|
138
|
-
})(["width:100%;"]);
|
|
134
|
+
})(["width:100%;height:100%;"]);
|
|
139
135
|
|
|
140
136
|
var List = /*#__PURE__*/_styledComponents["default"].ul.withConfig({
|
|
141
137
|
displayName: "channels__List",
|
|
142
138
|
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) {
|
|
139
|
+
})(["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
140
|
return props.bgColor || _colors["default"].white;
|
|
145
141
|
}, function (props) {
|
|
146
142
|
return props.direction;
|
|
@@ -153,7 +149,7 @@ var List = /*#__PURE__*/_styledComponents["default"].ul.withConfig({
|
|
|
153
149
|
var ListItem = /*#__PURE__*/_styledComponents["default"].li.withConfig({
|
|
154
150
|
displayName: "channels__ListItem",
|
|
155
151
|
componentId: "nu2llv-3"
|
|
156
|
-
})(["display:flex;flex-direction:", ";position:relative;width:", ";font-size:", ";letter-spacing:0.5px;cursor:pointer;margin:", ";flex:1;text-shadow:", ";border-style:solid;border-color:inherit;border-width:", ";&:first-child{border-width:", ";}&::after{", "}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) {
|
|
152
|
+
})(["display:flex;flex-direction:", ";position:relative;width:", ";height:100%;font-size:", ";letter-spacing:0.5px;cursor:pointer;margin:", ";flex:1;text-shadow:", ";border-style:solid;border-color:inherit;border-width:", ";&:first-child{border-width:", ";}&::after{", "}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
153
|
return props.direction;
|
|
158
154
|
}, function (props) {
|
|
159
155
|
return styles.itemWidth[props.direction];
|
|
@@ -200,18 +196,26 @@ var Channels = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
200
196
|
|
|
201
197
|
_this = _super.call(this, props);
|
|
202
198
|
_this.state = {
|
|
203
|
-
activeDataIndex: _this._checkWhichChannelActive(props.currentPathname)
|
|
199
|
+
activeDataIndex: _this._checkWhichChannelActive(props.currentPathname),
|
|
200
|
+
activeDropdownIndex: invalidDataIndex
|
|
204
201
|
};
|
|
205
202
|
_this.handleDropDownChannelClick = _this._handleDropDownChannelClick.bind(_assertThisInitialized(_this));
|
|
206
203
|
_this.handleNormalChannelClick = _this._handleNormalChannelClick.bind(_assertThisInitialized(_this));
|
|
207
204
|
_this.handleDropDownMenuClick = _this._handleDropDownMenuClick.bind(_assertThisInitialized(_this));
|
|
208
|
-
_this.setActiveData = _this._setActiveData.bind(_assertThisInitialized(_this));
|
|
209
|
-
_this.resetActiveData = _this._resetActiveDataIndex.bind(_assertThisInitialized(_this));
|
|
210
205
|
_this.callback = _this._callback.bind(_assertThisInitialized(_this));
|
|
211
206
|
return _this;
|
|
212
207
|
}
|
|
213
208
|
|
|
214
209
|
_createClass(Channels, [{
|
|
210
|
+
key: "componentDidUpdate",
|
|
211
|
+
value: function componentDidUpdate() {
|
|
212
|
+
if (this.context.hideHeader) {
|
|
213
|
+
this.setState({
|
|
214
|
+
activeDropdownIndex: invalidDataIndex
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}, {
|
|
215
219
|
key: "_checkWhichChannelActive",
|
|
216
220
|
value: function _checkWhichChannelActive(currentPathname) {
|
|
217
221
|
var data = this.props.data;
|
|
@@ -247,38 +251,35 @@ var Channels = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
247
251
|
key: "_handleDropDownChannelClick",
|
|
248
252
|
value: function _handleDropDownChannelClick(e, channelIndex) {
|
|
249
253
|
e.preventDefault();
|
|
250
|
-
this.
|
|
254
|
+
var activeDropdownIndex = this.state.activeDropdownIndex;
|
|
255
|
+
var nextActiveDropdownIndex = channelIndex === activeDropdownIndex ? invalidDataIndex : channelIndex;
|
|
256
|
+
this.setState({
|
|
257
|
+
activeDropdownIndex: nextActiveDropdownIndex
|
|
258
|
+
});
|
|
251
259
|
}
|
|
252
260
|
}, {
|
|
253
261
|
key: "_handleNormalChannelClick",
|
|
254
262
|
value: function _handleNormalChannelClick(channelIndex) {
|
|
255
|
-
this.
|
|
256
|
-
|
|
263
|
+
this.setState({
|
|
264
|
+
activeDataIndex: channelIndex,
|
|
265
|
+
activeDropdownIndex: invalidDataIndex
|
|
266
|
+
});
|
|
267
|
+
this.callback(channelIndex);
|
|
257
268
|
}
|
|
258
269
|
}, {
|
|
259
270
|
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;
|
|
271
|
+
value: function _handleDropDownMenuClick(parentIndex) {
|
|
269
272
|
this.setState({
|
|
270
|
-
activeDataIndex:
|
|
273
|
+
activeDataIndex: parentIndex,
|
|
274
|
+
activeDropdownIndex: invalidDataIndex
|
|
271
275
|
});
|
|
272
|
-
|
|
273
|
-
}, {
|
|
274
|
-
key: "_resetActiveDataIndex",
|
|
275
|
-
value: function _resetActiveDataIndex() {
|
|
276
|
-
this.setActiveData(invalidDataIndex);
|
|
276
|
+
this.callback(parentIndex);
|
|
277
277
|
}
|
|
278
278
|
}, {
|
|
279
279
|
key: "_callback",
|
|
280
|
-
value: function _callback() {
|
|
281
|
-
this.props.
|
|
280
|
+
value: function _callback(dataIndex) {
|
|
281
|
+
var currentActivePathname = dataIndex === invalidDataIndex ? '' : this.props.data[dataIndex].pathname;
|
|
282
|
+
this.props.callback(currentActivePathname);
|
|
282
283
|
}
|
|
283
284
|
}, {
|
|
284
285
|
key: "_prepareChannelItemJSX",
|
|
@@ -293,8 +294,8 @@ var Channels = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
293
294
|
var _this$props = this.props,
|
|
294
295
|
data = _this$props.data,
|
|
295
296
|
direction = _this$props.direction;
|
|
296
|
-
var
|
|
297
|
-
var toShowDropdownMenu =
|
|
297
|
+
var activeDropdownIndex = this.state.activeDropdownIndex;
|
|
298
|
+
var toShowDropdownMenu = activeDropdownIndex === dataIndex;
|
|
298
299
|
|
|
299
300
|
var dropdownMenuData = _.get(data, [dataIndex, dropDownMenuKey], []);
|
|
300
301
|
|
|
@@ -309,11 +310,12 @@ var Channels = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
309
310
|
unmountOnExit: true
|
|
310
311
|
}, /*#__PURE__*/_react["default"].createElement(_dropDownMenu["default"], {
|
|
311
312
|
data: dropdownMenuData,
|
|
312
|
-
onClick:
|
|
313
|
+
onClick: function onClick(e) {
|
|
314
|
+
return _this2.handleDropDownMenuClick(dataIndex);
|
|
315
|
+
}
|
|
313
316
|
})));
|
|
314
317
|
|
|
315
|
-
var
|
|
316
|
-
var status = isActive ? 'collapse' : 'expand';
|
|
318
|
+
var status = toShowDropdownMenu ? 'collapse' : 'expand';
|
|
317
319
|
|
|
318
320
|
var _themeUtils$selectIco = _slicedToArray(_theme["default"].selectIcons(theme)[status], 2),
|
|
319
321
|
StatusIcon = _themeUtils$selectIco[0],
|
|
@@ -340,7 +342,6 @@ var Channels = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
340
342
|
var _this3 = this;
|
|
341
343
|
|
|
342
344
|
var _this$props2 = this.props,
|
|
343
|
-
currentPathname = _this$props2.currentPathname,
|
|
344
345
|
data = _this$props2.data,
|
|
345
346
|
direction = _this$props2.direction,
|
|
346
347
|
borderWidth = _this$props2.borderWidth,
|
|
@@ -357,8 +358,7 @@ var Channels = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
357
358
|
var _themeFunction = themeFunction(theme),
|
|
358
359
|
fontColor = _themeFunction.fontColor,
|
|
359
360
|
hoverFontColor = _themeFunction.hoverFontColor,
|
|
360
|
-
hoverBgColor = _themeFunction.hoverBgColor
|
|
361
|
-
borderColor = _themeFunction.borderColor;
|
|
361
|
+
hoverBgColor = _themeFunction.hoverBgColor;
|
|
362
362
|
|
|
363
363
|
var channelItemJSX = _this3._prepareChannelItemJSX(channelItem, dataIndex, theme);
|
|
364
364
|
|
|
@@ -416,5 +416,7 @@ _defineProperty(Channels, "defaultProps", {
|
|
|
416
416
|
callback: function callback() {}
|
|
417
417
|
});
|
|
418
418
|
|
|
419
|
+
_defineProperty(Channels, "contextType", _headerContext["default"]);
|
|
420
|
+
|
|
419
421
|
var _default = Channels;
|
|
420
422
|
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, {
|
|
@@ -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
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
|
|
10
|
-
var _react =
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
|
|
@@ -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,18 +33,33 @@ 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
|
+
|
|
42
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
41
43
|
|
|
42
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); }
|
|
43
45
|
|
|
44
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; }
|
|
45
47
|
|
|
46
|
-
function
|
|
48
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
49
|
+
|
|
50
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
51
|
+
|
|
52
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
53
|
+
|
|
54
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
55
|
+
|
|
56
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
57
|
+
|
|
58
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
47
59
|
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
61
|
+
|
|
62
|
+
var CHANNEL_HEIGHT = 36; // px
|
|
50
63
|
|
|
51
64
|
var styles = {
|
|
52
65
|
headerHeight: {
|
|
@@ -68,26 +81,40 @@ var styles = {
|
|
|
68
81
|
hd: 1320 // px
|
|
69
82
|
|
|
70
83
|
},
|
|
71
|
-
|
|
84
|
+
channelTopBorderWidth: [0, 1, 1, 0],
|
|
85
|
+
// px
|
|
86
|
+
channelBottomBorderWidth: [1, 0, 1, 0],
|
|
87
|
+
// px
|
|
88
|
+
iconBorderWidth: {
|
|
89
|
+
wide: [0, 0, 0, 0],
|
|
90
|
+
// px
|
|
91
|
+
narrow: [0, 0, 1, 0] // px
|
|
72
92
|
|
|
93
|
+
},
|
|
94
|
+
zIndex: {
|
|
95
|
+
topRow: 3,
|
|
96
|
+
channelBottom: 1,
|
|
97
|
+
channelTop: 4,
|
|
98
|
+
actionButton: 5
|
|
99
|
+
}
|
|
73
100
|
};
|
|
74
101
|
|
|
75
102
|
var headerWide = _animations["default"].changeHeight("".concat(styles.headerHeight.narrow, "px"), "".concat(styles.headerHeight.wide, "px"));
|
|
76
103
|
|
|
77
104
|
var headerNarrow = _animations["default"].changeHeight("".concat(styles.headerHeight.wide, "px"), "".concat(styles.headerHeight.narrow, "px"));
|
|
78
105
|
|
|
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.
|
|
106
|
+
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);
|
|
107
|
+
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'));
|
|
108
|
+
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
109
|
var channelSlideIn = /*#__PURE__*/(0, _styledComponents.keyframes)(["from{transform:translateY(", "px);opacity:0;}to{transform:translateY(0);opacity:1;}"], -CHANNEL_HEIGHT);
|
|
83
110
|
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.
|
|
111
|
+
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);
|
|
112
|
+
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
113
|
|
|
87
114
|
var Box = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
88
115
|
displayName: "header__Box",
|
|
89
116
|
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) {
|
|
117
|
+
})(["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
118
|
return props.isHide ? "".concat(-styles.headerHeight.narrow, "px") : 0;
|
|
92
119
|
}, function (props) {
|
|
93
120
|
return props.bgColor;
|
|
@@ -96,12 +123,12 @@ var Box = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
96
123
|
var TopRow = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
97
124
|
displayName: "header__TopRow",
|
|
98
125
|
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:
|
|
126
|
+
})(["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
127
|
|
|
101
128
|
var ChannelContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
102
129
|
displayName: "header__ChannelContainer",
|
|
103
130
|
componentId: "sc-1krza7i-2"
|
|
104
|
-
})(["width:calc(100% - 120px);max-width:", "px;z-index:
|
|
131
|
+
})(["width:calc(100% - 120px);max-width:", "px;z-index:", ";", ""], styles.channelMaxWidth.hd, styles.zIndex.channelBottom, ChannelEffect);
|
|
105
132
|
|
|
106
133
|
var FlexGroup = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
107
134
|
displayName: "header__FlexGroup",
|
|
@@ -123,12 +150,21 @@ var SloganContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
123
150
|
var ActionContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
124
151
|
displayName: "header__ActionContainer",
|
|
125
152
|
componentId: "sc-1krza7i-6"
|
|
126
|
-
})(["", " ", ""], FlexItem, ActionEffect);
|
|
153
|
+
})(["z-index:", ";", " ", ""], styles.zIndex.actionButton, FlexItem, ActionEffect);
|
|
154
|
+
|
|
155
|
+
var IconContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
156
|
+
displayName: "header__IconContainer",
|
|
157
|
+
componentId: "sc-1krza7i-7"
|
|
158
|
+
})(["", " 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) {
|
|
159
|
+
return props.borderColor;
|
|
160
|
+
}, function (props) {
|
|
161
|
+
return (0, _css.arrayToCssShorthand)(styles.iconBorderWidth[props.headerType]);
|
|
162
|
+
});
|
|
127
163
|
|
|
128
164
|
var ChannelTopContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
129
165
|
displayName: "header__ChannelTopContainer",
|
|
130
|
-
componentId: "sc-1krza7i-
|
|
131
|
-
})(["position:absolute;width:calc(100% - 530px);min-width:480px;max-width:910px;right:
|
|
166
|
+
componentId: "sc-1krza7i-8"
|
|
167
|
+
})(["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
168
|
|
|
133
169
|
var Header = function Header(_ref) {
|
|
134
170
|
var pathname = _ref.pathname,
|
|
@@ -136,6 +172,12 @@ var Header = function Header(_ref) {
|
|
|
136
172
|
services = _ref.services,
|
|
137
173
|
actions = _ref.actions,
|
|
138
174
|
narrowActions = _ref.narrowActions;
|
|
175
|
+
|
|
176
|
+
var _useState = (0, _react.useState)(pathname),
|
|
177
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
178
|
+
currentPathname = _useState2[0],
|
|
179
|
+
setPathname = _useState2[1];
|
|
180
|
+
|
|
139
181
|
return /*#__PURE__*/_react["default"].createElement(_headerContext["default"].Consumer, null, function (_ref2) {
|
|
140
182
|
var releaseBranch = _ref2.releaseBranch,
|
|
141
183
|
isLinkExternal = _ref2.isLinkExternal,
|
|
@@ -143,7 +185,9 @@ var Header = function Header(_ref) {
|
|
|
143
185
|
toUseNarrow = _ref2.toUseNarrow,
|
|
144
186
|
hideHeader = _ref2.hideHeader;
|
|
145
187
|
|
|
146
|
-
var
|
|
188
|
+
var _themeUtils$selectHea = _theme["default"].selectHeaderTheme(theme),
|
|
189
|
+
bgColor = _themeUtils$selectHea.bgColor,
|
|
190
|
+
borderColor = _themeUtils$selectHea.borderColor;
|
|
147
191
|
|
|
148
192
|
var Logo = _theme["default"].selectLogoComponent(theme);
|
|
149
193
|
|
|
@@ -155,24 +199,24 @@ var Header = function Header(_ref) {
|
|
|
155
199
|
classNames: "header-effect",
|
|
156
200
|
timeout: {
|
|
157
201
|
appear: 0,
|
|
158
|
-
enter:
|
|
159
|
-
exit:
|
|
202
|
+
enter: 500,
|
|
203
|
+
exit: 500
|
|
160
204
|
}
|
|
161
205
|
}, /*#__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
206
|
"in": !toUseNarrow,
|
|
163
207
|
classNames: "logo-effect",
|
|
164
208
|
timeout: {
|
|
165
209
|
appear: 0,
|
|
166
|
-
enter:
|
|
167
|
-
exit:
|
|
210
|
+
enter: 500,
|
|
211
|
+
exit: 500
|
|
168
212
|
}
|
|
169
213
|
}, /*#__PURE__*/_react["default"].createElement(Logo, null)))), /*#__PURE__*/_react["default"].createElement(ActionContainer, null, /*#__PURE__*/_react["default"].createElement(_CSSTransition["default"], {
|
|
170
214
|
"in": !toUseNarrow,
|
|
171
215
|
classNames: "action-effect",
|
|
172
216
|
timeout: {
|
|
173
217
|
appear: 0,
|
|
174
|
-
enter:
|
|
175
|
-
exit:
|
|
218
|
+
enter: 500,
|
|
219
|
+
exit: 500
|
|
176
220
|
}
|
|
177
221
|
}, /*#__PURE__*/_react["default"].createElement(_actionButton["default"], {
|
|
178
222
|
actions: toUseNarrow ? narrowActions : actions
|
|
@@ -181,36 +225,42 @@ var Header = function Header(_ref) {
|
|
|
181
225
|
classNames: "slogan-effect",
|
|
182
226
|
timeout: {
|
|
183
227
|
appear: 0,
|
|
184
|
-
enter:
|
|
185
|
-
exit:
|
|
228
|
+
enter: 500,
|
|
229
|
+
exit: 500
|
|
186
230
|
}
|
|
187
231
|
}, /*#__PURE__*/_react["default"].createElement(_slogan["default"], null)))), /*#__PURE__*/_react["default"].createElement(ChannelTopContainer, null, /*#__PURE__*/_react["default"].createElement(_CSSTransition["default"], {
|
|
188
232
|
"in": toUseNarrow,
|
|
189
233
|
classNames: "channel-effect",
|
|
190
234
|
timeout: {
|
|
191
235
|
appear: 0,
|
|
192
|
-
enter:
|
|
193
|
-
exit:
|
|
236
|
+
enter: 600,
|
|
237
|
+
exit: 200
|
|
194
238
|
},
|
|
195
239
|
unmountOnExit: true
|
|
196
240
|
}, /*#__PURE__*/_react["default"].createElement(_channels["default"], {
|
|
197
|
-
currentPathname:
|
|
198
|
-
data: channels
|
|
199
|
-
|
|
241
|
+
currentPathname: currentPathname,
|
|
242
|
+
data: channels,
|
|
243
|
+
borderWidth: styles.channelTopBorderWidth,
|
|
244
|
+
callback: setPathname
|
|
245
|
+
}))), /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
246
|
+
headerType: toUseNarrow ? 'narrow' : 'wide',
|
|
247
|
+
borderColor: borderColor
|
|
248
|
+
}, /*#__PURE__*/_react["default"].createElement(_icons["default"], {
|
|
200
249
|
services: services
|
|
201
|
-
}))), /*#__PURE__*/_react["default"].createElement(ChannelContainer, null, /*#__PURE__*/_react["default"].createElement(_CSSTransition["default"], {
|
|
250
|
+
})))), /*#__PURE__*/_react["default"].createElement(ChannelContainer, null, /*#__PURE__*/_react["default"].createElement(_CSSTransition["default"], {
|
|
202
251
|
"in": !toUseNarrow,
|
|
203
252
|
classNames: "channel-effect",
|
|
204
253
|
timeout: {
|
|
205
254
|
appear: 0,
|
|
206
|
-
enter:
|
|
207
|
-
exit:
|
|
255
|
+
enter: 600,
|
|
256
|
+
exit: 200
|
|
208
257
|
},
|
|
209
258
|
unmountOnExit: true
|
|
210
259
|
}, /*#__PURE__*/_react["default"].createElement(_channels["default"], {
|
|
211
|
-
currentPathname:
|
|
260
|
+
currentPathname: currentPathname,
|
|
212
261
|
data: channels,
|
|
213
|
-
borderWidth: styles.channelBottomBorderWidth
|
|
262
|
+
borderWidth: styles.channelBottomBorderWidth,
|
|
263
|
+
callback: setPathname
|
|
214
264
|
}))));
|
|
215
265
|
});
|
|
216
266
|
};
|
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"));
|
|
@@ -81,7 +79,7 @@ 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
|
|
85
83
|
|
|
86
84
|
},
|
|
87
85
|
logoHeight: {
|
|
@@ -107,7 +105,7 @@ var styles = {
|
|
|
107
105
|
|
|
108
106
|
}
|
|
109
107
|
};
|
|
110
|
-
var SloganEffect = /*#__PURE__*/(0, _styledComponents.css)([".slogan-effect-enter{opacity:0;}.slogagn-effect-enter-active{animation:", " 0.
|
|
108
|
+
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
109
|
|
|
112
110
|
var TabletOnly = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
113
111
|
displayName: "mobile-header__TabletOnly",
|
|
@@ -117,7 +115,7 @@ var TabletOnly = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
117
115
|
var FlexBox = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
118
116
|
displayName: "mobile-header__FlexBox",
|
|
119
117
|
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) {
|
|
118
|
+
})(["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
119
|
return props.isHide ? "".concat(-styles.headerHeight.mobile, "px") : 0;
|
|
122
120
|
}, function (props) {
|
|
123
121
|
return props.bgColor;
|
|
@@ -218,7 +216,8 @@ var MobileHeader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
218
216
|
|
|
219
217
|
var Logo = _theme["default"].selectLogoComponent(theme);
|
|
220
218
|
|
|
221
|
-
var
|
|
219
|
+
var _themeUtils$selectHea = _theme["default"].selectHeaderTheme(theme),
|
|
220
|
+
bgColor = _themeUtils$selectHea.bgColor;
|
|
222
221
|
|
|
223
222
|
var MenuIcon = _theme["default"].selectIcons(theme).menu;
|
|
224
223
|
|
|
@@ -234,8 +233,8 @@ var MobileHeader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
234
233
|
classNames: "slogan-effect",
|
|
235
234
|
timeout: {
|
|
236
235
|
appear: 0,
|
|
237
|
-
enter:
|
|
238
|
-
exit:
|
|
236
|
+
enter: 400,
|
|
237
|
+
exit: 400
|
|
239
238
|
}
|
|
240
239
|
}, /*#__PURE__*/_react["default"].createElement(_slogan["default"], null))))), /*#__PURE__*/_react["default"].createElement(Hamburger, {
|
|
241
240
|
onClick: _this2.handleOnHamburgerClick
|
|
@@ -251,6 +250,7 @@ exports["default"] = MobileHeader;
|
|
|
251
250
|
|
|
252
251
|
_defineProperty(MobileHeader, "propTypes", {
|
|
253
252
|
actions: _propTypes["default"].array,
|
|
253
|
+
narrowActions: _propTypes["default"].array,
|
|
254
254
|
menuChannels: _propTypes["default"].array,
|
|
255
255
|
menuServices: _propTypes["default"].array,
|
|
256
256
|
menuActions: _propTypes["default"].array
|
|
@@ -258,6 +258,7 @@ _defineProperty(MobileHeader, "propTypes", {
|
|
|
258
258
|
|
|
259
259
|
_defineProperty(MobileHeader, "defaultProps", {
|
|
260
260
|
actions: [],
|
|
261
|
+
narrowActions: [],
|
|
261
262
|
menuChannels: [],
|
|
262
263
|
menuServices: [],
|
|
263
264
|
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;"], 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",
|
|
@@ -110,25 +110,6 @@ var DesktopAndAbove = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
110
110
|
componentId: "narage-2"
|
|
111
111
|
})(["display:none;", ""], _mediaQuery["default"].desktopAndAbove(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: block;\n ", "\n "])), stickyTop));
|
|
112
112
|
|
|
113
|
-
function mergeTwoArraysInOrder() {
|
|
114
|
-
var arr1 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
115
|
-
var arr2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
116
|
-
var rtn = [];
|
|
117
|
-
var maxLength = Math.max(arr1.length, arr2.length);
|
|
118
|
-
|
|
119
|
-
for (var i = 0; i < maxLength; i++) {
|
|
120
|
-
if (arr1[i]) {
|
|
121
|
-
rtn.push(arr1[i]);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (arr2[i]) {
|
|
125
|
-
rtn.push(arr2[i]);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return rtn;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
113
|
var Container = /*#__PURE__*/function (_React$PureComponent) {
|
|
133
114
|
_inherits(Container, _React$PureComponent);
|
|
134
115
|
|
|
@@ -148,7 +129,7 @@ var Container = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
148
129
|
|
|
149
130
|
_this.currentY = 0;
|
|
150
131
|
_this.readyY = 0;
|
|
151
|
-
_this.
|
|
132
|
+
_this.isTransforming = false;
|
|
152
133
|
_this.transformTimer = null;
|
|
153
134
|
return _this;
|
|
154
135
|
}
|
|
@@ -164,6 +145,11 @@ var Container = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
164
145
|
key: "componentWillUnmount",
|
|
165
146
|
value: function componentWillUnmount() {
|
|
166
147
|
window.removeEventListener('scroll', this.handleScroll);
|
|
148
|
+
this.handleScroll = null;
|
|
149
|
+
this.currentY = null;
|
|
150
|
+
this.readyY = null;
|
|
151
|
+
this.isTransforming = null;
|
|
152
|
+
this.transformTimer = null;
|
|
167
153
|
}
|
|
168
154
|
}, {
|
|
169
155
|
key: "__handleScroll",
|
|
@@ -182,14 +168,13 @@ var Container = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
182
168
|
var _this2 = this;
|
|
183
169
|
|
|
184
170
|
var isCurrentNarrow = this.state.toUseNarrow;
|
|
171
|
+
var nextToUseNarrow = scrollTop > TRANSFORM_HEADER_THRESHOLD;
|
|
185
172
|
var scrollState = {};
|
|
186
173
|
|
|
187
174
|
if (this.isTransforming) {
|
|
188
175
|
return scrollState;
|
|
189
176
|
}
|
|
190
177
|
|
|
191
|
-
scrollState.toUseNarrow = scrollTop > TRANSFORM_HEADER_THRESHOLD ? true : false;
|
|
192
|
-
|
|
193
178
|
if (scrollDirection === 'up') {
|
|
194
179
|
this.readyY = scrollTop;
|
|
195
180
|
scrollState.hideHeader = false;
|
|
@@ -200,6 +185,14 @@ var Container = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
200
185
|
if (isCurrentNarrow && scrollTop - this.readyY > HIDE_HEADER_THRESHOLD) {
|
|
201
186
|
scrollState.hideHeader = true;
|
|
202
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;
|
|
203
196
|
} // register transform timer to mark header transform status
|
|
204
197
|
|
|
205
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-rc.
|
|
3
|
+
"version": "2.2.0-rc.9",
|
|
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-rc.
|
|
22
|
+
"@twreporter/react-components": "^8.5.0-rc.1",
|
|
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": "81aa803c1e1cb4cfa5a858e5d2ba6bb502c4fef3"
|
|
38
38
|
}
|