@zendeskgarden/react-tags 9.0.0-next.9 → 9.1.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.
@@ -7,7 +7,7 @@
7
7
  import * as React from 'react';
8
8
 
9
9
  var _path;
10
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
10
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
11
11
  var SvgXStroke = function SvgXStroke(props) {
12
12
  return /*#__PURE__*/React.createElement("svg", _extends({
13
13
  xmlns: "http://www.w3.org/2000/svg",
@@ -5,18 +5,15 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  import styled from 'styled-components';
8
- import { StyledBaseIcon, retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
8
+ import { StyledBaseIcon, retrieveComponentStyles } from '@zendeskgarden/react-theming';
9
9
 
10
10
  const COMPONENT_ID = 'tags.avatar';
11
11
  const StyledAvatar = styled(StyledBaseIcon).attrs({
12
12
  'data-garden-id': COMPONENT_ID,
13
- 'data-garden-version': '9.0.0-next.9'
13
+ 'data-garden-version': '9.1.0'
14
14
  }).withConfig({
15
15
  displayName: "StyledAvatar",
16
16
  componentId: "sc-3kdmgt-0"
17
17
  })(["flex-shrink:0;font-size:0;", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
18
- StyledAvatar.defaultProps = {
19
- theme: DEFAULT_THEME
20
- };
21
18
 
22
19
  export { StyledAvatar };
@@ -5,18 +5,15 @@
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
7
  import styled from 'styled-components';
8
- import { retrieveComponentStyles, DEFAULT_THEME } from '@zendeskgarden/react-theming';
8
+ import { retrieveComponentStyles } from '@zendeskgarden/react-theming';
9
9
 
10
10
  const COMPONENT_ID = 'tags.close';
11
11
  const StyledClose = styled.button.attrs({
12
12
  'data-garden-id': COMPONENT_ID,
13
- 'data-garden-version': '9.0.0-next.9'
13
+ 'data-garden-version': '9.1.0'
14
14
  }).withConfig({
15
15
  displayName: "StyledClose",
16
16
  componentId: "sc-d6lrpn-0"
17
- })(["display:flex;flex-shrink:0;align-items:center;justify-content:center;transition:opacity 0.25s ease-in-out;opacity:0.8;border:0;background:transparent;cursor:pointer;padding:0;color:inherit;font-size:0;appearance:none;&:hover{opacity:0.9;}&:focus{outline:none;}", ";"], props => retrieveComponentStyles(COMPONENT_ID, props));
18
- StyledClose.defaultProps = {
19
- theme: DEFAULT_THEME
20
- };
17
+ })(["display:flex;flex-shrink:0;align-items:center;justify-content:center;transition:opacity 0.25s ease-in-out;opacity:", ";border:0;background:transparent;cursor:pointer;padding:0;color:inherit;font-size:0;appearance:none;&:hover{opacity:", ";}&:focus{outline:none;}&:active{opacity:", ";}", ";"], props => props.theme.opacity[1000], props => props.theme.opacity[1100], props => props.theme.opacity[1200], props => retrieveComponentStyles(COMPONENT_ID, props));
21
18
 
22
19
  export { StyledClose };
@@ -6,33 +6,134 @@
6
6
  */
7
7
  import styled, { css } from 'styled-components';
8
8
  import { readableColor, math } from 'polished';
9
- import { SELECTOR_FOCUS_VISIBLE, retrieveComponentStyles, DEFAULT_THEME, getColorV8, focusStyles, getLineHeight } from '@zendeskgarden/react-theming';
9
+ import { SELECTOR_FOCUS_VISIBLE, retrieveComponentStyles, DEFAULT_THEME, getColor, focusStyles, getLineHeight } from '@zendeskgarden/react-theming';
10
10
  import { StyledAvatar } from './StyledAvatar.js';
11
11
  import { StyledClose } from './StyledClose.js';
12
12
 
13
13
  const COMPONENT_ID = 'tags.tag_view';
14
- const colorStyles = props => {
14
+ const colorStyles = _ref => {
15
+ let {
16
+ theme,
17
+ hue
18
+ } = _ref;
15
19
  let backgroundColor;
16
20
  let foregroundColor;
17
- let closeColor;
18
- if (props.hue) {
19
- const shade = props.hue === 'yellow' ? 400 : 600;
20
- backgroundColor = getColorV8(props.hue, shade, props.theme);
21
- if (props.hue === 'yellow' || props.hue === 'lemon') {
22
- foregroundColor = getColorV8('yellow', 800, props.theme);
23
- } else {
24
- foregroundColor = readableColor(backgroundColor, props.theme.palette.grey[800], props.theme.palette.white);
21
+ if (hue) {
22
+ foregroundColor = getColor({
23
+ theme,
24
+ variable: 'foreground.onEmphasis'
25
+ });
26
+ switch (hue) {
27
+ case 'grey':
28
+ case 'neutralHue':
29
+ backgroundColor = getColor({
30
+ theme,
31
+ variable: 'background.emphasis',
32
+ dark: {
33
+ offset: -300
34
+ }
35
+ });
36
+ break;
37
+ case 'blue':
38
+ case 'primaryHue':
39
+ backgroundColor = getColor({
40
+ theme,
41
+ variable: 'background.primaryEmphasis'
42
+ });
43
+ break;
44
+ case 'red':
45
+ case 'dangerHue':
46
+ backgroundColor = getColor({
47
+ theme,
48
+ variable: 'background.dangerEmphasis'
49
+ });
50
+ break;
51
+ case 'green':
52
+ case 'successHue':
53
+ backgroundColor = getColor({
54
+ theme,
55
+ variable: 'background.successEmphasis'
56
+ });
57
+ break;
58
+ case 'yellow':
59
+ case 'warningHue':
60
+ backgroundColor = getColor({
61
+ theme,
62
+ hue: 'warningHue',
63
+ shade: 400
64
+ });
65
+ if (theme.colors.base === 'light') {
66
+ foregroundColor = getColor({
67
+ theme,
68
+ variable: 'foreground.warningEmphasis'
69
+ });
70
+ }
71
+ break;
72
+ case 'kale':
73
+ case 'chromeHue':
74
+ backgroundColor = getColor({
75
+ theme,
76
+ hue: 'chromeHue',
77
+ dark: {
78
+ shade: 500
79
+ },
80
+ light: {
81
+ shade: 800
82
+ }
83
+ });
84
+ break;
85
+ default:
86
+ {
87
+ const lightTheme = {
88
+ ...theme,
89
+ colors: {
90
+ ...theme.colors,
91
+ base: 'light'
92
+ }
93
+ };
94
+ const darkTheme = {
95
+ ...theme,
96
+ colors: {
97
+ ...theme.colors,
98
+ base: 'dark'
99
+ }
100
+ };
101
+ const variable = 'foreground.onEmphasis';
102
+ backgroundColor = getColor({
103
+ theme,
104
+ hue
105
+ });
106
+ foregroundColor = readableColor(backgroundColor, getColor({
107
+ theme: darkTheme,
108
+ variable
109
+ }), getColor({
110
+ theme: lightTheme,
111
+ variable
112
+ }), false );
113
+ break;
114
+ }
25
115
  }
26
116
  } else {
27
- backgroundColor = getColorV8('neutralHue', 200, props.theme);
28
- foregroundColor = getColorV8('neutralHue', 700, props.theme);
29
- closeColor = getColorV8('neutralHue', 600, props.theme);
117
+ backgroundColor = getColor({
118
+ theme,
119
+ hue: 'neutralHue',
120
+ dark: {
121
+ shade: 800
122
+ },
123
+ light: {
124
+ shade: 200
125
+ }
126
+ });
127
+ foregroundColor = getColor({
128
+ theme,
129
+ variable: 'foreground.default'
130
+ });
30
131
  }
31
- return css(["background-color:", ";color:", ";&:hover{color:", ";}", " & ", "{color:", ";}"], backgroundColor, foregroundColor, foregroundColor, focusStyles({
32
- theme: props.theme,
132
+ return css(["background-color:", ";color:", ";&:hover{color:", ";}", ""], backgroundColor, foregroundColor, foregroundColor, focusStyles({
133
+ theme,
33
134
  shadowWidth: 'sm',
34
135
  selector: '&:focus'
35
- }), StyledClose, closeColor);
136
+ }));
36
137
  };
37
138
  const sizeStyles = props => {
38
139
  let borderRadius;
@@ -84,7 +185,7 @@ const sizeStyles = props => {
84
185
  };
85
186
  const StyledTag = styled.div.attrs({
86
187
  'data-garden-id': COMPONENT_ID,
87
- 'data-garden-version': '9.0.0-next.9'
188
+ 'data-garden-version': '9.1.0'
88
189
  }).withConfig({
89
190
  displayName: "StyledTag",
90
191
  componentId: "sc-1jvbe03-0"
package/dist/index.cjs.js CHANGED
@@ -41,50 +41,145 @@ const SIZE = ['small', 'medium', 'large'];
41
41
  const COMPONENT_ID$2 = 'tags.avatar';
42
42
  const StyledAvatar = styled__default.default(reactTheming.StyledBaseIcon).attrs({
43
43
  'data-garden-id': COMPONENT_ID$2,
44
- 'data-garden-version': '9.0.0-next.9'
44
+ 'data-garden-version': '9.1.0'
45
45
  }).withConfig({
46
46
  displayName: "StyledAvatar",
47
47
  componentId: "sc-3kdmgt-0"
48
48
  })(["flex-shrink:0;font-size:0;", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$2, props));
49
- StyledAvatar.defaultProps = {
50
- theme: reactTheming.DEFAULT_THEME
51
- };
52
49
 
53
50
  const COMPONENT_ID$1 = 'tags.close';
54
51
  const StyledClose = styled__default.default.button.attrs({
55
52
  'data-garden-id': COMPONENT_ID$1,
56
- 'data-garden-version': '9.0.0-next.9'
53
+ 'data-garden-version': '9.1.0'
57
54
  }).withConfig({
58
55
  displayName: "StyledClose",
59
56
  componentId: "sc-d6lrpn-0"
60
- })(["display:flex;flex-shrink:0;align-items:center;justify-content:center;transition:opacity 0.25s ease-in-out;opacity:0.8;border:0;background:transparent;cursor:pointer;padding:0;color:inherit;font-size:0;appearance:none;&:hover{opacity:0.9;}&:focus{outline:none;}", ";"], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props));
61
- StyledClose.defaultProps = {
62
- theme: reactTheming.DEFAULT_THEME
63
- };
57
+ })(["display:flex;flex-shrink:0;align-items:center;justify-content:center;transition:opacity 0.25s ease-in-out;opacity:", ";border:0;background:transparent;cursor:pointer;padding:0;color:inherit;font-size:0;appearance:none;&:hover{opacity:", ";}&:focus{outline:none;}&:active{opacity:", ";}", ";"], props => props.theme.opacity[1000], props => props.theme.opacity[1100], props => props.theme.opacity[1200], props => reactTheming.retrieveComponentStyles(COMPONENT_ID$1, props));
64
58
 
65
59
  const COMPONENT_ID = 'tags.tag_view';
66
- const colorStyles = props => {
60
+ const colorStyles = _ref => {
61
+ let {
62
+ theme,
63
+ hue
64
+ } = _ref;
67
65
  let backgroundColor;
68
66
  let foregroundColor;
69
- let closeColor;
70
- if (props.hue) {
71
- const shade = props.hue === 'yellow' ? 400 : 600;
72
- backgroundColor = reactTheming.getColorV8(props.hue, shade, props.theme);
73
- if (props.hue === 'yellow' || props.hue === 'lemon') {
74
- foregroundColor = reactTheming.getColorV8('yellow', 800, props.theme);
75
- } else {
76
- foregroundColor = polished.readableColor(backgroundColor, props.theme.palette.grey[800], props.theme.palette.white);
67
+ if (hue) {
68
+ foregroundColor = reactTheming.getColor({
69
+ theme,
70
+ variable: 'foreground.onEmphasis'
71
+ });
72
+ switch (hue) {
73
+ case 'grey':
74
+ case 'neutralHue':
75
+ backgroundColor = reactTheming.getColor({
76
+ theme,
77
+ variable: 'background.emphasis',
78
+ dark: {
79
+ offset: -300
80
+ }
81
+ });
82
+ break;
83
+ case 'blue':
84
+ case 'primaryHue':
85
+ backgroundColor = reactTheming.getColor({
86
+ theme,
87
+ variable: 'background.primaryEmphasis'
88
+ });
89
+ break;
90
+ case 'red':
91
+ case 'dangerHue':
92
+ backgroundColor = reactTheming.getColor({
93
+ theme,
94
+ variable: 'background.dangerEmphasis'
95
+ });
96
+ break;
97
+ case 'green':
98
+ case 'successHue':
99
+ backgroundColor = reactTheming.getColor({
100
+ theme,
101
+ variable: 'background.successEmphasis'
102
+ });
103
+ break;
104
+ case 'yellow':
105
+ case 'warningHue':
106
+ backgroundColor = reactTheming.getColor({
107
+ theme,
108
+ hue: 'warningHue',
109
+ shade: 400
110
+ });
111
+ if (theme.colors.base === 'light') {
112
+ foregroundColor = reactTheming.getColor({
113
+ theme,
114
+ variable: 'foreground.warningEmphasis'
115
+ });
116
+ }
117
+ break;
118
+ case 'kale':
119
+ case 'chromeHue':
120
+ backgroundColor = reactTheming.getColor({
121
+ theme,
122
+ hue: 'chromeHue',
123
+ dark: {
124
+ shade: 500
125
+ },
126
+ light: {
127
+ shade: 800
128
+ }
129
+ });
130
+ break;
131
+ default:
132
+ {
133
+ const lightTheme = {
134
+ ...theme,
135
+ colors: {
136
+ ...theme.colors,
137
+ base: 'light'
138
+ }
139
+ };
140
+ const darkTheme = {
141
+ ...theme,
142
+ colors: {
143
+ ...theme.colors,
144
+ base: 'dark'
145
+ }
146
+ };
147
+ const variable = 'foreground.onEmphasis';
148
+ backgroundColor = reactTheming.getColor({
149
+ theme,
150
+ hue
151
+ });
152
+ foregroundColor = polished.readableColor(backgroundColor, reactTheming.getColor({
153
+ theme: darkTheme,
154
+ variable
155
+ }), reactTheming.getColor({
156
+ theme: lightTheme,
157
+ variable
158
+ }), false );
159
+ break;
160
+ }
77
161
  }
78
162
  } else {
79
- backgroundColor = reactTheming.getColorV8('neutralHue', 200, props.theme);
80
- foregroundColor = reactTheming.getColorV8('neutralHue', 700, props.theme);
81
- closeColor = reactTheming.getColorV8('neutralHue', 600, props.theme);
163
+ backgroundColor = reactTheming.getColor({
164
+ theme,
165
+ hue: 'neutralHue',
166
+ dark: {
167
+ shade: 800
168
+ },
169
+ light: {
170
+ shade: 200
171
+ }
172
+ });
173
+ foregroundColor = reactTheming.getColor({
174
+ theme,
175
+ variable: 'foreground.default'
176
+ });
82
177
  }
83
- return styled.css(["background-color:", ";color:", ";&:hover{color:", ";}", " & ", "{color:", ";}"], backgroundColor, foregroundColor, foregroundColor, reactTheming.focusStyles({
84
- theme: props.theme,
178
+ return styled.css(["background-color:", ";color:", ";&:hover{color:", ";}", ""], backgroundColor, foregroundColor, foregroundColor, reactTheming.focusStyles({
179
+ theme,
85
180
  shadowWidth: 'sm',
86
181
  selector: '&:focus'
87
- }), StyledClose, closeColor);
182
+ }));
88
183
  };
89
184
  const sizeStyles = props => {
90
185
  let borderRadius;
@@ -136,7 +231,7 @@ const sizeStyles = props => {
136
231
  };
137
232
  const StyledTag = styled__default.default.div.attrs({
138
233
  'data-garden-id': COMPONENT_ID,
139
- 'data-garden-version': '9.0.0-next.9'
234
+ 'data-garden-version': '9.1.0'
140
235
  }).withConfig({
141
236
  displayName: "StyledTag",
142
237
  componentId: "sc-1jvbe03-0"
@@ -147,7 +242,7 @@ StyledTag.defaultProps = {
147
242
  };
148
243
 
149
244
  var _path;
150
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
245
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
151
246
  var SvgXStroke = function SvgXStroke(props) {
152
247
  return /*#__PURE__*/React__namespace.createElement("svg", _extends({
153
248
  xmlns: "http://www.w3.org/2000/svg",
@@ -8,10 +8,12 @@ import React from 'react';
8
8
  import { ITagProps } from '../types';
9
9
  import { Close } from './Close';
10
10
  import { Avatar } from './Avatar';
11
+ declare const TagComponent: React.ForwardRefExoticComponent<ITagProps & React.RefAttributes<HTMLDivElement>>;
11
12
  /**
12
13
  * @extends HTMLAttributes<HTMLDivElement>
13
14
  */
14
- export declare const Tag: React.ForwardRefExoticComponent<ITagProps & React.RefAttributes<HTMLDivElement>> & {
15
+ export declare const Tag: typeof TagComponent & {
15
16
  Avatar: typeof Avatar;
16
17
  Close: typeof Close;
17
18
  };
19
+ export {};
@@ -4,8 +4,7 @@
4
4
  * Use of this source code is governed under the Apache License, Version 2.0
5
5
  * found at http://www.apache.org/licenses/LICENSE-2.0.
6
6
  */
7
- /// <reference types="react" />
8
- export declare const StyledAvatar: import("styled-components").StyledComponent<({ children, theme, ...props }: any) => import("react").DetailedReactHTMLElement<any, HTMLElement>, import("styled-components").DefaultTheme, {
7
+ export declare const StyledAvatar: import("styled-components").StyledComponent<({ children, theme, ...props }: any) => React.DetailedReactHTMLElement<any, HTMLElement>, import("styled-components").DefaultTheme, {
9
8
  'data-garden-id': string;
10
9
  'data-garden-version': string;
11
10
  }, "data-garden-id" | "data-garden-version">;
@@ -10,9 +10,13 @@ export interface ITagProps extends HTMLAttributes<HTMLDivElement> {
10
10
  /** Adjusts font size and padding */
11
11
  size?: (typeof SIZE)[number];
12
12
  /**
13
- * Sets the color of the tag. Refer to
14
- * [PALETTE](/components/palette#palette)
15
- * for available colors. Accepts any hex value.
13
+ * Sets the color of the tag. Refer to theming
14
+ * [colors](/components/theme-object#colors) or
15
+ * [PALETTE](/components/palette#palette) for available colors. Use [primary
16
+ * hues](/design/color#primary-colors) – `blue`, `green`, `grey`, `kale`,
17
+ * `red`, `yellow` or `primaryHue`, `successHue`, `neutralHue`, `chromeHue`,
18
+ * `dangerHue`, `warningHue` – to apply color based on light/dark mode.
19
+ * Accepts any hex value.
16
20
  */
17
21
  hue?: string;
18
22
  /** Applies pill styling */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendeskgarden/react-tags",
3
- "version": "9.0.0-next.9",
3
+ "version": "9.1.0",
4
4
  "description": "Components relating to tags in the Garden Design System",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Zendesk Garden <garden@zendesk.com>",
@@ -22,18 +22,18 @@
22
22
  "types": "dist/typings/index.d.ts",
23
23
  "dependencies": {
24
24
  "@zendeskgarden/container-utilities": "^2.0.0",
25
- "polished": "^4.0.0",
25
+ "polished": "^4.3.1",
26
26
  "prop-types": "^15.5.7"
27
27
  },
28
28
  "peerDependencies": {
29
29
  "@zendeskgarden/react-theming": ">=9.0.0-next",
30
- "react": ">=16.8.0",
31
- "react-dom": ">=16.8.0",
30
+ "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
31
+ "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
32
32
  "styled-components": "^5.3.1"
33
33
  },
34
34
  "devDependencies": {
35
- "@zendeskgarden/react-theming": "^9.0.0-next.9",
36
- "@zendeskgarden/svg-icons": "7.0.0"
35
+ "@zendeskgarden/react-theming": "^9.1.0",
36
+ "@zendeskgarden/svg-icons": "7.3.0"
37
37
  },
38
38
  "keywords": [
39
39
  "components",
@@ -45,5 +45,5 @@
45
45
  "access": "public"
46
46
  },
47
47
  "zendeskgarden:src": "src/index.ts",
48
- "gitHead": "771281b562d376a6aee04b0cd71dd888b3ae4a1d"
48
+ "gitHead": "a2842d18615ad057d75988fde4df5a0c79d2714e"
49
49
  }