-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix!: CSS based loading spinner #1532
fix!: CSS based loading spinner #1532
Conversation
.loading-spinner { | ||
--primary-color: var(--dh-accent-color, #4c7dee); | ||
/* stylelint-disable-next-line alpha-value-notation */ | ||
--secondary-color: rgba(240, 240, 240, 0.5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be based on a variable. A hardcoded value here would look terrible on a light theme for example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any thoughts on what it should be tied to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in theory a gray-XXX value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll tie it to a semantic color for now and refine it once I get into the color mapping
.message-icon { | ||
font-size: $iris-panel-icon-font-size; | ||
height: $iris-panel-icon-font-size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I set height + line height explicitly to avoid a layout shift after font load. The previous height was 96px based on 1.5 line-height from body. Converting to flexbox with a gap of 20px seems to match the layout as before but without the layout shift
packages/utils/src/DOMUtils.ts
Outdated
* @param animationName | ||
* @param startTime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Params need descriptions. Also as it is now, you could make startTime
default to 0
(since that's the only value you actually pass in).
animations.forEach(a => { | ||
// eslint-disable-next-line no-param-reassign | ||
a.startTime = startTime; | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I'm reading this incorrectly, but looking at the example on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Animation/startTime#examples
They're setting the new animation to be the same as the existing start time; here you're resetting all of the animations to the same startTime
(which is always 0
, since that's the only value you pass in). Wouldn't that mean that an existing animation would jump back when a new one is added? Whereas we should just be syncing the new animation to any existing loading spinner that's already shown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My observation when I dug into this is that the startTime
is usually null
by default (also was not what I expected from the docs). My understanding is that it's kind of a static value that determines the basis of when animations are calculated. Setting explicitly to zero later if the animation is already based on zero shouldn't impact the existing animation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Can't say I fully understand it, but it does look like they're in sync and doesn't reset the existing animations, so cool.
@@ -594,7 +594,7 @@ class ContextMenu extends PureComponent<ContextMenuProps, ContextMenuState> { | |||
if (pendingItems.length > 0) { | |||
pendingElement = ( | |||
<div className="loading"> | |||
<LoadingSpinner /> | |||
<LoadingSpinner className="mimic-fa-layers-vertical-align" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not crazy about needing to provide a long class name in many of these cases... should we have a verticalAlign
prop or something that maps to a class name instead? Or any other way to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking eventually we should use flex positioning for all of the cases and gradually get rid of the "hack" class. It's kind of a flag that this is styled in a deprecated way. That said, I'm not a big fan of it either, was just trying to not muck with too much of the existing layout. I'm fine to change this to a prop instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or just a different class name; like we have loading-spinner-large
, maybe loading-spinner-vertical-align
deef131
to
7898ba7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note, I imagine we're going to move to Spectrum's ProgressCircle
at some point for loading spinner: https://react-spectrum.adobe.com/react-spectrum/ProgressCircle.html
I wonder if that will cause this issue to come up again.
A lot of the tests will need to be updated to look for this new loading spinner... we should have a consistent way of determining that in the tests. data-testid is probably the easiest; accessibility roles like the aria-live don't really apply to the loading spinner itself, just to the element behind it... whatever you think may be best. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1532 +/- ##
=======================================
Coverage 46.41% 46.42%
=======================================
Files 564 564
Lines 35765 35775 +10
Branches 8946 8950 +4
=======================================
+ Hits 16599 16607 +8
- Misses 19116 19118 +2
Partials 50 50
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Ah yea, using |
aeeb5ce
to
77480a8
Compare
@mofojed all tests have been updated, and e2e are passing as well. |
font-size: $iris-panel-icon-font-size
in.message-icon
of LoadingOverlayRegression Tests Performed
Verified the following look as they did before
Community
Enterprise
fixes #1531
BREAKING CHANGE: Inline LoadingSpinner instances will need to be decorated with
className="loading-spinner-vertical-align"
for vertical alignment to work as before