@instructure/ui-avatar 10.14.1-snapshot-4 → 10.14.1-snapshot-5
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 -2
- package/es/Avatar/index.js +95 -91
- package/es/Avatar/styles.js +11 -12
- package/es/Avatar/theme.js +2 -2
- package/lib/Avatar/index.js +96 -90
- package/lib/Avatar/styles.js +11 -12
- package/lib/Avatar/theme.js +2 -2
- package/package.json +13 -13
- package/src/Avatar/index.tsx +93 -90
- package/src/Avatar/props.ts +5 -5
- package/src/Avatar/styles.ts +22 -14
- package/src/Avatar/theme.ts +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Avatar/index.d.ts +2 -58
- package/types/Avatar/index.d.ts.map +1 -1
- package/types/Avatar/props.d.ts +5 -5
- package/types/Avatar/props.d.ts.map +1 -1
- package/types/Avatar/styles.d.ts +15 -6
- package/types/Avatar/styles.d.ts.map +1 -1
- package/types/Avatar/theme.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
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
|
-
## [10.14.1-snapshot-
|
|
6
|
+
## [10.14.1-snapshot-5](https://github.com/instructure/instructure-ui/compare/v10.14.0...v10.14.1-snapshot-5) (2025-03-27)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **ui-avatar,emotion:** add theming solution to functional components ([9cbfd35](https://github.com/instructure/instructure-ui/commit/9cbfd35f038aed2942424707ec4669c820e3c820))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
package/es/Avatar/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
const _excluded = ["onImageLoaded", "styles"];
|
|
3
|
-
var _dec, _dec2, _class, _Avatar;
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
4
2
|
/*
|
|
5
3
|
* The MIT License (MIT)
|
|
6
4
|
*
|
|
@@ -26,120 +24,126 @@ var _dec, _dec2, _class, _Avatar;
|
|
|
26
24
|
*/
|
|
27
25
|
|
|
28
26
|
/** @jsx jsx */
|
|
29
|
-
import {
|
|
27
|
+
import { jsx, useStyle } from '@instructure/emotion';
|
|
28
|
+
import { useState, useEffect } from 'react';
|
|
30
29
|
import { View } from '@instructure/ui-view';
|
|
31
30
|
import { callRenderProp, passthroughProps } from '@instructure/ui-react-utils';
|
|
32
|
-
import { testable } from '@instructure/ui-testable';
|
|
33
|
-
import { withStyle, jsx } from '@instructure/emotion';
|
|
34
31
|
import generateStyle from './styles';
|
|
35
32
|
import generateComponentTheme from './theme';
|
|
36
|
-
|
|
33
|
+
|
|
37
34
|
/**
|
|
38
35
|
---
|
|
39
36
|
category: components
|
|
40
37
|
---
|
|
41
38
|
**/
|
|
42
|
-
let Avatar = (_dec = withStyle(generateStyle, generateComponentTheme), _dec2 = testable(), _dec(_class = _dec2(_class = (_Avatar = class Avatar extends Component {
|
|
43
|
-
constructor(...args) {
|
|
44
|
-
super(...args);
|
|
45
|
-
this.state = {
|
|
46
|
-
loaded: false
|
|
47
|
-
};
|
|
48
|
-
this.ref = null;
|
|
49
|
-
this.handleRef = el => {
|
|
50
|
-
const elementRef = this.props.elementRef;
|
|
51
|
-
this.ref = el;
|
|
52
|
-
if (typeof elementRef === 'function') {
|
|
53
|
-
elementRef(el);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
this.handleImageLoaded = event => {
|
|
57
|
-
this.setState({
|
|
58
|
-
loaded: true
|
|
59
|
-
});
|
|
60
|
-
this.props.onImageLoaded(event);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
componentDidMount() {
|
|
64
|
-
var _this$props$makeStyle, _this$props;
|
|
65
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.state);
|
|
66
|
-
}
|
|
67
|
-
componentDidUpdate() {
|
|
68
|
-
var _this$props$makeStyle2, _this$props2;
|
|
69
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.state);
|
|
70
39
|
|
|
40
|
+
const Avatar = ({
|
|
41
|
+
size = 'medium',
|
|
42
|
+
color = 'default',
|
|
43
|
+
hasInverseColor = false,
|
|
44
|
+
showBorder = 'auto',
|
|
45
|
+
shape = 'circle',
|
|
46
|
+
display = 'inline-block',
|
|
47
|
+
onImageLoaded = _event => {},
|
|
48
|
+
src,
|
|
49
|
+
name,
|
|
50
|
+
renderIcon,
|
|
51
|
+
alt,
|
|
52
|
+
as,
|
|
53
|
+
margin,
|
|
54
|
+
themeOverride,
|
|
55
|
+
elementRef,
|
|
56
|
+
...rest
|
|
57
|
+
}) => {
|
|
58
|
+
const _useState = useState(false),
|
|
59
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
60
|
+
loaded = _useState2[0],
|
|
61
|
+
setLoaded = _useState2[1];
|
|
62
|
+
const styles = useStyle({
|
|
63
|
+
generateStyle,
|
|
64
|
+
generateComponentTheme,
|
|
65
|
+
params: {
|
|
66
|
+
loaded,
|
|
67
|
+
size,
|
|
68
|
+
color,
|
|
69
|
+
hasInverseColor,
|
|
70
|
+
shape,
|
|
71
|
+
src,
|
|
72
|
+
showBorder,
|
|
73
|
+
themeOverride
|
|
74
|
+
},
|
|
75
|
+
componentId: 'Avatar',
|
|
76
|
+
displayName: 'Avatar'
|
|
77
|
+
});
|
|
78
|
+
useEffect(() => {
|
|
71
79
|
// in case the image is unset in an update, show icons/initials again
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
loaded: false
|
|
75
|
-
});
|
|
80
|
+
if (loaded && !src) {
|
|
81
|
+
setLoaded(false);
|
|
76
82
|
}
|
|
77
|
-
}
|
|
78
|
-
makeInitialsFromName() {
|
|
79
|
-
let name = this.props.name;
|
|
83
|
+
}, [loaded, src]);
|
|
84
|
+
const makeInitialsFromName = () => {
|
|
80
85
|
if (!name || typeof name !== 'string') {
|
|
81
86
|
return;
|
|
82
87
|
}
|
|
83
|
-
|
|
84
|
-
if (
|
|
88
|
+
const currentName = name.trim();
|
|
89
|
+
if (currentName.length === 0) {
|
|
85
90
|
return;
|
|
86
91
|
}
|
|
87
|
-
if (
|
|
88
|
-
const names =
|
|
92
|
+
if (currentName.match(/\s+/)) {
|
|
93
|
+
const names = currentName.split(/\s+/);
|
|
89
94
|
return (names[0][0] + names[names.length - 1][0]).toUpperCase();
|
|
90
95
|
} else {
|
|
91
|
-
return
|
|
96
|
+
return currentName[0].toUpperCase();
|
|
92
97
|
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
};
|
|
99
|
+
const handleImageLoaded = event => {
|
|
100
|
+
setLoaded(true);
|
|
101
|
+
onImageLoaded(event);
|
|
102
|
+
};
|
|
103
|
+
const renderInitials = () => {
|
|
96
104
|
return jsx("span", {
|
|
97
|
-
css:
|
|
105
|
+
css: styles === null || styles === void 0 ? void 0 : styles.initials,
|
|
98
106
|
"aria-hidden": "true"
|
|
99
|
-
},
|
|
100
|
-
}
|
|
101
|
-
renderContent() {
|
|
102
|
-
const _this$props3 = this.props,
|
|
103
|
-
renderIcon = _this$props3.renderIcon,
|
|
104
|
-
styles = _this$props3.styles;
|
|
107
|
+
}, makeInitialsFromName());
|
|
108
|
+
};
|
|
109
|
+
const renderContent = () => {
|
|
105
110
|
if (!renderIcon) {
|
|
106
|
-
return
|
|
111
|
+
return renderInitials();
|
|
107
112
|
}
|
|
108
113
|
return jsx("span", {
|
|
109
114
|
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG
|
|
110
115
|
}, callRenderProp(renderIcon));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}, _Avatar)) || _class) || _class);
|
|
116
|
+
};
|
|
117
|
+
return jsx(View, Object.assign({}, passthroughProps({
|
|
118
|
+
size,
|
|
119
|
+
color,
|
|
120
|
+
hasInverseColor,
|
|
121
|
+
showBorder,
|
|
122
|
+
shape,
|
|
123
|
+
display,
|
|
124
|
+
src,
|
|
125
|
+
name,
|
|
126
|
+
renderIcon,
|
|
127
|
+
alt,
|
|
128
|
+
as,
|
|
129
|
+
margin,
|
|
130
|
+
...rest
|
|
131
|
+
}), {
|
|
132
|
+
"aria-label": alt ? alt : void 0,
|
|
133
|
+
role: alt ? 'img' : void 0,
|
|
134
|
+
as: as,
|
|
135
|
+
elementRef: elementRef,
|
|
136
|
+
margin: margin,
|
|
137
|
+
css: styles === null || styles === void 0 ? void 0 : styles.avatar,
|
|
138
|
+
display: display
|
|
139
|
+
}), jsx("img", {
|
|
140
|
+
// This is visually hidden and is here for loading purposes only
|
|
141
|
+
src: src,
|
|
142
|
+
css: styles === null || styles === void 0 ? void 0 : styles.loadImage,
|
|
143
|
+
alt: alt,
|
|
144
|
+
onLoad: handleImageLoaded,
|
|
145
|
+
"aria-hidden": "true"
|
|
146
|
+
}), !loaded && renderContent());
|
|
147
|
+
};
|
|
144
148
|
export default Avatar;
|
|
145
149
|
export { Avatar };
|
package/es/Avatar/styles.js
CHANGED
|
@@ -27,19 +27,18 @@
|
|
|
27
27
|
* private: true
|
|
28
28
|
* ---
|
|
29
29
|
* Generates the style object from the theme and provided additional information
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
32
|
-
* @
|
|
33
|
-
* @return {Object} The final style object, which will be used in the component
|
|
30
|
+
* @param componentTheme The theme variable object.
|
|
31
|
+
* @param params Additional parameters to customize the style.
|
|
32
|
+
* @return The final style object, which will be used in the component
|
|
34
33
|
*/
|
|
35
|
-
const generateStyle = (componentTheme,
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
const generateStyle = (componentTheme, params) => {
|
|
35
|
+
const loaded = params.loaded,
|
|
36
|
+
size = params.size,
|
|
37
|
+
color = params.color,
|
|
38
|
+
hasInverseColor = params.hasInverseColor,
|
|
39
|
+
shape = params.shape,
|
|
40
|
+
src = params.src,
|
|
41
|
+
showBorder = params.showBorder;
|
|
43
42
|
const sizeStyles = {
|
|
44
43
|
auto: {
|
|
45
44
|
fontSize: 'inherit',
|
package/es/Avatar/theme.js
CHANGED
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
import { alpha } from '@instructure/ui-color-utils';
|
|
26
26
|
/**
|
|
27
27
|
* Generates the theme object for the component from the theme and provided additional information
|
|
28
|
-
* @param
|
|
29
|
-
* @return
|
|
28
|
+
* @param theme The current theme object.
|
|
29
|
+
* @return The final theme object with the overrides and component variables
|
|
30
30
|
*/
|
|
31
31
|
const generateComponentTheme = theme => {
|
|
32
32
|
var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8;
|
package/lib/Avatar/index.js
CHANGED
|
@@ -5,18 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = exports.Avatar = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
+
var _emotion = require("@instructure/emotion");
|
|
9
10
|
var _react = require("react");
|
|
10
11
|
var _View = require("@instructure/ui-view/lib/View");
|
|
11
12
|
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
12
13
|
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
13
|
-
var _testable = require("@instructure/ui-testable/lib/testable.js");
|
|
14
|
-
var _emotion = require("@instructure/emotion");
|
|
15
14
|
var _styles = _interopRequireDefault(require("./styles"));
|
|
16
15
|
var _theme = _interopRequireDefault(require("./theme"));
|
|
17
|
-
var _props = require("./props");
|
|
18
|
-
const _excluded = ["onImageLoaded", "styles"];
|
|
19
|
-
var _dec, _dec2, _class, _Avatar;
|
|
20
16
|
/*
|
|
21
17
|
* The MIT License (MIT)
|
|
22
18
|
*
|
|
@@ -40,112 +36,122 @@ var _dec, _dec2, _class, _Avatar;
|
|
|
40
36
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
41
37
|
* SOFTWARE.
|
|
42
38
|
*/
|
|
39
|
+
|
|
43
40
|
/** @jsx jsx */
|
|
41
|
+
|
|
44
42
|
/**
|
|
45
43
|
---
|
|
46
44
|
category: components
|
|
47
45
|
---
|
|
48
46
|
**/
|
|
49
|
-
let Avatar = exports.Avatar = (_dec = (0, _emotion.withStyle)(_styles.default, _theme.default), _dec2 = (0, _testable.testable)(), _dec(_class = _dec2(_class = (_Avatar = class Avatar extends _react.Component {
|
|
50
|
-
constructor(...args) {
|
|
51
|
-
super(...args);
|
|
52
|
-
this.state = {
|
|
53
|
-
loaded: false
|
|
54
|
-
};
|
|
55
|
-
this.ref = null;
|
|
56
|
-
this.handleRef = el => {
|
|
57
|
-
const elementRef = this.props.elementRef;
|
|
58
|
-
this.ref = el;
|
|
59
|
-
if (typeof elementRef === 'function') {
|
|
60
|
-
elementRef(el);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
this.handleImageLoaded = event => {
|
|
64
|
-
this.setState({
|
|
65
|
-
loaded: true
|
|
66
|
-
});
|
|
67
|
-
this.props.onImageLoaded(event);
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
componentDidMount() {
|
|
71
|
-
var _this$props$makeStyle, _this$props;
|
|
72
|
-
(_this$props$makeStyle = (_this$props = this.props).makeStyles) === null || _this$props$makeStyle === void 0 ? void 0 : _this$props$makeStyle.call(_this$props, this.state);
|
|
73
|
-
}
|
|
74
|
-
componentDidUpdate() {
|
|
75
|
-
var _this$props$makeStyle2, _this$props2;
|
|
76
|
-
(_this$props$makeStyle2 = (_this$props2 = this.props).makeStyles) === null || _this$props$makeStyle2 === void 0 ? void 0 : _this$props$makeStyle2.call(_this$props2, this.state);
|
|
77
47
|
|
|
48
|
+
const Avatar = ({
|
|
49
|
+
size = 'medium',
|
|
50
|
+
color = 'default',
|
|
51
|
+
hasInverseColor = false,
|
|
52
|
+
showBorder = 'auto',
|
|
53
|
+
shape = 'circle',
|
|
54
|
+
display = 'inline-block',
|
|
55
|
+
onImageLoaded = _event => {},
|
|
56
|
+
src,
|
|
57
|
+
name,
|
|
58
|
+
renderIcon,
|
|
59
|
+
alt,
|
|
60
|
+
as,
|
|
61
|
+
margin,
|
|
62
|
+
themeOverride,
|
|
63
|
+
elementRef,
|
|
64
|
+
...rest
|
|
65
|
+
}) => {
|
|
66
|
+
const _useState = (0, _react.useState)(false),
|
|
67
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
68
|
+
loaded = _useState2[0],
|
|
69
|
+
setLoaded = _useState2[1];
|
|
70
|
+
const styles = (0, _emotion.useStyle)({
|
|
71
|
+
generateStyle: _styles.default,
|
|
72
|
+
generateComponentTheme: _theme.default,
|
|
73
|
+
params: {
|
|
74
|
+
loaded,
|
|
75
|
+
size,
|
|
76
|
+
color,
|
|
77
|
+
hasInverseColor,
|
|
78
|
+
shape,
|
|
79
|
+
src,
|
|
80
|
+
showBorder,
|
|
81
|
+
themeOverride
|
|
82
|
+
},
|
|
83
|
+
componentId: 'Avatar',
|
|
84
|
+
displayName: 'Avatar'
|
|
85
|
+
});
|
|
86
|
+
(0, _react.useEffect)(() => {
|
|
78
87
|
// in case the image is unset in an update, show icons/initials again
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
loaded: false
|
|
82
|
-
});
|
|
88
|
+
if (loaded && !src) {
|
|
89
|
+
setLoaded(false);
|
|
83
90
|
}
|
|
84
|
-
}
|
|
85
|
-
makeInitialsFromName() {
|
|
86
|
-
let name = this.props.name;
|
|
91
|
+
}, [loaded, src]);
|
|
92
|
+
const makeInitialsFromName = () => {
|
|
87
93
|
if (!name || typeof name !== 'string') {
|
|
88
94
|
return;
|
|
89
95
|
}
|
|
90
|
-
|
|
91
|
-
if (
|
|
96
|
+
const currentName = name.trim();
|
|
97
|
+
if (currentName.length === 0) {
|
|
92
98
|
return;
|
|
93
99
|
}
|
|
94
|
-
if (
|
|
95
|
-
const names =
|
|
100
|
+
if (currentName.match(/\s+/)) {
|
|
101
|
+
const names = currentName.split(/\s+/);
|
|
96
102
|
return (names[0][0] + names[names.length - 1][0]).toUpperCase();
|
|
97
103
|
} else {
|
|
98
|
-
return
|
|
104
|
+
return currentName[0].toUpperCase();
|
|
99
105
|
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
};
|
|
107
|
+
const handleImageLoaded = event => {
|
|
108
|
+
setLoaded(true);
|
|
109
|
+
onImageLoaded(event);
|
|
110
|
+
};
|
|
111
|
+
const renderInitials = () => {
|
|
103
112
|
return (0, _emotion.jsx)("span", {
|
|
104
|
-
css:
|
|
113
|
+
css: styles === null || styles === void 0 ? void 0 : styles.initials,
|
|
105
114
|
"aria-hidden": "true"
|
|
106
|
-
},
|
|
107
|
-
}
|
|
108
|
-
renderContent() {
|
|
109
|
-
const _this$props3 = this.props,
|
|
110
|
-
renderIcon = _this$props3.renderIcon,
|
|
111
|
-
styles = _this$props3.styles;
|
|
115
|
+
}, makeInitialsFromName());
|
|
116
|
+
};
|
|
117
|
+
const renderContent = () => {
|
|
112
118
|
if (!renderIcon) {
|
|
113
|
-
return
|
|
119
|
+
return renderInitials();
|
|
114
120
|
}
|
|
115
121
|
return (0, _emotion.jsx)("span", {
|
|
116
122
|
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG
|
|
117
123
|
}, (0, _callRenderProp.callRenderProp)(renderIcon));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
124
|
+
};
|
|
125
|
+
return (0, _emotion.jsx)(_View.View, Object.assign({}, (0, _passthroughProps.passthroughProps)({
|
|
126
|
+
size,
|
|
127
|
+
color,
|
|
128
|
+
hasInverseColor,
|
|
129
|
+
showBorder,
|
|
130
|
+
shape,
|
|
131
|
+
display,
|
|
132
|
+
src,
|
|
133
|
+
name,
|
|
134
|
+
renderIcon,
|
|
135
|
+
alt,
|
|
136
|
+
as,
|
|
137
|
+
margin,
|
|
138
|
+
...rest
|
|
139
|
+
}), {
|
|
140
|
+
"aria-label": alt ? alt : void 0,
|
|
141
|
+
role: alt ? 'img' : void 0,
|
|
142
|
+
as: as,
|
|
143
|
+
elementRef: elementRef,
|
|
144
|
+
margin: margin,
|
|
145
|
+
css: styles === null || styles === void 0 ? void 0 : styles.avatar,
|
|
146
|
+
display: display
|
|
147
|
+
}), (0, _emotion.jsx)("img", {
|
|
148
|
+
// This is visually hidden and is here for loading purposes only
|
|
149
|
+
src: src,
|
|
150
|
+
css: styles === null || styles === void 0 ? void 0 : styles.loadImage,
|
|
151
|
+
alt: alt,
|
|
152
|
+
onLoad: handleImageLoaded,
|
|
153
|
+
"aria-hidden": "true"
|
|
154
|
+
}), !loaded && renderContent());
|
|
155
|
+
};
|
|
156
|
+
exports.Avatar = Avatar;
|
|
151
157
|
var _default = exports.default = Avatar;
|
package/lib/Avatar/styles.js
CHANGED
|
@@ -33,19 +33,18 @@ exports.default = void 0;
|
|
|
33
33
|
* private: true
|
|
34
34
|
* ---
|
|
35
35
|
* Generates the style object from the theme and provided additional information
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
38
|
-
* @
|
|
39
|
-
* @return {Object} The final style object, which will be used in the component
|
|
36
|
+
* @param componentTheme The theme variable object.
|
|
37
|
+
* @param params Additional parameters to customize the style.
|
|
38
|
+
* @return The final style object, which will be used in the component
|
|
40
39
|
*/
|
|
41
|
-
const generateStyle = (componentTheme,
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
const generateStyle = (componentTheme, params) => {
|
|
41
|
+
const loaded = params.loaded,
|
|
42
|
+
size = params.size,
|
|
43
|
+
color = params.color,
|
|
44
|
+
hasInverseColor = params.hasInverseColor,
|
|
45
|
+
shape = params.shape,
|
|
46
|
+
src = params.src,
|
|
47
|
+
showBorder = params.showBorder;
|
|
49
48
|
const sizeStyles = {
|
|
50
49
|
auto: {
|
|
51
50
|
fontSize: 'inherit',
|
package/lib/Avatar/theme.js
CHANGED
|
@@ -31,8 +31,8 @@ var _alpha = require("@instructure/ui-color-utils/lib/alpha.js");
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Generates the theme object for the component from the theme and provided additional information
|
|
34
|
-
* @param
|
|
35
|
-
* @return
|
|
34
|
+
* @param theme The current theme object.
|
|
35
|
+
* @return The final theme object with the overrides and component variables
|
|
36
36
|
*/
|
|
37
37
|
const generateComponentTheme = theme => {
|
|
38
38
|
var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-avatar",
|
|
3
|
-
"version": "10.14.1-snapshot-
|
|
3
|
+
"version": "10.14.1-snapshot-5",
|
|
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.26.0",
|
|
27
|
-
"@instructure/emotion": "10.14.1-snapshot-
|
|
28
|
-
"@instructure/shared-types": "10.14.1-snapshot-
|
|
29
|
-
"@instructure/ui-icons": "10.14.1-snapshot-
|
|
30
|
-
"@instructure/ui-react-utils": "10.14.1-snapshot-
|
|
31
|
-
"@instructure/ui-testable": "10.14.1-snapshot-
|
|
32
|
-
"@instructure/ui-view": "10.14.1-snapshot-
|
|
27
|
+
"@instructure/emotion": "10.14.1-snapshot-5",
|
|
28
|
+
"@instructure/shared-types": "10.14.1-snapshot-5",
|
|
29
|
+
"@instructure/ui-icons": "10.14.1-snapshot-5",
|
|
30
|
+
"@instructure/ui-react-utils": "10.14.1-snapshot-5",
|
|
31
|
+
"@instructure/ui-testable": "10.14.1-snapshot-5",
|
|
32
|
+
"@instructure/ui-view": "10.14.1-snapshot-5",
|
|
33
33
|
"prop-types": "^15.8.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@instructure/ui-axe-check": "10.14.1-snapshot-
|
|
37
|
-
"@instructure/ui-babel-preset": "10.14.1-snapshot-
|
|
38
|
-
"@instructure/ui-color-utils": "10.14.1-snapshot-
|
|
39
|
-
"@instructure/ui-test-locator": "10.14.1-snapshot-
|
|
40
|
-
"@instructure/ui-test-utils": "10.14.1-snapshot-
|
|
41
|
-
"@instructure/ui-themes": "10.14.1-snapshot-
|
|
36
|
+
"@instructure/ui-axe-check": "10.14.1-snapshot-5",
|
|
37
|
+
"@instructure/ui-babel-preset": "10.14.1-snapshot-5",
|
|
38
|
+
"@instructure/ui-color-utils": "10.14.1-snapshot-5",
|
|
39
|
+
"@instructure/ui-test-locator": "10.14.1-snapshot-5",
|
|
40
|
+
"@instructure/ui-test-utils": "10.14.1-snapshot-5",
|
|
41
|
+
"@instructure/ui-themes": "10.14.1-snapshot-5",
|
|
42
42
|
"@testing-library/jest-dom": "^6.6.3",
|
|
43
43
|
"@testing-library/react": "^16.0.1",
|
|
44
44
|
"vitest": "^2.1.8"
|