@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.
@@ -38,9 +38,6 @@ var navBar = {
38
38
  boxShadow: '0 2px 11px rgba(0, 0, 0, .13)',
39
39
  zIndex: 2
40
40
  },
41
- logoParent: {
42
- p: '8px'
43
- },
44
41
  sectionContainer: {
45
42
  pt: '0'
46
43
  },
@@ -272,7 +269,16 @@ var _default = exports["default"] = {
272
269
  separator: separator
273
270
  },
274
271
  links: {
275
- navItem: _objectSpread({}, navItemLink)
272
+ navItem: _objectSpread({}, navItemLink),
273
+ pingLogo: {
274
+ padding: '15px',
275
+ borderRadius: '4px',
276
+ '&.is-focused': {
277
+ outline: '2px solid',
278
+ outlineColor: 'active',
279
+ outlineOffset: '-2px'
280
+ }
281
+ }
276
282
  },
277
283
  icons: _objectSpread(_objectSpread({}, _icons["default"]), {}, {
278
284
  test: 'test',
@@ -146,6 +146,35 @@ var forms = {
146
146
  var links = {
147
147
  app: {
148
148
  '&:hover': _objectSpread({}, _theme["default"].links.app)
149
+ },
150
+ skip: {
151
+ '&:hover': {
152
+ color: 'white',
153
+ textDecoration: 'none',
154
+ '&:focus': {
155
+ outline: '2px solid',
156
+ outlineColor: 'active',
157
+ color: 'white',
158
+ textDecoration: 'none'
159
+ }
160
+ },
161
+ '&:visited': {
162
+ color: 'white',
163
+ textDecoration: 'none'
164
+ },
165
+ '&.is-pressed': {
166
+ color: 'white',
167
+ textDecoration: 'none'
168
+ }
169
+ },
170
+ pingLogo: {
171
+ '&:hover': {
172
+ '&.is-focused': {
173
+ outline: '2px solid',
174
+ outlineColor: 'active',
175
+ outlineOffset: '-2px'
176
+ }
177
+ }
149
178
  }
150
179
  };
151
180
  var variants = {
@@ -34,14 +34,16 @@ var Avatar = /*#__PURE__*/forwardRef(function (props, ref) {
34
34
  isSquare = props.isSquare,
35
35
  isLogo = props.isLogo,
36
36
  others = _objectWithoutProperties(props, _excluded);
37
-
38
- // this will use color prop if provided,
39
- // else will map colorId to a color, else defaults to 'green'
37
+ var safeColorId = colorId || '_INTERNAL_DEFAULT_ID_';
38
+ if (process.env.NODE_ENV !== 'production') {
39
+ if (!src && !color && !colorId) {
40
+ console.warn("[Astro] Avatar: No 'src', 'color', or 'colorId' provided. " + 'The component is falling back to a default generated color.');
41
+ }
42
+ }
40
43
  var finalColor = useMemo(function () {
41
44
  if (color) return color;
42
- if (colorId) return getColorFromUUID(colorId, avatarColors);
43
- return 'green';
44
- }, [color, colorId, avatarColors]);
45
+ return getColorFromUUID(safeColorId, avatarColors);
46
+ }, [color, safeColorId]);
45
47
  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)),
46
48
  classNames = _useStatusClasses.classNames;
47
49
  if (src) {
@@ -43,12 +43,14 @@ test('an avatar is rendered with custom alt', function () {
43
43
  expect(img).toHaveAttribute('alt', 'Custom Alt');
44
44
  });
45
45
  test('an avatar is rendered with custom alt', function () {
46
+ var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
46
47
  getComponent({
47
48
  src: undefined,
48
49
  defaultText: 'KL'
49
50
  });
50
51
  var avatar = screen.getByText('KL');
51
52
  expect(avatar).toBeInTheDocument();
53
+ warnSpy.mockRestore();
52
54
  });
53
55
  describe('getColorFromUUID', function () {
54
56
  test('returns a consistent color for the same UUID', function () {
@@ -107,6 +109,61 @@ describe('getColorFromUUID', function () {
107
109
  expect(avatar).toHaveClass('is-green');
108
110
  });
109
111
  });
112
+ describe('Avatar fallback behavior', function () {
113
+ test('warns in development when no src, color, or colorId is provided', function () {
114
+ var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
115
+ getComponent({
116
+ src: undefined
117
+ });
118
+ expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining("No 'src', 'color', or 'colorId' provided"));
119
+ warnSpy.mockRestore();
120
+ });
121
+ test('does not crash when colorId is null', function () {
122
+ var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
123
+ getComponent({
124
+ src: undefined,
125
+ colorId: null
126
+ });
127
+ var avatar = screen.getByTestId(datatestId);
128
+ var classList = _Array$from(avatar.classList);
129
+ var colorClass = _findInstanceProperty(classList).call(classList, function (cls) {
130
+ return _startsWithInstanceProperty(cls).call(cls, 'is-');
131
+ });
132
+ expect(colorClass).toBeDefined();
133
+ warnSpy.mockRestore();
134
+ });
135
+ test('two avatars with missing colorId get the same color class', function () {
136
+ var _context, _context2;
137
+ var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
138
+ var _render = render(___EmotionJSX(Avatar, {
139
+ "data-testid": "avatar-1"
140
+ })),
141
+ unmount = _render.unmount;
142
+ var avatar1 = screen.getByTestId('avatar-1');
143
+ var colorClass1 = _findInstanceProperty(_context = _Array$from(avatar1.classList)).call(_context, function (cls) {
144
+ return _startsWithInstanceProperty(cls).call(cls, 'is-');
145
+ });
146
+ unmount();
147
+ render(___EmotionJSX(Avatar, {
148
+ "data-testid": "avatar-2"
149
+ }));
150
+ var avatar2 = screen.getByTestId('avatar-2');
151
+ var colorClass2 = _findInstanceProperty(_context2 = _Array$from(avatar2.classList)).call(_context2, function (cls) {
152
+ return _startsWithInstanceProperty(cls).call(cls, 'is-');
153
+ });
154
+ expect(colorClass1).toBe(colorClass2);
155
+ warnSpy.mockRestore();
156
+ });
157
+ test('does not warn when color prop is provided', function () {
158
+ var warnSpy = jest.spyOn(console, 'warn').mockImplementation();
159
+ getComponent({
160
+ src: undefined,
161
+ color: 'blue'
162
+ });
163
+ expect(warnSpy).not.toHaveBeenCalled();
164
+ warnSpy.mockRestore();
165
+ });
166
+ });
110
167
  describe('getColorFromUUID Distribution', function () {
111
168
  test('distributes 10,000 UUIDs evenly across 10 colors', function () {
112
169
  var iterations = 10000;
@@ -99,9 +99,13 @@ var skip = {
99
99
  top: '10px'
100
100
  }
101
101
  };
102
+ var pingLogo = _objectSpread(_objectSpread({}, app), {}, {
103
+ padding: '15px'
104
+ });
102
105
  export default {
103
106
  app: app,
104
107
  skip: skip,
108
+ pingLogo: pingLogo,
105
109
  popover: popover,
106
110
  web: web,
107
111
  copyRightLink: copyRightLink,
@@ -218,9 +218,6 @@ var popUpHeaderText = _objectSpread(_objectSpread({}, headerText), {}, {
218
218
  color: 'white'
219
219
  }
220
220
  });
221
- var logoParent = {
222
- p: 'md'
223
- };
224
221
  var headerNav = {
225
222
  cursor: 'pointer',
226
223
  minHeight: '40px',
@@ -362,7 +359,6 @@ export default {
362
359
  itemLinkButtonColor: itemLinkButtonColor,
363
360
  sectionList: sectionList,
364
361
  sideNavItem: sideNavItem,
365
- logoParent: logoParent,
366
362
  itemIcon: itemIcon,
367
363
  itemIconSelected: itemIconSelected,
368
364
  itemCustomIcon: itemCustomIcon,
@@ -31,9 +31,6 @@ var navBar = {
31
31
  boxShadow: '0 2px 11px rgba(0, 0, 0, .13)',
32
32
  zIndex: 2
33
33
  },
34
- logoParent: {
35
- p: '8px'
36
- },
37
34
  sectionContainer: {
38
35
  pt: '0'
39
36
  },
@@ -265,7 +262,16 @@ export default {
265
262
  separator: separator
266
263
  },
267
264
  links: {
268
- navItem: _objectSpread({}, navItemLink)
265
+ navItem: _objectSpread({}, navItemLink),
266
+ pingLogo: {
267
+ padding: '15px',
268
+ borderRadius: '4px',
269
+ '&.is-focused': {
270
+ outline: '2px solid',
271
+ outlineColor: 'active',
272
+ outlineOffset: '-2px'
273
+ }
274
+ }
269
275
  },
270
276
  icons: _objectSpread(_objectSpread({}, icons), {}, {
271
277
  test: 'test',
@@ -139,6 +139,35 @@ var forms = {
139
139
  var links = {
140
140
  app: {
141
141
  '&:hover': _objectSpread({}, theme.links.app)
142
+ },
143
+ skip: {
144
+ '&:hover': {
145
+ color: 'white',
146
+ textDecoration: 'none',
147
+ '&:focus': {
148
+ outline: '2px solid',
149
+ outlineColor: 'active',
150
+ color: 'white',
151
+ textDecoration: 'none'
152
+ }
153
+ },
154
+ '&:visited': {
155
+ color: 'white',
156
+ textDecoration: 'none'
157
+ },
158
+ '&.is-pressed': {
159
+ color: 'white',
160
+ textDecoration: 'none'
161
+ }
162
+ },
163
+ pingLogo: {
164
+ '&:hover': {
165
+ '&.is-focused': {
166
+ outline: '2px solid',
167
+ outlineColor: 'active',
168
+ outlineOffset: '-2px'
169
+ }
170
+ }
142
171
  }
143
172
  };
144
173
  var variants = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.178.3",
3
+ "version": "2.179.0-alpha.0",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",