@7shifts/sous-chef 4.10.0 → 4.10.3

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/dist/index.js CHANGED
@@ -20727,14 +20727,25 @@ var Avatar = function Avatar(_ref) {
20727
20727
  var _useIsVisibleInViewPo = useIsVisibleInViewPort(),
20728
20728
  isVisible = _useIsVisibleInViewPo.isVisible,
20729
20729
  elementRef = _useIsVisibleInViewPo.elementRef;
20730
- var url = isVisible ? urlProp : undefined;
20730
+ // Latch visibility: unloading the image when the avatar leaves the
20731
+ // viewport makes it flash the fallback colors when it re-enters (e.g.
20732
+ // inside a scroll-away nav bar).
20731
20733
  var _useState = React.useState(false),
20732
- showIconInsteadOfImage = _useState[0],
20733
- setShowIconInsteadOfImage = _useState[1];
20734
- var _useState2 = React.useState(function () {
20734
+ hasBeenVisible = _useState[0],
20735
+ setHasBeenVisible = _useState[1];
20736
+ React.useEffect(function () {
20737
+ if (isVisible && !hasBeenVisible) {
20738
+ setHasBeenVisible(true);
20739
+ }
20740
+ }, [isVisible, hasBeenVisible]);
20741
+ var url = hasBeenVisible ? urlProp : undefined;
20742
+ var _useState2 = React.useState(false),
20743
+ showIconInsteadOfImage = _useState2[0],
20744
+ setShowIconInsteadOfImage = _useState2[1];
20745
+ var _useState3 = React.useState(function () {
20735
20746
  return PROFILE_IMAGES[Math.floor(Math.random() * PROFILE_IMAGES.length)];
20736
20747
  }),
20737
- defaultProfilePictureColors = _useState2[0];
20748
+ defaultProfilePictureColors = _useState3[0];
20738
20749
  // If passing an url we are defaulting to a lighter grey while the image loads
20739
20750
  var backgroundColor = url ? COLORS['surface-container-highest'] : getColor(color);
20740
20751
  return React__default["default"].createElement("div", {