@dhis2-ui/notice-box 9.11.0 → 9.11.1-beta.1
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/build/cjs/__tests__/notice-box-icon.test.js +1 -5
- package/build/cjs/__tests__/notice-box-message.test.js +1 -5
- package/build/cjs/__tests__/notice-box-title.test.js +1 -5
- package/build/cjs/features/accepts_children/index.js +0 -1
- package/build/cjs/features/accepts_title/index.js +0 -1
- package/build/cjs/index.js +0 -1
- package/build/cjs/notice-box-content.js +4 -13
- package/build/cjs/notice-box-icon.js +2 -15
- package/build/cjs/notice-box-message.js +2 -11
- package/build/cjs/notice-box-title.js +2 -11
- package/build/cjs/notice-box.e2e.stories.js +18 -0
- package/build/cjs/notice-box.js +4 -18
- package/build/cjs/{notice-box.stories.js → notice-box.prod.stories.js} +27 -27
- package/build/es/notice-box-content.js +3 -3
- package/build/es/notice-box-icon.js +1 -5
- package/build/es/notice-box-message.js +1 -3
- package/build/es/notice-box-title.js +1 -3
- package/build/es/notice-box.e2e.stories.js +9 -0
- package/build/es/notice-box.js +3 -6
- package/build/es/{notice-box.stories.js → notice-box.prod.stories.js} +27 -5
- package/package.json +6 -6
- package/build/cjs/notice-box.stories.e2e.js +0 -13
- package/build/es/notice-box.stories.e2e.js +0 -6
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _enzyme = require("enzyme");
|
|
4
|
-
|
|
5
4
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _noticeBoxIcon = require("../notice-box-icon.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
7
|
describe('NoticeBoxIcon', () => {
|
|
12
8
|
it('should render info icon by default', () => {
|
|
13
9
|
const wrapper = (0, _enzyme.shallow)( /*#__PURE__*/_react.default.createElement(_noticeBoxIcon.NoticeBoxIcon, {
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _enzyme = require("enzyme");
|
|
4
|
-
|
|
5
4
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _noticeBoxMessage = require("../notice-box-message.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
7
|
describe('NoticeBoxMessage', () => {
|
|
12
8
|
it('should return null when there are no children', () => {
|
|
13
9
|
const props = {
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _enzyme = require("enzyme");
|
|
4
|
-
|
|
5
4
|
var _react = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _noticeBoxTitle = require("../notice-box-title.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
7
|
describe('NoticeBoxTitle', () => {
|
|
12
8
|
it('should return null when there is no title', () => {
|
|
13
9
|
const props = {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a NoticeBox receives a message as children', () => {
|
|
6
5
|
cy.visitStory('NoticeBox', 'With children');
|
|
7
6
|
cy.get('[data-test="dhis2-uicore-noticebox"]').should('be.visible');
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a NoticeBox receives a title prop', () => {
|
|
6
5
|
cy.visitStory('NoticeBox', 'With title');
|
|
7
6
|
cy.get('[data-test="dhis2-uicore-noticebox"]').should('be.visible');
|
package/build/cjs/index.js
CHANGED
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.NoticeBoxContent = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
|
|
16
11
|
var _noticeBoxMessage = require("./notice-box-message.js");
|
|
17
|
-
|
|
18
12
|
var _noticeBoxTitle = require("./notice-box-title.js");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
14
|
const NoticeBoxContent = _ref => {
|
|
23
15
|
let {
|
|
24
16
|
children,
|
|
@@ -30,15 +22,14 @@ const NoticeBoxContent = _ref => {
|
|
|
30
22
|
className: _style.default.dynamic([["403435427", [_uiConstants.spacers.dp8]]])
|
|
31
23
|
}, /*#__PURE__*/_react.default.createElement(_noticeBoxTitle.NoticeBoxTitle, {
|
|
32
24
|
title: title,
|
|
33
|
-
dataTest:
|
|
25
|
+
dataTest: `${dataTest}-title`
|
|
34
26
|
}), /*#__PURE__*/_react.default.createElement(_noticeBoxMessage.NoticeBoxMessage, {
|
|
35
|
-
dataTest:
|
|
27
|
+
dataTest: `${dataTest}-message`
|
|
36
28
|
}, children), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
37
29
|
id: "403435427",
|
|
38
30
|
dynamic: [_uiConstants.spacers.dp8]
|
|
39
|
-
}, [
|
|
31
|
+
}, [`div.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;gap:${_uiConstants.spacers.dp8};padding-block-start:3px;}`]));
|
|
40
32
|
};
|
|
41
|
-
|
|
42
33
|
exports.NoticeBoxContent = NoticeBoxContent;
|
|
43
34
|
NoticeBoxContent.defaultProps = {
|
|
44
35
|
dataTest: 'dhis2-uicore-noticebox-content'
|
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.NoticeBoxIcon = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = require("@dhis2/prop-types");
|
|
11
|
-
|
|
12
9
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
13
|
-
|
|
14
10
|
var _uiIcons = require("@dhis2/ui-icons");
|
|
15
|
-
|
|
16
11
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireDefault(require("react"));
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
14
|
const NoticeBoxIcon = _ref => {
|
|
23
15
|
let {
|
|
24
16
|
valid,
|
|
@@ -29,22 +21,18 @@ const NoticeBoxIcon = _ref => {
|
|
|
29
21
|
// Info is the default icon
|
|
30
22
|
let color = _uiConstants.colors.blue900;
|
|
31
23
|
let Icon = _uiIcons.IconInfoFilled24;
|
|
32
|
-
|
|
33
24
|
if (valid) {
|
|
34
25
|
color = _uiConstants.colors.green700;
|
|
35
26
|
Icon = _uiIcons.IconCheckmarkCircle24;
|
|
36
27
|
}
|
|
37
|
-
|
|
38
28
|
if (warning) {
|
|
39
29
|
color = _uiConstants.colors.yellow700;
|
|
40
30
|
Icon = _uiIcons.IconWarningFilled24;
|
|
41
31
|
}
|
|
42
|
-
|
|
43
32
|
if (error) {
|
|
44
33
|
color = _uiConstants.colors.red700;
|
|
45
34
|
Icon = _uiIcons.IconErrorFilled24;
|
|
46
35
|
}
|
|
47
|
-
|
|
48
36
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
49
37
|
"data-test": dataTest,
|
|
50
38
|
className: _style.default.dynamic([["1909501516", [_uiConstants.spacers.dp12, _uiConstants.spacers.dp24]]])
|
|
@@ -54,9 +42,8 @@ const NoticeBoxIcon = _ref => {
|
|
|
54
42
|
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
55
43
|
id: "1909501516",
|
|
56
44
|
dynamic: [_uiConstants.spacers.dp12, _uiConstants.spacers.dp24]
|
|
57
|
-
}, [
|
|
45
|
+
}, [`.__jsx-style-dynamic-selector{margin-inline-end:${_uiConstants.spacers.dp12};height:${_uiConstants.spacers.dp24};}`]));
|
|
58
46
|
};
|
|
59
|
-
|
|
60
47
|
exports.NoticeBoxIcon = NoticeBoxIcon;
|
|
61
48
|
NoticeBoxIcon.propTypes = {
|
|
62
49
|
dataTest: _propTypes2.default.string.isRequired,
|
|
@@ -4,36 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.NoticeBoxMessage = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
12
|
const NoticeBoxMessage = _ref => {
|
|
19
13
|
let {
|
|
20
14
|
children,
|
|
21
15
|
dataTest
|
|
22
16
|
} = _ref;
|
|
23
|
-
|
|
24
17
|
if (!children) {
|
|
25
18
|
return null;
|
|
26
19
|
}
|
|
27
|
-
|
|
28
20
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
29
21
|
"data-test": dataTest,
|
|
30
22
|
className: _style.default.dynamic([["3568970766", [_uiConstants.colors.grey900]]])
|
|
31
23
|
}, children, /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
32
24
|
id: "3568970766",
|
|
33
25
|
dynamic: [_uiConstants.colors.grey900]
|
|
34
|
-
}, [
|
|
26
|
+
}, [`div.__jsx-style-dynamic-selector{color:${_uiConstants.colors.grey900};font-size:14px;line-height:19px;}`]));
|
|
35
27
|
};
|
|
36
|
-
|
|
37
28
|
exports.NoticeBoxMessage = NoticeBoxMessage;
|
|
38
29
|
NoticeBoxMessage.propTypes = {
|
|
39
30
|
dataTest: _propTypes.default.string.isRequired,
|
|
@@ -4,36 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.NoticeBoxTitle = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
11
|
-
|
|
12
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
12
|
const NoticeBoxTitle = _ref => {
|
|
19
13
|
let {
|
|
20
14
|
title,
|
|
21
15
|
dataTest
|
|
22
16
|
} = _ref;
|
|
23
|
-
|
|
24
17
|
if (!title) {
|
|
25
18
|
return null;
|
|
26
19
|
}
|
|
27
|
-
|
|
28
20
|
return /*#__PURE__*/_react.default.createElement("h6", {
|
|
29
21
|
"data-test": dataTest,
|
|
30
22
|
className: _style.default.dynamic([["1334557505", [_uiConstants.colors.grey900]]])
|
|
31
23
|
}, title, /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
32
24
|
id: "1334557505",
|
|
33
25
|
dynamic: [_uiConstants.colors.grey900]
|
|
34
|
-
}, [
|
|
26
|
+
}, [`h6.__jsx-style-dynamic-selector{color:${_uiConstants.colors.grey900};font-size:14px;font-weight:500;line-height:19px;margin:0;}`]));
|
|
35
27
|
};
|
|
36
|
-
|
|
37
28
|
exports.NoticeBoxTitle = NoticeBoxTitle;
|
|
38
29
|
NoticeBoxTitle.propTypes = {
|
|
39
30
|
dataTest: _propTypes.default.string.isRequired,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithTitle = exports.WithChildren = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _noticeBox = require("./notice-box.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
var _default = exports.default = {
|
|
11
|
+
title: 'NoticeBox'
|
|
12
|
+
};
|
|
13
|
+
const WithChildren = () => /*#__PURE__*/_react.default.createElement(_noticeBox.NoticeBox, null, "The noticebox content");
|
|
14
|
+
exports.WithChildren = WithChildren;
|
|
15
|
+
const WithTitle = () => /*#__PURE__*/_react.default.createElement(_noticeBox.NoticeBox, {
|
|
16
|
+
title: "The noticebox title"
|
|
17
|
+
});
|
|
18
|
+
exports.WithTitle = WithTitle;
|
package/build/cjs/notice-box.js
CHANGED
|
@@ -4,25 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.NoticeBox = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = require("@dhis2/prop-types");
|
|
11
|
-
|
|
12
9
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
13
|
-
|
|
14
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
|
|
16
11
|
var _propTypes2 = _interopRequireDefault(require("prop-types"));
|
|
17
|
-
|
|
18
12
|
var _react = _interopRequireDefault(require("react"));
|
|
19
|
-
|
|
20
13
|
var _noticeBoxContent = require("./notice-box-content.js");
|
|
21
|
-
|
|
22
14
|
var _noticeBoxIcon = require("./notice-box-icon.js");
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
26
16
|
const NoticeBox = _ref => {
|
|
27
17
|
let {
|
|
28
18
|
className,
|
|
@@ -45,18 +35,17 @@ const NoticeBox = _ref => {
|
|
|
45
35
|
error: error,
|
|
46
36
|
warning: warning,
|
|
47
37
|
valid: valid,
|
|
48
|
-
dataTest:
|
|
38
|
+
dataTest: `${dataTest}-icon`
|
|
49
39
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
50
40
|
className: _style.default.dynamic([["243875418", [_uiConstants.colors.blue050, _uiConstants.colors.blue200, _uiConstants.spacers.dp12, _uiConstants.spacers.dp16, _uiConstants.colors.yellow050, _uiConstants.colors.yellow200, _uiConstants.colors.red050, _uiConstants.colors.red500, _uiConstants.colors.green050, _uiConstants.colors.green200]]])
|
|
51
41
|
}, /*#__PURE__*/_react.default.createElement(_noticeBoxContent.NoticeBoxContent, {
|
|
52
42
|
title: title,
|
|
53
|
-
dataTest:
|
|
43
|
+
dataTest: `${dataTest}-content`
|
|
54
44
|
}, children)), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
55
45
|
id: "243875418",
|
|
56
46
|
dynamic: [_uiConstants.colors.blue050, _uiConstants.colors.blue200, _uiConstants.spacers.dp12, _uiConstants.spacers.dp16, _uiConstants.colors.yellow050, _uiConstants.colors.yellow200, _uiConstants.colors.red050, _uiConstants.colors.red500, _uiConstants.colors.green050, _uiConstants.colors.green200]
|
|
57
|
-
}, [
|
|
47
|
+
}, [`.root.__jsx-style-dynamic-selector{background:${_uiConstants.colors.blue050};border:1px solid ${_uiConstants.colors.blue200};border-radius:3px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding-block:${_uiConstants.spacers.dp12};padding-inline:${_uiConstants.spacers.dp16};}`, `.root.warning.__jsx-style-dynamic-selector{background:${_uiConstants.colors.yellow050};border:1px solid ${_uiConstants.colors.yellow200};}`, `.root.error.__jsx-style-dynamic-selector{background:${_uiConstants.colors.red050};border:2px solid ${_uiConstants.colors.red500};}`, `.root.valid.__jsx-style-dynamic-selector{background:${_uiConstants.colors.green050};border:1px solid ${_uiConstants.colors.green200};}`]));
|
|
58
48
|
};
|
|
59
|
-
|
|
60
49
|
exports.NoticeBox = NoticeBox;
|
|
61
50
|
NoticeBox.defaultProps = {
|
|
62
51
|
dataTest: 'dhis2-uicore-noticebox'
|
|
@@ -65,14 +54,11 @@ NoticeBox.propTypes = {
|
|
|
65
54
|
children: _propTypes2.default.node,
|
|
66
55
|
className: _propTypes2.default.string,
|
|
67
56
|
dataTest: _propTypes2.default.string,
|
|
68
|
-
|
|
69
57
|
/** Applies 'error' message styles. Mutually exclusive with the `valid` and `warning` props */
|
|
70
58
|
error: (0, _propTypes.mutuallyExclusive)(['error', 'valid', 'warning'], _propTypes2.default.bool),
|
|
71
59
|
title: _propTypes2.default.string,
|
|
72
|
-
|
|
73
60
|
/** Applies 'valid' message styles. Mutually exclusive with the `error` and `warning` props */
|
|
74
61
|
valid: (0, _propTypes.mutuallyExclusive)(['error', 'valid', 'warning'], _propTypes2.default.bool),
|
|
75
|
-
|
|
76
62
|
/** Applies 'warning' message styles. Mutually exclusive with the `error` and `valid` props */
|
|
77
63
|
warning: (0, _propTypes.mutuallyExclusive)(['error', 'valid', 'warning'], _propTypes2.default.bool)
|
|
78
64
|
};
|
|
@@ -4,18 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.WithoutTitle = exports.WithALongTitle = exports.Warning = exports.Valid = exports.TitleOnly = exports.RTL = exports.Error = exports.Default = void 0;
|
|
7
|
-
|
|
8
7
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _noticeBox = require("./notice-box.js");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
const subtitle = `Highlights useful information that is directly relevant to the page the user is viewing`;
|
|
12
|
+
const description = `
|
|
13
|
+
Use a notice box wherever there is important, temporary information about a page or situation that the user needs to be aware of.
|
|
14
|
+
|
|
15
|
+
Notice boxes are different from alert bars in several ways. Notice boxes cannot be dismissed, so they will always display until the situation is resolved. Notice boxes are for highlighting static information or information that is ongoing. Alert bars are suited to alerting a user about something that has just happened.
|
|
16
|
+
|
|
17
|
+
Another way to decide which component to use:
|
|
18
|
+
|
|
19
|
+
- a notice box will usually be displayed when a page loads, before a user takes action
|
|
20
|
+
- an alert bar will usually display in response to an action/event
|
|
13
21
|
|
|
14
|
-
|
|
22
|
+
Notice boxes cannot be dismissed, so it is important to provide guidance on how to fix the problem/condition that is causing the notice box to display.
|
|
15
23
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
Do not use a notice box to display permanent information. If there is information that always will be displayed on a page it should be designed as part of the page itself. Notice boxes are for temporary information.
|
|
25
|
+
|
|
26
|
+
Learn more about Notice Boxes at [Design System: Notice Box](https://github.com/dhis2/design-system/blob/master/molecules/notice-box.md).
|
|
27
|
+
|
|
28
|
+
\`\`\`js
|
|
29
|
+
import { NoticeBox } from '@dhis2/ui'
|
|
30
|
+
\`\`\`
|
|
31
|
+
`;
|
|
32
|
+
var _default = exports.default = {
|
|
19
33
|
title: 'Notice Box',
|
|
20
34
|
component: _noticeBox.NoticeBox,
|
|
21
35
|
parameters: {
|
|
@@ -27,73 +41,59 @@ var _default = {
|
|
|
27
41
|
}
|
|
28
42
|
},
|
|
29
43
|
argTypes: {
|
|
30
|
-
error: {
|
|
44
|
+
error: {
|
|
45
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
31
46
|
},
|
|
32
|
-
warning: {
|
|
47
|
+
warning: {
|
|
48
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
33
49
|
},
|
|
34
|
-
valid: {
|
|
50
|
+
valid: {
|
|
51
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
35
52
|
}
|
|
36
53
|
}
|
|
37
54
|
};
|
|
38
|
-
exports.default = _default;
|
|
39
|
-
|
|
40
55
|
const Default = args => /*#__PURE__*/_react.default.createElement(_noticeBox.NoticeBox, args, "Data shown in this dashboard may take a few hours to update. Scheduled dashboard updates can be managed in the scheduler app.");
|
|
41
|
-
|
|
42
56
|
exports.Default = Default;
|
|
43
57
|
Default.args = {
|
|
44
58
|
title: 'Your database was updated in the last 24 hours'
|
|
45
59
|
};
|
|
46
|
-
|
|
47
60
|
const Valid = args => /*#__PURE__*/_react.default.createElement(_noticeBox.NoticeBox, args, "Programs using these rules are updated automatically.");
|
|
48
|
-
|
|
49
61
|
exports.Valid = Valid;
|
|
50
62
|
Valid.args = {
|
|
51
63
|
valid: true,
|
|
52
64
|
title: 'Program rules exported successfully'
|
|
53
65
|
};
|
|
54
|
-
|
|
55
66
|
const Warning = args => /*#__PURE__*/_react.default.createElement(_noticeBox.NoticeBox, args, "No one will be able to access this program. Add some Organisation Units to the access list.");
|
|
56
|
-
|
|
57
67
|
exports.Warning = Warning;
|
|
58
68
|
Warning.args = {
|
|
59
69
|
warning: true,
|
|
60
70
|
title: 'This program has no assigned Organisation Units'
|
|
61
71
|
};
|
|
62
|
-
|
|
63
72
|
const Error = () => /*#__PURE__*/_react.default.createElement(_noticeBox.NoticeBox, {
|
|
64
73
|
title: "Access rules for this instance are set to 'Public'",
|
|
65
74
|
error: true
|
|
66
75
|
}, "Data could be accessed from outside this instance. Update access rules immediately.");
|
|
67
|
-
|
|
68
76
|
exports.Error = Error;
|
|
69
77
|
Error.args = {
|
|
70
78
|
error: true,
|
|
71
79
|
title: "Access rules for this instance are set to 'Public'"
|
|
72
80
|
};
|
|
73
81
|
const text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.' + 'Ut semper interdum scelerisque. Suspendisse ut velit sed' + 'lacus pretium convallis vitae sit amet purus. Nam ut' + 'libero rhoncus, consectetur sem a, sollicitudin lectus.';
|
|
74
|
-
|
|
75
82
|
const WithALongTitle = args => /*#__PURE__*/_react.default.createElement(_noticeBox.NoticeBox, args, "The title text will wrap");
|
|
76
|
-
|
|
77
83
|
exports.WithALongTitle = WithALongTitle;
|
|
78
84
|
WithALongTitle.args = {
|
|
79
85
|
error: true,
|
|
80
86
|
title: text
|
|
81
87
|
};
|
|
82
|
-
|
|
83
88
|
const WithoutTitle = () => /*#__PURE__*/_react.default.createElement(_noticeBox.NoticeBox, null, "This noticebox does not have a title.");
|
|
84
|
-
|
|
85
89
|
exports.WithoutTitle = WithoutTitle;
|
|
86
|
-
|
|
87
90
|
const TitleOnly = () => /*#__PURE__*/_react.default.createElement(_noticeBox.NoticeBox, {
|
|
88
91
|
title: "This noticebox has only a title"
|
|
89
92
|
});
|
|
90
|
-
|
|
91
93
|
exports.TitleOnly = TitleOnly;
|
|
92
|
-
|
|
93
94
|
const RTL = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
94
95
|
dir: "rtl"
|
|
95
96
|
}, /*#__PURE__*/_react.default.createElement(_noticeBox.NoticeBox, args, "\u0647\u0630\u0647 \u0631\u0633\u0627\u0644\u0629 \u0628\u0627\u0644\u0644\u063A\u0629 \u0627\u0644\u0639\u0631\u0628\u064A\u0629."));
|
|
96
|
-
|
|
97
97
|
exports.RTL = RTL;
|
|
98
98
|
RTL.args = {
|
|
99
99
|
title: 'مثال على العنوان'
|
|
@@ -15,13 +15,13 @@ export const NoticeBoxContent = _ref => {
|
|
|
15
15
|
className: _JSXStyle.dynamic([["403435427", [spacers.dp8]]])
|
|
16
16
|
}, /*#__PURE__*/React.createElement(NoticeBoxTitle, {
|
|
17
17
|
title: title,
|
|
18
|
-
dataTest:
|
|
18
|
+
dataTest: `${dataTest}-title`
|
|
19
19
|
}), /*#__PURE__*/React.createElement(NoticeBoxMessage, {
|
|
20
|
-
dataTest:
|
|
20
|
+
dataTest: `${dataTest}-message`
|
|
21
21
|
}, children), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
22
22
|
id: "403435427",
|
|
23
23
|
dynamic: [spacers.dp8]
|
|
24
|
-
}, [
|
|
24
|
+
}, [`div.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;gap:${spacers.dp8};padding-block-start:3px;}`]));
|
|
25
25
|
};
|
|
26
26
|
NoticeBoxContent.defaultProps = {
|
|
27
27
|
dataTest: 'dhis2-uicore-noticebox-content'
|
|
@@ -14,22 +14,18 @@ export const NoticeBoxIcon = _ref => {
|
|
|
14
14
|
// Info is the default icon
|
|
15
15
|
let color = colors.blue900;
|
|
16
16
|
let Icon = IconInfoFilled24;
|
|
17
|
-
|
|
18
17
|
if (valid) {
|
|
19
18
|
color = colors.green700;
|
|
20
19
|
Icon = IconCheckmarkCircle24;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
if (warning) {
|
|
24
22
|
color = colors.yellow700;
|
|
25
23
|
Icon = IconWarningFilled24;
|
|
26
24
|
}
|
|
27
|
-
|
|
28
25
|
if (error) {
|
|
29
26
|
color = colors.red700;
|
|
30
27
|
Icon = IconErrorFilled24;
|
|
31
28
|
}
|
|
32
|
-
|
|
33
29
|
return /*#__PURE__*/React.createElement("div", {
|
|
34
30
|
"data-test": dataTest,
|
|
35
31
|
className: _JSXStyle.dynamic([["1909501516", [spacers.dp12, spacers.dp24]]])
|
|
@@ -39,7 +35,7 @@ export const NoticeBoxIcon = _ref => {
|
|
|
39
35
|
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
40
36
|
id: "1909501516",
|
|
41
37
|
dynamic: [spacers.dp12, spacers.dp24]
|
|
42
|
-
}, [
|
|
38
|
+
}, [`.__jsx-style-dynamic-selector{margin-inline-end:${spacers.dp12};height:${spacers.dp24};}`]));
|
|
43
39
|
};
|
|
44
40
|
NoticeBoxIcon.propTypes = {
|
|
45
41
|
dataTest: PropTypes.string.isRequired,
|
|
@@ -7,18 +7,16 @@ export const NoticeBoxMessage = _ref => {
|
|
|
7
7
|
children,
|
|
8
8
|
dataTest
|
|
9
9
|
} = _ref;
|
|
10
|
-
|
|
11
10
|
if (!children) {
|
|
12
11
|
return null;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
return /*#__PURE__*/React.createElement("div", {
|
|
16
14
|
"data-test": dataTest,
|
|
17
15
|
className: _JSXStyle.dynamic([["3568970766", [colors.grey900]]])
|
|
18
16
|
}, children, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
19
17
|
id: "3568970766",
|
|
20
18
|
dynamic: [colors.grey900]
|
|
21
|
-
}, [
|
|
19
|
+
}, [`div.__jsx-style-dynamic-selector{color:${colors.grey900};font-size:14px;line-height:19px;}`]));
|
|
22
20
|
};
|
|
23
21
|
NoticeBoxMessage.propTypes = {
|
|
24
22
|
dataTest: PropTypes.string.isRequired,
|
|
@@ -7,18 +7,16 @@ export const NoticeBoxTitle = _ref => {
|
|
|
7
7
|
title,
|
|
8
8
|
dataTest
|
|
9
9
|
} = _ref;
|
|
10
|
-
|
|
11
10
|
if (!title) {
|
|
12
11
|
return null;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
13
|
return /*#__PURE__*/React.createElement("h6", {
|
|
16
14
|
"data-test": dataTest,
|
|
17
15
|
className: _JSXStyle.dynamic([["1334557505", [colors.grey900]]])
|
|
18
16
|
}, title, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
19
17
|
id: "1334557505",
|
|
20
18
|
dynamic: [colors.grey900]
|
|
21
|
-
}, [
|
|
19
|
+
}, [`h6.__jsx-style-dynamic-selector{color:${colors.grey900};font-size:14px;font-weight:500;line-height:19px;margin:0;}`]));
|
|
22
20
|
};
|
|
23
21
|
NoticeBoxTitle.propTypes = {
|
|
24
22
|
dataTest: PropTypes.string.isRequired,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NoticeBox } from './notice-box.js';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'NoticeBox'
|
|
5
|
+
};
|
|
6
|
+
export const WithChildren = () => /*#__PURE__*/React.createElement(NoticeBox, null, "The noticebox content");
|
|
7
|
+
export const WithTitle = () => /*#__PURE__*/React.createElement(NoticeBox, {
|
|
8
|
+
title: "The noticebox title"
|
|
9
|
+
});
|
package/build/es/notice-box.js
CHANGED
|
@@ -28,16 +28,16 @@ export const NoticeBox = _ref => {
|
|
|
28
28
|
error: error,
|
|
29
29
|
warning: warning,
|
|
30
30
|
valid: valid,
|
|
31
|
-
dataTest:
|
|
31
|
+
dataTest: `${dataTest}-icon`
|
|
32
32
|
}), /*#__PURE__*/React.createElement("div", {
|
|
33
33
|
className: _JSXStyle.dynamic([["243875418", [colors.blue050, colors.blue200, spacers.dp12, spacers.dp16, colors.yellow050, colors.yellow200, colors.red050, colors.red500, colors.green050, colors.green200]]])
|
|
34
34
|
}, /*#__PURE__*/React.createElement(NoticeBoxContent, {
|
|
35
35
|
title: title,
|
|
36
|
-
dataTest:
|
|
36
|
+
dataTest: `${dataTest}-content`
|
|
37
37
|
}, children)), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
38
38
|
id: "243875418",
|
|
39
39
|
dynamic: [colors.blue050, colors.blue200, spacers.dp12, spacers.dp16, colors.yellow050, colors.yellow200, colors.red050, colors.red500, colors.green050, colors.green200]
|
|
40
|
-
}, [
|
|
40
|
+
}, [`.root.__jsx-style-dynamic-selector{background:${colors.blue050};border:1px solid ${colors.blue200};border-radius:3px;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding-block:${spacers.dp12};padding-inline:${spacers.dp16};}`, `.root.warning.__jsx-style-dynamic-selector{background:${colors.yellow050};border:1px solid ${colors.yellow200};}`, `.root.error.__jsx-style-dynamic-selector{background:${colors.red050};border:2px solid ${colors.red500};}`, `.root.valid.__jsx-style-dynamic-selector{background:${colors.green050};border:1px solid ${colors.green200};}`]));
|
|
41
41
|
};
|
|
42
42
|
NoticeBox.defaultProps = {
|
|
43
43
|
dataTest: 'dhis2-uicore-noticebox'
|
|
@@ -46,14 +46,11 @@ NoticeBox.propTypes = {
|
|
|
46
46
|
children: PropTypes.node,
|
|
47
47
|
className: PropTypes.string,
|
|
48
48
|
dataTest: PropTypes.string,
|
|
49
|
-
|
|
50
49
|
/** Applies 'error' message styles. Mutually exclusive with the `valid` and `warning` props */
|
|
51
50
|
error: mutuallyExclusive(['error', 'valid', 'warning'], PropTypes.bool),
|
|
52
51
|
title: PropTypes.string,
|
|
53
|
-
|
|
54
52
|
/** Applies 'valid' message styles. Mutually exclusive with the `error` and `warning` props */
|
|
55
53
|
valid: mutuallyExclusive(['error', 'valid', 'warning'], PropTypes.bool),
|
|
56
|
-
|
|
57
54
|
/** Applies 'warning' message styles. Mutually exclusive with the `error` and `valid` props */
|
|
58
55
|
warning: mutuallyExclusive(['error', 'valid', 'warning'], PropTypes.bool)
|
|
59
56
|
};
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import { sharedPropTypes } from '@dhis2/ui-constants';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { NoticeBox } from './notice-box.js';
|
|
4
|
-
const subtitle =
|
|
5
|
-
const description =
|
|
4
|
+
const subtitle = `Highlights useful information that is directly relevant to the page the user is viewing`;
|
|
5
|
+
const description = `
|
|
6
|
+
Use a notice box wherever there is important, temporary information about a page or situation that the user needs to be aware of.
|
|
7
|
+
|
|
8
|
+
Notice boxes are different from alert bars in several ways. Notice boxes cannot be dismissed, so they will always display until the situation is resolved. Notice boxes are for highlighting static information or information that is ongoing. Alert bars are suited to alerting a user about something that has just happened.
|
|
9
|
+
|
|
10
|
+
Another way to decide which component to use:
|
|
11
|
+
|
|
12
|
+
- a notice box will usually be displayed when a page loads, before a user takes action
|
|
13
|
+
- an alert bar will usually display in response to an action/event
|
|
14
|
+
|
|
15
|
+
Notice boxes cannot be dismissed, so it is important to provide guidance on how to fix the problem/condition that is causing the notice box to display.
|
|
16
|
+
|
|
17
|
+
Do not use a notice box to display permanent information. If there is information that always will be displayed on a page it should be designed as part of the page itself. Notice boxes are for temporary information.
|
|
18
|
+
|
|
19
|
+
Learn more about Notice Boxes at [Design System: Notice Box](https://github.com/dhis2/design-system/blob/master/molecules/notice-box.md).
|
|
20
|
+
|
|
21
|
+
\`\`\`js
|
|
22
|
+
import { NoticeBox } from '@dhis2/ui'
|
|
23
|
+
\`\`\`
|
|
24
|
+
`;
|
|
6
25
|
export default {
|
|
7
26
|
title: 'Notice Box',
|
|
8
27
|
component: NoticeBox,
|
|
@@ -15,11 +34,14 @@ export default {
|
|
|
15
34
|
}
|
|
16
35
|
},
|
|
17
36
|
argTypes: {
|
|
18
|
-
error: {
|
|
37
|
+
error: {
|
|
38
|
+
...sharedPropTypes.statusArgType
|
|
19
39
|
},
|
|
20
|
-
warning: {
|
|
40
|
+
warning: {
|
|
41
|
+
...sharedPropTypes.statusArgType
|
|
21
42
|
},
|
|
22
|
-
valid: {
|
|
43
|
+
valid: {
|
|
44
|
+
...sharedPropTypes.statusArgType
|
|
23
45
|
}
|
|
24
46
|
}
|
|
25
47
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/notice-box",
|
|
3
|
-
"version": "9.11.
|
|
3
|
+
"version": "9.11.1-beta.1",
|
|
4
4
|
"description": "UI NoticeBox",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,19 +22,19 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"start": "
|
|
25
|
+
"start": "storybook dev -c ../../storybook/config --port 5000",
|
|
26
26
|
"build": "d2-app-scripts build",
|
|
27
27
|
"test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"react": "^16.
|
|
31
|
-
"react-dom": "^16.
|
|
30
|
+
"react": "^16.13",
|
|
31
|
+
"react-dom": "^16.13",
|
|
32
32
|
"styled-jsx": "^4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@dhis2/prop-types": "^3.1.2",
|
|
36
|
-
"@dhis2/ui-constants": "9.11.
|
|
37
|
-
"@dhis2/ui-icons": "9.11.
|
|
36
|
+
"@dhis2/ui-constants": "9.11.1-beta.1",
|
|
37
|
+
"@dhis2/ui-icons": "9.11.1-beta.1",
|
|
38
38
|
"classnames": "^2.3.1",
|
|
39
39
|
"prop-types": "^15.7.2"
|
|
40
40
|
},
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _noticeBox = require("./notice-box.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
(0, _react.storiesOf)('NoticeBox', module).add('With children', () => /*#__PURE__*/_react2.default.createElement(_noticeBox.NoticeBox, null, "The noticebox content")).add('With title', () => /*#__PURE__*/_react2.default.createElement(_noticeBox.NoticeBox, {
|
|
12
|
-
title: "The noticebox title"
|
|
13
|
-
}));
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { storiesOf } from '@storybook/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { NoticeBox } from './notice-box.js';
|
|
4
|
-
storiesOf('NoticeBox', module).add('With children', () => /*#__PURE__*/React.createElement(NoticeBox, null, "The noticebox content")).add('With title', () => /*#__PURE__*/React.createElement(NoticeBox, {
|
|
5
|
-
title: "The noticebox title"
|
|
6
|
-
}));
|