@instructure/ui-avatar 9.5.2-snapshot-7 → 9.6.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 +5 -5
- package/es/Avatar/__new-tests__/Avatar.test.js +5 -5
- package/es/Avatar/theme.js +17 -11
- package/lib/Avatar/__new-tests__/Avatar.test.js +5 -5
- package/lib/Avatar/theme.js +17 -11
- package/package.json +13 -13
- package/src/Avatar/__new-tests__/Avatar.test.tsx +5 -5
- package/src/Avatar/theme.ts +12 -10
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Avatar/theme.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,17 +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
|
-
|
|
6
|
+
# [9.6.0](https://github.com/instructure/instructure-ui/compare/v9.5.2...v9.6.0) (2024-08-14)
|
|
7
7
|
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-avatar
|
|
8
9
|
|
|
9
|
-
### Features
|
|
10
10
|
|
|
11
|
-
* **many:** rewrite color system ([1e5809e](https://github.com/instructure/instructure-ui/commit/1e5809e28dee8c2a71703a429609b8d2f95d76e6))
|
|
12
11
|
|
|
13
12
|
|
|
14
|
-
### BREAKING CHANGES
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
## [9.5.2](https://github.com/instructure/instructure-ui/compare/v9.5.1...v9.5.2) (2024-08-05)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @instructure/ui-avatar
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
|
|
@@ -78,7 +78,7 @@ describe('<Avatar />', () => {
|
|
|
78
78
|
name: "Jessica Jones"
|
|
79
79
|
})));
|
|
80
80
|
const initials = screen.getByText('JJ');
|
|
81
|
-
expect(getComputedStyle(initials).color).toBe('rgb(
|
|
81
|
+
expect(getComputedStyle(initials).color).toBe('rgb(3, 116, 181)');
|
|
82
82
|
});
|
|
83
83
|
it('should return the underlying component', async () => {
|
|
84
84
|
const elementRef = vi.fn();
|
|
@@ -194,7 +194,7 @@ describe('<Avatar />', () => {
|
|
|
194
194
|
color: "shamrock"
|
|
195
195
|
})));
|
|
196
196
|
const initials = screen.getByText('JJ');
|
|
197
|
-
expect(getComputedStyle(initials).color).toBe('rgb(
|
|
197
|
+
expect(getComputedStyle(initials).color).toBe('rgb(11, 135, 75)');
|
|
198
198
|
});
|
|
199
199
|
it('should display the icon in green (shamrock)', async () => {
|
|
200
200
|
const _render13 = render(_Avatar13 || (_Avatar13 = /*#__PURE__*/React.createElement(Avatar, {
|
|
@@ -205,7 +205,7 @@ describe('<Avatar />', () => {
|
|
|
205
205
|
container = _render13.container;
|
|
206
206
|
const avatarSvg = container.querySelector('svg');
|
|
207
207
|
expect(avatarSvg).toHaveStyle({
|
|
208
|
-
fill: '#
|
|
208
|
+
fill: '#FC5E13'
|
|
209
209
|
});
|
|
210
210
|
});
|
|
211
211
|
});
|
|
@@ -219,7 +219,7 @@ describe('<Avatar />', () => {
|
|
|
219
219
|
})));
|
|
220
220
|
const initials = screen.getByText('JJ');
|
|
221
221
|
expect(initials.parentNode).toHaveStyle({
|
|
222
|
-
backgroundColor: 'rgb(
|
|
222
|
+
backgroundColor: 'rgb(11, 135, 75)'
|
|
223
223
|
});
|
|
224
224
|
});
|
|
225
225
|
it('should display the initials in white', async () => {
|
|
@@ -245,7 +245,7 @@ describe('<Avatar />', () => {
|
|
|
245
245
|
container = _render14.container;
|
|
246
246
|
const element = container.querySelector('span');
|
|
247
247
|
expect(element).toHaveStyle({
|
|
248
|
-
backgroundColor: 'rgb(
|
|
248
|
+
backgroundColor: 'rgb(11, 135, 75)'
|
|
249
249
|
});
|
|
250
250
|
});
|
|
251
251
|
it('should display the icon in white', async () => {
|
package/es/Avatar/theme.js
CHANGED
|
@@ -29,28 +29,34 @@ import { alpha } from '@instructure/ui-color-utils';
|
|
|
29
29
|
* @return {Object} The final theme object with the overrides and component variables
|
|
30
30
|
*/
|
|
31
31
|
const generateComponentTheme = theme => {
|
|
32
|
-
var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8;
|
|
33
32
|
const colors = theme.colors,
|
|
34
33
|
borders = theme.borders,
|
|
35
34
|
typography = theme.typography;
|
|
35
|
+
const brand = colors.brand,
|
|
36
|
+
shamrock = colors.shamrock,
|
|
37
|
+
barney = colors.barney,
|
|
38
|
+
crimson = colors.crimson,
|
|
39
|
+
fire = colors.fire,
|
|
40
|
+
licorice = colors.licorice,
|
|
41
|
+
ash = colors.ash;
|
|
36
42
|
const componentVariables = {
|
|
37
|
-
background: colors === null || colors === void 0 ? void 0 :
|
|
43
|
+
background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
|
|
38
44
|
borderWidthSmall: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
|
|
39
45
|
borderWidthMedium: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
40
|
-
borderColor: colors === null || colors === void 0 ? void 0 :
|
|
41
|
-
boxShadowColor: alpha(
|
|
46
|
+
borderColor: colors === null || colors === void 0 ? void 0 : colors.borderMedium,
|
|
47
|
+
boxShadowColor: alpha(colors === null || colors === void 0 ? void 0 : colors.backgroundDarkest, 12),
|
|
42
48
|
boxShadowBlur: '1rem',
|
|
43
49
|
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
44
50
|
fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
|
|
45
51
|
// these colors have sufficient contrast with the white background
|
|
46
52
|
// in the normal and high contrast themes
|
|
47
|
-
color:
|
|
48
|
-
colorShamrock:
|
|
49
|
-
colorBarney:
|
|
50
|
-
colorCrimson:
|
|
51
|
-
colorFire:
|
|
52
|
-
colorLicorice:
|
|
53
|
-
colorAsh:
|
|
53
|
+
color: brand,
|
|
54
|
+
colorShamrock: shamrock,
|
|
55
|
+
colorBarney: barney,
|
|
56
|
+
colorCrimson: crimson,
|
|
57
|
+
colorFire: fire,
|
|
58
|
+
colorLicorice: licorice,
|
|
59
|
+
colorAsh: ash
|
|
54
60
|
};
|
|
55
61
|
return {
|
|
56
62
|
...componentVariables
|
|
@@ -81,7 +81,7 @@ describe('<Avatar />', () => {
|
|
|
81
81
|
name: "Jessica Jones"
|
|
82
82
|
})));
|
|
83
83
|
const initials = _react2.screen.getByText('JJ');
|
|
84
|
-
expect(getComputedStyle(initials).color).toBe('rgb(
|
|
84
|
+
expect(getComputedStyle(initials).color).toBe('rgb(3, 116, 181)');
|
|
85
85
|
});
|
|
86
86
|
it('should return the underlying component', async () => {
|
|
87
87
|
const elementRef = _vitest.vi.fn();
|
|
@@ -197,7 +197,7 @@ describe('<Avatar />', () => {
|
|
|
197
197
|
color: "shamrock"
|
|
198
198
|
})));
|
|
199
199
|
const initials = _react2.screen.getByText('JJ');
|
|
200
|
-
expect(getComputedStyle(initials).color).toBe('rgb(
|
|
200
|
+
expect(getComputedStyle(initials).color).toBe('rgb(11, 135, 75)');
|
|
201
201
|
});
|
|
202
202
|
it('should display the icon in green (shamrock)', async () => {
|
|
203
203
|
const _render13 = (0, _react2.render)(_Avatar13 || (_Avatar13 = /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
@@ -208,7 +208,7 @@ describe('<Avatar />', () => {
|
|
|
208
208
|
container = _render13.container;
|
|
209
209
|
const avatarSvg = container.querySelector('svg');
|
|
210
210
|
expect(avatarSvg).toHaveStyle({
|
|
211
|
-
fill: '#
|
|
211
|
+
fill: '#FC5E13'
|
|
212
212
|
});
|
|
213
213
|
});
|
|
214
214
|
});
|
|
@@ -222,7 +222,7 @@ describe('<Avatar />', () => {
|
|
|
222
222
|
})));
|
|
223
223
|
const initials = _react2.screen.getByText('JJ');
|
|
224
224
|
expect(initials.parentNode).toHaveStyle({
|
|
225
|
-
backgroundColor: 'rgb(
|
|
225
|
+
backgroundColor: 'rgb(11, 135, 75)'
|
|
226
226
|
});
|
|
227
227
|
});
|
|
228
228
|
it('should display the initials in white', async () => {
|
|
@@ -248,7 +248,7 @@ describe('<Avatar />', () => {
|
|
|
248
248
|
container = _render14.container;
|
|
249
249
|
const element = container.querySelector('span');
|
|
250
250
|
expect(element).toHaveStyle({
|
|
251
|
-
backgroundColor: 'rgb(
|
|
251
|
+
backgroundColor: 'rgb(11, 135, 75)'
|
|
252
252
|
});
|
|
253
253
|
});
|
|
254
254
|
it('should display the icon in white', async () => {
|
package/lib/Avatar/theme.js
CHANGED
|
@@ -35,28 +35,34 @@ var _alpha = require("@instructure/ui-color-utils/lib/alpha.js");
|
|
|
35
35
|
* @return {Object} The final theme object with the overrides and component variables
|
|
36
36
|
*/
|
|
37
37
|
const generateComponentTheme = theme => {
|
|
38
|
-
var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8;
|
|
39
38
|
const colors = theme.colors,
|
|
40
39
|
borders = theme.borders,
|
|
41
40
|
typography = theme.typography;
|
|
41
|
+
const brand = colors.brand,
|
|
42
|
+
shamrock = colors.shamrock,
|
|
43
|
+
barney = colors.barney,
|
|
44
|
+
crimson = colors.crimson,
|
|
45
|
+
fire = colors.fire,
|
|
46
|
+
licorice = colors.licorice,
|
|
47
|
+
ash = colors.ash;
|
|
42
48
|
const componentVariables = {
|
|
43
|
-
background: colors === null || colors === void 0 ? void 0 :
|
|
49
|
+
background: colors === null || colors === void 0 ? void 0 : colors.backgroundLightest,
|
|
44
50
|
borderWidthSmall: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
|
|
45
51
|
borderWidthMedium: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
46
|
-
borderColor: colors === null || colors === void 0 ? void 0 :
|
|
47
|
-
boxShadowColor: (0, _alpha.alpha)(
|
|
52
|
+
borderColor: colors === null || colors === void 0 ? void 0 : colors.borderMedium,
|
|
53
|
+
boxShadowColor: (0, _alpha.alpha)(colors === null || colors === void 0 ? void 0 : colors.backgroundDarkest, 12),
|
|
48
54
|
boxShadowBlur: '1rem',
|
|
49
55
|
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
50
56
|
fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
|
|
51
57
|
// these colors have sufficient contrast with the white background
|
|
52
58
|
// in the normal and high contrast themes
|
|
53
|
-
color:
|
|
54
|
-
colorShamrock:
|
|
55
|
-
colorBarney:
|
|
56
|
-
colorCrimson:
|
|
57
|
-
colorFire:
|
|
58
|
-
colorLicorice:
|
|
59
|
-
colorAsh:
|
|
59
|
+
color: brand,
|
|
60
|
+
colorShamrock: shamrock,
|
|
61
|
+
colorBarney: barney,
|
|
62
|
+
colorCrimson: crimson,
|
|
63
|
+
colorFire: fire,
|
|
64
|
+
colorLicorice: licorice,
|
|
65
|
+
colorAsh: ash
|
|
60
66
|
};
|
|
61
67
|
return {
|
|
62
68
|
...componentVariables
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-avatar",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.6.0",
|
|
4
4
|
"description": "An image or letters that represents a user.",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.24.5",
|
|
27
|
-
"@instructure/emotion": "9.
|
|
28
|
-
"@instructure/shared-types": "9.
|
|
29
|
-
"@instructure/ui-icons": "9.
|
|
30
|
-
"@instructure/ui-react-utils": "9.
|
|
31
|
-
"@instructure/ui-testable": "9.
|
|
32
|
-
"@instructure/ui-view": "9.
|
|
27
|
+
"@instructure/emotion": "9.6.0",
|
|
28
|
+
"@instructure/shared-types": "9.6.0",
|
|
29
|
+
"@instructure/ui-icons": "9.6.0",
|
|
30
|
+
"@instructure/ui-react-utils": "9.6.0",
|
|
31
|
+
"@instructure/ui-testable": "9.6.0",
|
|
32
|
+
"@instructure/ui-view": "9.6.0",
|
|
33
33
|
"prop-types": "^15.8.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@instructure/ui-axe-check": "9.
|
|
37
|
-
"@instructure/ui-babel-preset": "9.
|
|
38
|
-
"@instructure/ui-color-utils": "9.
|
|
39
|
-
"@instructure/ui-test-locator": "9.
|
|
40
|
-
"@instructure/ui-test-utils": "9.
|
|
41
|
-
"@instructure/ui-themes": "9.
|
|
36
|
+
"@instructure/ui-axe-check": "9.6.0",
|
|
37
|
+
"@instructure/ui-babel-preset": "9.6.0",
|
|
38
|
+
"@instructure/ui-color-utils": "9.6.0",
|
|
39
|
+
"@instructure/ui-test-locator": "9.6.0",
|
|
40
|
+
"@instructure/ui-test-utils": "9.6.0",
|
|
41
|
+
"@instructure/ui-themes": "9.6.0",
|
|
42
42
|
"@testing-library/jest-dom": "^6.4.6",
|
|
43
43
|
"@testing-library/react": "^15.0.7",
|
|
44
44
|
"vitest": "^2.0.2"
|
|
@@ -69,7 +69,7 @@ describe('<Avatar />', () => {
|
|
|
69
69
|
it('should display the initials in brand color', async () => {
|
|
70
70
|
render(<Avatar name="Jessica Jones" />)
|
|
71
71
|
const initials = screen.getByText('JJ')
|
|
72
|
-
expect(getComputedStyle(initials).color).toBe('rgb(
|
|
72
|
+
expect(getComputedStyle(initials).color).toBe('rgb(3, 116, 181)')
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
it('should return the underlying component', async () => {
|
|
@@ -176,7 +176,7 @@ describe('<Avatar />', () => {
|
|
|
176
176
|
it('should display the initials in green (shamrock)', async () => {
|
|
177
177
|
render(<Avatar name="Jessica Jones" color="shamrock" />)
|
|
178
178
|
const initials = screen.getByText('JJ')
|
|
179
|
-
expect(getComputedStyle(initials).color).toBe('rgb(
|
|
179
|
+
expect(getComputedStyle(initials).color).toBe('rgb(11, 135, 75)')
|
|
180
180
|
})
|
|
181
181
|
|
|
182
182
|
it('should display the icon in green (shamrock)', async () => {
|
|
@@ -190,7 +190,7 @@ describe('<Avatar />', () => {
|
|
|
190
190
|
</Avatar>
|
|
191
191
|
)
|
|
192
192
|
const avatarSvg = container.querySelector('svg')
|
|
193
|
-
expect(avatarSvg).toHaveStyle({ fill: '#
|
|
193
|
+
expect(avatarSvg).toHaveStyle({ fill: '#FC5E13' })
|
|
194
194
|
})
|
|
195
195
|
})
|
|
196
196
|
|
|
@@ -200,7 +200,7 @@ describe('<Avatar />', () => {
|
|
|
200
200
|
render(<Avatar name="Jessica Jones" color="shamrock" hasInverseColor />)
|
|
201
201
|
const initials = screen.getByText('JJ')
|
|
202
202
|
expect(initials.parentNode).toHaveStyle({
|
|
203
|
-
backgroundColor: 'rgb(
|
|
203
|
+
backgroundColor: 'rgb(11, 135, 75)'
|
|
204
204
|
})
|
|
205
205
|
})
|
|
206
206
|
|
|
@@ -222,7 +222,7 @@ describe('<Avatar />', () => {
|
|
|
222
222
|
/>
|
|
223
223
|
)
|
|
224
224
|
const element = container.querySelector('span')
|
|
225
|
-
expect(element).toHaveStyle({ backgroundColor: 'rgb(
|
|
225
|
+
expect(element).toHaveStyle({ backgroundColor: 'rgb(11, 135, 75)' })
|
|
226
226
|
})
|
|
227
227
|
|
|
228
228
|
it('should display the icon in white', async () => {
|
package/src/Avatar/theme.ts
CHANGED
|
@@ -34,25 +34,27 @@ import { AvatarTheme } from '@instructure/shared-types'
|
|
|
34
34
|
const generateComponentTheme = (theme: Theme): AvatarTheme => {
|
|
35
35
|
const { colors, borders, typography } = theme
|
|
36
36
|
|
|
37
|
+
const { brand, shamrock, barney, crimson, fire, licorice, ash } = colors
|
|
38
|
+
|
|
37
39
|
const componentVariables: AvatarTheme = {
|
|
38
|
-
background: colors?.
|
|
40
|
+
background: colors?.backgroundLightest,
|
|
39
41
|
borderWidthSmall: borders?.widthSmall,
|
|
40
42
|
borderWidthMedium: borders?.widthMedium,
|
|
41
|
-
borderColor: colors?.
|
|
42
|
-
boxShadowColor: alpha(
|
|
43
|
+
borderColor: colors?.borderMedium,
|
|
44
|
+
boxShadowColor: alpha(colors?.backgroundDarkest, 12),
|
|
43
45
|
boxShadowBlur: '1rem',
|
|
44
46
|
fontFamily: typography?.fontFamily,
|
|
45
47
|
fontWeight: typography?.fontWeightBold,
|
|
46
48
|
|
|
47
49
|
// these colors have sufficient contrast with the white background
|
|
48
50
|
// in the normal and high contrast themes
|
|
49
|
-
color:
|
|
50
|
-
colorShamrock:
|
|
51
|
-
colorBarney:
|
|
52
|
-
colorCrimson:
|
|
53
|
-
colorFire:
|
|
54
|
-
colorLicorice:
|
|
55
|
-
colorAsh:
|
|
51
|
+
color: brand,
|
|
52
|
+
colorShamrock: shamrock,
|
|
53
|
+
colorBarney: barney,
|
|
54
|
+
colorCrimson: crimson,
|
|
55
|
+
colorFire: fire,
|
|
56
|
+
colorLicorice: licorice,
|
|
57
|
+
colorAsh: ash
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
return {
|