@instructure/ui-pill 8.48.3 → 8.48.4-snapshot-0

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 CHANGED
@@ -3,6 +3,17 @@
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.48.4-snapshot-0](https://github.com/instructure/instructure-ui/compare/v8.48.3...v8.48.4-snapshot-0) (2023-11-24)
7
+
8
+
9
+ ### Features
10
+
11
+ * **shared-types,ui-pill:** change pill according to new design guidelines ([3bd8ee6](https://github.com/instructure/instructure-ui/commit/3bd8ee6316650dc66068f6e4d1a3fbb2fbb09e42))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [8.48.3](https://github.com/instructure/instructure-ui/compare/v8.48.2...v8.48.3) (2023-11-23)
7
18
 
8
19
  **Note:** Version bump only for package @instructure/ui-pill
@@ -0,0 +1,80 @@
1
+ var _Pill, _Pill2, _Pill3, _Pill4;
2
+ /*
3
+ * The MIT License (MIT)
4
+ *
5
+ * Copyright (c) 2015 - present Instructure, Inc.
6
+ *
7
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ * of this software and associated documentation files (the "Software"), to deal
9
+ * in the Software without restriction, including without limitation the rights
10
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ * copies of the Software, and to permit persons to whom the Software is
12
+ * furnished to do so, subject to the following conditions:
13
+ *
14
+ * The above copyright notice and this permission notice shall be included in all
15
+ * copies or substantial portions of the Software.
16
+ *
17
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ * SOFTWARE.
24
+ */
25
+
26
+ import React from 'react';
27
+ import { render } from '@testing-library/react';
28
+ import '@testing-library/jest-dom';
29
+
30
+ // eslint-disable-next-line no-restricted-imports
31
+ import { runAxeCheck } from '@instructure/ui-axe-check';
32
+ import { Pill } from '../index';
33
+ import { IconEyeLine } from '@instructure/ui-icons';
34
+ const originalResizeObserver = global.ResizeObserver;
35
+ describe('<Pill />', () => {
36
+ beforeAll(() => {
37
+ // Mock for ResizeObserver browser API
38
+ global.ResizeObserver = jest.fn().mockImplementation(() => ({
39
+ observe: jest.fn(),
40
+ unobserve: jest.fn(),
41
+ disconnect: jest.fn()
42
+ }));
43
+ });
44
+ it('should render', async () => {
45
+ const _render = render(_Pill || (_Pill = /*#__PURE__*/React.createElement(Pill, null, "Overdue"))),
46
+ container = _render.container;
47
+ expect(container).toHaveTextContent('Overdue');
48
+ });
49
+ it('should display status text', async () => {
50
+ const _render2 = render(_Pill2 || (_Pill2 = /*#__PURE__*/React.createElement(Pill, {
51
+ statusLabel: "Statuslabel"
52
+ }, "Overdue"))),
53
+ container = _render2.container;
54
+ expect(container).toHaveTextContent('Statuslabel:');
55
+ expect(container).toHaveTextContent('Overdue');
56
+ });
57
+ it('should render icon text', async () => {
58
+ const _render3 = render(_Pill3 || (_Pill3 = /*#__PURE__*/React.createElement(Pill, {
59
+ statusLabel: "Statuslabel",
60
+ renderIcon: /*#__PURE__*/React.createElement(IconEyeLine, {
61
+ color: "auto",
62
+ title: "Love"
63
+ })
64
+ }, "Overdue"))),
65
+ container = _render3.container;
66
+ const svg = container.querySelector('svg');
67
+ expect(container).toHaveTextContent('Statuslabel:');
68
+ expect(container).toHaveTextContent('Overdue');
69
+ expect(svg).toHaveAttribute('name', 'IconEye');
70
+ });
71
+ it('should be accessible', async () => {
72
+ const _render4 = render(_Pill4 || (_Pill4 = /*#__PURE__*/React.createElement(Pill, null, "Overdue"))),
73
+ container = _render4.container;
74
+ const axeCheck = await runAxeCheck(container);
75
+ expect(axeCheck).toBe(true);
76
+ });
77
+ afterAll(() => {
78
+ global.ResizeObserver = originalResizeObserver;
79
+ });
80
+ });
package/es/Pill/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
- const _excluded = ["margin", "children", "color", "as", "elementRef", "styles", "makeStyles"];
2
+ const _excluded = ["margin", "children", "color", "as", "elementRef", "styles", "makeStyles", "statusLabel", "renderIcon"];
3
3
  var _dec, _dec2, _class, _class2;
4
4
  /*
5
5
  * The MIT License (MIT)
@@ -28,7 +28,6 @@ var _dec, _dec2, _class, _class2;
28
28
  /** @jsx jsx */
29
29
  import { Component } from 'react';
30
30
  import { View } from '@instructure/ui-view';
31
- import { TruncateText } from '@instructure/ui-truncate-text';
32
31
  import { passthroughProps } from '@instructure/ui-react-utils';
33
32
  import { testable } from '@instructure/ui-testable';
34
33
  import { Tooltip } from '@instructure/ui-tooltip';
@@ -46,6 +45,7 @@ let Pill = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
46
45
  constructor(props) {
47
46
  super(props);
48
47
  this.ref = null;
48
+ this.ellipsisRef = null;
49
49
  this.handleRef = el => {
50
50
  const elementRef = this.props.elementRef;
51
51
  this.ref = el;
@@ -59,16 +59,17 @@ let Pill = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
59
59
  }
60
60
  componentDidMount() {
61
61
  var _this$props$makeStyle, _this$props;
62
+ this.setTruncation();
62
63
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
63
64
  }
64
65
  componentDidUpdate() {
65
66
  var _this$props$makeStyle2, _this$props2;
66
67
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
67
68
  }
68
- handleTruncation(truncated) {
69
- if (truncated !== this.state.truncated) {
69
+ setTruncation() {
70
+ if (this.ellipsisRef) {
70
71
  this.setState({
71
- truncated: truncated
72
+ truncated: this.ellipsisRef.offsetWidth < this.ellipsisRef.scrollWidth
72
73
  });
73
74
  }
74
75
  }
@@ -81,6 +82,8 @@ let Pill = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
81
82
  elementRef = _this$props3.elementRef,
82
83
  styles = _this$props3.styles,
83
84
  makeStyles = _this$props3.makeStyles,
85
+ statusLabel = _this$props3.statusLabel,
86
+ renderIcon = _this$props3.renderIcon,
84
87
  props = _objectWithoutProperties(_this$props3, _excluded);
85
88
  const filteredProps = passthroughProps(props);
86
89
  const containerProps = typeof getTriggerProps === 'function' ? getTriggerProps(filteredProps) : filteredProps;
@@ -100,20 +103,23 @@ let Pill = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = tes
100
103
  position: "relative",
101
104
  withFocusOutline: focused,
102
105
  focusColor: "info"
103
- }), jsx("span", {
106
+ }), jsx("div", {
104
107
  css: styles === null || styles === void 0 ? void 0 : styles.pill
105
- }, jsx("span", {
106
- css: styles === null || styles === void 0 ? void 0 : styles.text
107
- }, jsx(TruncateText, {
108
- onUpdate: truncated => {
109
- this.handleTruncation(truncated);
108
+ }, renderIcon && jsx("div", {
109
+ css: styles === null || styles === void 0 ? void 0 : styles.icon
110
+ }, renderIcon), jsx("div", {
111
+ css: styles === null || styles === void 0 ? void 0 : styles.text,
112
+ ref: el => {
113
+ this.ellipsisRef = el;
110
114
  }
111
- }, children))));
115
+ }, statusLabel && jsx("span", {
116
+ css: styles === null || styles === void 0 ? void 0 : styles.status
117
+ }, statusLabel && statusLabel.concat(':')), children)));
112
118
  }
