sag_components 1.0.628 → 1.0.630
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/.eslintrc.js +5 -1
- package/dist/Button.test.js +162 -0
- package/dist/LinkButton.test.js +150 -0
- package/dist/setupTests.js +3 -0
- package/dist/stories/CampaignTool/Card.stories.js +0 -1
- package/dist/stories/components/Button.js +163 -81
- package/dist/stories/components/Button.style.js +6 -3
- package/dist/stories/components/Datepicker.js +0 -4
- package/dist/stories/components/DropdownMulti.js +0 -2
- package/dist/stories/components/EventInfo.js +92 -0
- package/dist/stories/components/EventInfo.style.js +20 -0
- package/dist/stories/components/FilterButton.js +4 -10
- package/dist/stories/components/FilterButton.style.js +1 -1
- package/dist/stories/components/FilterPanel.js +27 -19
- package/dist/stories/components/LinkButton.js +161 -0
- package/dist/stories/components/LinkButton.style.js +14 -0
- package/dist/stories/components/MonthPopupPicker.js +0 -1
- package/dist/stories/components/PopupCharts.js +0 -1
- package/dist/stories/components/ReportTable.js +12 -2
- package/dist/stories/components/SagButton.js +0 -1
- package/dist/stories/components/Select.js +0 -1
- package/dist/stories/components/icons/BellIcon.js +3 -2
- package/dist/stories/components/icons/Duplicate.js +28 -0
- package/dist/stories/components/icons/ExitIcon.js +3 -2
- package/dist/stories/components/icons/EyeIcon.js +4 -3
- package/dist/stories/components/icons/FlyIcon.js +3 -2
- package/dist/stories/components/icons/MaintenanceIcon.js +3 -2
- package/jest.config.js +7 -0
- package/package.json +7 -1
- package/.history/.env_20231001120549 +0 -0
- package/.history/.env_20231001120613 +0 -1
- package/.history/.env_20231003143620 +0 -1
- package/.history/.eslintrc_20230928112617.js +0 -26
- package/.history/.eslintrc_20230928130534.js +0 -27
- package/.history/.eslintrc_20230928133400.js +0 -28
- package/.history/.eslintrc_20230928133404.js +0 -28
- package/.history/.eslintrc_20230928133416.js +0 -28
- package/.history/.eslintrc_20230928133419.js +0 -28
- package/.history/.eslintrc_20230928133432.js +0 -28
- package/.history/.eslintrc_20230928133439.js +0 -28
- package/.history/.eslintrc_20230928133458.js +0 -29
- package/.history/.eslintrc_20230928133500.js +0 -28
- package/.history/.eslintrc_20230928134009.js +0 -28
- package/.history/.eslintrc_20230928135318.js +0 -34
- package/.history/.eslintrc_20230928135321.js +0 -34
- package/.history/.eslintrc_20230928135323.js +0 -34
- package/.history/.eslintrc_20230928135332.js +0 -34
- package/.history/.eslintrc_20230928135333.js +0 -34
- package/.history/.eslintrc_20230928135352.js +0 -29
- package/.history/.eslintrc_20230928135353.js +0 -29
- package/.history/.eslintrc_20230928135355.js +0 -29
- package/.history/.eslintrc_20230928135408.js +0 -29
- package/.history/.eslintrc_20230928135538.js +0 -30
- package/.history/.eslintrc_20230928135539.js +0 -30
- package/.history/.eslintrc_20230928135543.js +0 -30
- package/.history/.gitignore_20230921093332 +0 -119
- package/.history/.gitignore_20230921111638 +0 -120
- package/.history/.gitignore_20230921111650 +0 -120
- package/.history/.gitignore_20230921111810 +0 -121
- package/.history/package-lock_20231114111138.json +0 -47810
- package/.history/package-lock_20231114111158.json +0 -47802
- package/.history/package_20231029152422.json +0 -82
- package/.history/package_20231029153420.json +0 -82
- package/.history/package_20231029154416.json +0 -82
- package/.history/package_20231030094127.json +0 -82
- package/.history/package_20231030114707.json +0 -82
- package/.history/package_20231030130704.json +0 -82
- package/.history/package_20231030132422.json +0 -82
- package/.history/package_20231030134051.json +0 -82
- package/.history/package_20231030142913.json +0 -82
- package/.history/package_20231030143556.json +0 -82
- package/.history/package_20231030144210.json +0 -82
- package/.history/package_20231101113942.json +0 -82
- package/.history/package_20231101114544.json +0 -82
- package/.history/package_20231101151518.json +0 -82
- package/.history/package_20231101154501.json +0 -82
- package/.history/package_20231101155811.json +0 -82
- package/.history/package_20231101160235.json +0 -82
- package/.history/package_20231101160406.json +0 -82
- package/.history/package_20231101161325.json +0 -82
- package/.history/package_20231101161333.json +0 -82
- package/.history/package_20231102123623.json +0 -82
- package/.history/package_20231102125741.json +0 -82
- package/.history/package_20231102130857.json +0 -82
- package/.history/package_20231102132227.json +0 -82
- package/.history/package_20231102142340.json +0 -82
- package/.history/package_20231102143256.json +0 -82
- package/.history/package_20231105153539.json +0 -82
- package/.history/package_20231105154332.json +0 -82
- package/.history/package_20231105171201.json +0 -82
- package/.history/package_20231106123849.json +0 -82
- package/.history/package_20231107170638.json +0 -82
- package/.history/package_20231109103647.json +0 -82
- package/.history/package_20231109103911.json +0 -82
- package/.history/package_20231109105426.json +0 -82
- package/.history/package_20231109132014.json +0 -82
- package/.history/package_20231109132115.json +0 -82
- package/.history/package_20231114100517.json +0 -82
- package/.history/package_20231114100859.json +0 -82
- package/.history/package_20231114101553.json +0 -82
- package/.history/package_20231114102545.json +0 -82
- package/.history/package_20231114111208.json +0 -83
- package/.history/package_20231114111515.json +0 -83
- package/.history/package_20231114112931.json +0 -83
- package/.history/package_20231114113014.json +0 -83
- package/.history/package_20231114113155.json +0 -83
- package/.history/package_20231114124318.json +0 -83
- package/.history/package_20231114125107.json +0 -83
- package/.history/package_20231114125510.json +0 -83
- package/.history/package_20231114132634.json +0 -83
- package/.history/package_20231116165815.json +0 -83
- package/.history/package_20231116165916.json +0 -83
- package/.history/package_20231119113637.json +0 -83
- package/.history/package_20231120100907.json +0 -83
- package/.history/package_20231121151523.json +0 -77
- package/.history/package_20231121155513.json +0 -77
- package/.history/package_20231121162434.json +0 -77
- package/.history/package_20231122100718.json +0 -77
- package/.history/package_20231128125149.json +0 -82
- package/.history/package_20231128125208.json +0 -82
package/.eslintrc.js
CHANGED
|
@@ -3,7 +3,7 @@ module.exports = {
|
|
|
3
3
|
browser: true,
|
|
4
4
|
es2021: true,
|
|
5
5
|
},
|
|
6
|
-
extends: 'airbnb',
|
|
6
|
+
extends: ['airbnb','eslint:recommended'],
|
|
7
7
|
overrides: [
|
|
8
8
|
{
|
|
9
9
|
env: {
|
|
@@ -17,6 +17,10 @@ module.exports = {
|
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
19
|
],
|
|
20
|
+
plugins: [
|
|
21
|
+
'react',
|
|
22
|
+
'jest',
|
|
23
|
+
],
|
|
20
24
|
parserOptions: {
|
|
21
25
|
ecmaVersion: 'latest',
|
|
22
26
|
sourceType: 'module',
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _Button = _interopRequireDefault(require("./stories/components/Button"));
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
9
|
+
/* eslint-disable import/no-unresolved */
|
|
10
|
+
/* eslint-disable no-undef */
|
|
11
|
+
|
|
12
|
+
test('Button Check text', () => {
|
|
13
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
14
|
+
text: "test",
|
|
15
|
+
type: "primary",
|
|
16
|
+
size: "small",
|
|
17
|
+
disabled: false,
|
|
18
|
+
leftIcon: "none",
|
|
19
|
+
rightIcon: "none"
|
|
20
|
+
}));
|
|
21
|
+
const buttonElement = _react2.screen.getByText(/test/i);
|
|
22
|
+
expect(buttonElement).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
test('Button Check type functionality: when "primary" type selected then background color must be specified as "rgb(146, 207, 23)" ', () => {
|
|
25
|
+
const {
|
|
26
|
+
container
|
|
27
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
28
|
+
text: "Button",
|
|
29
|
+
type: "primary",
|
|
30
|
+
size: "small",
|
|
31
|
+
disabled: false,
|
|
32
|
+
leftIcon: "none",
|
|
33
|
+
rightIcon: "none"
|
|
34
|
+
}));
|
|
35
|
+
const buttonElement = container.querySelector('.ButtonItem');
|
|
36
|
+
expect(buttonElement).toBeInTheDocument();
|
|
37
|
+
const computedStyles = getComputedStyle(buttonElement);
|
|
38
|
+
expect(computedStyles.getPropertyValue('background-color')).toBe('rgb(146, 207, 23)');
|
|
39
|
+
});
|
|
40
|
+
test('Button Check type functionality: when "secondary" type selected then background color must be specified as "rgb(232, 245, 235)" ', () => {
|
|
41
|
+
const {
|
|
42
|
+
container
|
|
43
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
44
|
+
text: "Button",
|
|
45
|
+
type: "secondary",
|
|
46
|
+
size: "small",
|
|
47
|
+
disabled: false,
|
|
48
|
+
leftIcon: "none",
|
|
49
|
+
rightIcon: "none"
|
|
50
|
+
}));
|
|
51
|
+
const buttonElement = container.querySelector('.ButtonItem');
|
|
52
|
+
expect(buttonElement).toBeInTheDocument();
|
|
53
|
+
const computedStyles = getComputedStyle(buttonElement);
|
|
54
|
+
expect(computedStyles.getPropertyValue('background-color')).toBe('rgb(232, 245, 235)');
|
|
55
|
+
});
|
|
56
|
+
test('Button Check disabled functionality: when disabled prop is true, button textColor should be "rgb(177, 177, 177)" ', () => {
|
|
57
|
+
const {
|
|
58
|
+
container
|
|
59
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
60
|
+
text: "Button",
|
|
61
|
+
type: "primary",
|
|
62
|
+
size: "small",
|
|
63
|
+
disabled: true,
|
|
64
|
+
leftIcon: "none",
|
|
65
|
+
rightIcon: "none"
|
|
66
|
+
}));
|
|
67
|
+
const buttonElement = container.querySelector('.ButtonItem');
|
|
68
|
+
expect(buttonElement).toBeInTheDocument();
|
|
69
|
+
const computedStyles = getComputedStyle(buttonElement);
|
|
70
|
+
expect(computedStyles.getPropertyValue('color')).toBe('rgb(177, 177, 177)');
|
|
71
|
+
});
|
|
72
|
+
test('Button Check leftIcon functionality: when "Filter" icons is specified as the leftIcon props, it should be rendered on the screen', () => {
|
|
73
|
+
const {
|
|
74
|
+
container
|
|
75
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
76
|
+
text: "Button",
|
|
77
|
+
type: "primary",
|
|
78
|
+
size: "small",
|
|
79
|
+
disabled: false,
|
|
80
|
+
leftIcon: "Filter",
|
|
81
|
+
rightIcon: "Exit"
|
|
82
|
+
}));
|
|
83
|
+
const elementFilter = container.querySelector('.FilterIcon');
|
|
84
|
+
expect(elementFilter).toBeInTheDocument();
|
|
85
|
+
});
|
|
86
|
+
test('Button Check rightIcon functionality: when "Exit" icons is specified as the rightIcon props, it should be rendered on the screen', () => {
|
|
87
|
+
const {
|
|
88
|
+
container
|
|
89
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
90
|
+
text: "Button",
|
|
91
|
+
type: "primary",
|
|
92
|
+
size: "small",
|
|
93
|
+
disabled: false,
|
|
94
|
+
leftIcon: "Filter",
|
|
95
|
+
rightIcon: "Exit"
|
|
96
|
+
}));
|
|
97
|
+
const elementExit = container.querySelector('.ExitIcon');
|
|
98
|
+
expect(elementExit).toBeInTheDocument();
|
|
99
|
+
});
|
|
100
|
+
test('Button Check leftIcon and rightIcon functionality: when "Filter" and "Exit" icons is specified as the leftIcon and rightIcon props, it should be rendered on the screen', () => {
|
|
101
|
+
const {
|
|
102
|
+
container
|
|
103
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
104
|
+
text: "Button",
|
|
105
|
+
type: "primary",
|
|
106
|
+
size: "small",
|
|
107
|
+
disabled: false,
|
|
108
|
+
leftIcon: "Filter",
|
|
109
|
+
rightIcon: "Exit"
|
|
110
|
+
}));
|
|
111
|
+
const elementFilter = container.querySelector('.FilterIcon');
|
|
112
|
+
expect(elementFilter).toBeInTheDocument();
|
|
113
|
+
const elementExit = container.querySelector('.ExitIcon');
|
|
114
|
+
expect(elementExit).toBeInTheDocument();
|
|
115
|
+
});
|
|
116
|
+
test('Button Check small/medium functionality: when "small" the height must be "33px" ', () => {
|
|
117
|
+
const {
|
|
118
|
+
container
|
|
119
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
120
|
+
text: "Button",
|
|
121
|
+
type: "primary",
|
|
122
|
+
size: "small",
|
|
123
|
+
disabled: false,
|
|
124
|
+
leftIcon: "none",
|
|
125
|
+
rightIcon: "none"
|
|
126
|
+
}));
|
|
127
|
+
const elementButtonContainer = container.querySelector('.ButtonContainer');
|
|
128
|
+
expect(elementButtonContainer).toBeInTheDocument();
|
|
129
|
+
const computedStyle = getComputedStyle(elementButtonContainer);
|
|
130
|
+
expect(computedStyle.height).toBe('33px');
|
|
131
|
+
});
|
|
132
|
+
test('Button Check small/medium functionality: when "medium" the height must be "45px" ', () => {
|
|
133
|
+
const {
|
|
134
|
+
container
|
|
135
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
136
|
+
text: "Button",
|
|
137
|
+
type: "primary",
|
|
138
|
+
size: "medium",
|
|
139
|
+
disabled: false
|
|
140
|
+
}));
|
|
141
|
+
const elementButtonContainer = container.querySelector('.ButtonContainer');
|
|
142
|
+
expect(elementButtonContainer).toBeInTheDocument();
|
|
143
|
+
const computedStyle = getComputedStyle(elementButtonContainer);
|
|
144
|
+
expect(computedStyle.height).toBe('45px');
|
|
145
|
+
});
|
|
146
|
+
test('Button Check specific height and width functionality: when height = 100px and width = 200px it should override small/medium functionality ', () => {
|
|
147
|
+
const {
|
|
148
|
+
container
|
|
149
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
150
|
+
text: "Button",
|
|
151
|
+
type: "primary",
|
|
152
|
+
size: "small",
|
|
153
|
+
disabled: false,
|
|
154
|
+
height: "100px",
|
|
155
|
+
width: "200px"
|
|
156
|
+
}));
|
|
157
|
+
const elementButtonContainer = container.querySelector('.ButtonContainer');
|
|
158
|
+
expect(elementButtonContainer).toBeInTheDocument();
|
|
159
|
+
const computedStyle = getComputedStyle(elementButtonContainer);
|
|
160
|
+
expect(computedStyle.height).toBe('100px');
|
|
161
|
+
expect(computedStyle.width).toBe('200px');
|
|
162
|
+
});
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _LinkButton = _interopRequireDefault(require("./stories/components/LinkButton"));
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
9
|
+
/* eslint-disable import/no-unresolved */
|
|
10
|
+
/* eslint-disable no-undef */
|
|
11
|
+
|
|
12
|
+
test('LinkButton Check text', () => {
|
|
13
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
|
|
14
|
+
text: "test",
|
|
15
|
+
type: "secondary",
|
|
16
|
+
size: "small",
|
|
17
|
+
disabled: false
|
|
18
|
+
}));
|
|
19
|
+
const buttonElement = _react2.screen.getByText(/test/i);
|
|
20
|
+
expect(buttonElement).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
test('LinkButton Check type functionality: when "primary" type selected then text color must be specified as "rgb(146, 207, 23)" ', () => {
|
|
23
|
+
const {
|
|
24
|
+
container
|
|
25
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
|
|
26
|
+
text: "LinkButton",
|
|
27
|
+
type: "primary",
|
|
28
|
+
size: "small",
|
|
29
|
+
disabled: false
|
|
30
|
+
}));
|
|
31
|
+
const buttonElement = container.querySelector('.LinkButtonItem');
|
|
32
|
+
expect(buttonElement).toBeInTheDocument();
|
|
33
|
+
const computedStyles = getComputedStyle(buttonElement);
|
|
34
|
+
expect(computedStyles.color).toBe('rgb(34, 158, 56)');
|
|
35
|
+
});
|
|
36
|
+
test('LinkButton Check type functionality: when "secondary" type selected then background color must be specified as "rgb(232, 245, 235)" ', () => {
|
|
37
|
+
const {
|
|
38
|
+
container
|
|
39
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
|
|
40
|
+
text: "LinkButton",
|
|
41
|
+
type: "secondary",
|
|
42
|
+
size: "small",
|
|
43
|
+
disabled: false
|
|
44
|
+
}));
|
|
45
|
+
const buttonElement = container.querySelector('.LinkButtonItem');
|
|
46
|
+
expect(buttonElement).toBeInTheDocument();
|
|
47
|
+
const computedStyles = getComputedStyle(buttonElement);
|
|
48
|
+
expect(computedStyles.color).toBe('rgb(33, 33, 33)');
|
|
49
|
+
});
|
|
50
|
+
test('LinkButton Check disabled functionality: when disabled prop is true, button textColor should be "rgb(177, 177, 177)" ', () => {
|
|
51
|
+
const {
|
|
52
|
+
container
|
|
53
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
|
|
54
|
+
text: "LinkButton",
|
|
55
|
+
type: "primary",
|
|
56
|
+
size: "small",
|
|
57
|
+
disabled: true
|
|
58
|
+
}));
|
|
59
|
+
const buttonElement = container.querySelector('.LinkButtonItem');
|
|
60
|
+
expect(buttonElement).toBeInTheDocument();
|
|
61
|
+
const computedStyles = getComputedStyle(buttonElement);
|
|
62
|
+
expect(computedStyles.color).toBe('rgb(177, 177, 177)');
|
|
63
|
+
});
|
|
64
|
+
test('LinkButton Check leftIcon and rightIcon functionality: when "Filter" and "Exit" icons is specified as the leftIcon and rightIcon props, it should be rendered on the screen', () => {
|
|
65
|
+
const {
|
|
66
|
+
container
|
|
67
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
|
|
68
|
+
text: "LinkButton",
|
|
69
|
+
type: "primary",
|
|
70
|
+
size: "small",
|
|
71
|
+
disabled: false,
|
|
72
|
+
leftIcon: "Filter",
|
|
73
|
+
rightIcon: "Exit"
|
|
74
|
+
}));
|
|
75
|
+
const elementFilter = container.querySelector('.FilterIcon');
|
|
76
|
+
expect(elementFilter).toBeInTheDocument();
|
|
77
|
+
const elementExit = container.querySelector('.ExitIcon');
|
|
78
|
+
expect(elementExit).toBeInTheDocument();
|
|
79
|
+
});
|
|
80
|
+
test('LinkButton Check rightIcon functionality: when "Exit" icons is specified as the rightIcon props, it should be rendered on the screen', () => {
|
|
81
|
+
const {
|
|
82
|
+
container
|
|
83
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
|
|
84
|
+
text: "LinkButton",
|
|
85
|
+
type: "primary",
|
|
86
|
+
size: "small",
|
|
87
|
+
disabled: false,
|
|
88
|
+
rightIcon: "Exit"
|
|
89
|
+
}));
|
|
90
|
+
const elementExit = container.querySelector('.ExitIcon');
|
|
91
|
+
expect(elementExit).toBeInTheDocument();
|
|
92
|
+
});
|
|
93
|
+
test('LinkButton Check leftIcon functionality: when "Filter" icons is specified as the leftIcon props, it should be rendered on the screen', () => {
|
|
94
|
+
const {
|
|
95
|
+
container
|
|
96
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
|
|
97
|
+
text: "LinkButton",
|
|
98
|
+
type: "primary",
|
|
99
|
+
size: "small",
|
|
100
|
+
disabled: false,
|
|
101
|
+
leftIcon: "Filter"
|
|
102
|
+
}));
|
|
103
|
+
const elementFilter = container.querySelector('.FilterIcon');
|
|
104
|
+
expect(elementFilter).toBeInTheDocument();
|
|
105
|
+
});
|
|
106
|
+
test('LinkButton Check small/medium functionality: when "small" the font-size must be "14px" ', () => {
|
|
107
|
+
const {
|
|
108
|
+
container
|
|
109
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
|
|
110
|
+
text: "LinkButton",
|
|
111
|
+
type: "primary",
|
|
112
|
+
size: "small",
|
|
113
|
+
disabled: false
|
|
114
|
+
}));
|
|
115
|
+
const elementLinkButtonContainer = container.querySelector('.LinkButtonItem');
|
|
116
|
+
expect(elementLinkButtonContainer).toBeInTheDocument();
|
|
117
|
+
const computedStyle = getComputedStyle(elementLinkButtonContainer);
|
|
118
|
+
expect(computedStyle.fontSize).toBe('14px');
|
|
119
|
+
});
|
|
120
|
+
test('LinkButton Check small/medium functionality: when "medium" the font-size must be "16px" ', () => {
|
|
121
|
+
const {
|
|
122
|
+
container
|
|
123
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
|
|
124
|
+
text: "LinkButton",
|
|
125
|
+
type: "primary",
|
|
126
|
+
size: "medium",
|
|
127
|
+
disabled: false
|
|
128
|
+
}));
|
|
129
|
+
const elementLinkButtonContainer = container.querySelector('.LinkButtonItem');
|
|
130
|
+
expect(elementLinkButtonContainer).toBeInTheDocument();
|
|
131
|
+
const computedStyle = getComputedStyle(elementLinkButtonContainer);
|
|
132
|
+
expect(computedStyle.fontSize).toBe('16px');
|
|
133
|
+
});
|
|
134
|
+
test('LinkButton Check specific height and width functionality: when height = 100px and width = 200px it should override small/medium functionality ', () => {
|
|
135
|
+
const {
|
|
136
|
+
container
|
|
137
|
+
} = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
|
|
138
|
+
text: "LinkButton",
|
|
139
|
+
type: "primary",
|
|
140
|
+
size: "small",
|
|
141
|
+
disabled: false,
|
|
142
|
+
height: "100px",
|
|
143
|
+
width: "200px"
|
|
144
|
+
}));
|
|
145
|
+
const elementLinkButtonContainer = container.querySelector('.LinkButtonContainer');
|
|
146
|
+
expect(elementLinkButtonContainer).toBeInTheDocument();
|
|
147
|
+
const computedStyle = getComputedStyle(elementLinkButtonContainer);
|
|
148
|
+
expect(computedStyle.height).toBe('100px');
|
|
149
|
+
expect(computedStyle.width).toBe('200px');
|
|
150
|
+
});
|
|
@@ -1,117 +1,199 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.Button = void 0;
|
|
9
|
-
var
|
|
10
|
-
var _Button =
|
|
11
|
-
var
|
|
12
|
-
var
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _Button = require("./Button.style");
|
|
10
|
+
var _FilterIcon = require("./icons/FilterIcon");
|
|
11
|
+
var _OptionsIcon = require("./icons/OptionsIcon");
|
|
12
|
+
var _DownloadIcon = require("./icons/DownloadIcon");
|
|
13
|
+
var _DocumentIcon = require("./icons/DocumentIcon");
|
|
14
|
+
var _FlyIcon = require("./icons/FlyIcon");
|
|
15
|
+
var _BellIcon = require("./icons/BellIcon");
|
|
16
|
+
var _MaintenanceIcon = require("./icons/MaintenanceIcon");
|
|
17
|
+
var _ExitIcon = require("./icons/ExitIcon");
|
|
18
|
+
var _EyeIcon = require("./icons/EyeIcon");
|
|
13
19
|
const Button = props => {
|
|
14
20
|
const {
|
|
15
21
|
text,
|
|
16
22
|
type,
|
|
17
|
-
fontFamily,
|
|
18
|
-
fontSize,
|
|
19
|
-
shape,
|
|
20
23
|
size,
|
|
21
24
|
height,
|
|
22
25
|
width,
|
|
23
26
|
disabled,
|
|
24
|
-
radius,
|
|
25
27
|
textColor,
|
|
26
28
|
backgroundColor,
|
|
27
29
|
borderColor,
|
|
28
30
|
hoverTextColor,
|
|
29
31
|
hoverBackgroundColor,
|
|
30
32
|
hoverBorderColor,
|
|
33
|
+
disabledTextColor,
|
|
34
|
+
// new
|
|
35
|
+
disabledBackgroundColor,
|
|
36
|
+
// new
|
|
37
|
+
disabledBorderColor,
|
|
38
|
+
// new
|
|
39
|
+
leftIcon,
|
|
40
|
+
// new
|
|
41
|
+
rightIcon,
|
|
42
|
+
// new
|
|
31
43
|
onClick
|
|
44
|
+
// radius, // removed
|
|
45
|
+
// fontFamily, // removed
|
|
46
|
+
// fontSize, // removed
|
|
47
|
+
// shape, // removed
|
|
32
48
|
} = props;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
return textColor;
|
|
49
|
+
const [clicked, setClicked] = (0, _react.useState)(false);
|
|
50
|
+
const [hover, setHover] = (0, _react.useState)(false);
|
|
51
|
+
const handleButtonClick = () => {
|
|
52
|
+
setClicked(true);
|
|
53
|
+
onClick(text);
|
|
54
|
+
setTimeout(() => {
|
|
55
|
+
setClicked(false);
|
|
56
|
+
}, 300);
|
|
42
57
|
};
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
58
|
+
const getIcon = icon => {
|
|
59
|
+
const iconHeight = '12px';
|
|
60
|
+
const iconWidth = '12px';
|
|
61
|
+
const newTextColor = textColor || (type === 'secondary' ? '#212121' : '#ffffff');
|
|
62
|
+
const newHoverTextColor = hoverTextColor || (type === 'secondary' ? '#229E38' : '#ffffff');
|
|
63
|
+
const newDisabledTextColor = disabledTextColor || '#B1B1B1';
|
|
64
|
+
const newEnabledTextColor = hover ? newHoverTextColor : newTextColor;
|
|
65
|
+
const color = disabled ? newDisabledTextColor : newEnabledTextColor;
|
|
66
|
+
switch (icon.toLowerCase()) {
|
|
67
|
+
case 'filter':
|
|
68
|
+
return /*#__PURE__*/_react.default.createElement(_Button.IconWrapper, {
|
|
69
|
+
className: "FilterIcon"
|
|
70
|
+
}, /*#__PURE__*/_react.default.createElement(_FilterIcon.FilterIcon, {
|
|
71
|
+
height: iconHeight,
|
|
72
|
+
width: iconWidth,
|
|
73
|
+
color: color
|
|
74
|
+
}));
|
|
75
|
+
case 'options':
|
|
76
|
+
return /*#__PURE__*/_react.default.createElement(_Button.IconWrapper, {
|
|
77
|
+
className: "OptionsIcon"
|
|
78
|
+
}, /*#__PURE__*/_react.default.createElement(_OptionsIcon.OptionsIcon, {
|
|
79
|
+
height: iconHeight,
|
|
80
|
+
width: iconWidth,
|
|
81
|
+
color: color
|
|
82
|
+
}));
|
|
83
|
+
case 'download':
|
|
84
|
+
return /*#__PURE__*/_react.default.createElement(_Button.IconWrapper, {
|
|
85
|
+
className: "DownloadIcon"
|
|
86
|
+
}, /*#__PURE__*/_react.default.createElement(_DownloadIcon.DownloadIcon, {
|
|
87
|
+
height: iconHeight,
|
|
88
|
+
width: iconWidth,
|
|
89
|
+
color: color
|
|
90
|
+
}));
|
|
91
|
+
case 'document':
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement(_Button.IconWrapper, {
|
|
93
|
+
className: "DocumentIcon"
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement(_DocumentIcon.DocumentIcon, {
|
|
95
|
+
height: iconHeight,
|
|
96
|
+
width: iconWidth,
|
|
97
|
+
color: color
|
|
98
|
+
}));
|
|
99
|
+
case 'fly':
|
|
100
|
+
return /*#__PURE__*/_react.default.createElement(_Button.IconWrapper, {
|
|
101
|
+
className: "FlyIcon"
|
|
102
|
+
}, /*#__PURE__*/_react.default.createElement(_FlyIcon.FlyIcon, {
|
|
103
|
+
height: iconHeight,
|
|
104
|
+
width: iconWidth,
|
|
105
|
+
color: color
|
|
106
|
+
}));
|
|
107
|
+
case 'bell':
|
|
108
|
+
return /*#__PURE__*/_react.default.createElement(_Button.IconWrapper, {
|
|
109
|
+
className: "BellIcon"
|
|
110
|
+
}, /*#__PURE__*/_react.default.createElement(_BellIcon.BellIcon, {
|
|
111
|
+
height: iconHeight,
|
|
112
|
+
width: iconWidth,
|
|
113
|
+
color: color
|
|
114
|
+
}));
|
|
115
|
+
case 'maintenance':
|
|
116
|
+
return /*#__PURE__*/_react.default.createElement(_Button.IconWrapper, {
|
|
117
|
+
className: "MaintenanceIcon"
|
|
118
|
+
}, /*#__PURE__*/_react.default.createElement(_MaintenanceIcon.MaintenanceIcon, {
|
|
119
|
+
height: iconHeight,
|
|
120
|
+
width: iconWidth,
|
|
121
|
+
color: color
|
|
122
|
+
}));
|
|
123
|
+
case 'exit':
|
|
124
|
+
return /*#__PURE__*/_react.default.createElement(_Button.IconWrapper, {
|
|
125
|
+
className: "ExitIcon"
|
|
126
|
+
}, /*#__PURE__*/_react.default.createElement(_ExitIcon.ExitIcon, {
|
|
127
|
+
height: iconHeight,
|
|
128
|
+
width: iconWidth,
|
|
129
|
+
color: color
|
|
130
|
+
}));
|
|
131
|
+
case 'eye':
|
|
132
|
+
return /*#__PURE__*/_react.default.createElement(_Button.IconWrapper, {
|
|
133
|
+
className: "EyeIcon"
|
|
134
|
+
}, /*#__PURE__*/_react.default.createElement(_EyeIcon.EyeIcon, {
|
|
135
|
+
height: iconHeight,
|
|
136
|
+
width: iconWidth,
|
|
137
|
+
color: color
|
|
138
|
+
}));
|
|
139
|
+
default:
|
|
140
|
+
return '';
|
|
65
141
|
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
borderColor,
|
|
87
|
-
fontFamily
|
|
88
|
-
},
|
|
89
|
-
variant: shape,
|
|
90
|
-
size: size,
|
|
142
|
+
};
|
|
143
|
+
const getLeftIcon = () => {
|
|
144
|
+
if (!leftIcon || leftIcon === 'none') return '';
|
|
145
|
+
return getIcon(leftIcon);
|
|
146
|
+
};
|
|
147
|
+
const getRightIcon = () => {
|
|
148
|
+
if (!rightIcon || rightIcon === 'none') return '';
|
|
149
|
+
return getIcon(rightIcon);
|
|
150
|
+
};
|
|
151
|
+
return /*#__PURE__*/_react.default.createElement(_Button.ButtonContainer, {
|
|
152
|
+
className: "ButtonContainer",
|
|
153
|
+
width: width || null,
|
|
154
|
+
height: height || (size === 'small' ? '33px' : '45px')
|
|
155
|
+
}, /*#__PURE__*/_react.default.createElement(_Button.ButtonItem, {
|
|
156
|
+
className: clicked ? 'ButtonItem-clicked' : 'ButtonItem',
|
|
157
|
+
onMouseEnter: () => setHover(true),
|
|
158
|
+
onMouseLeave: () => setHover(false),
|
|
159
|
+
onClick: !disabled ? handleButtonClick : null,
|
|
160
|
+
width: width || null,
|
|
161
|
+
height: height || (size === 'small' ? '33px' : '45px'),
|
|
91
162
|
disabled: disabled,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
163
|
+
text_color: textColor || (type === 'secondary' ? '#212121' : '#ffffff'),
|
|
164
|
+
background_color: backgroundColor || (type === 'secondary' ? '#ffffff' : '#229E38'),
|
|
165
|
+
border_color: borderColor || (type === 'secondary' ? '#B1B1B1' : '#229E38'),
|
|
166
|
+
hover_text_color: hoverTextColor || (type === 'secondary' ? '#229E38' : '#ffffff'),
|
|
167
|
+
hover_background_color: hoverBackgroundColor || (type === 'secondary' ? '#E8F5EB' : '#92CF17'),
|
|
168
|
+
hover_border_color: hoverBorderColor || (type === 'secondary' ? '#229E38' : '#92CF17'),
|
|
169
|
+
disabled_text_color: disabledTextColor || '#B1B1B1',
|
|
170
|
+
disabled_background_color: disabledBackgroundColor || (type === 'secondary' ? '#ffffff' : '#E3E4E5'),
|
|
171
|
+
disabled_border_color: disabledBorderColor || '#E3E4E5',
|
|
172
|
+
padding: size === 'small' ? '0 16px' : '0 20px'
|
|
173
|
+
}, getLeftIcon(), /*#__PURE__*/_react.default.createElement(_Button.Label, {
|
|
174
|
+
className: "Label",
|
|
175
|
+
disabled: disabled
|
|
176
|
+
}, text), getRightIcon()));
|
|
96
177
|
};
|
|
97
178
|
exports.Button = Button;
|
|
98
179
|
var _default = exports.default = Button;
|
|
99
180
|
Button.defaultProps = {
|
|
100
181
|
text: '',
|
|
101
|
-
type: '
|
|
102
|
-
fontFamily: '',
|
|
103
|
-
fontSize: 18,
|
|
104
|
-
shape: 'contained',
|
|
182
|
+
type: 'primary',
|
|
105
183
|
size: 'small',
|
|
106
|
-
height: '
|
|
107
|
-
width: '
|
|
184
|
+
height: '',
|
|
185
|
+
width: '',
|
|
108
186
|
disabled: false,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
borderColor: '#212121',
|
|
187
|
+
textColor: '',
|
|
188
|
+
backgroundColor: '',
|
|
189
|
+
borderColor: '',
|
|
113
190
|
hoverTextColor: '',
|
|
114
191
|
hoverBackgroundColor: '',
|
|
115
|
-
hoverBorderColor: '
|
|
116
|
-
|
|
192
|
+
hoverBorderColor: '',
|
|
193
|
+
disabledTextColor: '',
|
|
194
|
+
disabledBackgroundColor: '',
|
|
195
|
+
disabledBorderColor: '',
|
|
196
|
+
onClick: () => {},
|
|
197
|
+
leftIcon: 'none',
|
|
198
|
+
rightIcon: 'none'
|
|
117
199
|
};
|
|
@@ -4,8 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.Label = exports.IconWrapper = exports.ButtonItem = exports.ButtonContainer = void 0;
|
|
8
8
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/taggedTemplateLiteral"));
|
|
9
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
10
|
-
var _templateObject;
|
|
11
|
-
const
|
|
10
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
11
|
+
const ButtonContainer = exports.ButtonContainer = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n //position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n align-content: center; \n width: ", ";\n height: ", ";\n"])), props => props.width, props => props.height);
|
|
12
|
+
const ButtonItem = exports.ButtonItem = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n align-items: center;\n justify-content: center;\n align-content: center;\n flex-wrap: nowrap;\n overflow: hidden;\n width: ", ";\n height: ", "; \n color: ", "; \n border: ", "; \n border-radius: 12px;\n background-color: ", ";\n box-sizing: border-box;\n gap: 8px; \n padding: ", "; \n &:hover {\n background-color: ", ";\n border-color: ", "; \n color: ", "; \n box-shadow: ", ";\n cursor: ", ";\n }\n &.ButtonItem-clicked {\n background-color: ", ";\n //padding: 0 10px; \n cursor: pointer;\n box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.3);\n transition: background-color 0.3s, color 0.3s;\n }\n"])), props => props.width, props => props.height, props => props.disabled ? props.disabled_text_color : props.text_color, props => "1px solid ".concat(props.disabled ? props.disabled_border_color : props.border_color), props => props.disabled ? props.disabled_background_color : props.background_color, props => props.padding, props => props.disabled ? props.disabled_backgroundColor : props.hover_background_color, props => props.disabled ? props.disabled_border_color : props.hover_border_color, props => props.disabled ? props.disabled_text_color : props.hover_text_color, props => props.disabled ? '' : '5px 5px 10px 0px rgba(0, 0, 0, 0.2)', props => !props.disabled ? 'pointer' : 'default', props => props.background_color);
|
|
13
|
+
const Label = exports.Label = _styledComponents.default.label(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n font-family: 'Poppins';\n font-style: normal;\n font-weight: 400; \n pointer-events: none;\n font-size: 14px;\n user-select: none; \n"])));
|
|
14
|
+
const IconWrapper = exports.IconWrapper = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n align-items: center;\n justify-content: center;\n align-content: center; \n"])));
|