-
Notifications
You must be signed in to change notification settings - Fork 90
feat(pfCard): Add a loading state to the pfCards #670
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
Conversation
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.
LGTM. Nice job!
@amarie401 what's the -22px position on the spinner container for? to compensate for default padding or something? If so, would it be possible to use a pf variable that corresponds to the thing that's being compensated for instead? |
Hi @cshinn, when card is in the process of loading, it's body/contents are not shown, so there is no 'height' to the card. These changes add a height and adjust the position of the spinner. |
Wondering if, at minimum, we should all the consumer to set the card height when loading. When these cards are in a dashboard, the size changes may cause issues. |
+1 @jeff-phillips-18 I was wondering the same thing, if it would be a problem when card heights all of a sudden change on a dashboard. I like your suggestion |
Ok, we could add a |
15e6107
to
8499e0b
Compare
@@ -63,13 +66,19 @@ | |||
<i>(depreciated, use layout = 'tall' instead)</i> | |||
</br></br> | |||
<pf-aggregate-status-card status="aggStatusAlt" show-top-border="true" alt-layout="true"></pf-aggregate-status-card> | |||
<br/> | |||
<label>Loading State</label> | |||
<pf-aggregate-status-card status="aggStatusAlt2" loading-card-height="150px" show-top-border="true" show-spinner="dataLoading" spinner-text="Loading" layout="tall"></pf-aggregate-status-card> |
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.
Looking around at other examples of this in angular-patternfly we do not include the 'px' as part of the string, just the number.
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.
Can remove :)
@@ -28,8 +35,8 @@ <h2 class="card-pf-title"> | |||
</p> | |||
</div> | |||
</div> | |||
<div ng-if="$ctrl.isMiniLayout" class="card-pf card-pf-aggregate-status card-pf-aggregate-status-mini" ng-class="{'card-pf-accented': $ctrl.shouldShowTopBorder}"> | |||
<h2 class="card-pf-title"> | |||
<div ng-if="$ctrl.isMiniLayout" class="card-pf card-pf-aggregate-status card-pf-aggregate-status-mini" ng-class="{'card-pf-accented': $ctrl.shouldShowTopBorder}" ng-style="$ctrl.spinnerHeight"> |
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 why the ng-style was added here? It seemed to work in the show-spinner
div below.
@@ -41,7 +48,14 @@ <h2 class="card-pf-title"> | |||
{{$ctrl.status.title}} | |||
</span> | |||
</h2> | |||
<div class="card-pf-body"> | |||
<div class="card-pf-body" ng-class="{'show-spinner': $ctrl.showSpinner}"> |
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.
Try moving the ng-style
to here, it would be consistent with the !mini
HTML above where we added the ng-style
8499e0b
to
7fc5be4
Compare
Okay will look into it |
@@ -30,6 +30,9 @@ | |||
* </ul> | |||
* </ul> | |||
* @param {boolean=} show-top-border Show/hide the top border, true shows top border, false (default) hides top border | |||
* @param {boolean=} showSpinner Show/Hide the spinner for loading state. True shows the spinner, false (default) hides the spinner | |||
* @param {string=} spinnerText Text for the card spinner | |||
* @param {string=} loadingCardHeight Height to set for the card when data is loading |
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.
We use loading here but showSpinner. I think it needs to be named such that it is obvious that this is the card height when showing the spinner.
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.
good point. spinnerCardHeight?
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 think renaming to spinnerCardHeight is good to show the correlation
@@ -13,8 +13,15 @@ <h2 class="card-pf-title"> | |||
<span class="card-pf-aggregate-status-title">{{$ctrl.status.title}}</span> | |||
</span> | |||
</h2> | |||
<div class="card-pf-body"> | |||
<p class="card-pf-aggregate-status-notifications"> | |||
<div class="card-pf-body" ng-class="{'show-spinner': $ctrl.showSpinner}" ng-style="$ctrl.spinnerHeight"> |
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.
the spinnerHeight ought only be used when the spinner is 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.
Agree
@@ -29,7 +36,7 @@ <h2 class="card-pf-title"> | |||
</div> | |||
</div> | |||
<div ng-if="$ctrl.isMiniLayout" class="card-pf card-pf-aggregate-status card-pf-aggregate-status-mini" ng-class="{'card-pf-accented': $ctrl.shouldShowTopBorder}"> | |||
<h2 class="card-pf-title"> | |||
<h2 class="card-pf-title" ng-class="{'hide-for-spinner': $ctrl.showSpinner}"> |
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.
Should we be hiding the title while data is loading?
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 believe the title is showing and not hidden with the base pfCard from my previous PR, I can change this to be consistent.
7fc5be4
to
2ff39e8
Compare
I have changed the name from loadingCardHeight to spinnerCardHeight for better correlation, unhid the title when loading and updated the |
@amarie401 did you update the gif? I am still seeing that it isn't quite centered but I might be looking at an old version! |
Might the icon and/or title change based upon the loaded data? Ie. show an error icon/msg? If so, we should just hide everything until the data is loaded. |
The application can leave those values unset if that be the case. Can we try that scenario as well? |
My point being, that a blank card with just a spinner gives no indication of what is being loaded. If any of the info can be shown, then it gives the user an idea of what they are waiting for. |
Went looking to find PF doc/examples/css/HTML for this card, I can't find InfoStatusCard in any of these locations: |
@dtaylor113 The PR for this is still up in patternfly-design: patternfly/patternfly-design#483 |
ah...that's why I couldn't find it :-) So this seems to be a case of implementation before official PF html/css/less. |
Yeah, feel free to implement in PF first 😉 |
Does the icon image have any margins? Seems like the loading icon is being pushed over to the right. Could the right margin be removed/reduced during loading? |
3950e79
to
91e07a2
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.
LGTM
@@ -103,28 +112,49 @@ | |||
"href":"#" | |||
} | |||
] | |||
}; | |||
}; | |||
|
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.
Should setup the $scope.aggStatusAlt2 here with the title but the count and notifications being unknown.
@@ -13,8 +13,15 @@ <h2 class="card-pf-title"> | |||
<span class="card-pf-aggregate-status-title">{{$ctrl.status.title}}</span> | |||
</span> | |||
</h2> | |||
<div class="card-pf-body"> | |||
<p class="card-pf-aggregate-status-notifications"> | |||
<div class="card-pf-body" ng-class="{'show-spinner': $ctrl.showSpinner}" ng-style="$ctrl.showSpinner ? $ctrl.spinnerHeight : {}"> |
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 would expect the height to be set on the card, not on the body. It is called spinnerCardHeight and given the title height could potentially change based on knowing the title prior to data load it would be better to set the full card height.
<img ng-if="$ctrl.status.iconImage" ng-src="{{$ctrl.status.iconImage}}" alt="" | ||
class="info-img"/> | ||
<span class="info-icon {{$ctrl.status.iconClass}}"></span> | ||
</div> | ||
<div class="card-pf-info-content"> | ||
<div class="card-pf-info-content card-pf-body" ng-class="{'show-spinner': $ctrl.showSpinner}" ng-style="$ctrl.showSpinner ? $ctrl.spinnerHeight : {}"> |
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.
Again, the height should be on the entire card
src/card/examples/card-trend.js
Outdated
* @param {boolean=} showTopBorder Show/Hide the blue top border. True shows top border, false (default) hides top border | ||
* @param {boolean=} showSpinner Show/Hide the spinner for loading state. True shows the spinner, false (default) hides the spinner | ||
* @param {boolean=} showTitlesSeparator Show/Hide the grey line between the title and sub-title. |
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.
Need to document spinnerCardHeight
1dfcade
to
5edb266
Compare
80ddc03
to
c6b6f0f
Compare
With @jeff-phillips-18 changes aggStatus: infoStat: |
Not sure why your image above doesn't have the white background for the aggregate status cards. I pulled and tested and they correctly had the white background. |
@jeff-phillips-18 I noticed that as well. The giphy recording tool I'm using is being a bit weird it's showing the correct background but when I upload it doesn't show it anymore... but the actual background is correct and how it should be :) |
Description
Adding a loading state feature to the remaining pfCards as a continuation of PR #661. This would close #662
pfAggregateStatusCard
pfInfoStatusCard
pfCards - Trends (example)
PR Checklist