@instructure/ui-tag 8.33.1 → 8.33.2
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 +4 -0
- package/es/Tag/TagLocator.js +2 -1
- package/es/Tag/__examples__/Tag.examples.js +1 -0
- package/es/Tag/index.js +13 -27
- package/es/Tag/props.js +1 -0
- package/es/Tag/styles.js +14 -10
- package/es/Tag/theme.js +16 -18
- package/es/index.js +1 -0
- package/lib/Tag/TagLocator.js +1 -3
- package/lib/Tag/__examples__/Tag.examples.js +0 -1
- package/lib/Tag/index.js +12 -40
- package/lib/Tag/locator.js +0 -2
- package/lib/Tag/props.js +1 -4
- package/lib/Tag/styles.js +14 -11
- package/lib/Tag/theme.js +15 -19
- package/lib/index.js +0 -1
- package/package.json +14 -14
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.33.2](https://github.com/instructure/instructure-ui/compare/v8.33.1...v8.33.2) (2023-01-25)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-tag
|
|
9
|
+
|
|
6
10
|
## [8.33.1](https://github.com/instructure/instructure-ui/compare/v8.33.0...v8.33.1) (2023-01-06)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @instructure/ui-tag
|
package/es/Tag/TagLocator.js
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
import { locator } from '@instructure/ui-test-locator';
|
|
25
|
-
import { Tag } from './index';
|
|
25
|
+
import { Tag } from './index';
|
|
26
26
|
|
|
27
|
+
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
27
28
|
export const TagLocator = locator(Tag.selector);
|
package/es/Tag/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
var _dec, _dec2, _class, _class2;
|
|
2
|
-
|
|
3
2
|
/*
|
|
4
3
|
* The MIT License (MIT)
|
|
5
4
|
*
|
|
@@ -23,7 +22,6 @@ var _dec, _dec2, _class, _class2;
|
|
|
23
22
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
23
|
* SOFTWARE.
|
|
25
24
|
*/
|
|
26
|
-
|
|
27
25
|
/** @jsx jsx */
|
|
28
26
|
import React, { Component } from 'react';
|
|
29
27
|
import { IconXLine } from '@instructure/ui-icons';
|
|
@@ -35,28 +33,25 @@ import { withStyle, jsx } from '@instructure/emotion';
|
|
|
35
33
|
import generateStyle from './styles';
|
|
36
34
|
import generateComponentTheme from './theme';
|
|
37
35
|
import { allowedProps, propTypes } from './props';
|
|
36
|
+
|
|
38
37
|
/**
|
|
39
38
|
---
|
|
40
39
|
category: components
|
|
41
40
|
---
|
|
42
41
|
@tsProps
|
|
43
42
|
**/
|
|
44
|
-
|
|
45
43
|
let Tag = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_class2 = class Tag extends Component {
|
|
46
44
|
constructor() {
|
|
47
45
|
super(...arguments);
|
|
48
46
|
this.ref = null;
|
|
49
|
-
|
|
50
47
|
this.focus = () => {
|
|
51
48
|
this.ref && this.ref.focus();
|
|
52
49
|
};
|
|
53
|
-
|
|
54
50
|
this.handleClick = e => {
|
|
55
51
|
const _this$props = this.props,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
disabled = _this$props.disabled,
|
|
53
|
+
readOnly = _this$props.readOnly,
|
|
54
|
+
onClick = _this$props.onClick;
|
|
60
55
|
if (disabled || readOnly) {
|
|
61
56
|
e.preventDefault();
|
|
62
57
|
e.stopPropagation();
|
|
@@ -64,43 +59,35 @@ let Tag = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = test
|
|
|
64
59
|
onClick(e);
|
|
65
60
|
}
|
|
66
61
|
};
|
|
67
|
-
|
|
68
62
|
this.handleRef = element => {
|
|
69
63
|
this.ref = element;
|
|
70
|
-
|
|
71
64
|
if (typeof this.props.elementRef === 'function') {
|
|
72
65
|
this.props.elementRef(element);
|
|
73
66
|
}
|
|
74
67
|
};
|
|
75
68
|
}
|
|
76
|
-
|
|
77
69
|
componentDidMount() {
|
|
78
70
|
var _this$props$makeStyle, _this$props2;
|
|
79
|
-
|
|
80
71
|
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
81
72
|
}
|
|
82
|
-
|
|
83
73
|
componentDidUpdate() {
|
|
84
74
|
var _this$props$makeStyle2, _this$props3;
|
|
85
|
-
|
|
86
75
|
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
87
76
|
}
|
|
88
|
-
|
|
89
77
|
get focused() {
|
|
90
78
|
return isActiveElement(this.ref);
|
|
91
79
|
}
|
|
92
|
-
|
|
93
80
|
render() {
|
|
94
81
|
const _this$props4 = this.props,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
82
|
+
className = _this$props4.className,
|
|
83
|
+
dismissible = _this$props4.dismissible,
|
|
84
|
+
disabled = _this$props4.disabled,
|
|
85
|
+
readOnly = _this$props4.readOnly,
|
|
86
|
+
text = _this$props4.text,
|
|
87
|
+
title = _this$props4.title,
|
|
88
|
+
onClick = _this$props4.onClick,
|
|
89
|
+
margin = _this$props4.margin,
|
|
90
|
+
styles = _this$props4.styles;
|
|
104
91
|
const passthroughProps = View.omitViewProps(omitProps(this.props, Tag.allowedProps), Tag);
|
|
105
92
|
return jsx(View, Object.assign({}, passthroughProps, {
|
|
106
93
|
elementRef: this.handleRef,
|
|
@@ -119,7 +106,6 @@ let Tag = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = test
|
|
|
119
106
|
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
120
107
|
}) : null);
|
|
121
108
|
}
|
|
122
|
-
|
|
123
109
|
}, _class2.displayName = "Tag", _class2.componentId = 'Tag', _class2.allowedProps = allowedProps, _class2.propTypes = propTypes, _class2.defaultProps = {
|
|
124
110
|
size: 'medium',
|
|
125
111
|
dismissible: false,
|
package/es/Tag/props.js
CHANGED
package/es/Tag/styles.js
CHANGED
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
*/
|
|
35
35
|
const generateStyle = (componentTheme, props) => {
|
|
36
36
|
const variant = props.variant,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
size = props.size,
|
|
38
|
+
dismissible = props.dismissible,
|
|
39
|
+
onClick = props.onClick,
|
|
40
|
+
disabled = props.disabled;
|
|
41
41
|
const isButton = !!onClick;
|
|
42
42
|
const sizeVariants = {
|
|
43
43
|
small: {
|
|
@@ -127,7 +127,8 @@ const generateStyle = (componentTheme, props) => {
|
|
|
127
127
|
}
|
|
128
128
|
})
|
|
129
129
|
},
|
|
130
|
-
tagBefore: {
|
|
130
|
+
tagBefore: {
|
|
131
|
+
...(isButton && {
|
|
131
132
|
borderRadius: componentTheme.defaultBorderRadius
|
|
132
133
|
})
|
|
133
134
|
}
|
|
@@ -146,21 +147,24 @@ const generateStyle = (componentTheme, props) => {
|
|
|
146
147
|
}
|
|
147
148
|
})
|
|
148
149
|
},
|
|
149
|
-
tagBefore: {
|
|
150
|
+
tagBefore: {
|
|
151
|
+
...(isButton && {
|
|
150
152
|
borderRadius: `calc(${componentTheme.inlineBorderRadius} * 1.5)`
|
|
151
153
|
})
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
156
|
};
|
|
155
157
|
const iconVariantVariants = {
|
|
156
|
-
default: {
|
|
158
|
+
default: {
|
|
159
|
+
...(dismissible && {
|
|
157
160
|
color: componentTheme.defaultIconColor,
|
|
158
161
|
'[class$="-tag"]:hover > &': {
|
|
159
162
|
color: componentTheme.defaultIconHoverColor
|
|
160
163
|
}
|
|
161
164
|
})
|
|
162
165
|
},
|
|
163
|
-
inline: {
|
|
166
|
+
inline: {
|
|
167
|
+
...(dismissible && {
|
|
164
168
|
backgroundColor: componentTheme.inlineIconColor,
|
|
165
169
|
borderRadius: '50%',
|
|
166
170
|
color: componentTheme.inlineBackground,
|
|
@@ -193,7 +197,8 @@ const generateStyle = (componentTheme, props) => {
|
|
|
193
197
|
...sizeVariants[size].tag,
|
|
194
198
|
...buttonVariant.tag,
|
|
195
199
|
...tagVariantVariants[variant].tag,
|
|
196
|
-
'&::before': {
|
|
200
|
+
'&::before': {
|
|
201
|
+
...buttonVariant.tagBefore,
|
|
197
202
|
...tagVariantVariants[variant].tagBefore
|
|
198
203
|
}
|
|
199
204
|
},
|
|
@@ -216,5 +221,4 @@ const generateStyle = (componentTheme, props) => {
|
|
|
216
221
|
}
|
|
217
222
|
};
|
|
218
223
|
};
|
|
219
|
-
|
|
220
224
|
export default generateStyle;
|
package/es/Tag/theme.js
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
|
-
import { darken } from '@instructure/ui-color-utils';
|
|
25
24
|
|
|
25
|
+
import { darken } from '@instructure/ui-color-utils';
|
|
26
26
|
/**
|
|
27
27
|
* Generates the theme object for the component from the theme and provided additional information
|
|
28
28
|
* @param {Object} theme The actual theme object.
|
|
@@ -30,11 +30,11 @@ import { darken } from '@instructure/ui-color-utils';
|
|
|
30
30
|
*/
|
|
31
31
|
const generateComponentTheme = theme => {
|
|
32
32
|
const borders = theme.borders,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
colors = theme.colors,
|
|
34
|
+
forms = theme.forms,
|
|
35
|
+
spacing = theme.spacing,
|
|
36
|
+
typography = theme.typography,
|
|
37
|
+
themeName = theme.key;
|
|
38
38
|
const themeSpecificStyle = {
|
|
39
39
|
'canvas-high-contrast': {
|
|
40
40
|
defaultBackground: colors.backgroundLightest,
|
|
@@ -47,17 +47,16 @@ const generateComponentTheme = theme => {
|
|
|
47
47
|
defaultColor: theme['ic-brand-font-color-dark']
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
|
|
51
50
|
const tagVariant = function (style, _ref) {
|
|
52
51
|
let borderColor = _ref.borderColor,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
borderRadius = _ref.borderRadius,
|
|
53
|
+
borderStyle = _ref.borderStyle,
|
|
54
|
+
borderWidth = _ref.borderWidth,
|
|
55
|
+
hoverColor = _ref.hoverColor,
|
|
56
|
+
iconColor = _ref.iconColor,
|
|
57
|
+
iconHoverColor = _ref.iconHoverColor,
|
|
58
|
+
mainColor = _ref.mainColor,
|
|
59
|
+
textColor = _ref.textColor;
|
|
61
60
|
return {
|
|
62
61
|
[`${style}BackgroundHover`]: hoverColor || darken(mainColor, 5),
|
|
63
62
|
[`${style}Background`]: mainColor,
|
|
@@ -72,7 +71,6 @@ const generateComponentTheme = theme => {
|
|
|
72
71
|
[`${style}IconHoverColor`]: iconHoverColor || iconColor || textColor
|
|
73
72
|
};
|
|
74
73
|
};
|
|
75
|
-
|
|
76
74
|
const componentVariables = {
|
|
77
75
|
fontFamily: typography.fontFamily,
|
|
78
76
|
heightSmall: '1.3125rem',
|
|
@@ -106,9 +104,9 @@ const generateComponentTheme = theme => {
|
|
|
106
104
|
textColor: colors.textDarkest
|
|
107
105
|
})
|
|
108
106
|
};
|
|
109
|
-
return {
|
|
107
|
+
return {
|
|
108
|
+
...componentVariables,
|
|
110
109
|
...themeSpecificStyle[themeName]
|
|
111
110
|
};
|
|
112
111
|
};
|
|
113
|
-
|
|
114
112
|
export default generateComponentTheme;
|
package/es/index.js
CHANGED
package/lib/Tag/TagLocator.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TagLocator = void 0;
|
|
7
|
-
|
|
8
7
|
var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
|
|
9
|
-
|
|
10
8
|
var _index = require("./index");
|
|
11
|
-
|
|
12
9
|
/*
|
|
13
10
|
* The MIT License (MIT)
|
|
14
11
|
*
|
|
@@ -32,6 +29,7 @@ var _index = require("./index");
|
|
|
32
29
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
33
30
|
* SOFTWARE.
|
|
34
31
|
*/
|
|
32
|
+
|
|
35
33
|
// @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
|
|
36
34
|
const TagLocator = (0, _locator.locator)(_index.Tag.selector);
|
|
37
35
|
exports.TagLocator = TagLocator;
|
package/lib/Tag/index.js
CHANGED
|
@@ -1,36 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = exports.Tag = void 0;
|
|
11
|
-
|
|
12
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
10
|
var _IconXLine = require("@instructure/ui-icons/lib/IconXLine.js");
|
|
15
|
-
|
|
16
11
|
var _View = require("@instructure/ui-view/lib/View");
|
|
17
|
-
|
|
18
12
|
var _omitProps = require("@instructure/ui-react-utils/lib/omitProps.js");
|
|
19
|
-
|
|
20
13
|
var _isActiveElement = require("@instructure/ui-dom-utils/lib/isActiveElement.js");
|
|
21
|
-
|
|
22
14
|
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
23
|
-
|
|
24
15
|
var _emotion = require("@instructure/emotion");
|
|
25
|
-
|
|
26
16
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
27
|
-
|
|
28
17
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
29
|
-
|
|
30
18
|
var _props = require("./props");
|
|
31
|
-
|
|
32
19
|
var _dec, _dec2, _class, _class2;
|
|
33
|
-
|
|
34
20
|
/**
|
|
35
21
|
---
|
|
36
22
|
category: components
|
|
@@ -41,17 +27,14 @@ let Tag = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec
|
|
|
41
27
|
constructor() {
|
|
42
28
|
super(...arguments);
|
|
43
29
|
this.ref = null;
|
|
44
|
-
|
|
45
30
|
this.focus = () => {
|
|
46
31
|
this.ref && this.ref.focus();
|
|
47
32
|
};
|
|
48
|
-
|
|
49
33
|
this.handleClick = e => {
|
|
50
34
|
const _this$props = this.props,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
disabled = _this$props.disabled,
|
|
36
|
+
readOnly = _this$props.readOnly,
|
|
37
|
+
onClick = _this$props.onClick;
|
|
55
38
|
if (disabled || readOnly) {
|
|
56
39
|
e.preventDefault();
|
|
57
40
|
e.stopPropagation();
|
|
@@ -59,46 +42,36 @@ let Tag = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec
|
|
|
59
42
|
onClick(e);
|
|
60
43
|
}
|
|
61
44
|
};
|
|
62
|
-
|
|
63
45
|
this.handleRef = element => {
|
|
64
46
|
this.ref = element;
|
|
65
|
-
|
|
66
47
|
if (typeof this.props.elementRef === 'function') {
|
|
67
48
|
this.props.elementRef(element);
|
|
68
49
|
}
|
|
69
50
|
};
|
|
70
51
|
}
|
|
71
|
-
|
|
72
52
|
componentDidMount() {
|
|
73
53
|
var _this$props$makeStyle, _this$props2;
|
|
74
|
-
|
|
75
54
|
(_this$props$makeStyle = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props2);
|
|
76
55
|
}
|
|
77
|
-
|
|
78
56
|
componentDidUpdate() {
|
|
79
57
|
var _this$props$makeStyle2, _this$props3;
|
|
80
|
-
|
|
81
58
|
(_this$props$makeStyle2 = (_this$props3 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props3);
|
|
82
59
|
}
|
|
83
|
-
|
|
84
60
|
get focused() {
|
|
85
61
|
return (0, _isActiveElement.isActiveElement)(this.ref);
|
|
86
62
|
}
|
|
87
|
-
|
|
88
63
|
render() {
|
|
89
64
|
const _this$props4 = this.props,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
65
|
+
className = _this$props4.className,
|
|
66
|
+
dismissible = _this$props4.dismissible,
|
|
67
|
+
disabled = _this$props4.disabled,
|
|
68
|
+
readOnly = _this$props4.readOnly,
|
|
69
|
+
text = _this$props4.text,
|
|
70
|
+
title = _this$props4.title,
|
|
71
|
+
onClick = _this$props4.onClick,
|
|
72
|
+
margin = _this$props4.margin,
|
|
73
|
+
styles = _this$props4.styles;
|
|
100
74
|
const passthroughProps = _View.View.omitViewProps((0, _omitProps.omitProps)(this.props, Tag.allowedProps), Tag);
|
|
101
|
-
|
|
102
75
|
return (0, _emotion.jsx)(_View.View, Object.assign({}, passthroughProps, {
|
|
103
76
|
elementRef: this.handleRef,
|
|
104
77
|
css: styles === null || styles === void 0 ? void 0 : styles.tag,
|
|
@@ -116,7 +89,6 @@ let Tag = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec
|
|
|
116
89
|
css: styles === null || styles === void 0 ? void 0 : styles.icon
|
|
117
90
|
}) : null);
|
|
118
91
|
}
|
|
119
|
-
|
|
120
92
|
}, _class2.displayName = "Tag", _class2.componentId = 'Tag', _class2.allowedProps = _props.allowedProps, _class2.propTypes = _props.propTypes, _class2.defaultProps = {
|
|
121
93
|
size: 'medium',
|
|
122
94
|
dismissible: false,
|
package/lib/Tag/locator.js
CHANGED
package/lib/Tag/props.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.propTypes = exports.allowedProps = void 0;
|
|
9
|
-
|
|
10
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
|
-
|
|
12
9
|
var _emotion = require("@instructure/emotion");
|
|
13
|
-
|
|
14
10
|
/*
|
|
15
11
|
* The MIT License (MIT)
|
|
16
12
|
*
|
|
@@ -34,6 +30,7 @@ var _emotion = require("@instructure/emotion");
|
|
|
34
30
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
35
31
|
* SOFTWARE.
|
|
36
32
|
*/
|
|
33
|
+
|
|
37
34
|
const propTypes = {
|
|
38
35
|
className: _propTypes.default.string,
|
|
39
36
|
text: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.node]).isRequired,
|
package/lib/Tag/styles.js
CHANGED
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/*
|
|
9
8
|
* The MIT License (MIT)
|
|
10
9
|
*
|
|
@@ -41,10 +40,10 @@ exports.default = void 0;
|
|
|
41
40
|
*/
|
|
42
41
|
const generateStyle = (componentTheme, props) => {
|
|
43
42
|
const variant = props.variant,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
size = props.size,
|
|
44
|
+
dismissible = props.dismissible,
|
|
45
|
+
onClick = props.onClick,
|
|
46
|
+
disabled = props.disabled;
|
|
48
47
|
const isButton = !!onClick;
|
|
49
48
|
const sizeVariants = {
|
|
50
49
|
small: {
|
|
@@ -134,7 +133,8 @@ const generateStyle = (componentTheme, props) => {
|
|
|
134
133
|
}
|
|
135
134
|
})
|
|
136
135
|
},
|
|
137
|
-
tagBefore: {
|
|
136
|
+
tagBefore: {
|
|
137
|
+
...(isButton && {
|
|
138
138
|
borderRadius: componentTheme.defaultBorderRadius
|
|
139
139
|
})
|
|
140
140
|
}
|
|
@@ -153,21 +153,24 @@ const generateStyle = (componentTheme, props) => {
|
|
|
153
153
|
}
|
|
154
154
|
})
|
|
155
155
|
},
|
|
156
|
-
tagBefore: {
|
|
156
|
+
tagBefore: {
|
|
157
|
+
...(isButton && {
|
|
157
158
|
borderRadius: `calc(${componentTheme.inlineBorderRadius} * 1.5)`
|
|
158
159
|
})
|
|
159
160
|
}
|
|
160
161
|
}
|
|
161
162
|
};
|
|
162
163
|
const iconVariantVariants = {
|
|
163
|
-
default: {
|
|
164
|
+
default: {
|
|
165
|
+
...(dismissible && {
|
|
164
166
|
color: componentTheme.defaultIconColor,
|
|
165
167
|
'[class$="-tag"]:hover > &': {
|
|
166
168
|
color: componentTheme.defaultIconHoverColor
|
|
167
169
|
}
|
|
168
170
|
})
|
|
169
171
|
},
|
|
170
|
-
inline: {
|
|
172
|
+
inline: {
|
|
173
|
+
...(dismissible && {
|
|
171
174
|
backgroundColor: componentTheme.inlineIconColor,
|
|
172
175
|
borderRadius: '50%',
|
|
173
176
|
color: componentTheme.inlineBackground,
|
|
@@ -200,7 +203,8 @@ const generateStyle = (componentTheme, props) => {
|
|
|
200
203
|
...sizeVariants[size].tag,
|
|
201
204
|
...buttonVariant.tag,
|
|
202
205
|
...tagVariantVariants[variant].tag,
|
|
203
|
-
'&::before': {
|
|
206
|
+
'&::before': {
|
|
207
|
+
...buttonVariant.tagBefore,
|
|
204
208
|
...tagVariantVariants[variant].tagBefore
|
|
205
209
|
}
|
|
206
210
|
},
|
|
@@ -223,6 +227,5 @@ const generateStyle = (componentTheme, props) => {
|
|
|
223
227
|
}
|
|
224
228
|
};
|
|
225
229
|
};
|
|
226
|
-
|
|
227
230
|
var _default = generateStyle;
|
|
228
231
|
exports.default = _default;
|
package/lib/Tag/theme.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _darken = require("@instructure/ui-color-utils/lib/darken.js");
|
|
9
|
-
|
|
10
8
|
/*
|
|
11
9
|
* The MIT License (MIT)
|
|
12
10
|
*
|
|
@@ -38,11 +36,11 @@ var _darken = require("@instructure/ui-color-utils/lib/darken.js");
|
|
|
38
36
|
*/
|
|
39
37
|
const generateComponentTheme = theme => {
|
|
40
38
|
const borders = theme.borders,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
colors = theme.colors,
|
|
40
|
+
forms = theme.forms,
|
|
41
|
+
spacing = theme.spacing,
|
|
42
|
+
typography = theme.typography,
|
|
43
|
+
themeName = theme.key;
|
|
46
44
|
const themeSpecificStyle = {
|
|
47
45
|
'canvas-high-contrast': {
|
|
48
46
|
defaultBackground: colors.backgroundLightest,
|
|
@@ -55,17 +53,16 @@ const generateComponentTheme = theme => {
|
|
|
55
53
|
defaultColor: theme['ic-brand-font-color-dark']
|
|
56
54
|
}
|
|
57
55
|
};
|
|
58
|
-
|
|
59
56
|
const tagVariant = function (style, _ref) {
|
|
60
57
|
let borderColor = _ref.borderColor,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
borderRadius = _ref.borderRadius,
|
|
59
|
+
borderStyle = _ref.borderStyle,
|
|
60
|
+
borderWidth = _ref.borderWidth,
|
|
61
|
+
hoverColor = _ref.hoverColor,
|
|
62
|
+
iconColor = _ref.iconColor,
|
|
63
|
+
iconHoverColor = _ref.iconHoverColor,
|
|
64
|
+
mainColor = _ref.mainColor,
|
|
65
|
+
textColor = _ref.textColor;
|
|
69
66
|
return {
|
|
70
67
|
[`${style}BackgroundHover`]: hoverColor || (0, _darken.darken)(mainColor, 5),
|
|
71
68
|
[`${style}Background`]: mainColor,
|
|
@@ -80,7 +77,6 @@ const generateComponentTheme = theme => {
|
|
|
80
77
|
[`${style}IconHoverColor`]: iconHoverColor || iconColor || textColor
|
|
81
78
|
};
|
|
82
79
|
};
|
|
83
|
-
|
|
84
80
|
const componentVariables = {
|
|
85
81
|
fontFamily: typography.fontFamily,
|
|
86
82
|
heightSmall: '1.3125rem',
|
|
@@ -114,10 +110,10 @@ const generateComponentTheme = theme => {
|
|
|
114
110
|
textColor: colors.textDarkest
|
|
115
111
|
})
|
|
116
112
|
};
|
|
117
|
-
return {
|
|
113
|
+
return {
|
|
114
|
+
...componentVariables,
|
|
118
115
|
...themeSpecificStyle[themeName]
|
|
119
116
|
};
|
|
120
117
|
};
|
|
121
|
-
|
|
122
118
|
var _default = generateComponentTheme;
|
|
123
119
|
exports.default = _default;
|