@dhis2-ui/tag 9.10.3 → 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/features/accepts_icon/index.js +0 -1
- package/build/cjs/features/accepts_max_width/index.js +0 -1
- package/build/cjs/features/accepts_text/index.js +0 -1
- package/build/cjs/index.js +0 -1
- package/build/cjs/tag-icon.js +1 -7
- package/build/cjs/tag-text.js +1 -7
- package/build/cjs/tag.e2e.stories.js +26 -0
- package/build/cjs/tag.js +4 -19
- package/build/cjs/{tag.stories.js → tag.prod.stories.js} +28 -34
- package/build/es/tag.e2e.stories.js +14 -0
- package/build/es/tag.js +3 -7
- package/build/es/{tag.stories.js → tag.prod.stories.js} +18 -8
- package/package.json +5 -5
- package/build/cjs/tag.stories.e2e.js +0 -15
- package/build/es/tag.stories.e2e.js +0 -8
|
@@ -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 default Tag is rendered', () => {
|
|
6
5
|
cy.visitStory('Tag', 'Without icon');
|
|
7
6
|
cy.get('[data-test="dhis2-uicore-tag"]').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 tag with the default max width and enough content to fill it completely is rendered', () => {
|
|
6
5
|
cy.wrap('240px').as('maxWidth');
|
|
7
6
|
cy.visitStory('Tag', 'With default max width');
|
|
@@ -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 Tag with text is rendered', () => {
|
|
6
5
|
cy.visitStory('Tag', 'With text');
|
|
7
6
|
cy.get('[data-test="dhis2-uicore-tag"]').should('be.visible');
|
package/build/cjs/index.js
CHANGED
package/build/cjs/tag-icon.js
CHANGED
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TagIcon = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
11
|
const TagIcon = _ref => {
|
|
17
12
|
let {
|
|
18
13
|
children,
|
|
@@ -25,7 +20,6 @@ const TagIcon = _ref => {
|
|
|
25
20
|
id: "1638813748"
|
|
26
21
|
}, [".jsx-1638813748{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;margin-inline-end:4px;max-height:16px;max-width:16px;}"]));
|
|
27
22
|
};
|
|
28
|
-
|
|
29
23
|
exports.TagIcon = TagIcon;
|
|
30
24
|
TagIcon.propTypes = {
|
|
31
25
|
dataTest: _propTypes.default.string.isRequired,
|
package/build/cjs/tag-text.js
CHANGED
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TagText = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireDefault(require("react"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
11
|
const TagText = _ref => {
|
|
17
12
|
let {
|
|
18
13
|
children,
|
|
@@ -25,7 +20,6 @@ const TagText = _ref => {
|
|
|
25
20
|
id: "1110058759"
|
|
26
21
|
}, [".jsx-1110058759{overflow:hidden;white-space:nowrap;text-overflow:ellipsis;}"]));
|
|
27
22
|
};
|
|
28
|
-
|
|
29
23
|
exports.TagText = TagText;
|
|
30
24
|
TagText.propTypes = {
|
|
31
25
|
dataTest: _propTypes.default.string.isRequired,
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithoutIcon = exports.WithText = exports.WithIcon = exports.WithDefaultMaxWidth = exports.WithCustomMaxWidth = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _tag = require("./tag.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
var _default = exports.default = {
|
|
11
|
+
title: 'Tag'
|
|
12
|
+
};
|
|
13
|
+
const WithoutIcon = () => /*#__PURE__*/_react.default.createElement(_tag.Tag, null, "Default");
|
|
14
|
+
exports.WithoutIcon = WithoutIcon;
|
|
15
|
+
const WithIcon = () => /*#__PURE__*/_react.default.createElement(_tag.Tag, {
|
|
16
|
+
icon: /*#__PURE__*/_react.default.createElement("span", null, "Icon")
|
|
17
|
+
}, "Default");
|
|
18
|
+
exports.WithIcon = WithIcon;
|
|
19
|
+
const WithText = () => /*#__PURE__*/_react.default.createElement(_tag.Tag, null, "Text content");
|
|
20
|
+
exports.WithText = WithText;
|
|
21
|
+
const WithDefaultMaxWidth = () => /*#__PURE__*/_react.default.createElement(_tag.Tag, null, "This is a lot of content that should exceed the default max width of the tag component quite significantly so testing is still works when the default value of the max width is changed");
|
|
22
|
+
exports.WithDefaultMaxWidth = WithDefaultMaxWidth;
|
|
23
|
+
const WithCustomMaxWidth = () => /*#__PURE__*/_react.default.createElement(_tag.Tag, {
|
|
24
|
+
maxWidth: "30px"
|
|
25
|
+
}, "Text content");
|
|
26
|
+
exports.WithCustomMaxWidth = WithCustomMaxWidth;
|
package/build/cjs/tag.js
CHANGED
|
@@ -4,25 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Tag = 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 _tagIcon = require("./tag-icon.js");
|
|
21
|
-
|
|
22
14
|
var _tagText = require("./tag-text.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 Tag = _ref => {
|
|
27
17
|
let {
|
|
28
18
|
maxWidth,
|
|
@@ -44,15 +34,14 @@ const Tag = _ref => {
|
|
|
44
34
|
bold
|
|
45
35
|
}) || "")
|
|
46
36
|
}, icon && /*#__PURE__*/_react.default.createElement(_tagIcon.TagIcon, {
|
|
47
|
-
dataTest:
|
|
37
|
+
dataTest: `${dataTest}-icon`
|
|
48
38
|
}, icon), /*#__PURE__*/_react.default.createElement(_tagText.TagText, {
|
|
49
|
-
dataTest:
|
|
39
|
+
dataTest: `${dataTest}-text`
|
|
50
40
|
}, children), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
51
41
|
id: "2409336266",
|
|
52
42
|
dynamic: [_uiConstants.colors.grey300, _uiConstants.colors.grey700, _uiConstants.colors.grey900, maxWidth, _uiConstants.colors.red100, _uiConstants.colors.red800, _uiConstants.colors.red900, _uiConstants.colors.blue100, _uiConstants.colors.blue800, _uiConstants.colors.blue900, _uiConstants.colors.green100, _uiConstants.colors.green800, _uiConstants.colors.green900, _uiConstants.colors.grey700, _uiConstants.colors.white, _uiConstants.colors.white, _uiConstants.colors.blue800, _uiConstants.colors.blue050, _uiConstants.colors.white, _uiConstants.colors.green700, _uiConstants.colors.green050, _uiConstants.colors.white, _uiConstants.colors.red700, _uiConstants.colors.red050, _uiConstants.colors.white]
|
|
53
|
-
}, [
|
|
43
|
+
}, [`div.__jsx-style-dynamic-selector{padding:5px 6px;border-radius:3px;background-color:${_uiConstants.colors.grey300};fill:${_uiConstants.colors.grey700};color:${_uiConstants.colors.grey900};max-width:${maxWidth};display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;font-size:13px;height:23px;}`, `.negative.__jsx-style-dynamic-selector{background-color:${_uiConstants.colors.red100};fill:${_uiConstants.colors.red800};color:${_uiConstants.colors.red900};}`, `.neutral.__jsx-style-dynamic-selector{background-color:${_uiConstants.colors.blue100};fill:${_uiConstants.colors.blue800};color:${_uiConstants.colors.blue900};}`, `.positive.__jsx-style-dynamic-selector{background-color:${_uiConstants.colors.green100};fill:${_uiConstants.colors.green800};color:${_uiConstants.colors.green900};}`, `.bold.__jsx-style-dynamic-selector{font-weight:700;background-color:${_uiConstants.colors.grey700};color:${_uiConstants.colors.white};fill:${_uiConstants.colors.white};}`, `.bold.neutral.__jsx-style-dynamic-selector{background-color:${_uiConstants.colors.blue800};color:${_uiConstants.colors.blue050};fill:${_uiConstants.colors.white};}`, `.bold.positive.__jsx-style-dynamic-selector{background-color:${_uiConstants.colors.green700};color:${_uiConstants.colors.green050};fill:${_uiConstants.colors.white};}`, `.bold.negative.__jsx-style-dynamic-selector{background-color:${_uiConstants.colors.red700};color:${_uiConstants.colors.red050};fill:${_uiConstants.colors.white};}`]));
|
|
54
44
|
};
|
|
55
|
-
|
|
56
45
|
exports.Tag = Tag;
|
|
57
46
|
const tagVariantPropType = (0, _propTypes.mutuallyExclusive)(['neutral', 'positive', 'negative'], _propTypes2.default.bool);
|
|
58
47
|
Tag.defaultProps = {
|
|
@@ -65,17 +54,13 @@ Tag.propTypes = {
|
|
|
65
54
|
children: _propTypes2.default.node,
|
|
66
55
|
className: _propTypes2.default.string,
|
|
67
56
|
dataTest: _propTypes2.default.string,
|
|
68
|
-
|
|
69
57
|
/** Tags can contain icons. Use icons where they will help users easily identify the content of the tag. Tags must have a text label and cannot display only an icon. */
|
|
70
58
|
icon: _propTypes2.default.node,
|
|
71
59
|
maxWidth: _propTypes2.default.string,
|
|
72
|
-
|
|
73
60
|
/** Red 'negative' tags imply an error or a problem. `neutral`, `positive`, and `negative` are mutually exclusive props */
|
|
74
61
|
negative: tagVariantPropType,
|
|
75
|
-
|
|
76
62
|
/** Blue 'neutral' tags are used when a tag _could_ have valid or error status but is currently neutral. `neutral`, `positive`, and `negative` are mutually exclusive props */
|
|
77
63
|
neutral: tagVariantPropType,
|
|
78
|
-
|
|
79
64
|
/** Green 'valid' tags should be used to indicate validity or success. `neutral`, `positive`, and `negative` are mutually exclusive props */
|
|
80
65
|
positive: tagVariantPropType
|
|
81
66
|
};
|
|
@@ -4,15 +4,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.WithLargeIcon = exports.WithIcon = exports.WithClippedTextAndMaxWidth = exports.WithClippedLongText = exports.RTL = exports.Positive = exports.Neutral = exports.Negative = exports.Default = exports.Bold = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _tag = require("./tag.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const subtitle = 'Used to display categorizing labels or information for other elements in a collection.';
|
|
11
|
+
const description = `
|
|
12
|
+
Tags are used whenever an element in a collection needs to display its category or status. Tags should not be used for one-off, unique information. Tags can be displayed in any kind of component.
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
Tags are useful when displaying multiple elements in a collection that have the same basic attributes but belong to different categories or have different statuses. Do not use tags for elements that will always be the same, instead use a heading or other grouping method.
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
Tags are never used for primary interaction and should not be used as buttons. Clicking a tag could sort a collection by that tag, or open a page to display all elements that have that tag type. Tags should not be used as navigation elements.
|
|
17
|
+
|
|
18
|
+
\`\`\`js
|
|
19
|
+
import { Tag } from '@dhis2/ui'
|
|
20
|
+
\`\`\`
|
|
21
|
+
|
|
22
|
+
`;
|
|
16
23
|
const tagArgType = {
|
|
17
24
|
table: {
|
|
18
25
|
type: {
|
|
@@ -23,7 +30,7 @@ const tagArgType = {
|
|
|
23
30
|
type: 'boolean'
|
|
24
31
|
}
|
|
25
32
|
};
|
|
26
|
-
var _default = {
|
|
33
|
+
var _default = exports.default = {
|
|
27
34
|
title: 'Tag',
|
|
28
35
|
component: _tag.Tag,
|
|
29
36
|
parameters: {
|
|
@@ -35,19 +42,20 @@ var _default = {
|
|
|
35
42
|
}
|
|
36
43
|
},
|
|
37
44
|
argTypes: {
|
|
38
|
-
negative: {
|
|
45
|
+
negative: {
|
|
46
|
+
...tagArgType
|
|
39
47
|
},
|
|
40
|
-
neutral: {
|
|
48
|
+
neutral: {
|
|
49
|
+
...tagArgType
|
|
41
50
|
},
|
|
42
|
-
positive: {
|
|
51
|
+
positive: {
|
|
52
|
+
...tagArgType
|
|
43
53
|
}
|
|
44
54
|
},
|
|
45
55
|
args: {
|
|
46
56
|
children: 'Dog'
|
|
47
57
|
}
|
|
48
58
|
};
|
|
49
|
-
exports.default = _default;
|
|
50
|
-
|
|
51
59
|
const ExampleIcon = () => /*#__PURE__*/_react.default.createElement("svg", {
|
|
52
60
|
height: "12",
|
|
53
61
|
viewBox: "0 0 12 12",
|
|
@@ -68,7 +76,6 @@ const ExampleIcon = () => /*#__PURE__*/_react.default.createElement("svg", {
|
|
|
68
76
|
cy: "9.5",
|
|
69
77
|
r: "1"
|
|
70
78
|
})));
|
|
71
|
-
|
|
72
79
|
const ExampleLargeIcon = () => /*#__PURE__*/_react.default.createElement("svg", {
|
|
73
80
|
height: "24",
|
|
74
81
|
viewBox: "0 0 24 24",
|
|
@@ -78,58 +85,45 @@ const ExampleLargeIcon = () => /*#__PURE__*/_react.default.createElement("svg",
|
|
|
78
85
|
d: "m12 2c-5.52 0-10 4.48-10 10s4.48 10 10 10 10-4.48 10-10-4.48-10-10-10zm0 14.5c-2.49 0-4.5-2.01-4.5-4.5s2.01-4.5 4.5-4.5 4.5 2.01 4.5 4.5-2.01 4.5-4.5 4.5zm0-5.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z",
|
|
79
86
|
fill: "inherit"
|
|
80
87
|
}));
|
|
81
|
-
|
|
82
88
|
const Template = args => /*#__PURE__*/_react.default.createElement(_tag.Tag, args);
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
exports.Default = Default;
|
|
86
|
-
const WithIcon = Template.bind({});
|
|
87
|
-
exports.WithIcon = WithIcon;
|
|
89
|
+
const Default = exports.Default = Template.bind({});
|
|
90
|
+
const WithIcon = exports.WithIcon = Template.bind({});
|
|
88
91
|
WithIcon.args = {
|
|
89
92
|
icon: /*#__PURE__*/_react.default.createElement(ExampleIcon, null)
|
|
90
93
|
};
|
|
91
|
-
const Neutral = Template.bind({});
|
|
92
|
-
exports.Neutral = Neutral;
|
|
94
|
+
const Neutral = exports.Neutral = Template.bind({});
|
|
93
95
|
Neutral.args = {
|
|
94
96
|
neutral: true
|
|
95
97
|
};
|
|
96
|
-
const Positive = Template.bind({});
|
|
97
|
-
exports.Positive = Positive;
|
|
98
|
+
const Positive = exports.Positive = Template.bind({});
|
|
98
99
|
Positive.args = {
|
|
99
100
|
positive: true
|
|
100
101
|
};
|
|
101
|
-
const Negative = Template.bind({});
|
|
102
|
-
exports.Negative = Negative;
|
|
102
|
+
const Negative = exports.Negative = Template.bind({});
|
|
103
103
|
Negative.args = {
|
|
104
104
|
negative: true
|
|
105
105
|
};
|
|
106
|
-
const Bold = Template.bind({});
|
|
107
|
-
exports.Bold = Bold;
|
|
106
|
+
const Bold = exports.Bold = Template.bind({});
|
|
108
107
|
Bold.args = {
|
|
109
108
|
bold: true
|
|
110
109
|
};
|
|
111
|
-
const WithLargeIcon = Template.bind({});
|
|
112
|
-
exports.WithLargeIcon = WithLargeIcon;
|
|
110
|
+
const WithLargeIcon = exports.WithLargeIcon = Template.bind({});
|
|
113
111
|
WithLargeIcon.args = {
|
|
114
112
|
icon: /*#__PURE__*/_react.default.createElement(ExampleLargeIcon, null)
|
|
115
113
|
};
|
|
116
|
-
const WithClippedLongText = Template.bind({});
|
|
117
|
-
exports.WithClippedLongText = WithClippedLongText;
|
|
114
|
+
const WithClippedLongText = exports.WithClippedLongText = Template.bind({});
|
|
118
115
|
WithClippedLongText.args = {
|
|
119
116
|
icon: /*#__PURE__*/_react.default.createElement(ExampleIcon, null),
|
|
120
117
|
children: 'I am long text, therefore I get clipped before I finish'
|
|
121
118
|
};
|
|
122
|
-
const WithClippedTextAndMaxWidth = Template.bind({});
|
|
123
|
-
exports.WithClippedTextAndMaxWidth = WithClippedTextAndMaxWidth;
|
|
119
|
+
const WithClippedTextAndMaxWidth = exports.WithClippedTextAndMaxWidth = Template.bind({});
|
|
124
120
|
WithClippedTextAndMaxWidth.args = {
|
|
125
121
|
children: 'I am long text',
|
|
126
122
|
maxWidth: '50px'
|
|
127
123
|
};
|
|
128
|
-
|
|
129
124
|
const RTL = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
130
125
|
dir: "rtl"
|
|
131
126
|
}, /*#__PURE__*/_react.default.createElement(Template, args));
|
|
132
|
-
|
|
133
127
|
exports.RTL = RTL;
|
|
134
128
|
RTL.args = {
|
|
135
129
|
icon: /*#__PURE__*/_react.default.createElement(ExampleIcon, null)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tag } from './tag.js';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Tag'
|
|
5
|
+
};
|
|
6
|
+
export const WithoutIcon = () => /*#__PURE__*/React.createElement(Tag, null, "Default");
|
|
7
|
+
export const WithIcon = () => /*#__PURE__*/React.createElement(Tag, {
|
|
8
|
+
icon: /*#__PURE__*/React.createElement("span", null, "Icon")
|
|
9
|
+
}, "Default");
|
|
10
|
+
export const WithText = () => /*#__PURE__*/React.createElement(Tag, null, "Text content");
|
|
11
|
+
export const WithDefaultMaxWidth = () => /*#__PURE__*/React.createElement(Tag, null, "This is a lot of content that should exceed the default max width of the tag component quite significantly so testing is still works when the default value of the max width is changed");
|
|
12
|
+
export const WithCustomMaxWidth = () => /*#__PURE__*/React.createElement(Tag, {
|
|
13
|
+
maxWidth: "30px"
|
|
14
|
+
}, "Text content");
|
package/build/es/tag.js
CHANGED
|
@@ -27,13 +27,13 @@ export const Tag = _ref => {
|
|
|
27
27
|
bold
|
|
28
28
|
}) || "")
|
|
29
29
|
}, icon && /*#__PURE__*/React.createElement(TagIcon, {
|
|
30
|
-
dataTest:
|
|
30
|
+
dataTest: `${dataTest}-icon`
|
|
31
31
|
}, icon), /*#__PURE__*/React.createElement(TagText, {
|
|
32
|
-
dataTest:
|
|
32
|
+
dataTest: `${dataTest}-text`
|
|
33
33
|
}, children), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
34
34
|
id: "2409336266",
|
|
35
35
|
dynamic: [colors.grey300, colors.grey700, colors.grey900, maxWidth, colors.red100, colors.red800, colors.red900, colors.blue100, colors.blue800, colors.blue900, colors.green100, colors.green800, colors.green900, colors.grey700, colors.white, colors.white, colors.blue800, colors.blue050, colors.white, colors.green700, colors.green050, colors.white, colors.red700, colors.red050, colors.white]
|
|
36
|
-
}, [
|
|
36
|
+
}, [`div.__jsx-style-dynamic-selector{padding:5px 6px;border-radius:3px;background-color:${colors.grey300};fill:${colors.grey700};color:${colors.grey900};max-width:${maxWidth};display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;font-size:13px;height:23px;}`, `.negative.__jsx-style-dynamic-selector{background-color:${colors.red100};fill:${colors.red800};color:${colors.red900};}`, `.neutral.__jsx-style-dynamic-selector{background-color:${colors.blue100};fill:${colors.blue800};color:${colors.blue900};}`, `.positive.__jsx-style-dynamic-selector{background-color:${colors.green100};fill:${colors.green800};color:${colors.green900};}`, `.bold.__jsx-style-dynamic-selector{font-weight:700;background-color:${colors.grey700};color:${colors.white};fill:${colors.white};}`, `.bold.neutral.__jsx-style-dynamic-selector{background-color:${colors.blue800};color:${colors.blue050};fill:${colors.white};}`, `.bold.positive.__jsx-style-dynamic-selector{background-color:${colors.green700};color:${colors.green050};fill:${colors.white};}`, `.bold.negative.__jsx-style-dynamic-selector{background-color:${colors.red700};color:${colors.red050};fill:${colors.white};}`]));
|
|
37
37
|
};
|
|
38
38
|
const tagVariantPropType = mutuallyExclusive(['neutral', 'positive', 'negative'], PropTypes.bool);
|
|
39
39
|
Tag.defaultProps = {
|
|
@@ -46,17 +46,13 @@ Tag.propTypes = {
|
|
|
46
46
|
children: PropTypes.node,
|
|
47
47
|
className: PropTypes.string,
|
|
48
48
|
dataTest: PropTypes.string,
|
|
49
|
-
|
|
50
49
|
/** Tags can contain icons. Use icons where they will help users easily identify the content of the tag. Tags must have a text label and cannot display only an icon. */
|
|
51
50
|
icon: PropTypes.node,
|
|
52
51
|
maxWidth: PropTypes.string,
|
|
53
|
-
|
|
54
52
|
/** Red 'negative' tags imply an error or a problem. `neutral`, `positive`, and `negative` are mutually exclusive props */
|
|
55
53
|
negative: tagVariantPropType,
|
|
56
|
-
|
|
57
54
|
/** Blue 'neutral' tags are used when a tag _could_ have valid or error status but is currently neutral. `neutral`, `positive`, and `negative` are mutually exclusive props */
|
|
58
55
|
neutral: tagVariantPropType,
|
|
59
|
-
|
|
60
56
|
/** Green 'valid' tags should be used to indicate validity or success. `neutral`, `positive`, and `negative` are mutually exclusive props */
|
|
61
57
|
positive: tagVariantPropType
|
|
62
58
|
};
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Tag } from './tag.js';
|
|
3
3
|
const subtitle = 'Used to display categorizing labels or information for other elements in a collection.';
|
|
4
|
-
const description =
|
|
4
|
+
const description = `
|
|
5
|
+
Tags are used whenever an element in a collection needs to display its category or status. Tags should not be used for one-off, unique information. Tags can be displayed in any kind of component.
|
|
6
|
+
|
|
7
|
+
Tags are useful when displaying multiple elements in a collection that have the same basic attributes but belong to different categories or have different statuses. Do not use tags for elements that will always be the same, instead use a heading or other grouping method.
|
|
8
|
+
|
|
9
|
+
Tags are never used for primary interaction and should not be used as buttons. Clicking a tag could sort a collection by that tag, or open a page to display all elements that have that tag type. Tags should not be used as navigation elements.
|
|
10
|
+
|
|
11
|
+
\`\`\`js
|
|
12
|
+
import { Tag } from '@dhis2/ui'
|
|
13
|
+
\`\`\`
|
|
14
|
+
|
|
15
|
+
`;
|
|
5
16
|
const tagArgType = {
|
|
6
17
|
table: {
|
|
7
18
|
type: {
|
|
@@ -24,18 +35,20 @@ export default {
|
|
|
24
35
|
}
|
|
25
36
|
},
|
|
26
37
|
argTypes: {
|
|
27
|
-
negative: {
|
|
38
|
+
negative: {
|
|
39
|
+
...tagArgType
|
|
28
40
|
},
|
|
29
|
-
neutral: {
|
|
41
|
+
neutral: {
|
|
42
|
+
...tagArgType
|
|
30
43
|
},
|
|
31
|
-
positive: {
|
|
44
|
+
positive: {
|
|
45
|
+
...tagArgType
|
|
32
46
|
}
|
|
33
47
|
},
|
|
34
48
|
args: {
|
|
35
49
|
children: 'Dog'
|
|
36
50
|
}
|
|
37
51
|
};
|
|
38
|
-
|
|
39
52
|
const ExampleIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
40
53
|
height: "12",
|
|
41
54
|
viewBox: "0 0 12 12",
|
|
@@ -56,7 +69,6 @@ const ExampleIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
|
56
69
|
cy: "9.5",
|
|
57
70
|
r: "1"
|
|
58
71
|
})));
|
|
59
|
-
|
|
60
72
|
const ExampleLargeIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
61
73
|
height: "24",
|
|
62
74
|
viewBox: "0 0 24 24",
|
|
@@ -66,9 +78,7 @@ const ExampleLargeIcon = () => /*#__PURE__*/React.createElement("svg", {
|
|
|
66
78
|
d: "m12 2c-5.52 0-10 4.48-10 10s4.48 10 10 10 10-4.48 10-10-4.48-10-10-10zm0 14.5c-2.49 0-4.5-2.01-4.5-4.5s2.01-4.5 4.5-4.5 4.5 2.01 4.5 4.5-2.01 4.5-4.5 4.5zm0-5.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1z",
|
|
67
79
|
fill: "inherit"
|
|
68
80
|
}));
|
|
69
|
-
|
|
70
81
|
const Template = args => /*#__PURE__*/React.createElement(Tag, args);
|
|
71
|
-
|
|
72
82
|
export const Default = Template.bind({});
|
|
73
83
|
export const WithIcon = Template.bind({});
|
|
74
84
|
WithIcon.args = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/tag",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.11.1-beta.1",
|
|
4
4
|
"description": "UI Tag",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,18 +22,18 @@
|
|
|
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.
|
|
36
|
+
"@dhis2/ui-constants": "9.11.1-beta.1",
|
|
37
37
|
"classnames": "^2.3.1",
|
|
38
38
|
"prop-types": "^15.7.2"
|
|
39
39
|
},
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _tag = require("./tag.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
(0, _react.storiesOf)('Tag', module).add('Without icon', () => /*#__PURE__*/_react2.default.createElement(_tag.Tag, null, "Default")).add('With icon', () => /*#__PURE__*/_react2.default.createElement(_tag.Tag, {
|
|
12
|
-
icon: /*#__PURE__*/_react2.default.createElement("span", null, "Icon")
|
|
13
|
-
}, "Default")).add('With text', () => /*#__PURE__*/_react2.default.createElement(_tag.Tag, null, "Text content")).add('With default max width', () => /*#__PURE__*/_react2.default.createElement(_tag.Tag, null, "This is a lot of content that should exceed the default max width of the tag component quite significantly so testing is still works when the default value of the max width is changed")).add('With custom max width', () => /*#__PURE__*/_react2.default.createElement(_tag.Tag, {
|
|
14
|
-
maxWidth: "30px"
|
|
15
|
-
}, "Text content"));
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { storiesOf } from '@storybook/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Tag } from './tag.js';
|
|
4
|
-
storiesOf('Tag', module).add('Without icon', () => /*#__PURE__*/React.createElement(Tag, null, "Default")).add('With icon', () => /*#__PURE__*/React.createElement(Tag, {
|
|
5
|
-
icon: /*#__PURE__*/React.createElement("span", null, "Icon")
|
|
6
|
-
}, "Default")).add('With text', () => /*#__PURE__*/React.createElement(Tag, null, "Text content")).add('With default max width', () => /*#__PURE__*/React.createElement(Tag, null, "This is a lot of content that should exceed the default max width of the tag component quite significantly so testing is still works when the default value of the max width is changed")).add('With custom max width', () => /*#__PURE__*/React.createElement(Tag, {
|
|
7
|
-
maxWidth: "30px"
|
|
8
|
-
}, "Text content"));
|