@atlaskit/teams-avatar 1.2.0 → 1.2.2
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 +12 -0
- package/dist/cjs/ui/teams-avatar/index.js +2 -1
- package/dist/cjs/ui/teams-avatar/utils.js +31 -0
- package/dist/es2019/ui/teams-avatar/index.js +2 -1
- package/dist/es2019/ui/teams-avatar/utils.js +25 -0
- package/dist/esm/ui/teams-avatar/index.js +2 -1
- package/dist/esm/ui/teams-avatar/utils.js +25 -0
- package/dist/types/ui/teams-avatar/index.d.ts +2 -2
- package/dist/types/ui/teams-avatar/utils.d.ts +9 -0
- package/dist/types-ts4.5/ui/teams-avatar/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/teams-avatar/utils.d.ts +9 -0
- package/package.json +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
12
12
|
var _avatar = _interopRequireDefault(require("@atlaskit/avatar"));
|
|
13
13
|
var _colors = require("@atlaskit/theme/colors");
|
|
14
14
|
var _teamsAvatarImage = require("./teams-avatar-image");
|
|
15
|
+
var _utils = require("./utils");
|
|
15
16
|
var _excluded = ["testId", "src", "size"];
|
|
16
17
|
var ICON_BACKGROUND = exports.ICON_BACKGROUND = "var(--ds-icon-inverse, ".concat(_colors.N0, ")");
|
|
17
18
|
var ICON_COLOR = exports.ICON_COLOR = "var(--ds-icon-subtle, ".concat(_colors.N90, ")");
|
|
@@ -22,7 +23,7 @@ function TeamAvatar(_ref) {
|
|
|
22
23
|
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
23
24
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
24
25
|
return /*#__PURE__*/_react.default.createElement(_avatar.default, (0, _extends2.default)({
|
|
25
|
-
appearance:
|
|
26
|
+
appearance: (0, _utils.isSquareIcon)(src) ? 'square' : 'circle'
|
|
26
27
|
}, props, {
|
|
27
28
|
size: size,
|
|
28
29
|
src: src,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isSquareIcon = isSquareIcon;
|
|
7
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
8
|
+
/**
|
|
9
|
+
* This is a hack to toggle between square and circle icons based on the
|
|
10
|
+
* network response as we want to FG the change in the BE.
|
|
11
|
+
* This func will be removed once the BE is rolled out.
|
|
12
|
+
* Square icon URLs:
|
|
13
|
+
* - https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/teams/avatars/v4/blue_4.svg
|
|
14
|
+
* - https://teams-directory-frontend.stg-east.frontend.public.atl-paas.net/assets/teams/avatars/v4/blue_1.svg
|
|
15
|
+
*/
|
|
16
|
+
function isSquareIcon(src) {
|
|
17
|
+
if (!src) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
var url = new URL(src);
|
|
22
|
+
var host = url.host;
|
|
23
|
+
var path = url.pathname;
|
|
24
|
+
if ((host.startsWith('ptc-directory-sited-static') || host.startsWith('teams-directory-frontend')) && path.includes('teams/avatars/v4') && (0, _platformFeatureFlags.fg)('enable-team-avatar-switch')) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
} catch (_unused) {
|
|
28
|
+
// The src wasn't a URL, so it's obviously not the refreshed avatar.
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import Avatar from '@atlaskit/avatar';
|
|
4
4
|
import { N0, N90 } from '@atlaskit/theme/colors';
|
|
5
5
|
import { TeamAvatarImage } from './teams-avatar-image';
|
|
6
|
+
import { isSquareIcon } from './utils';
|
|
6
7
|
export const ICON_BACKGROUND = `var(--ds-icon-inverse, ${N0})`;
|
|
7
8
|
export const ICON_COLOR = `var(--ds-icon-subtle, ${N90})`;
|
|
8
9
|
export default function TeamAvatar({
|
|
@@ -12,7 +13,7 @@ export default function TeamAvatar({
|
|
|
12
13
|
...props
|
|
13
14
|
}) {
|
|
14
15
|
return /*#__PURE__*/React.createElement(Avatar, _extends({
|
|
15
|
-
appearance:
|
|
16
|
+
appearance: isSquareIcon(src) ? 'square' : 'circle'
|
|
16
17
|
}, props, {
|
|
17
18
|
size: size,
|
|
18
19
|
src: src,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
/**
|
|
3
|
+
* This is a hack to toggle between square and circle icons based on the
|
|
4
|
+
* network response as we want to FG the change in the BE.
|
|
5
|
+
* This func will be removed once the BE is rolled out.
|
|
6
|
+
* Square icon URLs:
|
|
7
|
+
* - https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/teams/avatars/v4/blue_4.svg
|
|
8
|
+
* - https://teams-directory-frontend.stg-east.frontend.public.atl-paas.net/assets/teams/avatars/v4/blue_1.svg
|
|
9
|
+
*/
|
|
10
|
+
export function isSquareIcon(src) {
|
|
11
|
+
if (!src) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const url = new URL(src);
|
|
16
|
+
const host = url.host;
|
|
17
|
+
const path = url.pathname;
|
|
18
|
+
if ((host.startsWith('ptc-directory-sited-static') || host.startsWith('teams-directory-frontend')) && path.includes('teams/avatars/v4') && fg('enable-team-avatar-switch')) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
} catch {
|
|
22
|
+
// The src wasn't a URL, so it's obviously not the refreshed avatar.
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
@@ -5,6 +5,7 @@ import React from 'react';
|
|
|
5
5
|
import Avatar from '@atlaskit/avatar';
|
|
6
6
|
import { N0, N90 } from '@atlaskit/theme/colors';
|
|
7
7
|
import { TeamAvatarImage } from './teams-avatar-image';
|
|
8
|
+
import { isSquareIcon } from './utils';
|
|
8
9
|
export var ICON_BACKGROUND = "var(--ds-icon-inverse, ".concat(N0, ")");
|
|
9
10
|
export var ICON_COLOR = "var(--ds-icon-subtle, ".concat(N90, ")");
|
|
10
11
|
export default function TeamAvatar(_ref) {
|
|
@@ -14,7 +15,7 @@ export default function TeamAvatar(_ref) {
|
|
|
14
15
|
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
15
16
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
16
17
|
return /*#__PURE__*/React.createElement(Avatar, _extends({
|
|
17
|
-
appearance:
|
|
18
|
+
appearance: isSquareIcon(src) ? 'square' : 'circle'
|
|
18
19
|
}, props, {
|
|
19
20
|
size: size,
|
|
20
21
|
src: src,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
/**
|
|
3
|
+
* This is a hack to toggle between square and circle icons based on the
|
|
4
|
+
* network response as we want to FG the change in the BE.
|
|
5
|
+
* This func will be removed once the BE is rolled out.
|
|
6
|
+
* Square icon URLs:
|
|
7
|
+
* - https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/teams/avatars/v4/blue_4.svg
|
|
8
|
+
* - https://teams-directory-frontend.stg-east.frontend.public.atl-paas.net/assets/teams/avatars/v4/blue_1.svg
|
|
9
|
+
*/
|
|
10
|
+
export function isSquareIcon(src) {
|
|
11
|
+
if (!src) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
var url = new URL(src);
|
|
16
|
+
var host = url.host;
|
|
17
|
+
var path = url.pathname;
|
|
18
|
+
if ((host.startsWith('ptc-directory-sited-static') || host.startsWith('teams-directory-frontend')) && path.includes('teams/avatars/v4') && fg('enable-team-avatar-switch')) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
} catch (_unused) {
|
|
22
|
+
// The src wasn't a URL, so it's obviously not the refreshed avatar.
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { type AvatarPropTypes } from '@atlaskit/avatar';
|
|
3
3
|
export type TeamAvatarProps = Omit<AvatarPropTypes, 'appearance'>;
|
|
4
4
|
export declare const ICON_BACKGROUND: "var(--ds-icon-inverse)";
|
|
5
5
|
export declare const ICON_COLOR: "var(--ds-icon-subtle)";
|
|
6
|
-
export default function TeamAvatar({ testId, src, size, ...props }: TeamAvatarProps): JSX.Element;
|
|
6
|
+
export default function TeamAvatar({ testId, src, size, ...props }: TeamAvatarProps): React.JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a hack to toggle between square and circle icons based on the
|
|
3
|
+
* network response as we want to FG the change in the BE.
|
|
4
|
+
* This func will be removed once the BE is rolled out.
|
|
5
|
+
* Square icon URLs:
|
|
6
|
+
* - https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/teams/avatars/v4/blue_4.svg
|
|
7
|
+
* - https://teams-directory-frontend.stg-east.frontend.public.atl-paas.net/assets/teams/avatars/v4/blue_1.svg
|
|
8
|
+
*/
|
|
9
|
+
export declare function isSquareIcon(src?: string): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { type AvatarPropTypes } from '@atlaskit/avatar';
|
|
3
3
|
export type TeamAvatarProps = Omit<AvatarPropTypes, 'appearance'>;
|
|
4
4
|
export declare const ICON_BACKGROUND: "var(--ds-icon-inverse)";
|
|
5
5
|
export declare const ICON_COLOR: "var(--ds-icon-subtle)";
|
|
6
|
-
export default function TeamAvatar({ testId, src, size, ...props }: TeamAvatarProps): JSX.Element;
|
|
6
|
+
export default function TeamAvatar({ testId, src, size, ...props }: TeamAvatarProps): React.JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is a hack to toggle between square and circle icons based on the
|
|
3
|
+
* network response as we want to FG the change in the BE.
|
|
4
|
+
* This func will be removed once the BE is rolled out.
|
|
5
|
+
* Square icon URLs:
|
|
6
|
+
* - https://ptc-directory-sited-static.us-east-1.prod.public.atl-paas.net/teams/avatars/v4/blue_4.svg
|
|
7
|
+
* - https://teams-directory-frontend.stg-east.frontend.public.atl-paas.net/assets/teams/avatars/v4/blue_1.svg
|
|
8
|
+
*/
|
|
9
|
+
export declare function isSquareIcon(src?: string): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/teams-avatar",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "A team avatar is a visual representation of a team.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,8 +36,9 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@atlaskit/avatar": "^21.18.0",
|
|
39
|
-
"@atlaskit/icon": "^23.
|
|
40
|
-
"@atlaskit/
|
|
39
|
+
"@atlaskit/icon": "^23.7.0",
|
|
40
|
+
"@atlaskit/platform-feature-flags": "^1.0.0",
|
|
41
|
+
"@atlaskit/theme": "^15.0.0",
|
|
41
42
|
"@atlaskit/tokens": "^3.3.0",
|
|
42
43
|
"@babel/runtime": "^7.0.0",
|
|
43
44
|
"@emotion/react": "^11.7.1"
|
|
@@ -50,6 +51,7 @@
|
|
|
50
51
|
"@af/visual-regression": "*",
|
|
51
52
|
"@atlaskit/ssr": "*",
|
|
52
53
|
"@atlaskit/visual-regression": "*",
|
|
54
|
+
"@atlassian/feature-flags-test-utils": "*",
|
|
53
55
|
"@testing-library/react": "^13.4.0",
|
|
54
56
|
"react-dom": "^18.2.0",
|
|
55
57
|
"typescript": "~5.4.2",
|
|
@@ -92,5 +94,10 @@
|
|
|
92
94
|
"import-no-extraneous-disable-for-examples-and-docs"
|
|
93
95
|
]
|
|
94
96
|
}
|
|
97
|
+
},
|
|
98
|
+
"platform-feature-flags": {
|
|
99
|
+
"enable-team-avatar-switch": {
|
|
100
|
+
"type": "boolean"
|
|
101
|
+
}
|
|
95
102
|
}
|
|
96
103
|
}
|