@twreporter/react-components 8.17.0-rc.1 → 8.17.0-rc.10
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 +291 -788
- package/lib/button/components/iconButton.js +7 -5
- package/lib/button/components/iconWithTextButton.js +7 -6
- package/lib/button/components/link.js +84 -0
- package/lib/button/components/pillButton.js +35 -17
- package/lib/button/components/textButton.js +17 -14
- package/lib/button/constants/index.js +2 -15
- package/lib/button/enums/index.js +22 -0
- package/lib/button/index.js +10 -1
- package/lib/button/stories/iconButton.stories.js +10 -8
- package/lib/button/stories/iconWithTextButton.stories.js +4 -4
- package/lib/button/stories/link.stories.js +81 -0
- package/lib/button/stories/pillButton.stories.js +51 -20
- package/lib/button/stories/textButton.stories.js +52 -23
- package/lib/button/utils/size.js +2 -2
- package/lib/button/utils/theme.js +85 -43
- package/lib/card/components/article-card.js +192 -0
- package/lib/card/components/dialog.js +6 -3
- package/lib/card/index.js +10 -1
- package/lib/card/stories/articleCard.stories.js +55 -0
- package/lib/card/stories/dialog.stories.js +7 -2
- package/lib/checkbox/checkbox.stories.js +39 -0
- package/lib/checkbox/index.js +99 -0
- package/lib/divider.js +8 -2
- package/lib/divider.stories.js +3 -3
- package/lib/icon/enum/index.js +34 -0
- package/lib/icon/index.js +99 -222
- package/lib/icon/stories/arrow.stories.js +7 -7
- package/lib/icon/stories/article.stories.js +2 -2
- package/lib/icon/stories/bookmark.stories.js +6 -6
- package/lib/icon/stories/clock.stories.js +2 -2
- package/lib/icon/stories/copy.stories.js +2 -2
- package/lib/icon/stories/cross.stories.js +2 -2
- package/lib/icon/stories/hamburger.stories.js +2 -2
- package/lib/icon/stories/home.stories.js +2 -2
- package/lib/icon/stories/letter.stories.js +29 -0
- package/lib/icon/stories/loading.stories.js +2 -2
- package/lib/icon/stories/member.stories.js +2 -2
- package/lib/icon/stories/printer.stories.js +2 -2
- package/lib/icon/stories/search.stories.js +2 -2
- package/lib/icon/stories/share.stories.js +2 -2
- package/lib/icon/stories/socialMedia.stories.js +7 -25
- package/lib/icon/stories/text.stories.js +2 -2
- package/lib/icon/stories/topic.stories.js +2 -2
- package/lib/image-with-fallback.js +141 -0
- package/lib/input/components/search-bar.js +6 -4
- package/lib/input/enums/index.js +11 -0
- package/lib/input/stories/search-bar.stories.js +8 -7
- package/lib/input/utils/theme.js +5 -3
- package/lib/listing-page/components/card-list.js +165 -0
- package/lib/listing-page/components/image.js +3 -0
- package/lib/listing-page/components/list.js +13 -8
- package/lib/listing-page/constants/prop-types.js +25 -0
- package/lib/listing-page/index.js +10 -1
- package/lib/listing-page/stories/cardList.stories.js +83 -0
- package/lib/logo/components/logo-header.js +8 -2
- package/lib/logo/components/logo-loading-fallback.js +43 -0
- package/lib/logo/components/logo-symbol.js +9 -2
- package/lib/logo/index.js +10 -1
- package/lib/logo/stories/logoFooter.stories.js +2 -2
- package/lib/logo/stories/logoHeader.stories.js +3 -3
- package/lib/logo/stories/logoLoadingFallback.stories.js +29 -0
- package/lib/logo/stories/logoSymbol.stories.js +3 -3
- package/lib/logo/utils/path.js +5 -0
- package/lib/material-icon.js +53 -0
- package/lib/pagination/index.js +8 -5
- package/lib/shared-enum.js +11 -0
- package/lib/snack-bar/components/snack-bar.js +2 -1
- package/lib/snack-bar/stories/snackBar.stories.js +4 -4
- package/lib/storybook/constants/index.js +27 -0
- package/lib/storybook/utils/get-enum-arg.js +18 -0
- package/lib/text/constants/headline-type.js +5 -24
- package/lib/text/enums/index.js +17 -0
- package/lib/text/headline.js +5 -2
- package/lib/text/paragraph.js +9 -6
- package/lib/text/stories/headline.stories.js +5 -3
- package/lib/text/stories/paragraph.stories.js +5 -3
- package/lib/title-bar/components/bar.js +2 -2
- package/lib/title-bar/components/tab.js +2 -2
- package/package.json +5 -4
- package/lib/button/constants/size.js +0 -28
- package/lib/button/constants/type.js +0 -28
- package/lib/input/constants/type.js +0 -20
- package/lib/text/constants/font-weight.js +0 -29
- package/lib/text/link.js +0 -87
- package/lib/text/stories/link.stories.js +0 -42
|
@@ -13,7 +13,7 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
13
13
|
|
|
14
14
|
var _theme = require("../utils/theme");
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _enums = require("../enums");
|
|
17
17
|
|
|
18
18
|
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
19
19
|
|
|
@@ -47,14 +47,14 @@ var IconButton = function IconButton(_ref) {
|
|
|
47
47
|
_ref$theme = _ref.theme,
|
|
48
48
|
theme = _ref$theme === void 0 ? _theme2.THEME.normal : _ref$theme,
|
|
49
49
|
_ref$type = _ref.type,
|
|
50
|
-
type = _ref$type === void 0 ?
|
|
50
|
+
type = _ref$type === void 0 ? _enums.Type.PRIMARY : _ref$type,
|
|
51
51
|
_ref$disabled = _ref.disabled,
|
|
52
52
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
53
53
|
_ref$active = _ref.active,
|
|
54
54
|
active = _ref$active === void 0 ? false : _ref$active,
|
|
55
55
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
56
56
|
|
|
57
|
-
var themeFunc = type ===
|
|
57
|
+
var themeFunc = type === _enums.Type.PRIMARY ? _theme.getPrimaryIconButtonTheme : _theme.getSecondaryIconButtonTheme;
|
|
58
58
|
|
|
59
59
|
var _themeFunc = themeFunc(theme, active, disabled),
|
|
60
60
|
color = _themeFunc.color,
|
|
@@ -68,10 +68,12 @@ var IconButton = function IconButton(_ref) {
|
|
|
68
68
|
|
|
69
69
|
IconButton.propTypes = {
|
|
70
70
|
iconComponent: _propTypes["default"].element.isRequired,
|
|
71
|
-
theme: _theme2.
|
|
72
|
-
type:
|
|
71
|
+
theme: _propTypes["default"].oneOf(Object.values(_theme2.THEME)),
|
|
72
|
+
type: _propTypes["default"].oneOf(Object.values(_enums.Type)),
|
|
73
73
|
disabled: _propTypes["default"].bool,
|
|
74
74
|
active: _propTypes["default"].bool
|
|
75
75
|
};
|
|
76
|
+
IconButton.THEME = _theme2.THEME;
|
|
77
|
+
IconButton.Type = _enums.Type;
|
|
76
78
|
var _default = IconButton;
|
|
77
79
|
exports["default"] = _default;
|
|
@@ -38,10 +38,10 @@ var ButtonContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
38
38
|
return props.hoverColor;
|
|
39
39
|
}));
|
|
40
40
|
|
|
41
|
-
var
|
|
42
|
-
displayName: "
|
|
41
|
+
var StyledP3 = /*#__PURE__*/(0, _styledComponents["default"])(_paragraph.P3).withConfig({
|
|
42
|
+
displayName: "iconWithTextButton__StyledP3",
|
|
43
43
|
componentId: "sc-1f9d1q4-1"
|
|
44
|
-
})(["max-height:", ";opacity:", ";transition:opacity 100ms;"], function (props) {
|
|
44
|
+
})(["margin-top:2px;max-height:", ";opacity:", ";transition:opacity 100ms;"], function (props) {
|
|
45
45
|
return props.hideText ? '0px' : 'none';
|
|
46
46
|
}, function (props) {
|
|
47
47
|
return props.hideText ? '0' : '1';
|
|
@@ -67,9 +67,9 @@ var IconWithTextButton = function IconWithTextButton(_ref) {
|
|
|
67
67
|
return /*#__PURE__*/_react["default"].createElement(ButtonContainer, {
|
|
68
68
|
color: color,
|
|
69
69
|
hoverColor: hoverColor
|
|
70
|
-
}, iconComponent, /*#__PURE__*/_react["default"].createElement(
|
|
70
|
+
}, iconComponent, /*#__PURE__*/_react["default"].createElement(StyledP3, {
|
|
71
71
|
text: text,
|
|
72
|
-
weight:
|
|
72
|
+
weight: _paragraph.P3.Weight.NORMAL,
|
|
73
73
|
hideText: hideText
|
|
74
74
|
}));
|
|
75
75
|
};
|
|
@@ -77,10 +77,11 @@ var IconWithTextButton = function IconWithTextButton(_ref) {
|
|
|
77
77
|
IconWithTextButton.propTypes = {
|
|
78
78
|
text: _propTypes["default"].string,
|
|
79
79
|
iconComponent: _propTypes["default"].element.isRequired,
|
|
80
|
-
theme: _theme2.
|
|
80
|
+
theme: _propTypes["default"].oneOf(Object.values(_theme2.THEME)),
|
|
81
81
|
disabled: _propTypes["default"].bool,
|
|
82
82
|
active: _propTypes["default"].bool,
|
|
83
83
|
hideText: _propTypes["default"].bool
|
|
84
84
|
};
|
|
85
|
+
IconWithTextButton.THEME = _theme2.THEME;
|
|
85
86
|
var _default = IconWithTextButton;
|
|
86
87
|
exports["default"] = _default;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _customizedLink = _interopRequireDefault(require("../../customized-link"));
|
|
15
|
+
|
|
16
|
+
var _paragraph = require("../../text/paragraph");
|
|
17
|
+
|
|
18
|
+
var _enums = require("../enums");
|
|
19
|
+
|
|
20
|
+
var _color2 = require("@twreporter/core/lib/constants/color");
|
|
21
|
+
|
|
22
|
+
var _excluded = ["type", "link", "text", "weight", "TextComponent"];
|
|
23
|
+
|
|
24
|
+
var _decoration, _color;
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
27
|
+
|
|
28
|
+
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); }
|
|
29
|
+
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
var style = {
|
|
37
|
+
decoration: (_decoration = {}, _defineProperty(_decoration, _enums.LinkType.DEFAULT, 'none'), _defineProperty(_decoration, _enums.LinkType.UNDERLINE, 'underline'), _decoration),
|
|
38
|
+
color: (_color = {}, _defineProperty(_color, _enums.LinkType.DEFAULT, _color2.COLOR_SEMANTIC.info), _defineProperty(_color, _enums.LinkType.UNDERLINE, _color2.colorGrayscale.gray600), _color)
|
|
39
|
+
};
|
|
40
|
+
var LinkContainer = /*#__PURE__*/(0, _styledComponents["default"])(_customizedLink["default"]).withConfig({
|
|
41
|
+
displayName: "link__LinkContainer",
|
|
42
|
+
componentId: "g5z7t5-0"
|
|
43
|
+
})(["display:flex;align-items:center;text-underline-offset:4px;text-decoration-line:", ";color:", ";&:hover{text-decoration-line:underline;}"], function (props) {
|
|
44
|
+
return style.decoration[props.type];
|
|
45
|
+
}, function (props) {
|
|
46
|
+
return style.color[props.type];
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
var LinkButton = function LinkButton(_ref) {
|
|
50
|
+
var _ref$type = _ref.type,
|
|
51
|
+
type = _ref$type === void 0 ? _enums.LinkType.DEFAULT : _ref$type,
|
|
52
|
+
_ref$link = _ref.link,
|
|
53
|
+
link = _ref$link === void 0 ? {} : _ref$link,
|
|
54
|
+
_ref$text = _ref.text,
|
|
55
|
+
text = _ref$text === void 0 ? '' : _ref$text,
|
|
56
|
+
_ref$weight = _ref.weight,
|
|
57
|
+
weight = _ref$weight === void 0 ? _paragraph.P1.Weight.NORMAL : _ref$weight,
|
|
58
|
+
_ref$TextComponent = _ref.TextComponent,
|
|
59
|
+
TextComponent = _ref$TextComponent === void 0 ? null : _ref$TextComponent,
|
|
60
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
61
|
+
|
|
62
|
+
var textJSX = TextComponent ? /*#__PURE__*/_react["default"].createElement(TextComponent, {
|
|
63
|
+
text: text,
|
|
64
|
+
weight: weight
|
|
65
|
+
}) : /*#__PURE__*/_react["default"].createElement(_paragraph.P1, {
|
|
66
|
+
text: text,
|
|
67
|
+
weight: weight
|
|
68
|
+
});
|
|
69
|
+
return /*#__PURE__*/_react["default"].createElement(LinkContainer, _extends({
|
|
70
|
+
type: type
|
|
71
|
+
}, link, props), textJSX);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
LinkButton.propTypes = {
|
|
75
|
+
type: _propTypes["default"].oneOf(Object.values(_enums.LinkType)),
|
|
76
|
+
link: _propTypes["default"].object,
|
|
77
|
+
text: _propTypes["default"].string.isRequired,
|
|
78
|
+
weight: _paragraph.P1.propTypes.weight,
|
|
79
|
+
TextComponent: _propTypes["default"].elementType
|
|
80
|
+
};
|
|
81
|
+
LinkButton.Type = _enums.LinkType;
|
|
82
|
+
LinkButton.Weight = _paragraph.P1.Weight;
|
|
83
|
+
var _default = LinkButton;
|
|
84
|
+
exports["default"] = _default;
|
|
@@ -17,13 +17,13 @@ var _theme = require("../utils/theme");
|
|
|
17
17
|
|
|
18
18
|
var _size = require("../utils/size");
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _enums = require("../enums");
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var _sharedEnum = require("../../shared-enum");
|
|
23
23
|
|
|
24
24
|
var _theme2 = require("@twreporter/core/lib/constants/theme");
|
|
25
25
|
|
|
26
|
-
var _excluded = ["text", "
|
|
26
|
+
var _excluded = ["text", "leftIconComponent", "rightIconComponent", "size", "theme", "type", "style", "disabled"];
|
|
27
27
|
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
29
29
|
|
|
@@ -36,8 +36,8 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
36
36
|
var ButtonContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
37
37
|
displayName: "pillButton__ButtonContainer",
|
|
38
38
|
componentId: "xa7tsy-0"
|
|
39
|
-
})(["width:fit-content;display:flex;align-items:center;border-radius:40px;background-color:", ";border-color:", ";border-style:solid;border-width:1.5px;color:", ";padding:", ";cursor:pointer;svg{
|
|
40
|
-
return props.type ===
|
|
39
|
+
})(["width:fit-content;display:flex;align-items:center;border-radius:40px;background-color:", ";border-color:", ";border-style:solid;border-width:1.5px;color:", ";padding:", ";cursor:pointer;svg{height:", ";width:", ";background-color:", ";}&:hover{color:", ";background-color:", ";border-color:", ";svg{background-color:", ";}}"], function (props) {
|
|
40
|
+
return props.type === _enums.Type.PRIMARY ? props.bgColor : 'transparent';
|
|
41
41
|
}, function (props) {
|
|
42
42
|
return props.bgColor;
|
|
43
43
|
}, function (props) {
|
|
@@ -53,30 +53,40 @@ var ButtonContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
53
53
|
}, function (props) {
|
|
54
54
|
return props.hoverColor;
|
|
55
55
|
}, function (props) {
|
|
56
|
-
return props.type ===
|
|
56
|
+
return props.type === _enums.Type.PRIMARY ? props.hoverBgColor : 'transparent';
|
|
57
57
|
}, function (props) {
|
|
58
58
|
return props.hoverBgColor;
|
|
59
59
|
}, function (props) {
|
|
60
60
|
return props.hoverColor;
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
var IconContainer = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
64
|
+
displayName: "pillButton__IconContainer",
|
|
65
|
+
componentId: "xa7tsy-1"
|
|
66
|
+
})(["display:flex;align-items:center;&:first-child{margin-right:4px;}&:last-child{margin-left:4px;}"]);
|
|
67
|
+
|
|
63
68
|
var PillButton = function PillButton(_ref) {
|
|
64
69
|
var _ref$text = _ref.text,
|
|
65
70
|
text = _ref$text === void 0 ? '' : _ref$text,
|
|
66
|
-
|
|
71
|
+
_ref$leftIconComponen = _ref.leftIconComponent,
|
|
72
|
+
leftIconComponent = _ref$leftIconComponen === void 0 ? null : _ref$leftIconComponen,
|
|
73
|
+
_ref$rightIconCompone = _ref.rightIconComponent,
|
|
74
|
+
rightIconComponent = _ref$rightIconCompone === void 0 ? null : _ref$rightIconCompone,
|
|
67
75
|
_ref$size = _ref.size,
|
|
68
|
-
size = _ref$size === void 0 ?
|
|
76
|
+
size = _ref$size === void 0 ? _sharedEnum.Size.S : _ref$size,
|
|
69
77
|
_ref$theme = _ref.theme,
|
|
70
78
|
theme = _ref$theme === void 0 ? _theme2.THEME.normal : _ref$theme,
|
|
71
79
|
_ref$type = _ref.type,
|
|
72
|
-
type = _ref$type === void 0 ?
|
|
80
|
+
type = _ref$type === void 0 ? _enums.Type.PRIMARY : _ref$type,
|
|
81
|
+
_ref$style = _ref.style,
|
|
82
|
+
style = _ref$style === void 0 ? _enums.Style.BRAND : _ref$style,
|
|
73
83
|
_ref$disabled = _ref.disabled,
|
|
74
84
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
75
85
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
76
86
|
|
|
77
|
-
var themeFunc = type ===
|
|
87
|
+
var themeFunc = type === _enums.Type.PRIMARY ? _theme.getFilledPillButtonTheme : _theme.getOutlinePillButtonTheme;
|
|
78
88
|
|
|
79
|
-
var _themeFunc = themeFunc(theme, disabled),
|
|
89
|
+
var _themeFunc = themeFunc(theme, disabled, style),
|
|
80
90
|
color = _themeFunc.color,
|
|
81
91
|
bgColor = _themeFunc.bgColor,
|
|
82
92
|
hoverColor = _themeFunc.hoverColor,
|
|
@@ -86,13 +96,15 @@ var PillButton = function PillButton(_ref) {
|
|
|
86
96
|
padding = _getSizeStyle.padding,
|
|
87
97
|
iconSize = _getSizeStyle.iconSize;
|
|
88
98
|
|
|
89
|
-
var textJSX = size ===
|
|
99
|
+
var textJSX = size === _sharedEnum.Size.S ? /*#__PURE__*/_react["default"].createElement(_paragraph.P2, {
|
|
90
100
|
text: text,
|
|
91
101
|
weight: "bold"
|
|
92
102
|
}) : /*#__PURE__*/_react["default"].createElement(_paragraph.P1, {
|
|
93
103
|
text: text,
|
|
94
104
|
weight: "bold"
|
|
95
105
|
});
|
|
106
|
+
var leftIconJSX = leftIconComponent ? /*#__PURE__*/_react["default"].createElement(IconContainer, null, leftIconComponent) : null;
|
|
107
|
+
var rightIconJSX = rightIconComponent ? /*#__PURE__*/_react["default"].createElement(IconContainer, null, rightIconComponent) : null;
|
|
96
108
|
return /*#__PURE__*/_react["default"].createElement(ButtonContainer, _extends({
|
|
97
109
|
type: type,
|
|
98
110
|
padding: padding,
|
|
@@ -101,16 +113,22 @@ var PillButton = function PillButton(_ref) {
|
|
|
101
113
|
iconSize: iconSize,
|
|
102
114
|
hoverColor: hoverColor,
|
|
103
115
|
hoverBgColor: hoverBgColor
|
|
104
|
-
}, props), textJSX,
|
|
116
|
+
}, props), leftIconJSX, textJSX, rightIconJSX);
|
|
105
117
|
};
|
|
106
118
|
|
|
107
119
|
PillButton.propTypes = {
|
|
108
|
-
|
|
120
|
+
leftIconComponent: _propTypes["default"].element,
|
|
121
|
+
rightIconComponent: _propTypes["default"].element,
|
|
109
122
|
text: _propTypes["default"].string,
|
|
110
|
-
size:
|
|
111
|
-
theme: _theme2.
|
|
112
|
-
type:
|
|
123
|
+
size: _propTypes["default"].oneOf(Object.values(_sharedEnum.Size)),
|
|
124
|
+
theme: _propTypes["default"].oneOf(Object.values(_theme2.THEME)),
|
|
125
|
+
type: _propTypes["default"].oneOf(Object.values(_enums.Type)),
|
|
126
|
+
style: _propTypes["default"].oneOf(Object.values(_enums.Style)),
|
|
113
127
|
disabled: _propTypes["default"].bool
|
|
114
128
|
};
|
|
129
|
+
PillButton.THEME = _theme2.THEME;
|
|
130
|
+
PillButton.Type = _enums.Type;
|
|
131
|
+
PillButton.Size = _sharedEnum.Size;
|
|
132
|
+
PillButton.Style = _enums.Style;
|
|
115
133
|
var _default = PillButton;
|
|
116
134
|
exports["default"] = _default;
|
|
@@ -17,14 +17,14 @@ var _size = require("../utils/size");
|
|
|
17
17
|
|
|
18
18
|
var _paragraph = require("../../text/paragraph");
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _enums = require("../enums");
|
|
21
21
|
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
var _type = require("../constants/type");
|
|
22
|
+
var _sharedEnum = require("../../shared-enum");
|
|
25
23
|
|
|
26
24
|
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
27
25
|
|
|
26
|
+
var _theme2 = require("@twreporter/core/lib/constants/theme");
|
|
27
|
+
|
|
28
28
|
var _excluded = ["text", "leftIconComponent", "rightIconComponent", "size", "theme", "type", "active", "disabled"];
|
|
29
29
|
|
|
30
30
|
var _templateObject;
|
|
@@ -71,11 +71,11 @@ var TextButton = function TextButton(_ref) {
|
|
|
71
71
|
_ref$rightIconCompone = _ref.rightIconComponent,
|
|
72
72
|
rightIconComponent = _ref$rightIconCompone === void 0 ? null : _ref$rightIconCompone,
|
|
73
73
|
_ref$size = _ref.size,
|
|
74
|
-
size = _ref$size === void 0 ?
|
|
74
|
+
size = _ref$size === void 0 ? _sharedEnum.Size.S : _ref$size,
|
|
75
75
|
_ref$theme = _ref.theme,
|
|
76
|
-
theme = _ref$theme === void 0 ?
|
|
76
|
+
theme = _ref$theme === void 0 ? _theme2.TEXT_BUTTON_THEME.normal : _ref$theme,
|
|
77
77
|
_ref$type = _ref.type,
|
|
78
|
-
type = _ref$type === void 0 ?
|
|
78
|
+
type = _ref$type === void 0 ? _enums.Type.PRIMARY : _ref$type,
|
|
79
79
|
_ref$active = _ref.active,
|
|
80
80
|
active = _ref$active === void 0 ? false : _ref$active,
|
|
81
81
|
_ref$disabled = _ref.disabled,
|
|
@@ -89,7 +89,7 @@ var TextButton = function TextButton(_ref) {
|
|
|
89
89
|
} else if (active) {
|
|
90
90
|
themeFunc = _theme.getActiveTextButtonTheme;
|
|
91
91
|
} else {
|
|
92
|
-
themeFunc = type ===
|
|
92
|
+
themeFunc = type === _enums.Type.PRIMARY ? _theme.getPrimaryTextButtonTheme : _theme.getSecondaryTextButtonTheme;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
var _themeFunc = themeFunc(theme, active),
|
|
@@ -99,7 +99,7 @@ var TextButton = function TextButton(_ref) {
|
|
|
99
99
|
var _getSizeStyle = (0, _size.getSizeStyle)(size),
|
|
100
100
|
iconSize = _getSizeStyle.iconSize;
|
|
101
101
|
|
|
102
|
-
var textJSX = size ===
|
|
102
|
+
var textJSX = size === _sharedEnum.Size.S ? /*#__PURE__*/_react["default"].createElement(_paragraph.P2, {
|
|
103
103
|
text: text,
|
|
104
104
|
weight: "bold"
|
|
105
105
|
}) : /*#__PURE__*/_react["default"].createElement(_paragraph.P1, {
|
|
@@ -110,20 +110,23 @@ var TextButton = function TextButton(_ref) {
|
|
|
110
110
|
color: color,
|
|
111
111
|
hoverColor: hoverColor,
|
|
112
112
|
iconSize: iconSize
|
|
113
|
-
}, props), size ===
|
|
113
|
+
}, props), size === _sharedEnum.Size.L ? /*#__PURE__*/_react["default"].createElement(IconContainer, {
|
|
114
114
|
isLeft: true
|
|
115
|
-
}, leftIconComponent) : leftIconComponent, textJSX, size ===
|
|
115
|
+
}, leftIconComponent) : leftIconComponent, textJSX, size === _sharedEnum.Size.L ? /*#__PURE__*/_react["default"].createElement(IconContainer, null, rightIconComponent) : rightIconComponent);
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
TextButton.propTypes = {
|
|
119
119
|
leftIconComponent: _propTypes["default"].element,
|
|
120
120
|
rightIconComponent: _propTypes["default"].element,
|
|
121
121
|
text: _propTypes["default"].string,
|
|
122
|
-
size:
|
|
123
|
-
theme:
|
|
124
|
-
type:
|
|
122
|
+
size: _propTypes["default"].oneOf(Object.values(_sharedEnum.Size)),
|
|
123
|
+
theme: _propTypes["default"].oneOf(Object.values(_theme2.TEXT_BUTTON_THEME)),
|
|
124
|
+
type: _propTypes["default"].oneOf(Object.values(_enums.Type)),
|
|
125
125
|
active: _propTypes["default"].bool,
|
|
126
126
|
disabled: _propTypes["default"].bool
|
|
127
127
|
};
|
|
128
|
+
TextButton.THEME = _theme2.TEXT_BUTTON_THEME;
|
|
129
|
+
TextButton.Size = _sharedEnum.Size;
|
|
130
|
+
TextButton.Type = _enums.Type;
|
|
128
131
|
var _default = TextButton;
|
|
129
132
|
exports["default"] = _default;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.TEXT_BUTTON_THEME_PROP_TYPES =
|
|
6
|
+
exports.TEXT_BUTTON_THEME_PROP_TYPES = void 0;
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
@@ -11,19 +11,6 @@ var _theme = require("@twreporter/core/lib/constants/theme");
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
|
-
|
|
18
|
-
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; }
|
|
19
|
-
|
|
20
|
-
var TEXT_BUTTON_THEME = Object.freeze(_objectSpread(_objectSpread({}, _theme.THEME), {}, {
|
|
21
|
-
brand: 'brand',
|
|
22
|
-
dark: 'dark',
|
|
23
|
-
light: 'light'
|
|
24
|
-
}));
|
|
25
|
-
exports.TEXT_BUTTON_THEME = TEXT_BUTTON_THEME;
|
|
26
|
-
|
|
27
|
-
var TEXT_BUTTON_THEME_PROP_TYPES = _propTypes["default"].oneOf(Object.values(TEXT_BUTTON_THEME));
|
|
14
|
+
var TEXT_BUTTON_THEME_PROP_TYPES = _propTypes["default"].oneOf(Object.values(_theme.TEXT_BUTTON_THEME));
|
|
28
15
|
|
|
29
16
|
exports.TEXT_BUTTON_THEME_PROP_TYPES = TEXT_BUTTON_THEME_PROP_TYPES;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LinkType = exports.Type = exports.Style = void 0;
|
|
7
|
+
var Style = Object.freeze({
|
|
8
|
+
BRAND: 'brand',
|
|
9
|
+
DARK: 'dark',
|
|
10
|
+
LIGHT: 'light'
|
|
11
|
+
});
|
|
12
|
+
exports.Style = Style;
|
|
13
|
+
var Type = Object.freeze({
|
|
14
|
+
PRIMARY: 'primary',
|
|
15
|
+
SECONDARY: 'secondary'
|
|
16
|
+
});
|
|
17
|
+
exports.Type = Type;
|
|
18
|
+
var LinkType = Object.freeze({
|
|
19
|
+
DEFAULT: 'default',
|
|
20
|
+
UNDERLINE: 'underline'
|
|
21
|
+
});
|
|
22
|
+
exports.LinkType = LinkType;
|
package/lib/button/index.js
CHANGED
|
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "ToggleButton", {
|
|
|
33
33
|
return _toggleButton["default"];
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
+
Object.defineProperty(exports, "LinkButton", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _link["default"];
|
|
40
|
+
}
|
|
41
|
+
});
|
|
36
42
|
exports["default"] = void 0;
|
|
37
43
|
|
|
38
44
|
var _pillButton = _interopRequireDefault(require("./components/pillButton"));
|
|
@@ -45,6 +51,8 @@ var _textButton = _interopRequireDefault(require("./components/textButton"));
|
|
|
45
51
|
|
|
46
52
|
var _toggleButton = _interopRequireDefault(require("./components/toggleButton"));
|
|
47
53
|
|
|
54
|
+
var _link = _interopRequireDefault(require("./components/link"));
|
|
55
|
+
|
|
48
56
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
49
57
|
|
|
50
58
|
var _default = {
|
|
@@ -52,6 +60,7 @@ var _default = {
|
|
|
52
60
|
IconButton: _iconButton["default"],
|
|
53
61
|
IconWithTextButton: _iconWithTextButton["default"],
|
|
54
62
|
TextButton: _textButton["default"],
|
|
55
|
-
ToggleButton: _toggleButton["default"]
|
|
63
|
+
ToggleButton: _toggleButton["default"],
|
|
64
|
+
LinkButton: _link["default"]
|
|
56
65
|
};
|
|
57
66
|
exports["default"] = _default;
|
|
@@ -7,13 +7,15 @@ exports.shareButton = exports.iconButton = exports["default"] = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
|
+
var _getEnumArg = require("../../storybook/utils/get-enum-arg");
|
|
11
|
+
|
|
10
12
|
var _iconButton = _interopRequireDefault(require("../components/iconButton"));
|
|
11
13
|
|
|
12
14
|
var _icon = require("../../icon");
|
|
13
15
|
|
|
14
|
-
var
|
|
16
|
+
var _enums = require("../enums");
|
|
15
17
|
|
|
16
|
-
var
|
|
18
|
+
var _constants = require("../../storybook/constants");
|
|
17
19
|
|
|
18
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
21
|
|
|
@@ -21,8 +23,8 @@ var _default = {
|
|
|
21
23
|
title: 'Button/Icon Button',
|
|
22
24
|
component: _iconButton["default"],
|
|
23
25
|
argTypes: {
|
|
24
|
-
theme:
|
|
25
|
-
type:
|
|
26
|
+
theme: _constants.THEME_STORYBOOK_ARG_TYPE,
|
|
27
|
+
type: (0, _getEnumArg.getRadioArg)(_enums.Type, _enums.Type.PRIMARY)
|
|
26
28
|
}
|
|
27
29
|
};
|
|
28
30
|
exports["default"] = _default;
|
|
@@ -37,8 +39,8 @@ iconButton.args = {
|
|
|
37
39
|
iconComponent: /*#__PURE__*/_react["default"].createElement(_icon.Arrow, {
|
|
38
40
|
direction: "down"
|
|
39
41
|
}),
|
|
40
|
-
theme:
|
|
41
|
-
type:
|
|
42
|
+
theme: _iconButton["default"].THEME.normal,
|
|
43
|
+
type: _iconButton["default"].Type.PRIMARY,
|
|
42
44
|
disabled: false,
|
|
43
45
|
active: false
|
|
44
46
|
};
|
|
@@ -46,8 +48,8 @@ var shareButton = Template.bind({});
|
|
|
46
48
|
exports.shareButton = shareButton;
|
|
47
49
|
shareButton.args = {
|
|
48
50
|
iconComponent: /*#__PURE__*/_react["default"].createElement(_icon.Share, null),
|
|
49
|
-
theme:
|
|
50
|
-
type:
|
|
51
|
+
theme: _iconButton["default"].THEME.normal,
|
|
52
|
+
type: _iconButton["default"].Type.PRIMARY,
|
|
51
53
|
disabled: false,
|
|
52
54
|
active: false
|
|
53
55
|
};
|
|
@@ -11,7 +11,7 @@ var _iconWithTextButton = _interopRequireDefault(require("../components/iconWith
|
|
|
11
11
|
|
|
12
12
|
var _icon = require("../../icon");
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _constants = require("../../storybook/constants");
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
17
|
|
|
@@ -19,7 +19,7 @@ var _default = {
|
|
|
19
19
|
title: 'Button/Icon With Text Button',
|
|
20
20
|
component: _iconWithTextButton["default"],
|
|
21
21
|
argTypes: {
|
|
22
|
-
theme:
|
|
22
|
+
theme: _constants.THEME_STORYBOOK_ARG_TYPE
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
25
|
exports["default"] = _default;
|
|
@@ -35,7 +35,7 @@ iconWithTextButton.args = {
|
|
|
35
35
|
iconComponent: /*#__PURE__*/_react["default"].createElement(_icon.Arrow, {
|
|
36
36
|
direction: "down"
|
|
37
37
|
}),
|
|
38
|
-
theme:
|
|
38
|
+
theme: _iconWithTextButton["default"].THEME.normal,
|
|
39
39
|
disabled: false,
|
|
40
40
|
active: false,
|
|
41
41
|
hideText: false
|
|
@@ -45,7 +45,7 @@ exports.shareButton = shareButton;
|
|
|
45
45
|
shareButton.args = {
|
|
46
46
|
text: '分享',
|
|
47
47
|
iconComponent: /*#__PURE__*/_react["default"].createElement(_icon.Share, null),
|
|
48
|
-
theme:
|
|
48
|
+
theme: _iconWithTextButton["default"].THEME.normal,
|
|
49
49
|
disabled: false,
|
|
50
50
|
active: false,
|
|
51
51
|
hideText: false
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.changeTextComponent = exports.link = exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _getEnumArg = require("../../storybook/utils/get-enum-arg");
|
|
11
|
+
|
|
12
|
+
var _link = _interopRequireDefault(require("../components/link"));
|
|
13
|
+
|
|
14
|
+
var _paragraph = require("../../text/paragraph");
|
|
15
|
+
|
|
16
|
+
var _headline = require("../../text/headline");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
20
|
+
var _default = {
|
|
21
|
+
title: 'Button/Link',
|
|
22
|
+
component: _link["default"],
|
|
23
|
+
argTypes: {
|
|
24
|
+
type: (0, _getEnumArg.getRadioArg)(_link["default"].Type, _link["default"].Type.DEFAULT),
|
|
25
|
+
// textComponent is only for storybook showcase, not real props
|
|
26
|
+
textComponent: {
|
|
27
|
+
defaultValue: 'P2',
|
|
28
|
+
options: ['not assign', 'P2', 'H4'],
|
|
29
|
+
control: {
|
|
30
|
+
type: 'radio'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports["default"] = _default;
|
|
36
|
+
|
|
37
|
+
var Template = function Template(args) {
|
|
38
|
+
return /*#__PURE__*/_react["default"].createElement(_link["default"], args);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
var link = Template.bind({});
|
|
42
|
+
exports.link = link;
|
|
43
|
+
link.args = {
|
|
44
|
+
text: '文字',
|
|
45
|
+
type: _link["default"].Type.DEFAULT,
|
|
46
|
+
link: {
|
|
47
|
+
to: 'https://www.twreporter.org'
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
link.parameters = {
|
|
51
|
+
controls: {
|
|
52
|
+
exclude: ['textComponent']
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
var changeTextComponent = function changeTextComponent(args) {
|
|
57
|
+
if (args.textComponent === 'P2') {
|
|
58
|
+
args.TextComponent = _paragraph.P2;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (args.textComponent === 'H4') {
|
|
62
|
+
args.TextComponent = _headline.H4;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return /*#__PURE__*/_react["default"].createElement(_link["default"], args);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
exports.changeTextComponent = changeTextComponent;
|
|
69
|
+
changeTextComponent.args = {
|
|
70
|
+
text: '文字',
|
|
71
|
+
type: _link["default"].Type.DEFAULT,
|
|
72
|
+
textComponent: 'P2',
|
|
73
|
+
link: {
|
|
74
|
+
to: 'https://www.twreporter.org'
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
changeTextComponent.parameters = {
|
|
78
|
+
controls: {
|
|
79
|
+
exclude: ['TextComponent']
|
|
80
|
+
}
|
|
81
|
+
};
|