@instructure/ui-avatar 11.6.0 → 11.6.1-pr-snapshot-1779894247159
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 +8 -0
- package/{lib/Avatar/props.js → babel.config.cjs} +13 -7
- package/package.json +12 -14
- package/lib/Avatar/index.js +0 -169
- package/lib/Avatar/styles.js +0 -239
- package/lib/Avatar/theme.js +0 -68
- package/lib/index.js +0 -12
- package/lib/package.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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
|
+
## [11.6.1-pr-snapshot-1779894247159](https://github.com/instructure/instructure-ui/compare/v11.6.0...v11.6.1-pr-snapshot-1779894247159) (2026-05-27)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @instructure/ui-avatar
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [11.6.0](https://github.com/instructure/instructure-ui/compare/v11.5.0...v11.6.0) (2026-02-18)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @instructure/ui-avatar
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.allowedProps = void 0;
|
|
7
1
|
/*
|
|
8
2
|
* The MIT License (MIT)
|
|
9
3
|
*
|
|
@@ -28,4 +22,16 @@ exports.allowedProps = void 0;
|
|
|
28
22
|
* SOFTWARE.
|
|
29
23
|
*/
|
|
30
24
|
|
|
31
|
-
|
|
25
|
+
module.exports = {
|
|
26
|
+
presets: [
|
|
27
|
+
[
|
|
28
|
+
require('@instructure/ui-babel-preset'),
|
|
29
|
+
{
|
|
30
|
+
coverage: Boolean(process.env.COVERAGE),
|
|
31
|
+
esModules: Boolean(process.env.ES_MODULES),
|
|
32
|
+
removeConsole: process.env.NODE_ENV === 'production',
|
|
33
|
+
transformImports: Boolean(process.env.TRANSFORM_IMPORTS)
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
]
|
|
37
|
+
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-avatar",
|
|
3
|
-
"version": "11.6.
|
|
3
|
+
"version": "11.6.1-pr-snapshot-1779894247159",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"description": "An image or letters that represents a user.",
|
|
5
6
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
7
|
"module": "./es/index.js",
|
|
7
|
-
"main": "./lib/index.js",
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -15,20 +15,20 @@
|
|
|
15
15
|
"license": "MIT",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@babel/runtime": "^7.27.6",
|
|
18
|
-
"@instructure/
|
|
19
|
-
"@instructure/
|
|
20
|
-
"@instructure/
|
|
21
|
-
"@instructure/ui-
|
|
22
|
-
"@instructure/ui-view": "11.6.
|
|
18
|
+
"@instructure/emotion": "11.6.1-pr-snapshot-1779894247159",
|
|
19
|
+
"@instructure/shared-types": "11.6.1-pr-snapshot-1779894247159",
|
|
20
|
+
"@instructure/ui-react-utils": "11.6.1-pr-snapshot-1779894247159",
|
|
21
|
+
"@instructure/ui-icons": "11.6.1-pr-snapshot-1779894247159",
|
|
22
|
+
"@instructure/ui-view": "11.6.1-pr-snapshot-1779894247159"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@testing-library/jest-dom": "^6.6.3",
|
|
26
26
|
"@testing-library/react": "15.0.7",
|
|
27
27
|
"vitest": "^3.2.2",
|
|
28
|
-
"@instructure/ui-axe-check": "11.6.
|
|
29
|
-
"@instructure/ui-babel-preset": "11.6.
|
|
30
|
-
"@instructure/ui-themes": "11.6.
|
|
31
|
-
"@instructure/ui-color-utils": "11.6.
|
|
28
|
+
"@instructure/ui-axe-check": "11.6.1-pr-snapshot-1779894247159",
|
|
29
|
+
"@instructure/ui-babel-preset": "11.6.1-pr-snapshot-1779894247159",
|
|
30
|
+
"@instructure/ui-themes": "11.6.1-pr-snapshot-1779894247159",
|
|
31
|
+
"@instructure/ui-color-utils": "11.6.1-pr-snapshot-1779894247159"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"react": ">=18 <=19"
|
|
@@ -41,10 +41,8 @@
|
|
|
41
41
|
".": {
|
|
42
42
|
"types": "./types/index.d.ts",
|
|
43
43
|
"import": "./es/index.js",
|
|
44
|
-
"require": "./lib/index.js",
|
|
45
44
|
"default": "./es/index.js"
|
|
46
45
|
},
|
|
47
|
-
"./lib/*": "./lib/*",
|
|
48
46
|
"./es/*": "./es/*",
|
|
49
47
|
"./types/*": "./types/*",
|
|
50
48
|
"./package.json": "./package.json",
|
|
@@ -54,7 +52,7 @@
|
|
|
54
52
|
"lint": "ui-scripts lint",
|
|
55
53
|
"lint:fix": "ui-scripts lint --fix",
|
|
56
54
|
"clean": "ui-scripts clean",
|
|
57
|
-
"build": "ui-scripts build
|
|
55
|
+
"build": "ui-scripts build",
|
|
58
56
|
"build:watch": "pnpm run ts:check -- --watch & ui-scripts build --watch",
|
|
59
57
|
"build:types": "tsc -p tsconfig.build.json",
|
|
60
58
|
"ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false"
|
package/lib/Avatar/index.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = exports.Avatar = void 0;
|
|
8
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
|
-
var _emotion = require("@instructure/emotion");
|
|
10
|
-
var _react = require("react");
|
|
11
|
-
var _View = require("@instructure/ui-view/lib/View");
|
|
12
|
-
var _callRenderProp = require("@instructure/ui-react-utils/lib/callRenderProp.js");
|
|
13
|
-
var _passthroughProps = require("@instructure/ui-react-utils/lib/passthroughProps.js");
|
|
14
|
-
var _styles = _interopRequireDefault(require("./styles"));
|
|
15
|
-
var _theme = _interopRequireDefault(require("./theme"));
|
|
16
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
17
|
-
/*
|
|
18
|
-
* The MIT License (MIT)
|
|
19
|
-
*
|
|
20
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
21
|
-
*
|
|
22
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
23
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
24
|
-
* in the Software without restriction, including without limitation the rights
|
|
25
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
26
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
27
|
-
* furnished to do so, subject to the following conditions:
|
|
28
|
-
*
|
|
29
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
30
|
-
* copies or substantial portions of the Software.
|
|
31
|
-
*
|
|
32
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
33
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
34
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
35
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
36
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
37
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
38
|
-
* SOFTWARE.
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
---
|
|
43
|
-
category: components
|
|
44
|
-
---
|
|
45
|
-
**/const Avatar = exports.Avatar = /*#__PURE__*/(0, _react.forwardRef)(({
|
|
46
|
-
size = 'medium',
|
|
47
|
-
color = 'default',
|
|
48
|
-
hasInverseColor = false,
|
|
49
|
-
showBorder = 'auto',
|
|
50
|
-
shape = 'circle',
|
|
51
|
-
display = 'inline-block',
|
|
52
|
-
onImageLoaded,
|
|
53
|
-
src,
|
|
54
|
-
name,
|
|
55
|
-
renderIcon,
|
|
56
|
-
alt,
|
|
57
|
-
as,
|
|
58
|
-
margin,
|
|
59
|
-
themeOverride,
|
|
60
|
-
elementRef,
|
|
61
|
-
...rest
|
|
62
|
-
}, ref) => {
|
|
63
|
-
const imgRef = (0, _react.useRef)(null);
|
|
64
|
-
const _useState = (0, _react.useState)(false),
|
|
65
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
66
|
-
loaded = _useState2[0],
|
|
67
|
-
setLoaded = _useState2[1];
|
|
68
|
-
const styles = (0, _emotion.useStyle)({
|
|
69
|
-
generateStyle: _styles.default,
|
|
70
|
-
generateComponentTheme: _theme.default,
|
|
71
|
-
params: {
|
|
72
|
-
loaded,
|
|
73
|
-
size,
|
|
74
|
-
color,
|
|
75
|
-
hasInverseColor,
|
|
76
|
-
shape,
|
|
77
|
-
src,
|
|
78
|
-
showBorder,
|
|
79
|
-
themeOverride
|
|
80
|
-
},
|
|
81
|
-
componentId: 'Avatar',
|
|
82
|
-
displayName: 'Avatar'
|
|
83
|
-
});
|
|
84
|
-
(0, _react.useEffect)(() => {
|
|
85
|
-
// in case the image is unset in an update, show icons/initials again
|
|
86
|
-
if (loaded && !src) {
|
|
87
|
-
setLoaded(false);
|
|
88
|
-
}
|
|
89
|
-
// Image already loaded (common in SSR)
|
|
90
|
-
if (src && !loaded && imgRef.current && imgRef.current.complete) {
|
|
91
|
-
setLoaded(true);
|
|
92
|
-
onImageLoaded === null || onImageLoaded === void 0 ? void 0 : onImageLoaded();
|
|
93
|
-
}
|
|
94
|
-
}, [loaded, src]);
|
|
95
|
-
const makeInitialsFromName = () => {
|
|
96
|
-
if (!name || typeof name !== 'string') {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const currentName = name.trim();
|
|
100
|
-
if (currentName.length === 0) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (currentName.match(/\s+/)) {
|
|
104
|
-
const names = currentName.split(/\s+/);
|
|
105
|
-
return (names[0][0] + names[names.length - 1][0]).toUpperCase();
|
|
106
|
-
} else {
|
|
107
|
-
return currentName[0].toUpperCase();
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
const handleImageLoaded = event => {
|
|
111
|
-
setLoaded(true);
|
|
112
|
-
onImageLoaded === null || onImageLoaded === void 0 ? void 0 : onImageLoaded(event);
|
|
113
|
-
};
|
|
114
|
-
const renderInitials = () => {
|
|
115
|
-
return (0, _jsxRuntime.jsx)("span", {
|
|
116
|
-
css: styles === null || styles === void 0 ? void 0 : styles.initials,
|
|
117
|
-
"aria-hidden": "true",
|
|
118
|
-
children: makeInitialsFromName()
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
const renderContent = () => {
|
|
122
|
-
if (!renderIcon) {
|
|
123
|
-
return renderInitials();
|
|
124
|
-
}
|
|
125
|
-
return (0, _jsxRuntime.jsx)("span", {
|
|
126
|
-
css: styles === null || styles === void 0 ? void 0 : styles.iconSVG,
|
|
127
|
-
children: (0, _callRenderProp.callRenderProp)(renderIcon)
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
return (0, _jsxRuntime.jsxs)(_View.View, {
|
|
131
|
-
...(0, _passthroughProps.passthroughProps)({
|
|
132
|
-
size,
|
|
133
|
-
color,
|
|
134
|
-
hasInverseColor,
|
|
135
|
-
showBorder,
|
|
136
|
-
shape,
|
|
137
|
-
display,
|
|
138
|
-
src,
|
|
139
|
-
name,
|
|
140
|
-
renderIcon,
|
|
141
|
-
alt,
|
|
142
|
-
as,
|
|
143
|
-
margin,
|
|
144
|
-
...rest
|
|
145
|
-
}),
|
|
146
|
-
ref: ref,
|
|
147
|
-
"aria-label": alt ? alt : void 0,
|
|
148
|
-
role: alt ? 'img' : void 0,
|
|
149
|
-
as: as,
|
|
150
|
-
elementRef: elementRef,
|
|
151
|
-
margin: margin,
|
|
152
|
-
css: styles === null || styles === void 0 ? void 0 : styles.avatar,
|
|
153
|
-
display: display,
|
|
154
|
-
children: [(0, _jsxRuntime.jsx)("img", {
|
|
155
|
-
// This is visually hidden and is here for loading purposes only
|
|
156
|
-
src: src,
|
|
157
|
-
ref: imgRef,
|
|
158
|
-
css: styles === null || styles === void 0 ? void 0 : styles.loadImage,
|
|
159
|
-
alt: alt,
|
|
160
|
-
onLoad: handleImageLoaded,
|
|
161
|
-
"aria-hidden": "true"
|
|
162
|
-
}), !loaded && renderContent()]
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
Avatar.displayName = 'Avatar';
|
|
166
|
-
|
|
167
|
-
// TODO - why is this needed?
|
|
168
|
-
Avatar.displayName = 'Avatar';
|
|
169
|
-
var _default = exports.default = Avatar;
|
package/lib/Avatar/styles.js
DELETED
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
/*
|
|
8
|
-
* The MIT License (MIT)
|
|
9
|
-
*
|
|
10
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
11
|
-
*
|
|
12
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
14
|
-
* in the Software without restriction, including without limitation the rights
|
|
15
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
17
|
-
* furnished to do so, subject to the following conditions:
|
|
18
|
-
*
|
|
19
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
20
|
-
* copies or substantial portions of the Software.
|
|
21
|
-
*
|
|
22
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
-
* SOFTWARE.
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* ---
|
|
33
|
-
* private: true
|
|
34
|
-
* ---
|
|
35
|
-
* Generates the style object from the theme and provided additional information
|
|
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
|
|
39
|
-
*/
|
|
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;
|
|
48
|
-
|
|
49
|
-
// TODO: this is a temporary solution and should be revised on component update
|
|
50
|
-
// NOTE: this is needed due to design changes. The size of the component is calculated from "em" which means it is
|
|
51
|
-
// tied to the fontSize. The font sizes changed for the icons, which meant that the container (component) size would've
|
|
52
|
-
// changed too without additional calculations
|
|
53
|
-
const calcNewScaler = (originalFontSize, newFontSize, originalScaler) => {
|
|
54
|
-
return `${originalFontSize * originalScaler / newFontSize}em`;
|
|
55
|
-
};
|
|
56
|
-
const sizeStyles = {
|
|
57
|
-
auto: {
|
|
58
|
-
fontSize: 'inherit',
|
|
59
|
-
borderWidth: componentTheme.borderWidthSmall,
|
|
60
|
-
width: '2.5em',
|
|
61
|
-
height: '2.5em'
|
|
62
|
-
},
|
|
63
|
-
'xx-small': {
|
|
64
|
-
fontSize: '0.625rem',
|
|
65
|
-
borderWidth: componentTheme.borderWidthSmall,
|
|
66
|
-
width: calcNewScaler(0.5, 0.625, shape === 'circle' ? 2.5 : 3),
|
|
67
|
-
height: calcNewScaler(0.5, 0.625, 2.5)
|
|
68
|
-
},
|
|
69
|
-
'x-small': {
|
|
70
|
-
fontSize: '0.875rem',
|
|
71
|
-
borderWidth: componentTheme.borderWidthSmall,
|
|
72
|
-
width: calcNewScaler(0.75, 0.875, shape === 'circle' ? 2.5 : 3),
|
|
73
|
-
height: calcNewScaler(0.75, 0.875, 2.5)
|
|
74
|
-
},
|
|
75
|
-
small: {
|
|
76
|
-
fontSize: '1.25rem',
|
|
77
|
-
borderWidth: componentTheme.borderWidthSmall,
|
|
78
|
-
width: calcNewScaler(1, 1.25, shape === 'circle' ? 2.5 : 3),
|
|
79
|
-
height: calcNewScaler(1, 1.25, 2.5)
|
|
80
|
-
},
|
|
81
|
-
medium: {
|
|
82
|
-
fontSize: '1.5rem',
|
|
83
|
-
borderWidth: componentTheme.borderWidthMedium,
|
|
84
|
-
width: calcNewScaler(1.25, 1.5, shape === 'circle' ? 2.5 : 3),
|
|
85
|
-
height: calcNewScaler(1.25, 1.5, 2.5)
|
|
86
|
-
},
|
|
87
|
-
large: {
|
|
88
|
-
fontSize: '1.75rem',
|
|
89
|
-
borderWidth: componentTheme.borderWidthMedium,
|
|
90
|
-
width: calcNewScaler(1.5, 1.75, shape === 'circle' ? 2.5 : 3),
|
|
91
|
-
height: calcNewScaler(1.5, 1.75, 2.5)
|
|
92
|
-
},
|
|
93
|
-
'x-large': {
|
|
94
|
-
fontSize: '2rem',
|
|
95
|
-
borderWidth: componentTheme.borderWidthMedium,
|
|
96
|
-
width: calcNewScaler(1.75, 2, shape === 'circle' ? 2.5 : 3),
|
|
97
|
-
height: calcNewScaler(1.75, 2, 2.5)
|
|
98
|
-
},
|
|
99
|
-
'xx-large': {
|
|
100
|
-
fontSize: '2.25rem',
|
|
101
|
-
borderWidth: componentTheme.borderWidthMedium,
|
|
102
|
-
width: calcNewScaler(2, 2.25, shape === 'circle' ? 2.5 : 3),
|
|
103
|
-
height: calcNewScaler(2, 2.25, 2.5)
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
const initialSizeStyles = {
|
|
107
|
-
auto: {
|
|
108
|
-
fontSize: 'inherit'
|
|
109
|
-
},
|
|
110
|
-
'xx-small': {
|
|
111
|
-
fontSize: '0.5rem'
|
|
112
|
-
},
|
|
113
|
-
'x-small': {
|
|
114
|
-
fontSize: '0.75rem'
|
|
115
|
-
},
|
|
116
|
-
small: {
|
|
117
|
-
fontSize: '1rem'
|
|
118
|
-
},
|
|
119
|
-
medium: {
|
|
120
|
-
fontSize: '1.25rem'
|
|
121
|
-
},
|
|
122
|
-
large: {
|
|
123
|
-
fontSize: '1.5rem'
|
|
124
|
-
},
|
|
125
|
-
'x-large': {
|
|
126
|
-
fontSize: '1.75rem'
|
|
127
|
-
},
|
|
128
|
-
'xx-large': {
|
|
129
|
-
fontSize: '2rem'
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
const shapeStyles = {
|
|
133
|
-
circle: {
|
|
134
|
-
position: 'relative',
|
|
135
|
-
borderRadius: '100%',
|
|
136
|
-
overflow: 'hidden'
|
|
137
|
-
},
|
|
138
|
-
rectangle: {
|
|
139
|
-
width: '3em'
|
|
140
|
-
}
|
|
141
|
-
};
|
|
142
|
-
const colorVariants = {
|
|
143
|
-
default: componentTheme.color,
|
|
144
|
-
// = brand
|
|
145
|
-
shamrock: componentTheme.colorShamrock,
|
|
146
|
-
barney: componentTheme.colorBarney,
|
|
147
|
-
crimson: componentTheme.colorCrimson,
|
|
148
|
-
fire: componentTheme.colorFire,
|
|
149
|
-
licorice: componentTheme.colorLicorice,
|
|
150
|
-
ash: componentTheme.colorAsh,
|
|
151
|
-
ai: `
|
|
152
|
-
linear-gradient(to bottom, ${componentTheme.aiTopGradientColor} 0%, ${componentTheme.aiBottomGradientColor} 100%) padding-box,
|
|
153
|
-
linear-gradient(to bottom right, ${componentTheme.aiTopGradientColor} 0%, ${componentTheme.aiBottomGradientColor} 100%) border-box`
|
|
154
|
-
};
|
|
155
|
-
const background = () => {
|
|
156
|
-
if (color === 'ai') {
|
|
157
|
-
return {
|
|
158
|
-
background: `
|
|
159
|
-
linear-gradient(to bottom, ${componentTheme.aiTopGradientColor} 0%, ${componentTheme.aiBottomGradientColor} 100%) padding-box,
|
|
160
|
-
linear-gradient(to bottom right, ${componentTheme.aiTopGradientColor} 0%, ${componentTheme.aiBottomGradientColor} 100%) border-box`,
|
|
161
|
-
border: 'solid transparent'
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
return hasInverseColor ? {
|
|
165
|
-
backgroundColor: colorVariants[color],
|
|
166
|
-
backgroundClip: 'content-box'
|
|
167
|
-
} : {
|
|
168
|
-
backgroundColor: componentTheme.background,
|
|
169
|
-
backgroundClip: 'content-box'
|
|
170
|
-
};
|
|
171
|
-
};
|
|
172
|
-
const contentColor = () => {
|
|
173
|
-
if (color === 'ai') {
|
|
174
|
-
return componentTheme.aiFontColor;
|
|
175
|
-
}
|
|
176
|
-
return hasInverseColor ? componentTheme.background : colorVariants[color];
|
|
177
|
-
};
|
|
178
|
-
return {
|
|
179
|
-
avatar: {
|
|
180
|
-
label: 'avatar',
|
|
181
|
-
boxSizing: 'border-box',
|
|
182
|
-
borderStyle: 'solid',
|
|
183
|
-
borderColor: componentTheme.borderColor,
|
|
184
|
-
...background(),
|
|
185
|
-
backgroundPosition: 'center',
|
|
186
|
-
backgroundSize: 'cover',
|
|
187
|
-
backgroundRepeat: 'no-repeat',
|
|
188
|
-
overflow: 'hidden',
|
|
189
|
-
lineHeight: 0,
|
|
190
|
-
textAlign: 'center',
|
|
191
|
-
...sizeStyles[size],
|
|
192
|
-
...shapeStyles[shape],
|
|
193
|
-
...(loaded ? {
|
|
194
|
-
backgroundImage: `url('${src}')`,
|
|
195
|
-
...(showBorder !== 'always' && {
|
|
196
|
-
border: 0
|
|
197
|
-
}),
|
|
198
|
-
boxShadow: `inset 0 0 ${componentTheme.boxShadowBlur} 0 ${componentTheme.boxShadowColor}`
|
|
199
|
-
} : {
|
|
200
|
-
backgroundImage: void 0,
|
|
201
|
-
...(hasInverseColor && {
|
|
202
|
-
border: 0,
|
|
203
|
-
padding: sizeStyles[size].borderWidth,
|
|
204
|
-
backgroundClip: 'border-box'
|
|
205
|
-
})
|
|
206
|
-
}),
|
|
207
|
-
...(showBorder === 'never' && {
|
|
208
|
-
border: 0
|
|
209
|
-
})
|
|
210
|
-
},
|
|
211
|
-
initials: {
|
|
212
|
-
label: 'avatar__initials',
|
|
213
|
-
color: contentColor(),
|
|
214
|
-
lineHeight: '2.375em',
|
|
215
|
-
fontFamily: componentTheme.fontFamily,
|
|
216
|
-
fontWeight: componentTheme.fontWeight,
|
|
217
|
-
letterSpacing: '0.0313em',
|
|
218
|
-
...initialSizeStyles[size]
|
|
219
|
-
},
|
|
220
|
-
loadImage: {
|
|
221
|
-
label: 'avatar__loadImage',
|
|
222
|
-
display: 'none'
|
|
223
|
-
},
|
|
224
|
-
iconSVG: {
|
|
225
|
-
label: 'avatar__iconSVG',
|
|
226
|
-
display: 'flex',
|
|
227
|
-
alignItems: 'center',
|
|
228
|
-
justifyContent: 'center',
|
|
229
|
-
height: '100%',
|
|
230
|
-
width: '100%',
|
|
231
|
-
svg: {
|
|
232
|
-
fill: contentColor(),
|
|
233
|
-
height: '1em',
|
|
234
|
-
width: '1em'
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
var _default = exports.default = generateStyle;
|
package/lib/Avatar/theme.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _alpha = require("@instructure/ui-color-utils/lib/alpha.js");
|
|
8
|
-
/*
|
|
9
|
-
* The MIT License (MIT)
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
12
|
-
*
|
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
-
* in the Software without restriction, including without limitation the rights
|
|
16
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
-
* furnished to do so, subject to the following conditions:
|
|
19
|
-
*
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
-
* copies or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
-
* SOFTWARE.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Generates the theme object for the component from the theme and provided additional information
|
|
34
|
-
* @param theme The current theme object.
|
|
35
|
-
* @return The final theme object with the overrides and component variables
|
|
36
|
-
*/
|
|
37
|
-
const generateComponentTheme = theme => {
|
|
38
|
-
var _colors$contrasts, _colors$contrasts2, _colors$contrasts3, _colors$contrasts4, _colors$contrasts5, _colors$contrasts6, _colors$contrasts7, _colors$contrasts8, _colors$contrasts9, _colors$contrasts0, _colors$contrasts1, _colors$contrasts10;
|
|
39
|
-
const colors = theme.colors,
|
|
40
|
-
borders = theme.borders,
|
|
41
|
-
typography = theme.typography;
|
|
42
|
-
const componentVariables = {
|
|
43
|
-
background: colors === null || colors === void 0 ? void 0 : (_colors$contrasts = colors.contrasts) === null || _colors$contrasts === void 0 ? void 0 : _colors$contrasts.white1010,
|
|
44
|
-
borderWidthSmall: borders === null || borders === void 0 ? void 0 : borders.widthSmall,
|
|
45
|
-
borderWidthMedium: borders === null || borders === void 0 ? void 0 : borders.widthMedium,
|
|
46
|
-
borderColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts2 = colors.contrasts) === null || _colors$contrasts2 === void 0 ? void 0 : _colors$contrasts2.grey3045,
|
|
47
|
-
boxShadowColor: (0, _alpha.alpha)('#2d3b45', 12),
|
|
48
|
-
boxShadowBlur: '1rem',
|
|
49
|
-
fontFamily: typography === null || typography === void 0 ? void 0 : typography.fontFamily,
|
|
50
|
-
fontWeight: typography === null || typography === void 0 ? void 0 : typography.fontWeightBold,
|
|
51
|
-
// these colors have sufficient contrast with the white background
|
|
52
|
-
// in the normal and high contrast themes
|
|
53
|
-
color: colors === null || colors === void 0 ? void 0 : (_colors$contrasts3 = colors.contrasts) === null || _colors$contrasts3 === void 0 ? void 0 : _colors$contrasts3.blue4570,
|
|
54
|
-
colorShamrock: colors === null || colors === void 0 ? void 0 : (_colors$contrasts4 = colors.contrasts) === null || _colors$contrasts4 === void 0 ? void 0 : _colors$contrasts4.green4570,
|
|
55
|
-
colorBarney: colors === null || colors === void 0 ? void 0 : (_colors$contrasts5 = colors.contrasts) === null || _colors$contrasts5 === void 0 ? void 0 : _colors$contrasts5.blue4570,
|
|
56
|
-
colorCrimson: colors === null || colors === void 0 ? void 0 : (_colors$contrasts6 = colors.contrasts) === null || _colors$contrasts6 === void 0 ? void 0 : _colors$contrasts6.red4570,
|
|
57
|
-
colorFire: colors === null || colors === void 0 ? void 0 : (_colors$contrasts7 = colors.contrasts) === null || _colors$contrasts7 === void 0 ? void 0 : _colors$contrasts7.orange4570,
|
|
58
|
-
colorLicorice: colors === null || colors === void 0 ? void 0 : (_colors$contrasts8 = colors.contrasts) === null || _colors$contrasts8 === void 0 ? void 0 : _colors$contrasts8.grey125125,
|
|
59
|
-
colorAsh: colors === null || colors === void 0 ? void 0 : (_colors$contrasts9 = colors.contrasts) === null || _colors$contrasts9 === void 0 ? void 0 : _colors$contrasts9.grey4570,
|
|
60
|
-
aiTopGradientColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts0 = colors.contrasts) === null || _colors$contrasts0 === void 0 ? void 0 : _colors$contrasts0.violet4570,
|
|
61
|
-
aiBottomGradientColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts1 = colors.contrasts) === null || _colors$contrasts1 === void 0 ? void 0 : _colors$contrasts1.sea4570,
|
|
62
|
-
aiFontColor: colors === null || colors === void 0 ? void 0 : (_colors$contrasts10 = colors.contrasts) === null || _colors$contrasts10 === void 0 ? void 0 : _colors$contrasts10.white1010
|
|
63
|
-
};
|
|
64
|
-
return {
|
|
65
|
-
...componentVariables
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
var _default = exports.default = generateComponentTheme;
|
package/lib/index.js
DELETED
package/lib/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|