@pingux/astro 2.170.0 → 2.171.0-alpha.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/lib/cjs/components/Avatar/Avatar.js +13 -2
- package/lib/cjs/components/Avatar/Avatar.test.js +95 -1
- package/lib/cjs/components/Avatar/constants.d.ts +2 -0
- package/lib/cjs/components/Avatar/constants.js +8 -0
- package/lib/cjs/components/Avatar/getColorFromUuid.d.ts +2 -0
- package/lib/cjs/components/Avatar/getColorFromUuid.js +37 -0
- package/lib/cjs/components/NavBar/stories/NavBarNextGenComponent.js +8 -1
- package/lib/cjs/components/NavBarSection/NavBarItem.js +2 -2
- package/lib/cjs/components/NavBarSection/NavBarItemHeader.js +3 -3
- package/lib/cjs/components/NavBarSection/NavBarItemHeader.test.js +1 -1
- package/lib/cjs/components/NavSideBar/NavSideBarItem.js +12 -4
- package/lib/cjs/components/NavSideBar/NavSideBarSectionHeader.js +4 -3
- package/lib/cjs/hooks/useGetTheme/useGetTheme.d.ts +2 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/customProperties/index.d.ts +1 -0
- package/lib/cjs/styles/themeOverrides/onyxSideNav.d.ts +15 -0
- package/lib/cjs/styles/themeOverrides/onyxSideNav.js +23 -8
- package/lib/cjs/styles/themes/astro/customProperties/index.d.ts +1 -0
- package/lib/cjs/styles/themes/astro/customProperties/index.js +2 -0
- package/lib/cjs/styles/themes/next-gen/customProperties/index.d.ts +1 -0
- package/lib/cjs/styles/themes/next-gen/customProperties/index.js +2 -0
- package/lib/cjs/types/avatar.d.ts +2 -0
- package/lib/components/Avatar/Avatar.js +14 -3
- package/lib/components/Avatar/Avatar.test.js +95 -1
- package/lib/components/Avatar/constants.js +2 -0
- package/lib/components/Avatar/getColorFromUuid.js +29 -0
- package/lib/components/NavBar/stories/NavBarNextGenComponent.js +8 -1
- package/lib/components/NavBarSection/NavBarItem.js +2 -2
- package/lib/components/NavBarSection/NavBarItemHeader.js +3 -3
- package/lib/components/NavBarSection/NavBarItemHeader.test.js +1 -1
- package/lib/components/NavSideBar/NavSideBarItem.js +13 -5
- package/lib/components/NavSideBar/NavSideBarSectionHeader.js +4 -3
- package/lib/styles/themeOverrides/onyxSideNav.js +23 -8
- package/lib/styles/themes/astro/customProperties/index.js +2 -0
- package/lib/styles/themes/next-gen/customProperties/index.js +2 -0
- package/lib/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -21,8 +21,10 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-c
|
|
|
21
21
|
var _react = _interopRequireWildcard(require("react"));
|
|
22
22
|
var _themeUi = require("theme-ui");
|
|
23
23
|
var _hooks = require("../../hooks");
|
|
24
|
+
var _constants = require("./constants");
|
|
25
|
+
var _getColorFromUuid = _interopRequireDefault(require("./getColorFromUuid"));
|
|
24
26
|
var _react2 = require("@emotion/react");
|
|
25
|
-
var _excluded = ["alt", "defaultText", "color", "className", "size", "src", "sx", "children", "isSquare", "isLogo"];
|
|
27
|
+
var _excluded = ["alt", "defaultText", "color", "colorId", "className", "size", "src", "sx", "children", "isSquare", "isLogo"];
|
|
26
28
|
function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = _Object$defineProperty) && _Object$getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
27
29
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
28
30
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -32,6 +34,7 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
32
34
|
_props$defaultText = props.defaultText,
|
|
33
35
|
defaultText = _props$defaultText === void 0 ? 'AA' : _props$defaultText,
|
|
34
36
|
color = props.color,
|
|
37
|
+
colorId = props.colorId,
|
|
35
38
|
className = props.className,
|
|
36
39
|
_props$size = props.size,
|
|
37
40
|
size = _props$size === void 0 ? 'sm' : _props$size,
|
|
@@ -41,7 +44,15 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
41
44
|
isSquare = props.isSquare,
|
|
42
45
|
isLogo = props.isLogo,
|
|
43
46
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
44
|
-
|
|
47
|
+
|
|
48
|
+
// this will use color prop if provided,
|
|
49
|
+
// else will map colorId to a color, else defaults to 'green'
|
|
50
|
+
var finalColor = (0, _react.useMemo)(function () {
|
|
51
|
+
if (color) return color;
|
|
52
|
+
if (colorId) return (0, _getColorFromUuid["default"])(colorId, _constants.avatarColors);
|
|
53
|
+
return 'green';
|
|
54
|
+
}, [color, colorId, _constants.avatarColors]);
|
|
55
|
+
var _useStatusClasses = (0, _hooks.useStatusClasses)(className, (0, _defineProperty2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])((0, _defineProperty2["default"])({}, "is-".concat(finalColor), finalColor), "size-".concat(size), size), "font-size-".concat(size), src ? false : size), 'is-square', isSquare), 'is-image', src), 'is-logo', isLogo)),
|
|
45
56
|
classNames = _useStatusClasses.classNames;
|
|
46
57
|
if (src) {
|
|
47
58
|
return (0, _react2.jsx)(_themeUi.Box, (0, _extends2["default"])({
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from"));
|
|
5
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
6
|
+
var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
|
|
7
|
+
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
4
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
5
9
|
var _react = _interopRequireDefault(require("react"));
|
|
6
10
|
var _faker = require("@faker-js/faker");
|
|
11
|
+
var _nodeCrypto = require("node:crypto");
|
|
7
12
|
var _testWrapper = require("../../utils/testUtils/testWrapper");
|
|
8
13
|
var _universalComponentTest = require("../../utils/testUtils/universalComponentTest");
|
|
14
|
+
var _constants = require("./constants");
|
|
15
|
+
var _getColorFromUuid = _interopRequireDefault(require("./getColorFromUuid"));
|
|
9
16
|
var _ = _interopRequireDefault(require("."));
|
|
10
17
|
var _react2 = require("@emotion/react");
|
|
11
18
|
var src = _faker.faker.image.lorempicsum.imageUrl(150, 150, false, undefined, '1');
|
|
19
|
+
var datatestId = 'avatar-component';
|
|
12
20
|
var defaultProps = {
|
|
13
|
-
src: src
|
|
21
|
+
src: src,
|
|
22
|
+
'data-testid': datatestId
|
|
14
23
|
};
|
|
15
24
|
var getComponent = function getComponent() {
|
|
16
25
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -43,4 +52,89 @@ test('an avatar is rendered with custom alt', function () {
|
|
|
43
52
|
});
|
|
44
53
|
var avatar = _testWrapper.screen.getByText('KL');
|
|
45
54
|
expect(avatar).toBeInTheDocument();
|
|
55
|
+
});
|
|
56
|
+
describe('getColorFromUUID', function () {
|
|
57
|
+
test('returns a consistent color for the same UUID', function () {
|
|
58
|
+
var uuid = '123e4567-e89b-12d3-a456-426614174000';
|
|
59
|
+
var result1 = (0, _getColorFromUuid["default"])(uuid, _constants.avatarColors);
|
|
60
|
+
var result2 = (0, _getColorFromUuid["default"])(uuid, _constants.avatarColors);
|
|
61
|
+
expect(result1).toBe(result2);
|
|
62
|
+
});
|
|
63
|
+
test('returns a color from the provided array', function () {
|
|
64
|
+
var uuid = 'random-id';
|
|
65
|
+
var result = (0, _getColorFromUuid["default"])(uuid, _constants.avatarColors);
|
|
66
|
+
expect(_constants.avatarColors).toContain(result);
|
|
67
|
+
});
|
|
68
|
+
test('distributes colors differently for different UUIDs', function () {
|
|
69
|
+
var colorA = (0, _getColorFromUuid["default"])('id-1', _constants.avatarColors);
|
|
70
|
+
var colorB = (0, _getColorFromUuid["default"])('id-2', _constants.avatarColors);
|
|
71
|
+
|
|
72
|
+
// While collisions are mathematically possible, for 2 items in a 10-item list,
|
|
73
|
+
// these specific IDs yield different results in FNV-1a.
|
|
74
|
+
expect(colorA).not.toBe(colorB);
|
|
75
|
+
});
|
|
76
|
+
test('throws error if color array is empty', function () {
|
|
77
|
+
expect(function () {
|
|
78
|
+
return (0, _getColorFromUuid["default"])('uuid', []);
|
|
79
|
+
}).toThrow('Color array cannot be empty.');
|
|
80
|
+
});
|
|
81
|
+
test('uses the specific color class when color prop is provided', function () {
|
|
82
|
+
getComponent({
|
|
83
|
+
color: 'blue',
|
|
84
|
+
colorId: 'some-id'
|
|
85
|
+
});
|
|
86
|
+
var avatar = _testWrapper.screen.getByTestId(datatestId);
|
|
87
|
+
|
|
88
|
+
// Checking for 'is-blue'
|
|
89
|
+
expect(avatar).toHaveClass('is-blue');
|
|
90
|
+
});
|
|
91
|
+
test('applies a hashed color class from colorId', function () {
|
|
92
|
+
var uuid = '550e8400-e29b-41d4-a716-446655440000';
|
|
93
|
+
getComponent({
|
|
94
|
+
colorId: uuid
|
|
95
|
+
});
|
|
96
|
+
var avatar = _testWrapper.screen.getByTestId(datatestId);
|
|
97
|
+
|
|
98
|
+
// We check that it has *a* class starting with 'is-'
|
|
99
|
+
// and specifically isn't the default 'is-green'
|
|
100
|
+
var classList = (0, _from["default"])(avatar.classList);
|
|
101
|
+
var colorClass = (0, _find["default"])(classList).call(classList, function (cls) {
|
|
102
|
+
return (0, _startsWith["default"])(cls).call(cls, 'is-');
|
|
103
|
+
});
|
|
104
|
+
expect(colorClass).toBeDefined();
|
|
105
|
+
expect(avatar).not.toHaveClass('is-green');
|
|
106
|
+
});
|
|
107
|
+
test('defaults to is-green when no color props are passed', function () {
|
|
108
|
+
getComponent();
|
|
109
|
+
var avatar = _testWrapper.screen.getByTestId(datatestId);
|
|
110
|
+
expect(avatar).toHaveClass('is-green');
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
describe('getColorFromUUID Distribution', function () {
|
|
114
|
+
test('distributes 10,000 UUIDs evenly across 10 colors', function () {
|
|
115
|
+
var iterations = 10000;
|
|
116
|
+
var distribution = {};
|
|
117
|
+
|
|
118
|
+
// Initialize counts
|
|
119
|
+
(0, _forEach["default"])(_constants.avatarColors).call(_constants.avatarColors, function (c) {
|
|
120
|
+
distribution[c] = 0;
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// Generate and hash
|
|
124
|
+
for (var i = 0; i < iterations; i += 1) {
|
|
125
|
+
// Use the imported randomUUID function directly
|
|
126
|
+
var uuid = (0, _nodeCrypto.randomUUID)();
|
|
127
|
+
var selectedColor = (0, _getColorFromUuid["default"])(uuid, _constants.avatarColors);
|
|
128
|
+
distribution[selectedColor] += 1;
|
|
129
|
+
}
|
|
130
|
+
var expectedMean = iterations / _constants.avatarColors.length;
|
|
131
|
+
// 15% variance is a safe threshold for 10k iterations
|
|
132
|
+
var allowedVariance = 0.15;
|
|
133
|
+
(0, _forEach["default"])(_constants.avatarColors).call(_constants.avatarColors, function (color) {
|
|
134
|
+
var count = distribution[color];
|
|
135
|
+
// Assert that each color is roughly 10% of the total
|
|
136
|
+
expect(count).toBeGreaterThan(expectedMean * (1 - allowedVariance));
|
|
137
|
+
expect(count).toBeLessThan(expectedMean * (1 + allowedVariance));
|
|
138
|
+
});
|
|
139
|
+
});
|
|
46
140
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.avatarColors = void 0;
|
|
8
|
+
var avatarColors = exports.avatarColors = ['green', 'purple', 'pink', 'red', 'orange', 'yellow', 'teal', 'cyan', 'blue', 'indigo'];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
5
|
+
_Object$defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
var _imul = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/math/imul"));
|
|
10
|
+
// * Maps a UUID to a specific color from a provided array.
|
|
11
|
+
// * @param uuid - The unique identifier string.
|
|
12
|
+
// * @param colors - An array of color strings/objects.
|
|
13
|
+
// * @returns A single color from the array.
|
|
14
|
+
|
|
15
|
+
var getColorFromUUID = function getColorFromUUID(uuid, colors) {
|
|
16
|
+
if (colors.length === 0) {
|
|
17
|
+
throw new Error('Color array cannot be empty.');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// FNV-1a Hash implementation
|
|
21
|
+
// This spreads the bits of the UUID string evenly across a 32-bit integer
|
|
22
|
+
var hash = 2166136261;
|
|
23
|
+
for (var i = 0; i < uuid.length; i += 1) {
|
|
24
|
+
/* eslint-disable no-bitwise */
|
|
25
|
+
hash ^= uuid.charCodeAt(i);
|
|
26
|
+
// Standard FNV prime (using Math.imul for 32-bit integer multiplication)
|
|
27
|
+
|
|
28
|
+
hash = (0, _imul["default"])(hash, 16777619);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Convert to an unsigned index using the modulo operator
|
|
32
|
+
// The >>> 0 ensures we are dealing with an unsigned 32-bit integer
|
|
33
|
+
/* eslint-disable no-bitwise */
|
|
34
|
+
var index = (hash >>> 0) % colors.length;
|
|
35
|
+
return colors[index];
|
|
36
|
+
};
|
|
37
|
+
var _default = exports["default"] = getColorFromUUID;
|
|
@@ -57,11 +57,18 @@ var NavBarNextGenComponent = exports.NavBarNextGenComponent = function NavBarNex
|
|
|
57
57
|
'data-id': 'Authentication-data-id',
|
|
58
58
|
heading: 'Authentication',
|
|
59
59
|
icon: icons.authenticationIcon,
|
|
60
|
+
title: 'Policies',
|
|
60
61
|
key: 'Authentication',
|
|
61
62
|
children: [(0, _react2.jsx)(_.NavBarItemButton, {
|
|
62
63
|
key: "Authentication-Policies",
|
|
63
64
|
id: "Authentication-Policies"
|
|
64
|
-
}, "Authentication Policies"),
|
|
65
|
+
}, "Authentication Policies"), {
|
|
66
|
+
hasSeparator: false,
|
|
67
|
+
subTitle: 'Applications'
|
|
68
|
+
}, (0, _react2.jsx)(_.Separator, {
|
|
69
|
+
key: "separator",
|
|
70
|
+
variant: "separator.navBarSubtitleSeparator"
|
|
71
|
+
}), (0, _react2.jsx)(_.NavBarItemButton, {
|
|
65
72
|
key: "Password-Policies",
|
|
66
73
|
id: "Password-Policies"
|
|
67
74
|
}, "Password Policies")]
|
|
@@ -67,7 +67,7 @@ var NavBarItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
67
67
|
classNames = _useStatusClasses.classNames;
|
|
68
68
|
var color = isSelected ? 'white' : 'neutral.95';
|
|
69
69
|
var _useGetTheme = (0, _hooks.useGetTheme)(),
|
|
70
|
-
|
|
70
|
+
navBarIconSize = _useGetTheme.navBarIconSize;
|
|
71
71
|
return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
|
|
72
72
|
id: key,
|
|
73
73
|
variant: state.navStyles.navBarItem,
|
|
@@ -89,7 +89,7 @@ var NavBarItem = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
89
89
|
title: {
|
|
90
90
|
name: text
|
|
91
91
|
},
|
|
92
|
-
size:
|
|
92
|
+
size: navBarIconSize || 18,
|
|
93
93
|
sx: {
|
|
94
94
|
mr: 'sm',
|
|
95
95
|
color: color,
|
|
@@ -38,8 +38,8 @@ var NavBarSectionItemHeader = function NavBarSectionItemHeader(_ref2) {
|
|
|
38
38
|
heading = item.heading;
|
|
39
39
|
var navBarState = (0, _NavBarContext.useNavBarContext)();
|
|
40
40
|
var _useGetTheme = (0, _useGetTheme3["default"])(),
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
icons = _useGetTheme.icons,
|
|
42
|
+
navBarIconSize = _useGetTheme.navBarIconSize;
|
|
43
43
|
var MenuDown = icons.MenuDown,
|
|
44
44
|
MenuUp = icons.MenuUp;
|
|
45
45
|
var selectedKey = navBarState.selectedKey,
|
|
@@ -74,7 +74,7 @@ var NavBarSectionItemHeader = function NavBarSectionItemHeader(_ref2) {
|
|
|
74
74
|
"data-testid": heading
|
|
75
75
|
}, icon && (0, _react2.jsx)(_index.Icon, {
|
|
76
76
|
icon: icon,
|
|
77
|
-
size:
|
|
77
|
+
size: navBarIconSize || 18,
|
|
78
78
|
sx: {
|
|
79
79
|
mr: 'sm',
|
|
80
80
|
color: getIconColor(),
|
|
@@ -81,6 +81,6 @@ describe('NavItemHeader', function () {
|
|
|
81
81
|
getComponent();
|
|
82
82
|
var icon = _testWrapper.screen.getByTestId('Dashboard').querySelector('svg');
|
|
83
83
|
expect(icon).toBeInTheDocument();
|
|
84
|
-
expect(icon).toHaveAttribute('width', '
|
|
84
|
+
expect(icon).toHaveAttribute('width', '18');
|
|
85
85
|
});
|
|
86
86
|
});
|
|
@@ -9,8 +9,8 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
9
9
|
value: true
|
|
10
10
|
});
|
|
11
11
|
exports["default"] = void 0;
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
13
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties"));
|
|
13
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
14
14
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
15
|
var _reactAria = require("react-aria");
|
|
16
16
|
var _interactions = require("@react-aria/interactions");
|
|
@@ -23,8 +23,13 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var
|
|
|
23
23
|
var NavSideBarItem = function NavSideBarItem(props) {
|
|
24
24
|
var children = props.children,
|
|
25
25
|
linkProps = props.linkProps;
|
|
26
|
+
console.log(props);
|
|
26
27
|
if (linkProps && linkProps !== null && linkProps !== void 0 && linkProps.href) {
|
|
27
|
-
return (0, _react2.jsx)(_index.Link,
|
|
28
|
+
return (0, _react2.jsx)(_index.Link, (0, _extends2["default"])({}, linkProps, {
|
|
29
|
+
sx: {
|
|
30
|
+
textDecoration: 'none !important'
|
|
31
|
+
}
|
|
32
|
+
}), (0, _react2.jsx)(ChildWrapper, props, children));
|
|
28
33
|
}
|
|
29
34
|
return (0, _react2.jsx)(_index.Button, {
|
|
30
35
|
variant: "link",
|
|
@@ -68,6 +73,8 @@ var ChildWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
68
73
|
}),
|
|
69
74
|
pressProps = _usePress.pressProps,
|
|
70
75
|
isPressed = _usePress.isPressed;
|
|
76
|
+
var _useGetTheme = (0, _hooks.useGetTheme)(),
|
|
77
|
+
navBarIconSize = _useGetTheme.navBarIconSize;
|
|
71
78
|
var mergedProps = (0, _reactAria.mergeProps)(pressProps, hoverProps, focusWithinProps, focusProps, others);
|
|
72
79
|
var _useStatusClasses = (0, _hooks.useStatusClasses)(className, {
|
|
73
80
|
isPressed: isPressed,
|
|
@@ -76,6 +83,7 @@ var ChildWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
76
83
|
isFocused: isFocusVisible
|
|
77
84
|
}),
|
|
78
85
|
classNames = _useStatusClasses.classNames;
|
|
86
|
+
console.log(state.navStyles.navBarItem);
|
|
79
87
|
return (0, _react2.jsx)(_index.Box, (0, _extends2["default"])({
|
|
80
88
|
id: key,
|
|
81
89
|
variant: state.navStyles.navBarItem,
|
|
@@ -93,13 +101,13 @@ var ChildWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
|
93
101
|
title: {
|
|
94
102
|
name: children
|
|
95
103
|
},
|
|
96
|
-
size:
|
|
104
|
+
size: navBarIconSize,
|
|
97
105
|
variant: isSelected ? state.navStyles.navBarItemIconSelected : state.navStyles.navBarItemIcon
|
|
98
106
|
}, iconProps)), (0, _react2.jsx)(_index.Text, {
|
|
99
107
|
variant: state.navStyles.navBarItemText
|
|
100
108
|
}, children), customIcon && (0, _react2.jsx)(_index.Icon, (0, _extends2["default"])({
|
|
101
109
|
icon: customIcon,
|
|
102
|
-
size:
|
|
110
|
+
size: navBarIconSize,
|
|
103
111
|
variant: isSelected ? state.navStyles.navBarItemCustomIconSelected : state.navStyles.navBarItemCustomIcon
|
|
104
112
|
}, customIconProps, {
|
|
105
113
|
title: {
|
|
@@ -33,7 +33,8 @@ var NavSideBarSectionHeader = function NavSideBarSectionHeader(props) {
|
|
|
33
33
|
onExpandedChange = props.onExpandedChange,
|
|
34
34
|
others = (0, _objectWithoutProperties2["default"])(props, _excluded);
|
|
35
35
|
var _useGetTheme = (0, _useGetTheme2["default"])(),
|
|
36
|
-
icons = _useGetTheme.icons
|
|
36
|
+
icons = _useGetTheme.icons,
|
|
37
|
+
navBarIconSize = _useGetTheme.navBarIconSize;
|
|
37
38
|
var MenuUp = icons.MenuUp,
|
|
38
39
|
MenuDown = icons.MenuDown;
|
|
39
40
|
var navBarState = (0, _NavBarContext.useNavBarContext)();
|
|
@@ -74,7 +75,7 @@ var NavSideBarSectionHeader = function NavSideBarSectionHeader(props) {
|
|
|
74
75
|
isRow: true
|
|
75
76
|
}, icon && (0, _react2.jsx)(_index.Icon, {
|
|
76
77
|
icon: icon,
|
|
77
|
-
size:
|
|
78
|
+
size: navBarIconSize,
|
|
78
79
|
variant: variant,
|
|
79
80
|
"aria-hidden": "true"
|
|
80
81
|
}), (0, _react2.jsx)(_index.Text, {
|
|
@@ -87,7 +88,7 @@ var NavSideBarSectionHeader = function NavSideBarSectionHeader(props) {
|
|
|
87
88
|
}
|
|
88
89
|
}, (0, _react2.jsx)(_index.Icon, {
|
|
89
90
|
icon: isExpanded ? MenuUp : MenuDown,
|
|
90
|
-
size:
|
|
91
|
+
size: navBarIconSize,
|
|
91
92
|
variant: variant,
|
|
92
93
|
mr: "0",
|
|
93
94
|
title: {
|
|
@@ -7,6 +7,7 @@ export declare const baseState: {
|
|
|
7
7
|
declare const useGetTheme: () => {
|
|
8
8
|
name: string;
|
|
9
9
|
accordionItemDefaultLabelTag: string;
|
|
10
|
+
navBarIconSize: import("../..").IconSize;
|
|
10
11
|
activeColor: string;
|
|
11
12
|
backgroundBaseColor: string;
|
|
12
13
|
icons: {
|
|
@@ -157,6 +158,7 @@ declare const useGetTheme: () => {
|
|
|
157
158
|
pageHeaderAddIconSize: string;
|
|
158
159
|
defaultLoaderSize: number;
|
|
159
160
|
activeColor: string;
|
|
161
|
+
navBarIconSize: import("../..").IconSize;
|
|
160
162
|
styles: {
|
|
161
163
|
navButtonEstHeight: number;
|
|
162
164
|
};
|
|
@@ -16,6 +16,7 @@ declare const _default: {
|
|
|
16
16
|
p: string;
|
|
17
17
|
backgroundColor: string;
|
|
18
18
|
boxShadow: string;
|
|
19
|
+
zIndex: number;
|
|
19
20
|
};
|
|
20
21
|
logoParent: {
|
|
21
22
|
p: string;
|
|
@@ -127,6 +128,7 @@ declare const _default: {
|
|
|
127
128
|
textTransform: string;
|
|
128
129
|
fontSize: string;
|
|
129
130
|
letterSpacing: string;
|
|
131
|
+
lineHeight: string;
|
|
130
132
|
};
|
|
131
133
|
headerText: {
|
|
132
134
|
color: string;
|
|
@@ -156,6 +158,7 @@ declare const _default: {
|
|
|
156
158
|
py: string;
|
|
157
159
|
color: string;
|
|
158
160
|
borderRadius: string;
|
|
161
|
+
textDecoration: string;
|
|
159
162
|
mb: string;
|
|
160
163
|
'&.is-hovered': {
|
|
161
164
|
backgroundColor: string;
|
|
@@ -163,6 +166,9 @@ declare const _default: {
|
|
|
163
166
|
'> div > svg': {
|
|
164
167
|
fill: string;
|
|
165
168
|
};
|
|
169
|
+
'> svg': {
|
|
170
|
+
fill: string;
|
|
171
|
+
};
|
|
166
172
|
'&.is-pressed': {
|
|
167
173
|
backgroundColor: string;
|
|
168
174
|
};
|
|
@@ -170,6 +176,9 @@ declare const _default: {
|
|
|
170
176
|
'> div > svg': {
|
|
171
177
|
fill: string;
|
|
172
178
|
};
|
|
179
|
+
'> svg': {
|
|
180
|
+
fill: string;
|
|
181
|
+
};
|
|
173
182
|
backgroundColor: string;
|
|
174
183
|
boxShadow: string;
|
|
175
184
|
};
|
|
@@ -217,6 +226,11 @@ declare const _default: {
|
|
|
217
226
|
maxWidth: string;
|
|
218
227
|
backgroundColor: string;
|
|
219
228
|
};
|
|
229
|
+
navBarSubtitleSeparator: {
|
|
230
|
+
backgroundColor: string;
|
|
231
|
+
mx: string;
|
|
232
|
+
my: string;
|
|
233
|
+
};
|
|
220
234
|
};
|
|
221
235
|
};
|
|
222
236
|
icons: {
|
|
@@ -269,5 +283,6 @@ declare const _default: {
|
|
|
269
283
|
md: number;
|
|
270
284
|
xsm: number;
|
|
271
285
|
};
|
|
286
|
+
navBarIconSize: string;
|
|
272
287
|
};
|
|
273
288
|
export default _default;
|
|
@@ -35,7 +35,8 @@ var navBar = {
|
|
|
35
35
|
width: '230px',
|
|
36
36
|
p: '8px',
|
|
37
37
|
backgroundColor: 'white',
|
|
38
|
-
boxShadow: '0
|
|
38
|
+
boxShadow: '0 2px 11px rgba(0, 0, 0, .13)',
|
|
39
|
+
zIndex: 2
|
|
39
40
|
},
|
|
40
41
|
logoParent: {
|
|
41
42
|
p: '8px'
|
|
@@ -51,7 +52,7 @@ var navBar = {
|
|
|
51
52
|
backgroundColor: '#f6f8fa'
|
|
52
53
|
},
|
|
53
54
|
'&.is-pressed': {
|
|
54
|
-
backgroundColor: '#
|
|
55
|
+
backgroundColor: '#EDEFF1'
|
|
55
56
|
},
|
|
56
57
|
'&.is-focused': _objectSpread({}, navBarFocus),
|
|
57
58
|
':focus': {
|
|
@@ -65,7 +66,7 @@ var navBar = {
|
|
|
65
66
|
backgroundColor: '#f6f8fa'
|
|
66
67
|
},
|
|
67
68
|
'&.is-pressed': {
|
|
68
|
-
backgroundColor: '#
|
|
69
|
+
backgroundColor: '#EDEFF1'
|
|
69
70
|
},
|
|
70
71
|
'&.is-focused': _objectSpread({}, navBarFocus),
|
|
71
72
|
backgroundColor: '#f6f8fa'
|
|
@@ -99,7 +100,7 @@ var navBar = {
|
|
|
99
100
|
border: 'none'
|
|
100
101
|
},
|
|
101
102
|
'&.is-pressed': {
|
|
102
|
-
backgroundColor: '#
|
|
103
|
+
backgroundColor: '#EDEFF1',
|
|
103
104
|
color: '#455469'
|
|
104
105
|
},
|
|
105
106
|
'&.is-selected': {
|
|
@@ -116,7 +117,7 @@ var navBar = {
|
|
|
116
117
|
border: 'none'
|
|
117
118
|
},
|
|
118
119
|
'&.is-pressed': {
|
|
119
|
-
backgroundColor: '#
|
|
120
|
+
backgroundColor: '#EDEFF1',
|
|
120
121
|
color: '#455469'
|
|
121
122
|
},
|
|
122
123
|
'&.is-selected': {
|
|
@@ -130,7 +131,8 @@ var navBar = {
|
|
|
130
131
|
marginLeft: '50px !important',
|
|
131
132
|
textTransform: 'uppercase',
|
|
132
133
|
fontSize: '12px',
|
|
133
|
-
letterSpacing: '1px'
|
|
134
|
+
letterSpacing: '1px',
|
|
135
|
+
lineHeight: '140%'
|
|
134
136
|
},
|
|
135
137
|
headerText: {
|
|
136
138
|
color: '#455469',
|
|
@@ -160,6 +162,7 @@ var navBar = {
|
|
|
160
162
|
py: '.75rem',
|
|
161
163
|
color: '#455469',
|
|
162
164
|
borderRadius: '4px',
|
|
165
|
+
textDecoration: 'none',
|
|
163
166
|
mb: '2px',
|
|
164
167
|
'&.is-hovered': {
|
|
165
168
|
backgroundColor: '#f6f8fa'
|
|
@@ -167,12 +170,18 @@ var navBar = {
|
|
|
167
170
|
'> div > svg': {
|
|
168
171
|
fill: '#455469'
|
|
169
172
|
},
|
|
173
|
+
'> svg': {
|
|
174
|
+
fill: '#455469'
|
|
175
|
+
},
|
|
170
176
|
'&.is-pressed': {
|
|
171
|
-
backgroundColor: '#
|
|
177
|
+
backgroundColor: '#EDEFF1'
|
|
172
178
|
},
|
|
173
179
|
'&.is-selected': _objectSpread(_objectSpread({}, navBarSelected), {}, {
|
|
174
180
|
'> div > svg': {
|
|
175
181
|
fill: 'accent.40'
|
|
182
|
+
},
|
|
183
|
+
'> svg': {
|
|
184
|
+
fill: 'accent.40'
|
|
176
185
|
}
|
|
177
186
|
}),
|
|
178
187
|
'&.is-focused': {
|
|
@@ -216,6 +225,11 @@ var separator = {
|
|
|
216
225
|
mx: '0px',
|
|
217
226
|
maxWidth: '236px',
|
|
218
227
|
backgroundColor: '#e7eef4'
|
|
228
|
+
},
|
|
229
|
+
navBarSubtitleSeparator: {
|
|
230
|
+
backgroundColor: '#e7eef4',
|
|
231
|
+
mx: '0px',
|
|
232
|
+
my: '10px'
|
|
219
233
|
}
|
|
220
234
|
};
|
|
221
235
|
var _default = exports["default"] = {
|
|
@@ -235,5 +249,6 @@ var _default = exports["default"] = {
|
|
|
235
249
|
sm: 20,
|
|
236
250
|
md: 25,
|
|
237
251
|
'xsm': 16
|
|
238
|
-
}
|
|
252
|
+
},
|
|
253
|
+
navBarIconSize: '20px'
|
|
239
254
|
};
|
|
@@ -32,8 +32,10 @@ var defaultIconColor = 'currentColor';
|
|
|
32
32
|
var defaultIconSize = 'sm';
|
|
33
33
|
var linkSelectFieldWidth = '10em';
|
|
34
34
|
var calendarIconSize = 25;
|
|
35
|
+
var navBarIconSize = 18;
|
|
35
36
|
var astroThemeValues = exports.astroThemeValues = {
|
|
36
37
|
accordionItemDefaultLabelTag: accordionItemDefaultLabelTag,
|
|
38
|
+
navBarIconSize: navBarIconSize,
|
|
37
39
|
activeColor: activeColor,
|
|
38
40
|
backgroundBaseColor: backgroundBaseColor,
|
|
39
41
|
icons: _icons["default"],
|
|
@@ -39,8 +39,10 @@ var badgeStyles = {
|
|
|
39
39
|
};
|
|
40
40
|
var linkSelectFieldWidth = '12em';
|
|
41
41
|
var calendarIconSize = 'sm';
|
|
42
|
+
var navBarIconSize = '20px';
|
|
42
43
|
var nextGenThemeValues = exports.nextGenThemeValues = _objectSpread({
|
|
43
44
|
activeColor: activeColor,
|
|
45
|
+
navBarIconSize: navBarIconSize,
|
|
44
46
|
backgroundBaseColor: backgroundBaseColor,
|
|
45
47
|
styles: _styles["default"],
|
|
46
48
|
icons: _icons["default"],
|
|
@@ -9,12 +9,14 @@ import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object
|
|
|
9
9
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
10
10
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
11
11
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
|
12
|
-
var _excluded = ["alt", "defaultText", "color", "className", "size", "src", "sx", "children", "isSquare", "isLogo"];
|
|
12
|
+
var _excluded = ["alt", "defaultText", "color", "colorId", "className", "size", "src", "sx", "children", "isSquare", "isLogo"];
|
|
13
13
|
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = _filterInstanceProperty(o).call(o, function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
14
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var _context, _context2; var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(t), !0)).call(_context, function (r) { _defineProperty(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : _forEachInstanceProperty(_context2 = ownKeys(Object(t))).call(_context2, function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
-
import React, { forwardRef } from 'react';
|
|
15
|
+
import React, { forwardRef, useMemo } from 'react';
|
|
16
16
|
import { Avatar as ThemeUIAvatar, Box } from 'theme-ui';
|
|
17
17
|
import { useStatusClasses } from '../../hooks';
|
|
18
|
+
import { avatarColors } from './constants';
|
|
19
|
+
import getColorFromUUID from './getColorFromUuid';
|
|
18
20
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
19
21
|
var Avatar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
20
22
|
var _props$alt = props.alt,
|
|
@@ -22,6 +24,7 @@ var Avatar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
22
24
|
_props$defaultText = props.defaultText,
|
|
23
25
|
defaultText = _props$defaultText === void 0 ? 'AA' : _props$defaultText,
|
|
24
26
|
color = props.color,
|
|
27
|
+
colorId = props.colorId,
|
|
25
28
|
className = props.className,
|
|
26
29
|
_props$size = props.size,
|
|
27
30
|
size = _props$size === void 0 ? 'sm' : _props$size,
|
|
@@ -31,7 +34,15 @@ var Avatar = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
31
34
|
isSquare = props.isSquare,
|
|
32
35
|
isLogo = props.isLogo,
|
|
33
36
|
others = _objectWithoutProperties(props, _excluded);
|
|
34
|
-
|
|
37
|
+
|
|
38
|
+
// this will use color prop if provided,
|
|
39
|
+
// else will map colorId to a color, else defaults to 'green'
|
|
40
|
+
var finalColor = useMemo(function () {
|
|
41
|
+
if (color) return color;
|
|
42
|
+
if (colorId) return getColorFromUUID(colorId, avatarColors);
|
|
43
|
+
return 'green';
|
|
44
|
+
}, [color, colorId, avatarColors]);
|
|
45
|
+
var _useStatusClasses = useStatusClasses(className, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "is-".concat(finalColor), finalColor), "size-".concat(size), size), "font-size-".concat(size), src ? false : size), 'is-square', isSquare), 'is-image', src), 'is-logo', isLogo)),
|
|
35
46
|
classNames = _useStatusClasses.classNames;
|
|
36
47
|
if (src) {
|
|
37
48
|
return ___EmotionJSX(Box, _extends({
|