@twreporter/react-components 8.17.0-rc.0 → 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 +304 -793
- package/lib/badge/index.js +10 -5
- 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 +23 -11
- package/lib/button/components/toggleButton.js +11 -10
- package/lib/button/constants/index.js +16 -0
- 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 +55 -20
- package/lib/button/utils/size.js +2 -2
- package/lib/button/utils/theme.js +158 -55
- 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 +20 -7
- 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/simple-header/index.js +6 -1
- 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
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.article = exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
+
|
|
12
|
+
var _articleCard = _interopRequireDefault(require("../components/article-card"));
|
|
13
|
+
|
|
14
|
+
var _constants = require("../../storybook/constants");
|
|
15
|
+
|
|
16
|
+
var _releaseBranch = require("@twreporter/core/lib/constants/release-branch");
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
+
|
|
20
|
+
var _default = {
|
|
21
|
+
title: 'Card/Article',
|
|
22
|
+
component: _articleCard["default"],
|
|
23
|
+
argTypes: {
|
|
24
|
+
releaseBranch: _constants.BRANCH_STORYBOOK_ARG_TYPE,
|
|
25
|
+
size: _constants.SIZE_STORYBOOK_ARG_TYPE
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports["default"] = _default;
|
|
29
|
+
|
|
30
|
+
var Container = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
31
|
+
displayName: "articleCardstories__Container",
|
|
32
|
+
componentId: "q36nxb-0"
|
|
33
|
+
})(["width:", "px;"], function (props) {
|
|
34
|
+
return props.size === _articleCard["default"].Size.S ? '343' : '878';
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
var article = function article(args) {
|
|
38
|
+
return /*#__PURE__*/_react["default"].createElement(Container, {
|
|
39
|
+
size: args.size
|
|
40
|
+
}, /*#__PURE__*/_react["default"].createElement(_articleCard["default"], args));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
exports.article = article;
|
|
44
|
+
article.args = {
|
|
45
|
+
size: _articleCard["default"].Size.L,
|
|
46
|
+
title: '文章標題文章標題文章標題文章標題文章標題文章標題文章標題文章標題',
|
|
47
|
+
description: '文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述文章描述',
|
|
48
|
+
category: '主分類',
|
|
49
|
+
date: '2022/01/01',
|
|
50
|
+
image: {
|
|
51
|
+
src: 'https://upload.wikimedia.org/wikipedia/commons/thumb/7/77/Google_Images_2015_logo.svg/220px-Google_Images_2015_logo.svg.png',
|
|
52
|
+
alt: 'test'
|
|
53
|
+
},
|
|
54
|
+
releaseBranch: _releaseBranch.BRANCH.master
|
|
55
|
+
};
|
|
@@ -11,11 +11,16 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
|
11
11
|
|
|
12
12
|
var _dialog = _interopRequireDefault(require("../components/dialog"));
|
|
13
13
|
|
|
14
|
+
var _constants = require("../../storybook/constants");
|
|
15
|
+
|
|
14
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
17
|
|
|
16
18
|
var _default = {
|
|
17
19
|
title: 'Card/Dialog',
|
|
18
|
-
component: _dialog["default"]
|
|
20
|
+
component: _dialog["default"],
|
|
21
|
+
argTypes: {
|
|
22
|
+
size: _constants.SIZE_STORYBOOK_ARG_TYPE
|
|
23
|
+
}
|
|
19
24
|
};
|
|
20
25
|
exports["default"] = _default;
|
|
21
26
|
var StyledDialog = /*#__PURE__*/(0, _styledComponents["default"])(_dialog["default"]).withConfig({
|
|
@@ -30,7 +35,7 @@ var dialog = function dialog(args) {
|
|
|
30
35
|
exports.dialog = dialog;
|
|
31
36
|
dialog.args = {
|
|
32
37
|
text: '登出',
|
|
33
|
-
size:
|
|
38
|
+
size: _dialog["default"].Size.S
|
|
34
39
|
};
|
|
35
40
|
dialog.parameters = {
|
|
36
41
|
backgrounds: {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.checkbox = exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _ = _interopRequireDefault(require("."));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
|
|
14
|
+
var _default = {
|
|
15
|
+
title: 'Checkbox',
|
|
16
|
+
component: _["default"],
|
|
17
|
+
argTypes: {
|
|
18
|
+
value: {
|
|
19
|
+
defaultValue: false,
|
|
20
|
+
options: [true, false]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports["default"] = _default;
|
|
25
|
+
|
|
26
|
+
var Template = function Template(args) {
|
|
27
|
+
return /*#__PURE__*/_react["default"].createElement(_["default"], args);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var checkbox = Template.bind({});
|
|
31
|
+
exports.checkbox = checkbox;
|
|
32
|
+
checkbox.args = {
|
|
33
|
+
label: '藝術',
|
|
34
|
+
value: false,
|
|
35
|
+
disabled: false,
|
|
36
|
+
onChange: function onChange(e) {
|
|
37
|
+
console.log('callback', e.target.checked);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.Checkbox = 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 _paragraph = require("../text/paragraph");
|
|
15
|
+
|
|
16
|
+
var _color = require("@twreporter/core/lib/constants/color");
|
|
17
|
+
|
|
18
|
+
var _excluded = ["value", "label", "disabled", "onChange"];
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
+
|
|
22
|
+
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; }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
var disableColor = _color.colorGrayscale.gray400;
|
|
27
|
+
var activeColor = _color.colorGrayscale.gray800;
|
|
28
|
+
|
|
29
|
+
var Container = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
30
|
+
displayName: "checkbox__Container",
|
|
31
|
+
componentId: "vzoxib-0"
|
|
32
|
+
})(["display:flex;flex-direction:'row';"]);
|
|
33
|
+
|
|
34
|
+
var Input = /*#__PURE__*/_styledComponents["default"].input.withConfig({
|
|
35
|
+
displayName: "checkbox__Input",
|
|
36
|
+
componentId: "vzoxib-1"
|
|
37
|
+
})(["width:0;height:0;opacity:0;z-index:-1;"]);
|
|
38
|
+
|
|
39
|
+
var Label = /*#__PURE__*/_styledComponents["default"].label.withConfig({
|
|
40
|
+
displayName: "checkbox__Label",
|
|
41
|
+
componentId: "vzoxib-2"
|
|
42
|
+
})(["display:block;position:relative;padding-left:25px;"]);
|
|
43
|
+
|
|
44
|
+
var Indicator = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
45
|
+
displayName: "checkbox__Indicator",
|
|
46
|
+
componentId: "vzoxib-3"
|
|
47
|
+
})(["width:16px;height:16px;background:", ";position:absolute;top:0px;left:0px;border-color:", ";border-radius:2px;box-shadow:0 0 0 1px ", ";margin:3px 8px 0px 0px;&::after{content:'';position:absolute;display:none;}", ":checked + &::after{display:block;left:5px;top:0px;width:4px;height:10px;border:solid white;border-width:0 2px 2px 0;-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);transform:rotate(45deg);}"], function (props) {
|
|
48
|
+
return props.value ? props.disabled ? disableColor : activeColor : 'rgba(0, 0, 0, 0)';
|
|
49
|
+
}, function (props) {
|
|
50
|
+
return props.disabled ? disableColor : activeColor;
|
|
51
|
+
}, function (props) {
|
|
52
|
+
return props.disabled ? disableColor : activeColor;
|
|
53
|
+
}, Input);
|
|
54
|
+
|
|
55
|
+
var ColorP1 = /*#__PURE__*/(0, _styledComponents["default"])(_paragraph.P1).withConfig({
|
|
56
|
+
displayName: "checkbox__ColorP1",
|
|
57
|
+
componentId: "vzoxib-4"
|
|
58
|
+
})(["color:", ";"], function (props) {
|
|
59
|
+
return props.disabled ? disableColor : activeColor;
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
var Checkbox = function Checkbox(_ref) {
|
|
63
|
+
var _ref$value = _ref.value,
|
|
64
|
+
value = _ref$value === void 0 ? false : _ref$value,
|
|
65
|
+
_ref$label = _ref.label,
|
|
66
|
+
label = _ref$label === void 0 ? '' : _ref$label,
|
|
67
|
+
_ref$disabled = _ref.disabled,
|
|
68
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
69
|
+
_ref$onChange = _ref.onChange,
|
|
70
|
+
onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
|
|
71
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
72
|
+
|
|
73
|
+
var handleChange = function handleChange(e) {
|
|
74
|
+
onChange && onChange(e);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return /*#__PURE__*/_react["default"].createElement(Container, props, /*#__PURE__*/_react["default"].createElement(Label, null, label && /*#__PURE__*/_react["default"].createElement(ColorP1, {
|
|
78
|
+
text: label,
|
|
79
|
+
disabled: disabled
|
|
80
|
+
}), /*#__PURE__*/_react["default"].createElement(Input, {
|
|
81
|
+
type: "checkbox",
|
|
82
|
+
checked: value,
|
|
83
|
+
disabled: disabled,
|
|
84
|
+
onChange: handleChange
|
|
85
|
+
}), /*#__PURE__*/_react["default"].createElement(Indicator, {
|
|
86
|
+
value: value,
|
|
87
|
+
disabled: disabled
|
|
88
|
+
})));
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
exports.Checkbox = Checkbox;
|
|
92
|
+
Checkbox.propTypes = {
|
|
93
|
+
value: _propTypes["default"].bool.isRequired,
|
|
94
|
+
label: _propTypes["default"].string,
|
|
95
|
+
disabled: _propTypes["default"].bool,
|
|
96
|
+
onChange: _propTypes["default"].func.isRequired
|
|
97
|
+
};
|
|
98
|
+
var _default = Checkbox;
|
|
99
|
+
exports["default"] = _default;
|
package/lib/divider.js
CHANGED
|
@@ -25,6 +25,11 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
25
25
|
|
|
26
26
|
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; }
|
|
27
27
|
|
|
28
|
+
// direction enum
|
|
29
|
+
var Direction = {
|
|
30
|
+
HORIZONTAL: 'horizontal',
|
|
31
|
+
VERTICAL: 'vertical'
|
|
32
|
+
};
|
|
28
33
|
var borderWidth = {
|
|
29
34
|
vertical: [0, '1px', 0, 0],
|
|
30
35
|
horizontal: ['1px', 0, 0, 0]
|
|
@@ -51,7 +56,7 @@ var DividerBox = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
|
|
51
56
|
|
|
52
57
|
var Divider = function Divider(_ref) {
|
|
53
58
|
var _ref$direction = _ref.direction,
|
|
54
|
-
direction = _ref$direction === void 0 ?
|
|
59
|
+
direction = _ref$direction === void 0 ? Direction.HORIZONTAL : _ref$direction,
|
|
55
60
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
56
61
|
|
|
57
62
|
return /*#__PURE__*/_react["default"].createElement(DividerBox, _extends({
|
|
@@ -60,7 +65,8 @@ var Divider = function Divider(_ref) {
|
|
|
60
65
|
};
|
|
61
66
|
|
|
62
67
|
Divider.propTypes = {
|
|
63
|
-
direction: _propTypes["default"].oneOf(
|
|
68
|
+
direction: _propTypes["default"].oneOf(Object.values(Direction))
|
|
64
69
|
};
|
|
70
|
+
Divider.Direction = Direction;
|
|
65
71
|
var _default = Divider;
|
|
66
72
|
exports["default"] = _default;
|
package/lib/divider.stories.js
CHANGED
|
@@ -46,12 +46,12 @@ var divider = function divider(args) {
|
|
|
46
46
|
|
|
47
47
|
exports.divider = divider;
|
|
48
48
|
divider.args = {
|
|
49
|
-
direction:
|
|
49
|
+
direction: _divider["default"].Direction.HORIZONTAL
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
var horizontal = function horizontal() {
|
|
53
53
|
return /*#__PURE__*/_react["default"].createElement(_divider["default"], {
|
|
54
|
-
direction: "
|
|
54
|
+
direction: _divider["default"].Direction.HORIZONTAL
|
|
55
55
|
});
|
|
56
56
|
};
|
|
57
57
|
|
|
@@ -64,7 +64,7 @@ horizontal.parameters = {
|
|
|
64
64
|
|
|
65
65
|
var vertical = function vertical() {
|
|
66
66
|
return /*#__PURE__*/_react["default"].createElement(VerticalContainer, null, /*#__PURE__*/_react["default"].createElement(_divider["default"], {
|
|
67
|
-
direction: "
|
|
67
|
+
direction: _divider["default"].Direction.VERTICAL
|
|
68
68
|
}));
|
|
69
69
|
};
|
|
70
70
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MediaType = exports.BookmarkType = exports.ArrowDirection = exports.IconType = void 0;
|
|
7
|
+
var IconType = Object.freeze({
|
|
8
|
+
MASK: 'mask',
|
|
9
|
+
RAW: 'raw'
|
|
10
|
+
});
|
|
11
|
+
exports.IconType = IconType;
|
|
12
|
+
var ArrowDirection = Object.freeze({
|
|
13
|
+
RIGHT: 'right',
|
|
14
|
+
LEFT: 'left',
|
|
15
|
+
UP: 'up',
|
|
16
|
+
DOWN: 'down'
|
|
17
|
+
});
|
|
18
|
+
exports.ArrowDirection = ArrowDirection;
|
|
19
|
+
var BookmarkType = Object.freeze({
|
|
20
|
+
BASIC: 'basic',
|
|
21
|
+
ADD: 'add',
|
|
22
|
+
SAVED: 'saved'
|
|
23
|
+
});
|
|
24
|
+
exports.BookmarkType = BookmarkType;
|
|
25
|
+
var MediaType = Object.freeze({
|
|
26
|
+
FACEBOOK: 'facebook',
|
|
27
|
+
INSTAGRAM: 'instagram',
|
|
28
|
+
MEDIUM: 'medium',
|
|
29
|
+
TWITTER: 'twitter',
|
|
30
|
+
YOUTUBE: 'youtube',
|
|
31
|
+
LINE: 'line',
|
|
32
|
+
GOOGLE: 'google'
|
|
33
|
+
});
|
|
34
|
+
exports.MediaType = MediaType;
|