@atlaskit/status 0.11.3
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 +577 -0
- package/LICENSE +13 -0
- package/build/tsconfig.json +17 -0
- package/dist/cjs/components/Status.js +150 -0
- package/dist/cjs/components/StatusPicker.js +121 -0
- package/dist/cjs/components/analytics.js +40 -0
- package/dist/cjs/components/constants.js +8 -0
- package/dist/cjs/components/i18n.js +42 -0
- package/dist/cjs/components/internal/color-palette.js +67 -0
- package/dist/cjs/components/internal/color.js +139 -0
- package/dist/cjs/element.js +13 -0
- package/dist/cjs/i18n/cs.js +23 -0
- package/dist/cjs/i18n/da.js +23 -0
- package/dist/cjs/i18n/de.js +23 -0
- package/dist/cjs/i18n/en.js +16 -0
- package/dist/cjs/i18n/en_GB.js +16 -0
- package/dist/cjs/i18n/es.js +23 -0
- package/dist/cjs/i18n/et.js +23 -0
- package/dist/cjs/i18n/fi.js +23 -0
- package/dist/cjs/i18n/fr.js +23 -0
- package/dist/cjs/i18n/hu.js +23 -0
- package/dist/cjs/i18n/index.js +239 -0
- package/dist/cjs/i18n/is.js +16 -0
- package/dist/cjs/i18n/it.js +23 -0
- package/dist/cjs/i18n/ja.js +23 -0
- package/dist/cjs/i18n/ko.js +23 -0
- package/dist/cjs/i18n/languages.js +33 -0
- package/dist/cjs/i18n/nb.js +23 -0
- package/dist/cjs/i18n/nl.js +23 -0
- package/dist/cjs/i18n/pl.js +23 -0
- package/dist/cjs/i18n/pt_BR.js +23 -0
- package/dist/cjs/i18n/pt_PT.js +23 -0
- package/dist/cjs/i18n/ro.js +16 -0
- package/dist/cjs/i18n/ru.js +23 -0
- package/dist/cjs/i18n/sk.js +23 -0
- package/dist/cjs/i18n/sv.js +23 -0
- package/dist/cjs/i18n/th.js +23 -0
- package/dist/cjs/i18n/tr.js +23 -0
- package/dist/cjs/i18n/uk.js +23 -0
- package/dist/cjs/i18n/vi.js +23 -0
- package/dist/cjs/i18n/zh.js +23 -0
- package/dist/cjs/i18n/zh_TW.js +23 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/picker.js +13 -0
- package/dist/cjs/version.json +4 -0
- package/dist/es2019/components/Status.js +106 -0
- package/dist/es2019/components/StatusPicker.js +71 -0
- package/dist/es2019/components/analytics.js +18 -0
- package/dist/es2019/components/constants.js +1 -0
- package/dist/es2019/components/i18n.js +33 -0
- package/dist/es2019/components/internal/color-palette.js +33 -0
- package/dist/es2019/components/internal/color.js +102 -0
- package/dist/es2019/element.js +1 -0
- package/dist/es2019/i18n/cs.js +15 -0
- package/dist/es2019/i18n/da.js +15 -0
- package/dist/es2019/i18n/de.js +15 -0
- package/dist/es2019/i18n/en.js +9 -0
- package/dist/es2019/i18n/en_GB.js +9 -0
- package/dist/es2019/i18n/es.js +15 -0
- package/dist/es2019/i18n/et.js +15 -0
- package/dist/es2019/i18n/fi.js +15 -0
- package/dist/es2019/i18n/fr.js +15 -0
- package/dist/es2019/i18n/hu.js +15 -0
- package/dist/es2019/i18n/index.js +35 -0
- package/dist/es2019/i18n/is.js +9 -0
- package/dist/es2019/i18n/it.js +15 -0
- package/dist/es2019/i18n/ja.js +15 -0
- package/dist/es2019/i18n/ko.js +15 -0
- package/dist/es2019/i18n/languages.js +26 -0
- package/dist/es2019/i18n/nb.js +15 -0
- package/dist/es2019/i18n/nl.js +15 -0
- package/dist/es2019/i18n/pl.js +15 -0
- package/dist/es2019/i18n/pt_BR.js +15 -0
- package/dist/es2019/i18n/pt_PT.js +15 -0
- package/dist/es2019/i18n/ro.js +9 -0
- package/dist/es2019/i18n/ru.js +15 -0
- package/dist/es2019/i18n/sk.js +15 -0
- package/dist/es2019/i18n/sv.js +15 -0
- package/dist/es2019/i18n/th.js +15 -0
- package/dist/es2019/i18n/tr.js +15 -0
- package/dist/es2019/i18n/uk.js +15 -0
- package/dist/es2019/i18n/vi.js +15 -0
- package/dist/es2019/i18n/zh.js +15 -0
- package/dist/es2019/i18n/zh_TW.js +15 -0
- package/dist/es2019/index.js +2 -0
- package/dist/es2019/picker.js +1 -0
- package/dist/es2019/version.json +4 -0
- package/dist/esm/components/Status.js +130 -0
- package/dist/esm/components/StatusPicker.js +100 -0
- package/dist/esm/components/analytics.js +26 -0
- package/dist/esm/components/constants.js +1 -0
- package/dist/esm/components/i18n.js +33 -0
- package/dist/esm/components/internal/color-palette.js +42 -0
- package/dist/esm/components/internal/color.js +117 -0
- package/dist/esm/element.js +1 -0
- package/dist/esm/i18n/cs.js +15 -0
- package/dist/esm/i18n/da.js +15 -0
- package/dist/esm/i18n/de.js +15 -0
- package/dist/esm/i18n/en.js +9 -0
- package/dist/esm/i18n/en_GB.js +9 -0
- package/dist/esm/i18n/es.js +15 -0
- package/dist/esm/i18n/et.js +15 -0
- package/dist/esm/i18n/fi.js +15 -0
- package/dist/esm/i18n/fr.js +15 -0
- package/dist/esm/i18n/hu.js +15 -0
- package/dist/esm/i18n/index.js +35 -0
- package/dist/esm/i18n/is.js +9 -0
- package/dist/esm/i18n/it.js +15 -0
- package/dist/esm/i18n/ja.js +15 -0
- package/dist/esm/i18n/ko.js +15 -0
- package/dist/esm/i18n/languages.js +26 -0
- package/dist/esm/i18n/nb.js +15 -0
- package/dist/esm/i18n/nl.js +15 -0
- package/dist/esm/i18n/pl.js +15 -0
- package/dist/esm/i18n/pt_BR.js +15 -0
- package/dist/esm/i18n/pt_PT.js +15 -0
- package/dist/esm/i18n/ro.js +9 -0
- package/dist/esm/i18n/ru.js +15 -0
- package/dist/esm/i18n/sk.js +15 -0
- package/dist/esm/i18n/sv.js +15 -0
- package/dist/esm/i18n/th.js +15 -0
- package/dist/esm/i18n/tr.js +15 -0
- package/dist/esm/i18n/uk.js +15 -0
- package/dist/esm/i18n/vi.js +15 -0
- package/dist/esm/i18n/zh.js +15 -0
- package/dist/esm/i18n/zh_TW.js +15 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/picker.js +1 -0
- package/dist/esm/version.json +4 -0
- package/dist/types/components/Status.d.ts +14 -0
- package/dist/types/components/StatusPicker.d.ts +23 -0
- package/dist/types/components/analytics.d.ts +11 -0
- package/dist/types/components/constants.d.ts +1 -0
- package/dist/types/components/i18n.d.ts +2 -0
- package/dist/types/components/internal/color-palette.d.ts +10 -0
- package/dist/types/components/internal/color.d.ts +21 -0
- package/dist/types/element.d.ts +2 -0
- package/dist/types/i18n/cs.d.ts +15 -0
- package/dist/types/i18n/da.d.ts +15 -0
- package/dist/types/i18n/de.d.ts +15 -0
- package/dist/types/i18n/en.d.ts +9 -0
- package/dist/types/i18n/en_GB.d.ts +9 -0
- package/dist/types/i18n/es.d.ts +15 -0
- package/dist/types/i18n/et.d.ts +15 -0
- package/dist/types/i18n/fi.d.ts +15 -0
- package/dist/types/i18n/fr.d.ts +15 -0
- package/dist/types/i18n/hu.d.ts +15 -0
- package/dist/types/i18n/index.d.ts +35 -0
- package/dist/types/i18n/is.d.ts +9 -0
- package/dist/types/i18n/it.d.ts +15 -0
- package/dist/types/i18n/ja.d.ts +15 -0
- package/dist/types/i18n/ko.d.ts +15 -0
- package/dist/types/i18n/languages.d.ts +27 -0
- package/dist/types/i18n/nb.d.ts +15 -0
- package/dist/types/i18n/nl.d.ts +15 -0
- package/dist/types/i18n/pl.d.ts +15 -0
- package/dist/types/i18n/pt_BR.d.ts +15 -0
- package/dist/types/i18n/pt_PT.d.ts +15 -0
- package/dist/types/i18n/ro.d.ts +9 -0
- package/dist/types/i18n/ru.d.ts +15 -0
- package/dist/types/i18n/sk.d.ts +15 -0
- package/dist/types/i18n/sv.d.ts +15 -0
- package/dist/types/i18n/th.d.ts +15 -0
- package/dist/types/i18n/tr.d.ts +15 -0
- package/dist/types/i18n/uk.d.ts +15 -0
- package/dist/types/i18n/vi.d.ts +15 -0
- package/dist/types/i18n/zh.d.ts +15 -0
- package/dist/types/i18n/zh_TW.d.ts +15 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/picker.d.ts +2 -0
- package/docs/0-intro.tsx +53 -0
- package/element/package.json +7 -0
- package/package.json +59 -0
- package/picker/package.json +7 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* NOTE:
|
|
10
|
+
*
|
|
11
|
+
* This file is automatically generated by i18n-tools.
|
|
12
|
+
* DO NOT CHANGE IT BY HAND or your changes will be lost.
|
|
13
|
+
*/
|
|
14
|
+
// undefined
|
|
15
|
+
var _default = {
|
|
16
|
+
'fabric.status.color.blue': '藍色',
|
|
17
|
+
'fabric.status.color.green': '綠色',
|
|
18
|
+
'fabric.status.color.grey': '灰色',
|
|
19
|
+
'fabric.status.color.purple': '紫色',
|
|
20
|
+
'fabric.status.color.red': '紅色',
|
|
21
|
+
'fabric.status.color.yellow': '黃色'
|
|
22
|
+
};
|
|
23
|
+
exports.default = _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Status", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _Status.Status;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "StatusPicker", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _StatusPicker.StatusPicker;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
var _Status = require("./components/Status");
|
|
20
|
+
|
|
21
|
+
var _StatusPicker = require("./components/StatusPicker");
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "StatusPicker", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _StatusPicker.StatusPicker;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
var _StatusPicker = require("./components/StatusPicker");
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { PureComponent } from 'react';
|
|
4
|
+
import Lozenge from '@atlaskit/lozenge';
|
|
5
|
+
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
6
|
+
import { createStatusAnalyticsAndFire } from './analytics';
|
|
7
|
+
import { ANALYTICS_HOVER_DELAY } from './constants';
|
|
8
|
+
const colorToLozengeAppearanceMap = {
|
|
9
|
+
neutral: 'default',
|
|
10
|
+
purple: 'new',
|
|
11
|
+
blue: 'inprogress',
|
|
12
|
+
red: 'removed',
|
|
13
|
+
yellow: 'moved',
|
|
14
|
+
green: 'success'
|
|
15
|
+
};
|
|
16
|
+
const DEFAULT_APPEARANCE = 'default';
|
|
17
|
+
const MAX_WIDTH = 200;
|
|
18
|
+
|
|
19
|
+
class StatusInternal extends PureComponent {
|
|
20
|
+
constructor(...args) {
|
|
21
|
+
super(...args);
|
|
22
|
+
|
|
23
|
+
_defineProperty(this, "hoverStartTime", 0);
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "handleMouseEnter", _e => {
|
|
26
|
+
this.hoverStartTime = Date.now();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
_defineProperty(this, "handleMouseLeave", _e => {
|
|
30
|
+
const {
|
|
31
|
+
onHover
|
|
32
|
+
} = this.props;
|
|
33
|
+
const delay = Date.now() - this.hoverStartTime;
|
|
34
|
+
|
|
35
|
+
if (delay >= ANALYTICS_HOVER_DELAY && onHover) {
|
|
36
|
+
onHover();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
this.hoverStartTime = 0;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
componentWillUnmount() {
|
|
44
|
+
this.hoverStartTime = 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
render() {
|
|
48
|
+
const {
|
|
49
|
+
text,
|
|
50
|
+
color,
|
|
51
|
+
style,
|
|
52
|
+
onClick
|
|
53
|
+
} = this.props;
|
|
54
|
+
|
|
55
|
+
if (text.trim().length === 0) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const appearance = colorToLozengeAppearanceMap[color] || DEFAULT_APPEARANCE; // Note: ommitted data-local-id attribute to avoid copying/pasting the same localId
|
|
60
|
+
|
|
61
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
62
|
+
className: "status-lozenge-span" // Using title here as `@atlaskit/tooltip` adds too much overhead
|
|
63
|
+
,
|
|
64
|
+
title: text,
|
|
65
|
+
onClick: onClick,
|
|
66
|
+
onMouseEnter: this.handleMouseEnter,
|
|
67
|
+
onMouseLeave: this.handleMouseLeave,
|
|
68
|
+
"data-node-type": "status",
|
|
69
|
+
"data-color": color,
|
|
70
|
+
"data-style": style
|
|
71
|
+
}, /*#__PURE__*/React.createElement(Lozenge, {
|
|
72
|
+
appearance: appearance,
|
|
73
|
+
maxWidth: MAX_WIDTH
|
|
74
|
+
}, text));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
_defineProperty(StatusInternal, "displayName", 'StatusInternal');
|
|
80
|
+
|
|
81
|
+
export const Status = withAnalyticsEvents({
|
|
82
|
+
onClick: (createEvent, props) => {
|
|
83
|
+
const {
|
|
84
|
+
localId
|
|
85
|
+
} = props;
|
|
86
|
+
return createStatusAnalyticsAndFire(createEvent)({
|
|
87
|
+
action: 'clicked',
|
|
88
|
+
actionSubject: 'statusLozenge',
|
|
89
|
+
attributes: {
|
|
90
|
+
localId
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
onHover: (createEvent, props) => {
|
|
95
|
+
const {
|
|
96
|
+
localId
|
|
97
|
+
} = props;
|
|
98
|
+
return createStatusAnalyticsAndFire(createEvent)({
|
|
99
|
+
action: 'hovered',
|
|
100
|
+
actionSubject: 'statusLozenge',
|
|
101
|
+
attributes: {
|
|
102
|
+
localId
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
})(StatusInternal);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import TextField from '@atlaskit/textfield';
|
|
3
|
+
import { gridSize } from '@atlaskit/theme/constants';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { PureComponent } from 'react';
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import ColorPalette from './internal/color-palette';
|
|
8
|
+
const FieldTextWrapper = styled.div`
|
|
9
|
+
margin: 0 ${gridSize()}px;
|
|
10
|
+
`;
|
|
11
|
+
export class StatusPicker extends PureComponent {
|
|
12
|
+
constructor(...args) {
|
|
13
|
+
super(...args);
|
|
14
|
+
|
|
15
|
+
_defineProperty(this, "fieldTextWrapperKey", Math.random().toString());
|
|
16
|
+
|
|
17
|
+
_defineProperty(this, "colorPaletteKey", Math.random().toString());
|
|
18
|
+
|
|
19
|
+
_defineProperty(this, "onChange", evt => {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
this.props.onTextChanged(evt.target.value);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
_defineProperty(this, "onKeyPress", event => {
|
|
25
|
+
if (event.key === 'Enter') {
|
|
26
|
+
this.props.onEnter();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
_defineProperty(this, "handleInputRef", ref => {
|
|
31
|
+
if (ref && this.props.autoFocus) {
|
|
32
|
+
// Defer to prevent editor scrolling to top (See FS-3227, also ED-2992)
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
ref.focus();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
render() {
|
|
41
|
+
const {
|
|
42
|
+
text,
|
|
43
|
+
selectedColor,
|
|
44
|
+
onColorClick,
|
|
45
|
+
onColorHover
|
|
46
|
+
} = this.props; // Using <React.Fragment> instead of [] to workaround Enzyme
|
|
47
|
+
// (https://github.com/airbnb/enzyme/issues/1149)
|
|
48
|
+
|
|
49
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FieldTextWrapper, {
|
|
50
|
+
key: this.fieldTextWrapperKey
|
|
51
|
+
}, /*#__PURE__*/React.createElement(TextField, {
|
|
52
|
+
value: text,
|
|
53
|
+
isCompact: true,
|
|
54
|
+
ref: this.handleInputRef,
|
|
55
|
+
onChange: this.onChange,
|
|
56
|
+
onKeyPress: this.onKeyPress,
|
|
57
|
+
spellCheck: false,
|
|
58
|
+
autoComplete: "off"
|
|
59
|
+
})), /*#__PURE__*/React.createElement(ColorPalette, {
|
|
60
|
+
key: this.colorPaletteKey,
|
|
61
|
+
onClick: onColorClick,
|
|
62
|
+
onHover: onColorHover,
|
|
63
|
+
selectedColor: selectedColor
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_defineProperty(StatusPicker, "defaultProps", {
|
|
70
|
+
autoFocus: true
|
|
71
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { name as packageName, version as packageVersion } from '../version.json';
|
|
2
|
+
export const ELEMENTS_CHANNEL = 'fabric-elements';
|
|
3
|
+
export const createStatusAnalyticsAndFire = createAnalyticsEvent => payload => {
|
|
4
|
+
const statusPayload = { ...payload,
|
|
5
|
+
eventType: 'ui'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
if (!statusPayload.attributes) {
|
|
9
|
+
statusPayload.attributes = {};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
statusPayload.attributes.packageName = packageName;
|
|
13
|
+
statusPayload.attributes.packageVersion = packageVersion;
|
|
14
|
+
statusPayload.attributes.componentName = 'status';
|
|
15
|
+
const event = createAnalyticsEvent(statusPayload);
|
|
16
|
+
event.fire(ELEMENTS_CHANNEL);
|
|
17
|
+
return event;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const ANALYTICS_HOVER_DELAY = 1000;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
export const messages = defineMessages({
|
|
3
|
+
neutralColor: {
|
|
4
|
+
id: 'fabric.status.color.grey',
|
|
5
|
+
defaultMessage: 'Grey',
|
|
6
|
+
description: 'Tooltip for the grey color in color palette'
|
|
7
|
+
},
|
|
8
|
+
purpleColor: {
|
|
9
|
+
id: 'fabric.status.color.purple',
|
|
10
|
+
defaultMessage: 'Purple',
|
|
11
|
+
description: 'Tooltip for the purple color in color palette'
|
|
12
|
+
},
|
|
13
|
+
blueColor: {
|
|
14
|
+
id: 'fabric.status.color.blue',
|
|
15
|
+
defaultMessage: 'Blue',
|
|
16
|
+
description: 'Tooltip for the blue color in color palette'
|
|
17
|
+
},
|
|
18
|
+
redColor: {
|
|
19
|
+
id: 'fabric.status.color.red',
|
|
20
|
+
defaultMessage: 'Red',
|
|
21
|
+
description: 'Tooltip for the red color in color palette'
|
|
22
|
+
},
|
|
23
|
+
yellowColor: {
|
|
24
|
+
id: 'fabric.status.color.yellow',
|
|
25
|
+
defaultMessage: 'Yellow',
|
|
26
|
+
description: 'Tooltip for the yellow color in color palette'
|
|
27
|
+
},
|
|
28
|
+
greenColor: {
|
|
29
|
+
id: 'fabric.status.color.green',
|
|
30
|
+
defaultMessage: 'Green',
|
|
31
|
+
description: 'Tooltip for the green color in color palette'
|
|
32
|
+
}
|
|
33
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { gridSize } from '@atlaskit/theme/constants';
|
|
2
|
+
import * as colors from '@atlaskit/theme/colors';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import styled from 'styled-components';
|
|
5
|
+
import Color from './color'; // color value, label, background, borderColor
|
|
6
|
+
|
|
7
|
+
const palette = [['neutral', colors.N40, colors.N400], ['purple', colors.P50, colors.P400], ['blue', colors.B50, colors.B400], ['red', colors.R50, colors.R400], ['yellow', colors.Y75, colors.Y400], ['green', colors.G50, colors.G400]];
|
|
8
|
+
const ColorPaletteWrapper = styled.div`
|
|
9
|
+
margin: ${gridSize()}px ${gridSize()}px 0 ${gridSize()}px;
|
|
10
|
+
/* Firefox bug fix: https://product-fabric.atlassian.net/browse/ED-1789 */
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-wrap: wrap;
|
|
13
|
+
`;
|
|
14
|
+
export default (({
|
|
15
|
+
cols = 7,
|
|
16
|
+
onClick,
|
|
17
|
+
selectedColor,
|
|
18
|
+
className,
|
|
19
|
+
onHover
|
|
20
|
+
}) => /*#__PURE__*/React.createElement(ColorPaletteWrapper, {
|
|
21
|
+
className: className,
|
|
22
|
+
style: {
|
|
23
|
+
maxWidth: cols * 32
|
|
24
|
+
}
|
|
25
|
+
}, palette.map(([colorValue, backgroundColor, borderColor]) => /*#__PURE__*/React.createElement(Color, {
|
|
26
|
+
key: colorValue,
|
|
27
|
+
value: colorValue,
|
|
28
|
+
backgroundColor: backgroundColor,
|
|
29
|
+
borderColor: borderColor,
|
|
30
|
+
onClick: onClick,
|
|
31
|
+
onHover: onHover,
|
|
32
|
+
isSelected: colorValue === selectedColor
|
|
33
|
+
}))));
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import EditorDoneIcon from '@atlaskit/icon/glyph/editor/done';
|
|
3
|
+
import { N900, N0, N50 } from '@atlaskit/theme/colors';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { PureComponent } from 'react';
|
|
6
|
+
import { FormattedMessage } from 'react-intl';
|
|
7
|
+
import styled from 'styled-components';
|
|
8
|
+
import { ANALYTICS_HOVER_DELAY } from '../constants';
|
|
9
|
+
import { messages } from '../i18n';
|
|
10
|
+
const Button = styled.button`
|
|
11
|
+
height: 24px;
|
|
12
|
+
width: 24px;
|
|
13
|
+
background: ${N900};
|
|
14
|
+
padding: 0;
|
|
15
|
+
border-radius: 4px;
|
|
16
|
+
border: 1px solid ${N0};
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
display: block;
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
`;
|
|
22
|
+
const ButtonWrapper = styled.span`
|
|
23
|
+
border: 1px solid transparent;
|
|
24
|
+
margin: 0 2px;
|
|
25
|
+
font-size: 0;
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
padding: 1px;
|
|
29
|
+
border-radius: 6px;
|
|
30
|
+
&:hover {
|
|
31
|
+
border: 1px solid ${N50};
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
34
|
+
export default class Color extends PureComponent {
|
|
35
|
+
constructor(...args) {
|
|
36
|
+
super(...args);
|
|
37
|
+
|
|
38
|
+
_defineProperty(this, "hoverStartTime", 0);
|
|
39
|
+
|
|
40
|
+
_defineProperty(this, "onMouseEnter", () => {
|
|
41
|
+
this.hoverStartTime = Date.now();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
_defineProperty(this, "onMouseLeave", () => {
|
|
45
|
+
const {
|
|
46
|
+
onHover
|
|
47
|
+
} = this.props;
|
|
48
|
+
const delay = Date.now() - this.hoverStartTime;
|
|
49
|
+
|
|
50
|
+
if (delay >= ANALYTICS_HOVER_DELAY && onHover) {
|
|
51
|
+
onHover(this.props.value);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.hoverStartTime = 0;
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
_defineProperty(this, "onMouseDown", e => {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
_defineProperty(this, "onClick", e => {
|
|
62
|
+
const {
|
|
63
|
+
onClick,
|
|
64
|
+
value
|
|
65
|
+
} = this.props;
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
onClick(value);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
render() {
|
|
72
|
+
const {
|
|
73
|
+
tabIndex,
|
|
74
|
+
backgroundColor,
|
|
75
|
+
isSelected,
|
|
76
|
+
borderColor,
|
|
77
|
+
value
|
|
78
|
+
} = this.props;
|
|
79
|
+
const borderStyle = `1px solid ${borderColor}`;
|
|
80
|
+
return /*#__PURE__*/React.createElement(ButtonWrapper, null, /*#__PURE__*/React.createElement(FormattedMessage, messages[`${value}Color`], label => /*#__PURE__*/React.createElement(Button, {
|
|
81
|
+
onClick: this.onClick,
|
|
82
|
+
onMouseEnter: this.onMouseEnter,
|
|
83
|
+
onMouseLeave: this.onMouseLeave,
|
|
84
|
+
onMouseDown: this.onMouseDown,
|
|
85
|
+
tabIndex: tabIndex,
|
|
86
|
+
className: `${isSelected ? 'selected' : ''}`,
|
|
87
|
+
title: label,
|
|
88
|
+
style: {
|
|
89
|
+
backgroundColor: backgroundColor || 'transparent',
|
|
90
|
+
border: borderStyle
|
|
91
|
+
}
|
|
92
|
+
}, isSelected && /*#__PURE__*/React.createElement(EditorDoneIcon, {
|
|
93
|
+
primaryColor: borderColor,
|
|
94
|
+
label: label
|
|
95
|
+
}))));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
componentWillUnmount() {
|
|
99
|
+
this.hoverStartTime = 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Status } from './components/Status';
|