@pingux/astro 2.178.3 → 2.179.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.
@@ -44,14 +44,16 @@ var Avatar = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
44
44
  isSquare = props.isSquare,
45
45
  isLogo = props.isLogo,
46
46
  others = (0, _objectWithoutProperties2["default"])(props, _excluded);
47
-
48
- // this will use color prop if provided,
49
- // else will map colorId to a color, else defaults to 'green'
47
+ var safeColorId = colorId || '_INTERNAL_DEFAULT_ID_';
48
+ if (process.env.NODE_ENV !== 'production') {
49
+ if (!src && !color && !colorId) {
50
+ console.warn("[Astro] Avatar: No 'src', 'color', or 'colorId' provided. " + 'The component is falling back to a default generated color.');
51
+ }
52
+ }
50
53
  var finalColor = (0, _react.useMemo)(function () {
51
54
  if (color) return color;
52
- if (colorId) return (0, _getColorFromUuid["default"])(colorId, _constants.avatarColors);
53
- return 'green';
54
- }, [color, colorId, _constants.avatarColors]);
55
+ return (0, _getColorFromUuid["default"])(safeColorId, _constants.avatarColors);
56
+ }, [color, safeColorId]);
55
57
  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)),
56
58
  classNames = _useStatusClasses.classNames;
