@atlaskit/inline-message 11.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +709 -0
- package/LICENSE +13 -0
- package/README.md +11 -0
- package/__perf__/default.tsx +14 -0
- package/constants/package.json +7 -0
- package/dist/cjs/components/inline-message/index.js +220 -0
- package/dist/cjs/components/message-icon/index.js +86 -0
- package/dist/cjs/constants.js +44 -0
- package/dist/cjs/index.js +15 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/version.json +5 -0
- package/dist/es2019/components/inline-message/index.js +182 -0
- package/dist/es2019/components/message-icon/index.js +72 -0
- package/dist/es2019/constants.js +28 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/version.json +5 -0
- package/dist/esm/components/inline-message/index.js +196 -0
- package/dist/esm/components/message-icon/index.js +68 -0
- package/dist/esm/constants.js +28 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/version.json +5 -0
- package/dist/types/components/inline-message/index.d.ts +68 -0
- package/dist/types/components/message-icon/index.d.ts +16 -0
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types.d.ts +9 -0
- package/package.json +70 -0
- package/types/package.json +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2019 Atlassian Pty Ltd
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Inline message
|
|
2
|
+
|
|
3
|
+
An inline message lets users know when important information is available or when an action is required.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
yarn add @atlaskit/inline-message
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Detailed docs and example usage can be found [here](https://atlaskit.atlassian.com/packages/core/inline-message).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import InlineMessage from '../src';
|
|
4
|
+
|
|
5
|
+
export default () => (
|
|
6
|
+
<div>
|
|
7
|
+
<InlineMessage
|
|
8
|
+
title="Inline Message Title Example"
|
|
9
|
+
secondaryText="Secondary Text"
|
|
10
|
+
>
|
|
11
|
+
<p>Primary and secondary text dialog</p>
|
|
12
|
+
</InlineMessage>
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _react = require("react");
|
|
15
|
+
|
|
16
|
+
var _core = require("@emotion/core");
|
|
17
|
+
|
|
18
|
+
var _customThemeButton = _interopRequireDefault(require("@atlaskit/button/custom-theme-button"));
|
|
19
|
+
|
|
20
|
+
var _inlineDialog = _interopRequireDefault(require("@atlaskit/inline-dialog"));
|
|
21
|
+
|
|
22
|
+
var colors = _interopRequireWildcard(require("@atlaskit/theme/colors"));
|
|
23
|
+
|
|
24
|
+
var _components = require("@atlaskit/theme/components");
|
|
25
|
+
|
|
26
|
+
var _constants = require("../../constants");
|
|
27
|
+
|
|
28
|
+
var _messageIcon = _interopRequireDefault(require("../message-icon"));
|
|
29
|
+
|
|
30
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
+
|
|
32
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
+
|
|
34
|
+
/** @jsx jsx */
|
|
35
|
+
var buttonContentsStyles = (0, _core.css)({
|
|
36
|
+
display: 'flex',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
textDecoration: 'none'
|
|
39
|
+
});
|
|
40
|
+
var titleStyles = (0, _core.css)({
|
|
41
|
+
padding: "0 ".concat(_constants.itemSpacing, "px"),
|
|
42
|
+
fontWeight: 500
|
|
43
|
+
});
|
|
44
|
+
var textStyles = (0, _core.css)({
|
|
45
|
+
padding: "0 ".concat(_constants.itemSpacing, "px"),
|
|
46
|
+
overflow: 'hidden',
|
|
47
|
+
textOverflow: 'ellipsis',
|
|
48
|
+
whiteSpace: 'nowrap'
|
|
49
|
+
});
|
|
50
|
+
var rootStyles = (0, _core.css)({
|
|
51
|
+
display: 'inline-block',
|
|
52
|
+
maxWidth: '100%',
|
|
53
|
+
'&:focus': {
|
|
54
|
+
outline: '1px solid'
|
|
55
|
+
},
|
|
56
|
+
'&:hover': {
|
|
57
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
58
|
+
'[data-ds--inline-message--icon]': {
|
|
59
|
+
color: 'var(--icon-accent-color)'
|
|
60
|
+
},
|
|
61
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
62
|
+
'[data-ds--inline-message--button]': {
|
|
63
|
+
textDecoration: 'underline'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
var titleColor = (0, _components.themed)({
|
|
68
|
+
light: colors.N600,
|
|
69
|
+
dark: colors.DN600
|
|
70
|
+
});
|
|
71
|
+
var textColor = (0, _components.themed)({
|
|
72
|
+
light: colors.N300,
|
|
73
|
+
dark: colors.DN100
|
|
74
|
+
});
|
|
75
|
+
var rootFocusColor = (0, _components.themed)('appearance', {
|
|
76
|
+
connectivity: {
|
|
77
|
+
light: colors.B500,
|
|
78
|
+
dark: colors.B200
|
|
79
|
+
},
|
|
80
|
+
confirmation: {
|
|
81
|
+
light: colors.G400,
|
|
82
|
+
dark: colors.G400
|
|
83
|
+
},
|
|
84
|
+
info: {
|
|
85
|
+
light: colors.P500,
|
|
86
|
+
dark: colors.P300
|
|
87
|
+
},
|
|
88
|
+
warning: {
|
|
89
|
+
light: colors.Y500,
|
|
90
|
+
dark: colors.Y500
|
|
91
|
+
},
|
|
92
|
+
error: {
|
|
93
|
+
light: colors.R500,
|
|
94
|
+
dark: colors.R500
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
var iconColor = (0, _components.themed)('appearance', {
|
|
98
|
+
connectivity: {
|
|
99
|
+
light: colors.B300,
|
|
100
|
+
dark: colors.B75
|
|
101
|
+
},
|
|
102
|
+
confirmation: {
|
|
103
|
+
light: colors.G200,
|
|
104
|
+
dark: colors.G200
|
|
105
|
+
},
|
|
106
|
+
info: {
|
|
107
|
+
light: colors.P200,
|
|
108
|
+
dark: colors.P200
|
|
109
|
+
},
|
|
110
|
+
warning: {
|
|
111
|
+
light: colors.Y200,
|
|
112
|
+
dark: colors.Y200
|
|
113
|
+
},
|
|
114
|
+
error: {
|
|
115
|
+
light: colors.R300,
|
|
116
|
+
dark: colors.R300
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
/**
|
|
120
|
+
* __Inline message__
|
|
121
|
+
*
|
|
122
|
+
* An inline message lets users know when important information is available or when an action is required.
|
|
123
|
+
*
|
|
124
|
+
* - [Examples](https://atlassian.design/components/inline-message/examples)
|
|
125
|
+
* - [Code](https://atlassian.design/components/inline-message/code)
|
|
126
|
+
* - [Usage](https://atlassian.design/components/inline-message/usage)
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
*
|
|
130
|
+
* ```jsx
|
|
131
|
+
* const Component = () => (
|
|
132
|
+
* <InlineMessage
|
|
133
|
+
* title="Inline Message Title Example"
|
|
134
|
+
* secondaryText="Secondary Text"
|
|
135
|
+
* >
|
|
136
|
+
* <p>Some text that would be inside the open dialog and otherwise hidden.</p>
|
|
137
|
+
* </InlineMessage>
|
|
138
|
+
* );
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
|
|
142
|
+
var InlineMessage = function InlineMessage(_ref) {
|
|
143
|
+
var _ref$placement = _ref.placement,
|
|
144
|
+
placement = _ref$placement === void 0 ? 'bottom-start' : _ref$placement,
|
|
145
|
+
_ref$secondaryText = _ref.secondaryText,
|
|
146
|
+
secondaryText = _ref$secondaryText === void 0 ? '' : _ref$secondaryText,
|
|
147
|
+
_ref$title = _ref.title,
|
|
148
|
+
title = _ref$title === void 0 ? '' : _ref$title,
|
|
149
|
+
_ref$type = _ref.type,
|
|
150
|
+
type = _ref$type === void 0 ? 'connectivity' : _ref$type,
|
|
151
|
+
children = _ref.children,
|
|
152
|
+
testId = _ref.testId,
|
|
153
|
+
iconLabel = _ref.iconLabel;
|
|
154
|
+
|
|
155
|
+
var _useState = (0, _react.useState)(false),
|
|
156
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
157
|
+
isOpen = _useState2[0],
|
|
158
|
+
setIsOpen = _useState2[1];
|
|
159
|
+
|
|
160
|
+
var toggleDialog = (0, _react.useCallback)(function () {
|
|
161
|
+
setIsOpen(function (oldState) {
|
|
162
|
+
return !oldState;
|
|
163
|
+
});
|
|
164
|
+
}, [setIsOpen]);
|
|
165
|
+
var onCloseDialog = (0, _react.useCallback)(function () {
|
|
166
|
+
return setIsOpen(false);
|
|
167
|
+
}, [setIsOpen]);
|
|
168
|
+
var theme = (0, _components.useGlobalTheme)();
|
|
169
|
+
return (0, _core.jsx)("div", {
|
|
170
|
+
css: rootStyles,
|
|
171
|
+
style: {
|
|
172
|
+
outlineColor: rootFocusColor({
|
|
173
|
+
appearance: type,
|
|
174
|
+
theme: theme
|
|
175
|
+
}),
|
|
176
|
+
'--icon-accent-color': iconColor({
|
|
177
|
+
appearance: type,
|
|
178
|
+
theme: theme
|
|
179
|
+
})
|
|
180
|
+
},
|
|
181
|
+
"data-testid": testId
|
|
182
|
+
}, (0, _core.jsx)(_inlineDialog.default, {
|
|
183
|
+
onClose: onCloseDialog,
|
|
184
|
+
content: children,
|
|
185
|
+
isOpen: isOpen,
|
|
186
|
+
placement: placement,
|
|
187
|
+
testId: testId && "".concat(testId, "--inline-dialog")
|
|
188
|
+
}, (0, _core.jsx)(_customThemeButton.default, {
|
|
189
|
+
"data-ds--inline-message--button": true,
|
|
190
|
+
appearance: "subtle-link",
|
|
191
|
+
onClick: toggleDialog,
|
|
192
|
+
spacing: "none",
|
|
193
|
+
testId: testId && "".concat(testId, "--button")
|
|
194
|
+
}, (0, _core.jsx)("div", {
|
|
195
|
+
css: buttonContentsStyles
|
|
196
|
+
}, (0, _core.jsx)(_messageIcon.default, {
|
|
197
|
+
isOpen: isOpen,
|
|
198
|
+
appearance: type,
|
|
199
|
+
label: iconLabel
|
|
200
|
+
}), title && (0, _core.jsx)("span", {
|
|
201
|
+
style: {
|
|
202
|
+
color: titleColor({
|
|
203
|
+
theme: theme
|
|
204
|
+
})
|
|
205
|
+
},
|
|
206
|
+
css: titleStyles,
|
|
207
|
+
"data-testid": testId && "".concat(testId, "--title")
|
|
208
|
+
}, title), secondaryText && (0, _core.jsx)("span", {
|
|
209
|
+
style: {
|
|
210
|
+
color: textColor({
|
|
211
|
+
theme: theme
|
|
212
|
+
})
|
|
213
|
+
},
|
|
214
|
+
css: textStyles,
|
|
215
|
+
"data-testid": testId && "".concat(testId, "--text")
|
|
216
|
+
}, secondaryText)))));
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
var _default = InlineMessage;
|
|
220
|
+
exports.default = _default;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _core = require("@emotion/core");
|
|
11
|
+
|
|
12
|
+
var colors = _interopRequireWildcard(require("@atlaskit/theme/colors"));
|
|
13
|
+
|
|
14
|
+
var _components = require("@atlaskit/theme/components");
|
|
15
|
+
|
|
16
|
+
var _constants = require("../../constants");
|
|
17
|
+
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
/** @jsx jsx */
|
|
23
|
+
var iconColor = (0, _components.themed)('appearance', {
|
|
24
|
+
connectivity: {
|
|
25
|
+
light: colors.B400,
|
|
26
|
+
dark: colors.B100
|
|
27
|
+
},
|
|
28
|
+
confirmation: {
|
|
29
|
+
light: colors.G300,
|
|
30
|
+
dark: colors.G300
|
|
31
|
+
},
|
|
32
|
+
info: {
|
|
33
|
+
light: colors.P300,
|
|
34
|
+
dark: colors.P300
|
|
35
|
+
},
|
|
36
|
+
warning: {
|
|
37
|
+
light: colors.Y300,
|
|
38
|
+
dark: colors.Y300
|
|
39
|
+
},
|
|
40
|
+
error: {
|
|
41
|
+
light: colors.R400,
|
|
42
|
+
dark: colors.R400
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
var iconWrapperStyles = (0, _core.css)({
|
|
46
|
+
display: 'flex',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
flex: '0 0 auto',
|
|
49
|
+
color: 'var(--icon-color)'
|
|
50
|
+
});
|
|
51
|
+
var iconColorStyles = (0, _core.css)({
|
|
52
|
+
color: 'var(--icon-accent-color)'
|
|
53
|
+
});
|
|
54
|
+
/**
|
|
55
|
+
* __Selected icon__
|
|
56
|
+
*
|
|
57
|
+
* The selected icon is used as the primary interactive element for the dialog.
|
|
58
|
+
* Can be used with or without supporting text.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
var SelectedIcon = function SelectedIcon(_ref) {
|
|
62
|
+
var appearance = _ref.appearance,
|
|
63
|
+
isOpen = _ref.isOpen,
|
|
64
|
+
label = _ref.label;
|
|
65
|
+
var _typesMapping$appeara = _constants.typesMapping[appearance],
|
|
66
|
+
SelectedIcon = _typesMapping$appeara.icon,
|
|
67
|
+
defaultLabel = _typesMapping$appeara.defaultLabel;
|
|
68
|
+
var theme = (0, _components.useGlobalTheme)();
|
|
69
|
+
return (0, _core.jsx)("span", {
|
|
70
|
+
"data-ds--inline-message--icon": true,
|
|
71
|
+
style: {
|
|
72
|
+
'--icon-color': iconColor({
|
|
73
|
+
appearance: appearance,
|
|
74
|
+
theme: theme
|
|
75
|
+
})
|
|
76
|
+
},
|
|
77
|
+
css: [iconWrapperStyles, isOpen && iconColorStyles]
|
|
78
|
+
}, (0, _core.jsx)(SelectedIcon, {
|
|
79
|
+
testId: "inline-message-icon",
|
|
80
|
+
label: label || defaultLabel,
|
|
81
|
+
size: "medium"
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
var _default = SelectedIcon;
|
|
86
|
+
exports.default = _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.typesMapping = exports.itemSpacing = void 0;
|
|
9
|
+
|
|
10
|
+
var _checkCircle = _interopRequireDefault(require("@atlaskit/icon/glyph/check-circle"));
|
|
11
|
+
|
|
12
|
+
var _error = _interopRequireDefault(require("@atlaskit/icon/glyph/error"));
|
|
13
|
+
|
|
14
|
+
var _info = _interopRequireDefault(require("@atlaskit/icon/glyph/info"));
|
|
15
|
+
|
|
16
|
+
var _warning = _interopRequireDefault(require("@atlaskit/icon/glyph/warning"));
|
|
17
|
+
|
|
18
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
19
|
+
|
|
20
|
+
var itemSpacing = (0, _constants.gridSize)() / 2;
|
|
21
|
+
exports.itemSpacing = itemSpacing;
|
|
22
|
+
var typesMapping = {
|
|
23
|
+
connectivity: {
|
|
24
|
+
icon: _warning.default,
|
|
25
|
+
defaultLabel: 'connectivity inline message'
|
|
26
|
+
},
|
|
27
|
+
confirmation: {
|
|
28
|
+
icon: _checkCircle.default,
|
|
29
|
+
defaultLabel: 'confirmation inline message'
|
|
30
|
+
},
|
|
31
|
+
info: {
|
|
32
|
+
icon: _info.default,
|
|
33
|
+
defaultLabel: 'info inline message'
|
|
34
|
+
},
|
|
35
|
+
warning: {
|
|
36
|
+
icon: _warning.default,
|
|
37
|
+
defaultLabel: 'warning inline message'
|
|
38
|
+
},
|
|
39
|
+
error: {
|
|
40
|
+
icon: _error.default,
|
|
41
|
+
defaultLabel: 'error inline message'
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.typesMapping = typesMapping;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "default", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _inlineMessage.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
var _inlineMessage = _interopRequireDefault(require("./components/inline-message"));
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { useCallback, useState } from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/core';
|
|
4
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
5
|
+
import InlineDialog from '@atlaskit/inline-dialog';
|
|
6
|
+
import * as colors from '@atlaskit/theme/colors';
|
|
7
|
+
import { themed, useGlobalTheme } from '@atlaskit/theme/components';
|
|
8
|
+
import { itemSpacing } from '../../constants';
|
|
9
|
+
import MessageIcon from '../message-icon';
|
|
10
|
+
const buttonContentsStyles = css({
|
|
11
|
+
display: 'flex',
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
textDecoration: 'none'
|
|
14
|
+
});
|
|
15
|
+
const titleStyles = css({
|
|
16
|
+
padding: `0 ${itemSpacing}px`,
|
|
17
|
+
fontWeight: 500
|
|
18
|
+
});
|
|
19
|
+
const textStyles = css({
|
|
20
|
+
padding: `0 ${itemSpacing}px`,
|
|
21
|
+
overflow: 'hidden',
|
|
22
|
+
textOverflow: 'ellipsis',
|
|
23
|
+
whiteSpace: 'nowrap'
|
|
24
|
+
});
|
|
25
|
+
const rootStyles = css({
|
|
26
|
+
display: 'inline-block',
|
|
27
|
+
maxWidth: '100%',
|
|
28
|
+
'&:focus': {
|
|
29
|
+
outline: '1px solid'
|
|
30
|
+
},
|
|
31
|
+
'&:hover': {
|
|
32
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
33
|
+
'[data-ds--inline-message--icon]': {
|
|
34
|
+
color: 'var(--icon-accent-color)'
|
|
35
|
+
},
|
|
36
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
37
|
+
'[data-ds--inline-message--button]': {
|
|
38
|
+
textDecoration: 'underline'
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
const titleColor = themed({
|
|
43
|
+
light: colors.N600,
|
|
44
|
+
dark: colors.DN600
|
|
45
|
+
});
|
|
46
|
+
const textColor = themed({
|
|
47
|
+
light: colors.N300,
|
|
48
|
+
dark: colors.DN100
|
|
49
|
+
});
|
|
50
|
+
const rootFocusColor = themed('appearance', {
|
|
51
|
+
connectivity: {
|
|
52
|
+
light: colors.B500,
|
|
53
|
+
dark: colors.B200
|
|
54
|
+
},
|
|
55
|
+
confirmation: {
|
|
56
|
+
light: colors.G400,
|
|
57
|
+
dark: colors.G400
|
|
58
|
+
},
|
|
59
|
+
info: {
|
|
60
|
+
light: colors.P500,
|
|
61
|
+
dark: colors.P300
|
|
62
|
+
},
|
|
63
|
+
warning: {
|
|
64
|
+
light: colors.Y500,
|
|
65
|
+
dark: colors.Y500
|
|
66
|
+
},
|
|
67
|
+
error: {
|
|
68
|
+
light: colors.R500,
|
|
69
|
+
dark: colors.R500
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
const iconColor = themed('appearance', {
|
|
73
|
+
connectivity: {
|
|
74
|
+
light: colors.B300,
|
|
75
|
+
dark: colors.B75
|
|
76
|
+
},
|
|
77
|
+
confirmation: {
|
|
78
|
+
light: colors.G200,
|
|
79
|
+
dark: colors.G200
|
|
80
|
+
},
|
|
81
|
+
info: {
|
|
82
|
+
light: colors.P200,
|
|
83
|
+
dark: colors.P200
|
|
84
|
+
},
|
|
85
|
+
warning: {
|
|
86
|
+
light: colors.Y200,
|
|
87
|
+
dark: colors.Y200
|
|
88
|
+
},
|
|
89
|
+
error: {
|
|
90
|
+
light: colors.R300,
|
|
91
|
+
dark: colors.R300
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
/**
|
|
95
|
+
* __Inline message__
|
|
96
|
+
*
|
|
97
|
+
* An inline message lets users know when important information is available or when an action is required.
|
|
98
|
+
*
|
|
99
|
+
* - [Examples](https://atlassian.design/components/inline-message/examples)
|
|
100
|
+
* - [Code](https://atlassian.design/components/inline-message/code)
|
|
101
|
+
* - [Usage](https://atlassian.design/components/inline-message/usage)
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
*
|
|
105
|
+
* ```jsx
|
|
106
|
+
* const Component = () => (
|
|
107
|
+
* <InlineMessage
|
|
108
|
+
* title="Inline Message Title Example"
|
|
109
|
+
* secondaryText="Secondary Text"
|
|
110
|
+
* >
|
|
111
|
+
* <p>Some text that would be inside the open dialog and otherwise hidden.</p>
|
|
112
|
+
* </InlineMessage>
|
|
113
|
+
* );
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
const InlineMessage = ({
|
|
118
|
+
placement = 'bottom-start',
|
|
119
|
+
secondaryText = '',
|
|
120
|
+
title = '',
|
|
121
|
+
type = 'connectivity',
|
|
122
|
+
children,
|
|
123
|
+
testId,
|
|
124
|
+
iconLabel
|
|
125
|
+
}) => {
|
|
126
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
127
|
+
const toggleDialog = useCallback(() => {
|
|
128
|
+
setIsOpen(oldState => !oldState);
|
|
129
|
+
}, [setIsOpen]);
|
|
130
|
+
const onCloseDialog = useCallback(() => setIsOpen(false), [setIsOpen]);
|
|
131
|
+
const theme = useGlobalTheme();
|
|
132
|
+
return jsx("div", {
|
|
133
|
+
css: rootStyles,
|
|
134
|
+
style: {
|
|
135
|
+
outlineColor: rootFocusColor({
|
|
136
|
+
appearance: type,
|
|
137
|
+
theme
|
|
138
|
+
}),
|
|
139
|
+
'--icon-accent-color': iconColor({
|
|
140
|
+
appearance: type,
|
|
141
|
+
theme
|
|
142
|
+
})
|
|
143
|
+
},
|
|
144
|
+
"data-testid": testId
|
|
145
|
+
}, jsx(InlineDialog, {
|
|
146
|
+
onClose: onCloseDialog,
|
|
147
|
+
content: children,
|
|
148
|
+
isOpen: isOpen,
|
|
149
|
+
placement: placement,
|
|
150
|
+
testId: testId && `${testId}--inline-dialog`
|
|
151
|
+
}, jsx(Button, {
|
|
152
|
+
"data-ds--inline-message--button": true,
|
|
153
|
+
appearance: "subtle-link",
|
|
154
|
+
onClick: toggleDialog,
|
|
155
|
+
spacing: "none",
|
|
156
|
+
testId: testId && `${testId}--button`
|
|
157
|
+
}, jsx("div", {
|
|
158
|
+
css: buttonContentsStyles
|
|
159
|
+
}, jsx(MessageIcon, {
|
|
160
|
+
isOpen: isOpen,
|
|
161
|
+
appearance: type,
|
|
162
|
+
label: iconLabel
|
|
163
|
+
}), title && jsx("span", {
|
|
164
|
+
style: {
|
|
165
|
+
color: titleColor({
|
|
166
|
+
theme
|
|
167
|
+
})
|
|
168
|
+
},
|
|
169
|
+
css: titleStyles,
|
|
170
|
+
"data-testid": testId && `${testId}--title`
|
|
171
|
+
}, title), secondaryText && jsx("span", {
|
|
172
|
+
style: {
|
|
173
|
+
color: textColor({
|
|
174
|
+
theme
|
|
175
|
+
})
|
|
176
|
+
},
|
|
177
|
+
css: textStyles,
|
|
178
|
+
"data-testid": testId && `${testId}--text`
|
|
179
|
+
}, secondaryText)))));
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export default InlineMessage;
|