113
119
  render() {
114
120
  if (this.state.truncated) {
115
121
  return jsx(Tooltip, {
116
- renderTip: this.props.children,
122
+ renderTip: this.props.statusLabel ? this.props.statusLabel.concat(': ', this.props.children) : this.props.children,
117
123
  elementRef: this.handleRef
118
124
  }, ({
119
125
  focused,
package/es/Pill/props.js CHANGED
@@ -30,7 +30,9 @@ const propTypes = {
30
30
  children: PropTypes.node.isRequired,
31
31
  color: PropTypes.oneOf(['primary', 'success', 'danger', 'info', 'warning', 'alert']),
32
32
  elementRef: PropTypes.func,
33
- margin: ThemeablePropTypes.spacing
33
+ margin: ThemeablePropTypes.spacing,
34
+ statusLabel: PropTypes.string,
35
+ renderIcon: PropTypes.oneOfType([PropTypes.node, PropTypes.func])
34
36
  };
35
37
  const allowedProps = ['as', 'children', 'color', 'elementRef', 'margin'];
36
38
  export { propTypes, allowedProps };
package/es/Pill/styles.js CHANGED
@@ -63,7 +63,9 @@ const generateStyle = (componentTheme, props) => {
63
63
  return {
64
64
  pill: {
65
65
  label: 'pill',
66
- display: 'block',
66
+ display: 'flex',
67
+ alignItems: 'center',
68
+ justifyContent: 'center',
67
69
  fontFamily: componentTheme.fontFamily,
68
70
  boxSizing: 'border-box',
69
71
  padding: componentTheme.padding,
@@ -75,13 +77,29 @@ const generateStyle = (componentTheme, props) => {
75
77
  lineHeight: `calc(${componentTheme.height} - (${componentTheme.borderWidth} * 2))`,
76
78
  ...pillColorVariants[color]
77
79
  },
80
+ status: {
81
+ label: 'pill__status',
82
+ boxSizing: 'border-box',
83
+ fontSize: componentTheme.textFontSize,
84
+ fontWeight: componentTheme.statusLabelFontWeight,
85
+ marginRight: '0.125rem'
86
+ },
87
+ icon: {
88
+ label: 'pill__icon',
89
+ display: 'flex',
90
+ alignItems: 'center',
91
+ marginRight: '0.375rem',
92
+ fontSize: '0.75rem'
93
+ },
78
94
  text: {
79
95
  label: 'pill__text',
80
96
  boxSizing: 'border-box',
81
- textTransform: componentTheme.textTransformStyle,
97
+ maxWidth: componentTheme.maxWidth,
82
98
  fontSize: componentTheme.textFontSize,
83
99
  fontWeight: componentTheme.textFontWeight,
84
- letterSpacing: '0.0625rem'
100
+ textOverflow: 'ellipsis',
101
+ whiteSpace: 'nowrap',
102
+ overflow: 'hidden'
85
103
  },
86
104
  maxWidth: componentTheme.maxWidth
87
105
  };
package/es/Pill/theme.js CHANGED
@@ -41,11 +41,11 @@ const generateComponentTheme = theme => {
41
41
  const componentVariables = {
42
42
  fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
43
43
  padding: `0 ${spacing === null || spacing === void 0 ? void 0 : spacing.xSmall}`,
44
- height: '1.3125rem',
44
+ height: '1.5rem',
45
45
  background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
46
- textTransformStyle: 'uppercase',
47
- textFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
48
- textFontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
46
+ textFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
47
+ textFontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightNormal,
48
+ statusLabelFontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
49
49
  maxWidth: '15rem',
50
50
  primaryColor: colors === null || colors === void 0 ? void 0 : colors.textDark,
51
51
  infoColor: colors === null || colors === void 0 ? void 0 : colors.textInfo,
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _react2 = require("@testing-library/react");
6
+ require("@testing-library/jest-dom");
7
+ var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
8
+ var _index = require("../index");
9
+ var _IconEyeLine = require("@instructure/ui-icons/lib/IconEyeLine.js");
10
+ var _Pill, _Pill2, _Pill3, _Pill4;
11
+ /*
12
+ * The MIT License (MIT)
13
+ *
14
+ * Copyright (c) 2015 - present Instructure, Inc.
15
+ *
16
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ * of this software and associated documentation files (the "Software"), to deal
18
+ * in the Software without restriction, including without limitation the rights
19
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ * copies of the Software, and to permit persons to whom the Software is
21
+ * furnished to do so, subject to the following conditions:
22
+ *
23
+ * The above copyright notice and this permission notice shall be included in all
24
+ * copies or substantial portions of the Software.
25
+ *
26
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ * SOFTWARE.
33
+ */
34
+ // eslint-disable-next-line no-restricted-imports
35
+ const originalResizeObserver = global.ResizeObserver;
36
+ describe('<Pill />', () => {
37
+ beforeAll(() => {
38
+ // Mock for ResizeObserver browser API
39
+ global.ResizeObserver = jest.fn().mockImplementation(() => ({
40
+ observe: jest.fn(),
41
+ unobserve: jest.fn(),
42
+ disconnect: jest.fn()
43
+ }));
44
+ });
45
+ it('should render', async () => {
46
+ const _render = (0, _react2.render)(_Pill || (_Pill = /*#__PURE__*/_react.default.createElement(_index.Pill, null, "Overdue"))),
47
+ container = _render.container;
48
+ expect(container).toHaveTextContent('Overdue');
49
+ });
50
+ it('should display status text', async () => {
51
+ const _render2 = (0, _react2.render)(_Pill2 || (_Pill2 = /*#__PURE__*/_react.default.createElement(_index.Pill, {
52
+ statusLabel: "Statuslabel"
53
+ }, "Overdue"))),
54
+ container = _render2.container;
55
+ expect(container).toHaveTextContent('Statuslabel:');
56
+ expect(container).toHaveTextContent('Overdue');
57
+ });
58
+ it('should render icon text', async () => {
59
+ const _render3 = (0, _react2.render)(_Pill3 || (_Pill3 = /*#__PURE__*/_react.default.createElement(_index.Pill, {
60
+ statusLabel: "Statuslabel",
61
+ renderIcon: /*#__PURE__*/_react.default.createElement(_IconEyeLine.IconEyeLine, {
62
+ color: "auto",
63
+ title: "Love"
64
+ })
65
+ }, "Overdue"))),
66
+ container = _render3.container;
67
+ const svg = container.querySelector('svg');
68
+ expect(container).toHaveTextContent('Statuslabel:');
69
+ expect(container).toHaveTextContent('Overdue');
70
+ expect(svg).toHaveAttribute('name', 'IconEye');
71
+ });
72
+ it('should be accessible', async () => {
73
+ const _render4 = (0, _react2.render)(_Pill4 || (_Pill4 = /*#__PURE__*/_react.default.createElement(_index.Pill, null, "Overdue"))),
74
+ container = _render4.container;
75
+ const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
76
+ expect(axeCheck).toBe(true);
77
+ });
78
+ afterAll(() => {
79
+ global.ResizeObserver = originalResizeObserver;
80
+ });
81
+ });
package/lib/Pill/index.js CHANGED
@@ -8,7 +8,6 @@ exports.default = exports.Pill = void 0;
8
8
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
9
9
  var _react = require("react");
10
10
  var _View = require("@instructure/ui-view/lib/View");
11
- var _TruncateText = require("@instructure/ui-truncate-text/lib/TruncateText");
12
11
  var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
13
12
  var _testable = require("@instructure/ui-testable/lib/testable.js");
14
13
  var _Tooltip = require("@instructure/ui-tooltip/lib/Tooltip");
@@ -16,7 +15,7 @@ var _emotion = require("@instructure/emotion");
16
15
  var _styles = _interopRequireDefault(require("./styles"));
17
16
  var _theme = _interopRequireDefault(require("./theme"));
18
17
  var _props = require("./props");
19
- const _excluded = ["margin", "children", "color", "as", "elementRef", "styles", "makeStyles"];
18
+ const _excluded = ["margin", "children", "color", "as", "elementRef", "styles", "makeStyles", "statusLabel", "renderIcon"];
20
19
  var _dec, _dec2, _class, _class2;
21
20
  /*
22
21
  * The MIT License (MIT)
@@ -51,6 +50,7 @@ let Pill = exports.Pill = (_dec = (0, _emotion.withStyle)(_styles.default, _them
51
50
  constructor(props) {
52
51
  super(props);
53
52
  this.ref = null;
53
+ this.ellipsisRef = null;
54
54
  this.handleRef = el => {
55
55
  const elementRef = this.props.elementRef;
56
56
  this.ref = el;
@@ -64,16 +64,17 @@ let Pill = exports.Pill = (_dec = (0, _emotion.withStyle)(_styles.default, _them
64
64
  }
65
65
  componentDidMount() {
66
66
  var _this$props$makeStyle, _this$props;
67
+ this.setTruncation();
67
68
  (_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props);
68
69
  }
69
70
  componentDidUpdate() {
70
71
  var _this$props$makeStyle2, _this$props2;
71
72
  (_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2);
72
73
  }
73
- handleTruncation(truncated) {
74
- if (truncated !== this.state.truncated) {
74
+ setTruncation() {
75
+ if (this.ellipsisRef) {
75
76
  this.setState({
76
- truncated: truncated
77
+ truncated: this.ellipsisRef.offsetWidth < this.ellipsisRef.scrollWidth
77
78
  });
78
79
  }
79
80
  }
@@ -86,6 +87,8 @@ let Pill = exports.Pill = (_dec = (0, _emotion.withStyle)(_styles.default, _them
86
87
  elementRef = _this$props3.elementRef,
87
88
  styles = _this$props3.styles,
88
89
  makeStyles = _this$props3.makeStyles,
90
+ statusLabel = _this$props3.statusLabel,
91
+ renderIcon = _this$props3.renderIcon,
89
92
  props = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
90
93
  const filteredProps = (0, _passthroughProps.passthroughProps)(props);
91
94
  const containerProps = typeof getTriggerProps === 'function' ? getTriggerProps(filteredProps) : filteredProps;
@@ -105,20 +108,23 @@ let Pill = exports.Pill = (_dec = (0, _emotion.withStyle)(_styles.default, _them
105
108
  position: "relative",
106
109
  withFocusOutline: focused,
107
110
  focusColor: "info"
108
- }), (0, _emotion.jsx)("span", {
111
+ }), (0, _emotion.jsx)("div", {
109
112
  css: styles === null || styles === void 0 ? void 0 : styles.pill
110
- }, (0, _emotion.jsx)("span", {
111
- css: styles === null || styles === void 0 ? void 0 : styles.text
112
- }, (0, _emotion.jsx)(_TruncateText.TruncateText, {
113
- onUpdate: truncated => {
114
- this.handleTruncation(truncated);
113
+ }, renderIcon && (0, _emotion.jsx)("div", {
114
+ css: styles === null || styles === void 0 ? void 0 : styles.icon
115
+ }, renderIcon), (0, _emotion.jsx)("div", {
116
+ css: styles === null || styles === void 0 ? void 0 : styles.text,
117
+ ref: el => {
118
+ this.ellipsisRef = el;
115
119
  }
116
- }, children))));
120
+ }, statusLabel && (0, _emotion.jsx)("span", {
121
+ css: styles === null || styles === void 0 ? void 0 : styles.status
122
+ }, statusLabel && statusLabel.concat(':')), children)));
117
123
  }
118
124
  render() {
119
125
  if (this.state.truncated) {
120
126
  return (0, _emotion.jsx)(_Tooltip.Tooltip, {
121
- renderTip: this.props.children,
127
+ renderTip: this.props.statusLabel ? this.props.statusLabel.concat(': ', this.props.children) : this.props.children,
122
128
  elementRef: this.handleRef
123
129
  }, ({
124
130
  focused,
package/lib/Pill/props.js CHANGED
@@ -37,6 +37,8 @@ const propTypes = exports.propTypes = {
37
37
  children: _propTypes.default.node.isRequired,
38
38
  color: _propTypes.default.oneOf(['primary', 'success', 'danger', 'info', 'warning', 'alert']),
39
39
  elementRef: _propTypes.default.func,
40
- margin: _emotion.ThemeablePropTypes.spacing
40
+ margin: _emotion.ThemeablePropTypes.spacing,
41
+ statusLabel: _propTypes.default.string,
42
+ renderIcon: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func])
41
43
  };
42
44
  const allowedProps = exports.allowedProps = ['as', 'children', 'color', 'elementRef', 'margin'];
@@ -69,7 +69,9 @@ const generateStyle = (componentTheme, props) => {
69
69
  return {
70
70
  pill: {
71
71
  label: 'pill',
72
- display: 'block',
72
+ display: 'flex',
73
+ alignItems: 'center',
74
+ justifyContent: 'center',
73
75
  fontFamily: componentTheme.fontFamily,
74
76
  boxSizing: 'border-box',
75
77
  padding: componentTheme.padding,
@@ -81,13 +83,29 @@ const generateStyle = (componentTheme, props) => {
81
83
  lineHeight: `calc(${componentTheme.height} - (${componentTheme.borderWidth} * 2))`,
82
84
  ...pillColorVariants[color]
83
85
  },
86
+ status: {
87
+ label: 'pill__status',
88
+ boxSizing: 'border-box',
89
+ fontSize: componentTheme.textFontSize,
90
+ fontWeight: componentTheme.statusLabelFontWeight,
91
+ marginRight: '0.125rem'
92
+ },
93
+ icon: {
94
+ label: 'pill__icon',
95
+ display: 'flex',
96
+ alignItems: 'center',
97
+ marginRight: '0.375rem',
98
+ fontSize: '0.75rem'
99
+ },
84
100
  text: {
85
101
  label: 'pill__text',
86
102
  boxSizing: 'border-box',
87
- textTransform: componentTheme.textTransformStyle,
103
+ maxWidth: componentTheme.maxWidth,
88
104
  fontSize: componentTheme.textFontSize,
89
105
  fontWeight: componentTheme.textFontWeight,
90
- letterSpacing: '0.0625rem'
106
+ textOverflow: 'ellipsis',
107
+ whiteSpace: 'nowrap',
108
+ overflow: 'hidden'
91
109
  },
92
110
  maxWidth: componentTheme.maxWidth
93
111
  };
package/lib/Pill/theme.js CHANGED
@@ -47,11 +47,11 @@ const generateComponentTheme = theme => {
47
47
  const componentVariables = {
48
48
  fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
49
49
  padding: `0 ${spacing === null || spacing === void 0 ? void 0 : spacing.xSmall}`,
50
- height: '1.3125rem',
50
+ height: '1.5rem',
51
51
  background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
52
- textTransformStyle: 'uppercase',
53
- textFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeXSmall,
54
- textFontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
52
+ textFontSize: typography === null || typography === void 0 ? void 0 : typography.fontSizeSmall,
53
+ textFontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightNormal,
54
+ statusLabelFontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
55
55
  maxWidth: '15rem',
56
56
  primaryColor: colors === null || colors === void 0 ? void 0 : colors.textDark,
57
57
  infoColor: colors === null || colors === void 0 ? void 0 : colors.textInfo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-pill",
3
- "version": "8.48.3",
3
+ "version": "8.48.4-snapshot-0",
4
4
  "description": "A UI component to communicate concise status.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,24 +24,29 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.23.2",
27
- "@instructure/console": "8.48.3",
28
- "@instructure/emotion": "8.48.3",
29
- "@instructure/shared-types": "8.48.3",
30
- "@instructure/ui-react-utils": "8.48.3",
31
- "@instructure/ui-testable": "8.48.3",
32
- "@instructure/ui-tooltip": "8.48.3",
33
- "@instructure/ui-truncate-text": "8.48.3",
34
- "@instructure/ui-utils": "8.48.3",
35
- "@instructure/ui-view": "8.48.3",
27
+ "@instructure/console": "8.48.4-snapshot-0",
28
+ "@instructure/emotion": "8.48.4-snapshot-0",
29
+ "@instructure/shared-types": "8.48.4-snapshot-0",
30
+ "@instructure/ui-react-utils": "8.48.4-snapshot-0",
31
+ "@instructure/ui-testable": "8.48.4-snapshot-0",
32
+ "@instructure/ui-tooltip": "8.48.4-snapshot-0",
33
+ "@instructure/ui-truncate-text": "8.48.4-snapshot-0",
34
+ "@instructure/ui-utils": "8.48.4-snapshot-0",
35
+ "@instructure/ui-view": "8.48.4-snapshot-0",
36
36
  "prop-types": "^15.8.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@instructure/ui-babel-preset": "8.48.3",
40
- "@instructure/ui-color-utils": "8.48.3",
41
- "@instructure/ui-test-locator": "8.48.3",
42
- "@instructure/ui-test-queries": "8.48.3",
43
- "@instructure/ui-test-utils": "8.48.3",
44
- "@instructure/ui-themes": "8.48.3"
39
+ "@instructure/ui-axe-check": "8.48.4-snapshot-0",
40
+ "@instructure/ui-babel-preset": "8.48.4-snapshot-0",
41
+ "@instructure/ui-color-utils": "8.48.4-snapshot-0",
42
+ "@instructure/ui-icons": "8.48.4-snapshot-0",
43
+ "@instructure/ui-scripts": "8.48.4-snapshot-0",
44
+ "@instructure/ui-test-locator": "8.48.4-snapshot-0",
45
+ "@instructure/ui-test-queries": "8.48.4-snapshot-0",
46
+ "@instructure/ui-test-utils": "8.48.4-snapshot-0",
47
+ "@instructure/ui-themes": "8.48.4-snapshot-0",
48
+ "@testing-library/jest-dom": "^6.1.4",
49
+ "@testing-library/react": "^14.0.0"
45
50
  },
46
51
  "peerDependencies": {
47
52
  "react": ">=16.8 <=18"
@@ -4,7 +4,8 @@ describes: Pill
4
4
 
5
5
  Displays short, contextual information about an item. Change the border
6
6
  and text color via the `color` prop. Use the `margin` prop to add space around
7
- the component.
7
+ the component. Use the `renderIcon` prop to add an icon to the left of the text. Additionally,
8
+ you can use the `statusLabel` prop to add a label to the left of the main text.
8
9
 
9
10
  ```js
10
11
  ---
@@ -17,30 +18,36 @@ example: true
17
18
  Excused
18
19
  </Pill>
19
20
  <Pill
21
+ statusLabel="Status"
20
22
  color="info"
21
23
  margin="x-small"
22
24
  >
23
25
  Draft
24
26
  </Pill>
25
27
  <Pill
28
+ statusLabel="Status"
29
+ renderIcon={<IconCheckLine />}
26
30
  color="success"
27
31
  margin="x-small"
28
32
  >
29
33
  Checked In
30
34
  </Pill>
31
35
  <Pill
36
+ renderIcon={<IconEndLine />}
32
37
  color="danger"
33
38
  margin="x-small"
34
39
  >
35
40
  Missing
36
41
  </Pill>
37
42
  <Pill
43
+ renderIcon={<IconClockLine />}
38
44
  color="warning"
39
45
  margin="x-small"
40
46
  >
41
47
  Late
42
48
  </Pill>
43
49
  <Pill
50
+ renderIcon={<IconMessageLine />}
44
51
  color="alert"
45
52
  margin="x-small"
46
53
  >
@@ -57,7 +64,7 @@ be handled via ellipses.
57
64
  example: true
58
65
  ---
59
66
  <Pill>
60
- extraordinary superfluousness
67
+ Supercalifragilisticexpialidocious bear
61
68
  </Pill>
62
69
  ```
63
70