57
59
  if (src) {
@@ -46,12 +46,14 @@ test('an avatar is rendered with custom alt', function () {
46
46
  expect(img).toHaveAttribute('alt', 'Custom Alt');
47
47
  });
48
48
  test('an avatar is rendered with custom alt', function () {
49
+ var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
49
50
  getComponent({
50
51
  src: undefined,
51
52
  defaultText: 'KL'
52
53
  });
53
54
  var avatar = _testWrapper.screen.getByText('KL');
54
55
  expect(avatar).toBeInTheDocument();
56
+ warnSpy.mockRestore();
55
57
  });
56
58
  describe('getColorFromUUID', function () {
57
59
  test('returns a consistent color for the same UUID', function () {
@@ -110,6 +112,61 @@ describe('getColorFromUUID', function () {
110
112
  expect(avatar).toHaveClass('is-green');
111
113
  });
112
114
  });
115
+ describe('Avatar fallback behavior', function () {
116
+ test('warns in development when no src, color, or colorId is provided', function () {
117
+ var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
118
+ getComponent({
119
+ src: undefined
120
+ });
121
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("No 'src', 'color', or 'colorId' provided"));
122
+ warnSpy.mockRestore();
123
+ });
124
+ test('does not crash when colorId is null', function () {
125
+ var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
126
+ getComponent({
127
+ src: undefined,
128
+ colorId: null
129
+ });
130
+ var avatar = _testWrapper.screen.getByTestId(datatestId);
131
+ var classList = (0, _from["default"])(avatar.classList);
132
+ var colorClass = (0, _find["default"])(classList).call(classList, function (cls) {
133
+ return (0, _startsWith["default"])(cls).call(cls, 'is-');
134
+ });
135
+ expect(colorClass).toBeDefined();
136
+ warnSpy.mockRestore();
137
+ });
138
+ test('two avatars with missing colorId get the same color class', function () {
139
+ var _context, _context2;
140
+ var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
141
+ var _render = (0, _testWrapper.render)((0, _react2.jsx)(_["default"], {
142
+ "data-testid": "avatar-1"
143
+ })),
144
+ unmount = _render.unmount;
145
+ var avatar1 = _testWrapper.screen.getByTestId('avatar-1');
146
+ var colorClass1 = (0, _find["default"])(_context = (0, _from["default"])(avatar1.classList)).call(_context, function (cls) {
147
+ return (0, _startsWith["default"])(cls).call(cls, 'is-');
148
+ });
149
+ unmount();
150
+ (0, _testWrapper.render)((0, _react2.jsx)(_["default"], {
151
+ "data-testid": "avatar-2"
152
+ }));
153
+ var avatar2 = _testWrapper.screen.getByTestId('avatar-2');
154
+ var colorClass2 = (0, _find["default"])(_context2 = (0, _from["default"])(avatar2.classList)).call(_context2, function (cls) {
155
+ return (0, _startsWith["default"])(cls).call(cls, 'is-');
156
+ });
157
+ expect(colorClass1).toBe(colorClass2);
158
+ warnSpy.mockRestore();
159
+ });
160
+ test('does not warn when color prop is provided', function () {
161
+ var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
162
+ getComponent({
163
+ src: undefined,
164
+ color: 'blue'
165
+ });
166
+ expect(warnSpy).not.toHaveBeenCalled();
167
+ warnSpy.mockRestore();
168
+ });
169
+ });
113
170
  describe('getColorFromUUID Distribution', function () {
114
171
  test('distributes 10,000 UUIDs evenly across 10 colors', function () {
115
172
  var iterations = 10000;
@@ -106,9 +106,13 @@ var skip = {
106
106
  top: '10px'
107
107
  }
108
108
  };
109
+ var pingLogo = _objectSpread(_objectSpread({}, app), {}, {
110
+ padding: '15px'
111
+ });
109
112
  var _default = exports["default"] = {
110
113
  app: app,
111
114
  skip: skip,
115
+ pingLogo: pingLogo,
112
116
  popover: popover,
113
117
  web: web,
114
118
  copyRightLink: copyRightLink,
@@ -225,9 +225,6 @@ var popUpHeaderText = _objectSpread(_objectSpread({}, headerText), {}, {
225
225
  color: 'white'
226
226
  }
227
227
  });
228
- var logoParent = {
229
- p: 'md'
230
- };
231
228
  var headerNav = {
232
229
  cursor: 'pointer',
233
230
  minHeight: '40px',
@@ -369,7 +366,6 @@ var _default = exports["default"] = {
369
366
  itemLinkButtonColor: itemLinkButtonColor,
370
367
  sectionList: sectionList,
371
368
  sideNavItem: sideNavItem,
372
- logoParent: logoParent,
373
369
  itemIcon: itemIcon,
374
370
  itemIconSelected: itemIconSelected,
375
371
  itemCustomIcon: itemCustomIcon,
@@ -41,6 +41,30 @@ declare const _default: {
41
41
  top: string;
42
42
  };
43
43
  };
44
+ pingLogo: {
45
+ padding: string;
46
+ color: string;
47
+ fontFamily: string;
48
+ fontSize: string;
49
+ textDecoration: string;
50
+ outline: string;
51
+ '&.is-hovered': {
52
+ textDecoration: string;
53
+ };
54
+ '&.is-focused': {
55
+ boxShadow: string;
56
+ outline: string;
57
+ outlineColor: string;
58
+ outlineOffset: string;
59
+ };
60
+ '&.is-pressed': {
61
+ color: string;
62
+ textDecoration: string;
63
+ };
64
+ '&.is-disabled': {
65
+ pointerEvents: string;
66
+ };
67
+ };
44
68
  popover: {
45
69
  color: string;
46
70
  fontSize: string;
@@ -429,9 +429,6 @@ declare const _default: {
429
429
  backgroundColor: string;
430
430
  };
431
431
  };
432
- logoParent: {
433
- p: string;
434
- };
435
432
  itemIcon: {
436
433
  mr: string;
437
434
  color: string;
@@ -18,9 +18,6 @@ declare const _default: {
18
18
  boxShadow: string;
19
19
  zIndex: number;
20
20
  };
21
- logoParent: {
22
- p: string;
23
- };
24
21
  sectionContainer: {
25
22
  pt: string;
26
23
  };
@@ -268,6 +265,15 @@ declare const _default: {
268
265
  MozBoxShadow: string;
269
266
  };
270
267
  };
268
+ pingLogo: {
269
+ padding: string;
270
+ borderRadius: string;
271
+ '&.is-focused': {
272
+ outline: string;
273
+ outlineColor: string;
274
+ outlineOffset: string;
275
+ };
276
+ };
271
277
  };
272
278
  icons: {
273
279
  test: string;
@@ -83,6 +83,35 @@ declare const _default: {
83
83
  app: {
84
84
  '&:hover': any;
85
85
  };
86
+ skip: {
87
+ '&:hover': {
88
+ color: string;
89
+ textDecoration: string;
90
+ '&:focus': {
91
+ outline: string;
92
+ outlineColor: string;
93
+ color: string;
94
+ textDecoration: string;
95
+ };
96
+ };
97
+ '&:visited': {
98
+ color: string;
99
+ textDecoration: string;
100
+ };
101
+ '&.is-pressed': {
102
+ color: string;
103
+ textDecoration: string;
104
+ };
105
+ };
106
+ pingLogo: {
107
+ '&:hover': {
108
+ '&.is-focused': {
109
+ outline: string;
110
+ outlineColor: string;
111
+ outlineOffset: string;
112
+ };
113
+ };
114
+ };
86
115
  };
87
116
  variants: {
88
117
  accordion: {
@@ -10,7 +10,7 @@ export interface AvatarProps extends ThemeUIAvatarProps {
10
10
  defaultText?: string;
11
11
  size?: string;
12
12
  color?: string;
13
- colorId?: string;
13
+ colorId?: string | null;
14
14
  isSquare?: boolean;
15
15
  isLogo?: boolean;
16
16
  'data-testid'?: string;