@twreporter/universal-header 2.4.0-rc.5 → 2.4.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/lib/components/action-button-item.js +169 -0
- package/lib/components/{action-button.stories.js → action-button-item.stories.js} +20 -18
- package/lib/components/action-button.js +51 -114
- package/lib/components/hamburger-menu.js +59 -59
- package/lib/components/hamburger-menu.stories.js +1 -7
- package/lib/components/header.js +111 -48
- package/lib/components/header.stories.js +17 -16
- package/lib/components/icons.js +26 -6
- package/lib/components/slogan.js +3 -1
- package/lib/components/tab-bar.js +117 -0
- package/lib/components/tab-bar.stories.js +51 -0
- package/lib/constants/action-item-types.js +79 -0
- package/lib/constants/actions.js +3 -3
- package/lib/constants/channels.js +1 -1
- package/lib/constants/prop-types.js +6 -2
- package/lib/containers/header.js +7 -3
- package/lib/utils/links.js +25 -2
- package/lib/utils/theme-old.js +90 -158
- package/lib/utils/theme.js +75 -82
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,33 @@
|
|
|
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.4.0-rc.7](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.4.0-rc.6...@twreporter/universal-header@2.4.0-rc.7) (2022-11-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @twreporter/universal-header
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [2.4.0-rc.6](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.4.0-rc.5...@twreporter/universal-header@2.4.0-rc.6) (2022-11-25)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* add constants file to manage prop types ([4841e86](https://github.com/twreporter/twreporter-npm-packages/commit/4841e868cad52cfd2168f0c146de30950e27c996))
|
|
20
|
+
* move action button storybook arg types in constants ([c4c066f](https://github.com/twreporter/twreporter-npm-packages/commit/c4c066f540628686478d44662a7c177021f52c59))
|
|
21
|
+
* remove unnecessary parantheses ([13df7e4](https://github.com/twreporter/twreporter-npm-packages/commit/13df7e49084d1e2f895ee7ebce4349c77a0810c2))
|
|
22
|
+
* update `latest` page path ([a592546](https://github.com/twreporter/twreporter-npm-packages/commit/a5925467548d33179b8b9122f0c3c83ad61e1fcd))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* add mobile & tablet view for new info structure ([b0e158c](https://github.com/twreporter/twreporter-npm-packages/commit/b0e158c751230723626c9cb9de83641f0588c189))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
6
33
|
# [2.4.0-rc.5](https://github.com/twreporter/twreporter-npm-packages/compare/@twreporter/universal-header@2.4.0-rc.4...@twreporter/universal-header@2.4.0-rc.5) (2022-11-07)
|
|
7
34
|
|
|
8
35
|
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
|
|
14
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _headerContext = _interopRequireDefault(require("../contexts/header-context"));
|
|
17
|
+
|
|
18
|
+
var _links = require("../utils/links");
|
|
19
|
+
|
|
20
|
+
var _actions = require("../constants/actions");
|
|
21
|
+
|
|
22
|
+
var _actionItemTypes = require("../constants/action-item-types");
|
|
23
|
+
|
|
24
|
+
var _customizedLink = _interopRequireDefault(require("@twreporter/react-components/lib/customized-link"));
|
|
25
|
+
|
|
26
|
+
var _css = require("@twreporter/core/lib/utils/css");
|
|
27
|
+
|
|
28
|
+
var _button = require("@twreporter/react-components/lib/button");
|
|
29
|
+
|
|
30
|
+
var _theme = require("@twreporter/core/lib/constants/theme");
|
|
31
|
+
|
|
32
|
+
var _map = _interopRequireDefault(require("lodash/map"));
|
|
33
|
+
|
|
34
|
+
var _excluded = ["actions", "direction", "textType", "buttonWidth", "buttonSize", "callback"];
|
|
35
|
+
|
|
36
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
37
|
+
|
|
38
|
+
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); }
|
|
39
|
+
|
|
40
|
+
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; }
|
|
41
|
+
|
|
42
|
+
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); }
|
|
43
|
+
|
|
44
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
45
|
+
|
|
46
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
47
|
+
|
|
48
|
+
var _ = {
|
|
49
|
+
map: _map["default"]
|
|
50
|
+
}; // global var
|
|
51
|
+
|
|
52
|
+
var defaultFunc = function defaultFunc() {};
|
|
53
|
+
|
|
54
|
+
var styles = {
|
|
55
|
+
itemMargin: {
|
|
56
|
+
row: [0, 0, 0, 16],
|
|
57
|
+
// px
|
|
58
|
+
column: [16, 0, 0, 0] // px
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var StyledPillButton = /*#__PURE__*/(0, _styledComponents["default"])(_button.PillButton).withConfig({
|
|
63
|
+
displayName: "action-button-item__StyledPillButton",
|
|
64
|
+
componentId: "z0zuf3-0"
|
|
65
|
+
})(["justify-content:center;", ""], function (props) {
|
|
66
|
+
return props.buttonWidth === 'stretch' ? 'width: auto;' : '';
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
var ActionItem = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
70
|
+
displayName: "action-button-item__ActionItem",
|
|
71
|
+
componentId: "z0zuf3-1"
|
|
72
|
+
})(["display:flex;align-items:center;justify-content:center;margin:", ";&:first-child{margin-top:0;margin-left:0;}a{text-decoration:none;}"], function (props) {
|
|
73
|
+
return (0, _css.arrayToCssShorthand)(styles.itemMargin[props.direction]);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
var ActionsContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
77
|
+
displayName: "action-button-item__ActionsContainer",
|
|
78
|
+
componentId: "z0zuf3-2"
|
|
79
|
+
})(["display:flex;align-items:center;flex-direction:", ";&,", ",a{", "}"], function (props) {
|
|
80
|
+
return props.direction;
|
|
81
|
+
}, ActionItem, function (props) {
|
|
82
|
+
return props.buttonWidth === 'stretch' ? 'width: 100%;' : '';
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
var ActionButtonItem = function ActionButtonItem(_ref) {
|
|
86
|
+
var _ref$action = _ref.action,
|
|
87
|
+
action = _ref$action === void 0 ? {} : _ref$action,
|
|
88
|
+
_ref$direction = _ref.direction,
|
|
89
|
+
direction = _ref$direction === void 0 ? _actionItemTypes.DIRECTION_TYPE.row : _ref$direction,
|
|
90
|
+
_ref$textType = _ref.textType,
|
|
91
|
+
textType = _ref$textType === void 0 ? _actionItemTypes.TEXT_TYPE.brief : _ref$textType,
|
|
92
|
+
_ref$buttonWidth = _ref.buttonWidth,
|
|
93
|
+
buttonWidth = _ref$buttonWidth === void 0 ? _actionItemTypes.BUTTON_WIDTH_TYPE.fit : _ref$buttonWidth,
|
|
94
|
+
_ref$buttonSize = _ref.buttonSize,
|
|
95
|
+
buttonSize = _ref$buttonSize === void 0 ? _actionItemTypes.BUTTON_SIZE_TYPE.S : _ref$buttonSize,
|
|
96
|
+
_ref$callback = _ref.callback,
|
|
97
|
+
callback = _ref$callback === void 0 ? defaultFunc : _ref$callback;
|
|
98
|
+
|
|
99
|
+
var _useContext = (0, _react.useContext)(_headerContext["default"]),
|
|
100
|
+
theme = _useContext.theme;
|
|
101
|
+
|
|
102
|
+
var buttonTheme = direction === _actionItemTypes.DIRECTION_TYPE.row || theme === _theme.THEME.photography ? theme : _theme.THEME.noraml;
|
|
103
|
+
var actionKey = action.key;
|
|
104
|
+
var actionLabel = _actions.ACTION_LABEL[textType][actionKey];
|
|
105
|
+
var actionLink = (0, _links.getActionLinks)()[actionKey];
|
|
106
|
+
var buttonType = _actions.ACTION_BUTTON_TYPE[actionKey];
|
|
107
|
+
return /*#__PURE__*/_react["default"].createElement(ActionItem, {
|
|
108
|
+
onClick: callback,
|
|
109
|
+
direction: direction
|
|
110
|
+
}, /*#__PURE__*/_react["default"].createElement(_customizedLink["default"], actionLink, /*#__PURE__*/_react["default"].createElement(StyledPillButton, {
|
|
111
|
+
text: actionLabel,
|
|
112
|
+
theme: buttonTheme,
|
|
113
|
+
type: buttonType,
|
|
114
|
+
size: buttonSize,
|
|
115
|
+
buttonWidth: buttonWidth
|
|
116
|
+
})));
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
ActionButtonItem.propTypes = {
|
|
120
|
+
action: _propTypes["default"].shape({
|
|
121
|
+
key: _propTypes["default"].string
|
|
122
|
+
}),
|
|
123
|
+
direction: _actionItemTypes.DIRECTION_PROP_TYPE,
|
|
124
|
+
textType: _actionItemTypes.TEXT_PROP_TYPE,
|
|
125
|
+
buttonWidth: _actionItemTypes.BUTTON_WIDTH_PROP_TYPE,
|
|
126
|
+
buttonSize: _actionItemTypes.BUTTON_SIZE_PROP_TYPE,
|
|
127
|
+
callback: _propTypes["default"].func
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
var ActionButton = function ActionButton(_ref2) {
|
|
131
|
+
var _ref2$actions = _ref2.actions,
|
|
132
|
+
actions = _ref2$actions === void 0 ? [] : _ref2$actions,
|
|
133
|
+
_ref2$direction = _ref2.direction,
|
|
134
|
+
direction = _ref2$direction === void 0 ? _actionItemTypes.DIRECTION_TYPE.row : _ref2$direction,
|
|
135
|
+
_ref2$textType = _ref2.textType,
|
|
136
|
+
textType = _ref2$textType === void 0 ? _actionItemTypes.TEXT_TYPE.brief : _ref2$textType,
|
|
137
|
+
_ref2$buttonWidth = _ref2.buttonWidth,
|
|
138
|
+
buttonWidth = _ref2$buttonWidth === void 0 ? _actionItemTypes.BUTTON_WIDTH_TYPE.fit : _ref2$buttonWidth,
|
|
139
|
+
_ref2$buttonSize = _ref2.buttonSize,
|
|
140
|
+
buttonSize = _ref2$buttonSize === void 0 ? _actionItemTypes.BUTTON_SIZE_TYPE.S : _ref2$buttonSize,
|
|
141
|
+
_ref2$callback = _ref2.callback,
|
|
142
|
+
callback = _ref2$callback === void 0 ? defaultFunc : _ref2$callback,
|
|
143
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
|
144
|
+
|
|
145
|
+
return /*#__PURE__*/_react["default"].createElement(ActionsContainer, _extends({
|
|
146
|
+
direction: direction,
|
|
147
|
+
buttonWidth: buttonWidth
|
|
148
|
+
}, rest), _.map(actions, function (action) {
|
|
149
|
+
return /*#__PURE__*/_react["default"].createElement(ActionButtonItem, {
|
|
150
|
+
action: action,
|
|
151
|
+
direction: direction,
|
|
152
|
+
textType: textType,
|
|
153
|
+
buttonWidth: buttonWidth,
|
|
154
|
+
buttonSize: buttonSize,
|
|
155
|
+
key: action.key
|
|
156
|
+
});
|
|
157
|
+
}));
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
ActionButton.propTypes = {
|
|
161
|
+
actions: _propTypes["default"].arrayOf(ActionButtonItem.propTypes.action),
|
|
162
|
+
direction: ActionButtonItem.propTypes.direction,
|
|
163
|
+
textType: ActionButtonItem.propTypes.textType,
|
|
164
|
+
buttonWidth: ActionButtonItem.propTypes.buttonWidth,
|
|
165
|
+
buttonSize: ActionButtonItem.propTypes.buttonSize,
|
|
166
|
+
callback: _propTypes["default"].func
|
|
167
|
+
};
|
|
168
|
+
var _default = ActionButton;
|
|
169
|
+
exports["default"] = _default;
|
|
@@ -9,10 +9,12 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _actionButtonItem = _interopRequireDefault(require("./action-button-item"));
|
|
13
13
|
|
|
14
14
|
var _headerContext = _interopRequireDefault(require("../contexts/header-context"));
|
|
15
15
|
|
|
16
|
+
var _actionItemTypes = require("../constants/action-item-types");
|
|
17
|
+
|
|
16
18
|
var _theme = require("@twreporter/core/lib/constants/theme");
|
|
17
19
|
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -20,23 +22,20 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
20
22
|
/* eslint-disable react/prop-types */
|
|
21
23
|
var _default = {
|
|
22
24
|
title: 'Action Button',
|
|
23
|
-
component:
|
|
25
|
+
component: _actionButtonItem["default"],
|
|
24
26
|
argTypes: {
|
|
25
27
|
theme: _theme.THEME_STORYBOOK_ARG_TYPE,
|
|
26
|
-
direction:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
type: 'radio'
|
|
31
|
-
}
|
|
32
|
-
}
|
|
28
|
+
direction: _actionItemTypes.DIRECTION_STORYBOOK_ARG_TYPE,
|
|
29
|
+
textType: _actionItemTypes.TEXT_STORYBOOK_ARG_TYPE,
|
|
30
|
+
buttonWidth: _actionItemTypes.BUTTON_WIDTH_STORYBOOK_ARG_TYPE,
|
|
31
|
+
buttonSize: _actionItemTypes.BUTTON_SIZE_STORYBOOK_ARG_TYPE
|
|
33
32
|
}
|
|
34
33
|
};
|
|
35
34
|
exports["default"] = _default;
|
|
36
35
|
|
|
37
36
|
var Container = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
38
|
-
displayName: "action-
|
|
39
|
-
componentId: "
|
|
37
|
+
displayName: "action-button-itemstories__Container",
|
|
38
|
+
componentId: "sc-1bpjnxr-0"
|
|
40
39
|
})(["max-width:500px;width:100%;"]);
|
|
41
40
|
|
|
42
41
|
var defaultActions = [{
|
|
@@ -52,7 +51,7 @@ var actionButton = function actionButton(props) {
|
|
|
52
51
|
};
|
|
53
52
|
return /*#__PURE__*/_react["default"].createElement(_headerContext["default"].Provider, {
|
|
54
53
|
value: context
|
|
55
|
-
}, /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(
|
|
54
|
+
}, /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(_actionButtonItem["default"], props)));
|
|
56
55
|
};
|
|
57
56
|
|
|
58
57
|
exports.actionButton = actionButton;
|
|
@@ -65,7 +64,7 @@ var photographyTheme = function photographyTheme(props) {
|
|
|
65
64
|
value: {
|
|
66
65
|
theme: _theme.THEME.photography
|
|
67
66
|
}
|
|
68
|
-
}, /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(
|
|
67
|
+
}, /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(_actionButtonItem["default"], props)));
|
|
69
68
|
};
|
|
70
69
|
|
|
71
70
|
exports.photographyTheme = photographyTheme;
|
|
@@ -86,7 +85,7 @@ var transparentTheme = function transparentTheme(props) {
|
|
|
86
85
|
value: {
|
|
87
86
|
theme: _theme.THEME.transparent
|
|
88
87
|
}
|
|
89
|
-
}, /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(
|
|
88
|
+
}, /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(_actionButtonItem["default"], props)));
|
|
90
89
|
};
|
|
91
90
|
|
|
92
91
|
exports.transparentTheme = transparentTheme;
|
|
@@ -105,21 +104,24 @@ transparentTheme.parameters = {
|
|
|
105
104
|
var hamburger = function hamburger(props) {
|
|
106
105
|
return /*#__PURE__*/_react["default"].createElement(_headerContext["default"].Provider, {
|
|
107
106
|
value: {
|
|
108
|
-
theme:
|
|
107
|
+
theme: props.theme
|
|
109
108
|
}
|
|
110
|
-
}, /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(
|
|
109
|
+
}, /*#__PURE__*/_react["default"].createElement(Container, null, /*#__PURE__*/_react["default"].createElement(_actionButtonItem["default"], props)));
|
|
111
110
|
};
|
|
112
111
|
|
|
113
112
|
exports.hamburger = hamburger;
|
|
114
113
|
hamburger.args = {
|
|
115
114
|
actions: defaultActions,
|
|
116
|
-
direction:
|
|
115
|
+
direction: _actionItemTypes.DIRECTION_TYPE.column,
|
|
116
|
+
textType: _actionItemTypes.TEXT_TYPE.full,
|
|
117
|
+
buttonWidth: _actionItemTypes.BUTTON_WIDTH_TYPE.stretch,
|
|
118
|
+
buttonSize: _actionItemTypes.BUTTON_SIZE_TYPE.L
|
|
117
119
|
};
|
|
118
120
|
hamburger.parameters = {
|
|
119
121
|
backgrounds: {
|
|
120
122
|
"default": 'white'
|
|
121
123
|
},
|
|
122
124
|
controls: {
|
|
123
|
-
exclude: ['actions', 'callback', '
|
|
125
|
+
exclude: ['actions', 'callback', 'direction', 'textType', 'buttonWidth', 'buttonSize']
|
|
124
126
|
}
|
|
125
127
|
};
|
|
@@ -1,146 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
6
|
+
exports.MobileHamburgerAction = exports.DesktopHamburgerAction = exports.MobileHeaderAction = exports.DesktopHeaderAction = void 0;
|
|
13
7
|
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
var _headerContext = _interopRequireDefault(require("../contexts/header-context"));
|
|
17
|
-
|
|
18
|
-
var _links = require("../utils/links");
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
19
9
|
|
|
20
10
|
var _actions = require("../constants/actions");
|
|
21
11
|
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var _css = require("@twreporter/core/lib/utils/css");
|
|
12
|
+
var _actionItemTypes = require("../constants/action-item-types");
|
|
25
13
|
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
var _theme = require("@twreporter/core/lib/constants/theme");
|
|
14
|
+
var _actionButtonItem = _interopRequireDefault(require("./action-button-item"));
|
|
29
15
|
|
|
30
16
|
var _map = _interopRequireDefault(require("lodash/map"));
|
|
31
17
|
|
|
32
|
-
var _excluded = ["actions", "direction", "callback"];
|
|
33
|
-
|
|
34
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
35
19
|
|
|
36
|
-
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); }
|
|
37
|
-
|
|
38
|
-
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; }
|
|
39
|
-
|
|
40
20
|
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); }
|
|
41
21
|
|
|
42
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
43
|
-
|
|
44
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
45
|
-
|
|
46
22
|
var _ = {
|
|
47
23
|
map: _map["default"]
|
|
48
|
-
};
|
|
24
|
+
};
|
|
49
25
|
|
|
50
|
-
var
|
|
26
|
+
var getActionProps = function getActionProps(type) {
|
|
27
|
+
return _.map(_actions.ACTION_ORDER[type], function (key) {
|
|
28
|
+
return {
|
|
29
|
+
key: key
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
};
|
|
51
33
|
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
row: [0, 0, 0, 16],
|
|
55
|
-
// px
|
|
56
|
-
column: [16, 0, 0, 0] // px
|
|
34
|
+
var DesktopHeaderAction = function DesktopHeaderAction(_ref) {
|
|
35
|
+
var props = _extends({}, _ref);
|
|
57
36
|
|
|
58
|
-
|
|
37
|
+
var actionProps = getActionProps('desktop');
|
|
38
|
+
return /*#__PURE__*/_react["default"].createElement(_actionButtonItem["default"], _extends({
|
|
39
|
+
actions: actionProps
|
|
40
|
+
}, props));
|
|
59
41
|
};
|
|
60
|
-
var StyledPillButton = /*#__PURE__*/(0, _styledComponents["default"])(_button.PillButton).withConfig({
|
|
61
|
-
displayName: "action-button__StyledPillButton",
|
|
62
|
-
componentId: "sc-4wc24t-0"
|
|
63
|
-
})(["justify-content:center;", ""], function (props) {
|
|
64
|
-
return props.direction === 'column' ? 'width: auto;' : '';
|
|
65
|
-
});
|
|
66
42
|
|
|
67
|
-
|
|
68
|
-
displayName: "action-button__ActionItem",
|
|
69
|
-
componentId: "sc-4wc24t-1"
|
|
70
|
-
})(["display:flex;align-items:center;justify-content:center;margin:", ";&:first-child{margin-top:0;margin-left:0;}a{text-decoration:none;}"], function (props) {
|
|
71
|
-
return (0, _css.arrayToCssShorthand)(styles.itemMargin[props.direction]);
|
|
72
|
-
});
|
|
43
|
+
exports.DesktopHeaderAction = DesktopHeaderAction;
|
|
73
44
|
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
componentId: "sc-4wc24t-2"
|
|
77
|
-
})(["display:flex;align-items:center;flex-direction:", ";&,", ",a{", "}"], function (props) {
|
|
78
|
-
return props.direction;
|
|
79
|
-
}, ActionItem, function (props) {
|
|
80
|
-
return props.direction === 'column' ? 'width: 100%;' : '';
|
|
81
|
-
});
|
|
45
|
+
var MobileHeaderAction = function MobileHeaderAction(_ref2) {
|
|
46
|
+
var props = _extends({}, _ref2);
|
|
82
47
|
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
direction = _ref$direction === void 0 ? 'row' : _ref$direction,
|
|
88
|
-
_ref$callback = _ref.callback,
|
|
89
|
-
callback = _ref$callback === void 0 ? defaultFunc : _ref$callback;
|
|
90
|
-
|
|
91
|
-
var _useContext = (0, _react.useContext)(_headerContext["default"]),
|
|
92
|
-
theme = _useContext.theme;
|
|
93
|
-
|
|
94
|
-
var buttonTheme = direction === 'row' || theme === _theme.THEME.photography ? theme : _theme.THEME.noraml;
|
|
95
|
-
var actionKey = action.key;
|
|
96
|
-
var actionLabel = _actions.ACTION_LABEL[direction][actionKey];
|
|
97
|
-
var actionLink = (0, _links.getActionLinks)()[actionKey];
|
|
98
|
-
var buttonType = _actions.ACTION_BUTTON_TYPE[actionKey];
|
|
99
|
-
var buttonSize = direction === 'column' ? 'L' : 'S';
|
|
100
|
-
return /*#__PURE__*/_react["default"].createElement(ActionItem, {
|
|
101
|
-
onClick: callback,
|
|
102
|
-
direction: direction
|
|
103
|
-
}, /*#__PURE__*/_react["default"].createElement(_customizedLink["default"], actionLink, /*#__PURE__*/_react["default"].createElement(StyledPillButton, {
|
|
104
|
-
text: actionLabel,
|
|
105
|
-
theme: buttonTheme,
|
|
106
|
-
type: buttonType,
|
|
107
|
-
size: buttonSize,
|
|
108
|
-
direction: direction
|
|
109
|
-
})));
|
|
48
|
+
var actionProps = getActionProps('mobile');
|
|
49
|
+
return /*#__PURE__*/_react["default"].createElement(_actionButtonItem["default"], _extends({
|
|
50
|
+
actions: actionProps
|
|
51
|
+
}, props));
|
|
110
52
|
};
|
|
111
53
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
})
|
|
116
|
-
direction: _propTypes["default"].oneOf(['row', 'column']),
|
|
117
|
-
callback: _propTypes["default"].func
|
|
118
|
-
};
|
|
54
|
+
exports.MobileHeaderAction = MobileHeaderAction;
|
|
55
|
+
|
|
56
|
+
var DesktopHamburgerAction = function DesktopHamburgerAction(_ref3) {
|
|
57
|
+
var props = _extends({}, _ref3);
|
|
119
58
|
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
return /*#__PURE__*/_react["default"].createElement(ActionsContainer, _extends({
|
|
130
|
-
direction: direction
|
|
131
|
-
}, rest), _.map(actions, function (action) {
|
|
132
|
-
return /*#__PURE__*/_react["default"].createElement(ActionButtonItem, {
|
|
133
|
-
action: action,
|
|
134
|
-
direction: direction,
|
|
135
|
-
key: action.key
|
|
136
|
-
});
|
|
137
|
-
}));
|
|
59
|
+
var actionProps = getActionProps('hamburger');
|
|
60
|
+
return /*#__PURE__*/_react["default"].createElement(_actionButtonItem["default"], _extends({
|
|
61
|
+
actions: actionProps,
|
|
62
|
+
direction: _actionItemTypes.DIRECTION_TYPE.column,
|
|
63
|
+
textType: _actionItemTypes.TEXT_TYPE.full,
|
|
64
|
+
buttonWidth: _actionItemTypes.BUTTON_WIDTH_TYPE.stretch,
|
|
65
|
+
buttonSize: _actionItemTypes.BUTTON_SIZE_TYPE.L
|
|
66
|
+
}, props));
|
|
138
67
|
};
|
|
139
68
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
69
|
+
exports.DesktopHamburgerAction = DesktopHamburgerAction;
|
|
70
|
+
|
|
71
|
+
var MobileHamburgerAction = function MobileHamburgerAction(_ref4) {
|
|
72
|
+
var props = _extends({}, _ref4);
|
|
73
|
+
|
|
74
|
+
var actionProps = getActionProps('hamburger');
|
|
75
|
+
return /*#__PURE__*/_react["default"].createElement(_actionButtonItem["default"], _extends({
|
|
76
|
+
actions: actionProps,
|
|
77
|
+
textType: _actionItemTypes.TEXT_TYPE.full,
|
|
78
|
+
buttonWidth: _actionItemTypes.BUTTON_WIDTH_TYPE.stretch,
|
|
79
|
+
buttonSize: _actionItemTypes.BUTTON_SIZE_TYPE.L
|
|
80
|
+
}, props));
|
|
144
81
|
};
|
|
145
|
-
|
|
146
|
-
exports
|
|
82
|
+
|
|
83
|
+
exports.MobileHamburgerAction = MobileHamburgerAction;
|