-
Notifications
You must be signed in to change notification settings - Fork 90
feat(pfCard): Add loading state for pfCard #661
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
src/card/examples/card-timeframe.js
Outdated
@@ -40,6 +41,9 @@ | |||
<pf-card head-title="Card Title" sub-title="Card Subtitle" show-top-border="true" filter="filterConfigHeader" style="width: 50%"> | |||
Card Contents | |||
</pf-card> | |||
<label class="label-title">Timeframe filter in header & loading state</label> | |||
<pf-card show-spinner="true" head-title="Card Title" sub-title="Card Subtitle" show-top-border="true" filter="filterConfigHeader" style="width: 50%"> |
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.
Please tie this to a $scope var which is initially 'true'. Then in a $timeout delay, have it set to 'false' . Just so we can see the state change.
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.
Please tie this to a $scope var which is initially 'true'. Then in a $timeout delay, have it set to 'false' . Just so we can see the state change.
I'm wondering if we should also hide the filter dropdown (in header and/or footer) and the footer if the spinner is showing? If the data isn't available yet, we probably shouldn't show a filter control yet. |
82c92ca
to
6d25b74
Compare
@dtaylor113 Agreed, I would think filters and actions should be hidden as well, thanks! |
src/card/basic/card.component.js
Outdated
@@ -91,6 +92,7 @@ angular.module('patternfly.card').component('pfCard', { | |||
subTitle: '@?', | |||
showTopBorder: '@?', | |||
showTitlesSeparator: '@?', | |||
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.
Better to make this a binding and use true/false rather that 'true'/'false'
src/card/basic/card.component.js
Outdated
@@ -130,6 +130,9 @@ angular.module('patternfly.card').component('pfCard', { | |||
|
|||
ctrl.$onInit = function () { | |||
ctrl.shouldShowTitlesSeparator = (!ctrl.showTitlesSeparator || ctrl.showTitlesSeparator === 'true'); | |||
if (angular.isUndefined(ctrl.showSpinner)) { | |||
ctrl.showSpinner = 'false'; | |||
} | |||
}; |
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.
Once this is a binding you can use
ctrl.showSpinner = ctrl.showSpinner === true
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.
@jeff-phillips-18 Shouldn't I do ctrl.showSpinner = ctrl.showSpinner === false
if we want it to be false by default? Or should it be set to true by default? If the spinner showing is dependent on if there is data to load or not..
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.
so you want it to be true if they pass false?
What I have above says it is true only if the specifically pass true. Any other value would resolve to false (the default).
src/card/basic/card.html
Outdated
|
||
<div class="card-pf-body"> | ||
<div ng-class="{'spinner spinner-lg': $ctrl.showSpinner === 'true'}"></div> |
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 div should only exist if $ctrl.showSpinner
src/card/basic/card.html
Outdated
|
||
<div class="card-pf-body"> | ||
<div ng-class="{'spinner spinner-lg': $ctrl.showSpinner === 'true'}"></div> | ||
<div ng-transclude></div> |
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 should not be shown if showSpinner is true. You may need to use ng-show though due to the transclude.
6d25b74
to
208898e
Compare
src/card/examples/card-timeframe.js
Outdated
@@ -45,10 +46,19 @@ | |||
footer="footerConfig" filter="filterConfig" style="width: 50%"> | |||
Card Contents | |||
</pf-card> | |||
<label class="label-title">Loading State</label> | |||
<pf-card show-spinner="dataLoading" head-title="Card Title" sub-title="Card Subtitle" show-top-border="true" filter="filterConfigHeader" style="width: 50%"> |
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'd add "Card Contents" here, between the <pf-card>
and </pf-card>
, just to show that transclusion will come through when the spinner is off.
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.
Will do!
src/card/basic/card.component.js
Outdated
@@ -130,6 +130,9 @@ angular.module('patternfly.card').component('pfCard', { | |||
|
|||
ctrl.$onInit = function () { | |||
ctrl.shouldShowTitlesSeparator = (!ctrl.showTitlesSeparator || ctrl.showTitlesSeparator === 'true'); | |||
if (angular.isUndefined(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.
No need to check if it is defined.
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.
Okay no prob!
208898e
to
eae502d
Compare
src/card/basic/card.html
Outdated
@@ -1,15 +1,15 @@ | |||
<div ng-class="$ctrl.showTopBorder === 'true' ? 'card-pf card-pf-accented' : 'card-pf'"> | |||
<div ng-if="$ctrl.showHeader()" ng-class="$ctrl.shouldShowTitlesSeparator ? 'card-pf-heading' : 'card-pf-heading-no-bottom'"> | |||
<div ng-if="$ctrl.showFilterInHeader()" ng-include="'card/basic/card-filter.html'"></div> | |||
<div ng-class="{'hide': $ctrl.showSpinner === true}" ng-if="$ctrl.showFilterInHeader()" ng-include="'card/basic/card-filter.html'"></div> |
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 might be better written as:
<div ng-if="$ctrl.showFilterInHeader() && !$ctrl.showSpinner" ...
...or you could even move the logic into the $ctrl.showFilterInHeader() function.
src/card/basic/card.html
Outdated
|
||
<div class="card-pf-body"> | ||
<div ng-show="$ctrl.showSpinner" ng-class="{'spinner spinner-lg': $ctrl.showSpinner}"></div> |
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 should be ng-if and no need to ng-class since it won't be shown without the class.
src/card/basic/card.html
Outdated
<h2 class="card-pf-title">{{$ctrl.headTitle}}</h2> | ||
</div> | ||
|
||
<span ng-if="$ctrl.subTitle" class="card-pf-subtitle">{{$ctrl.subTitle}}</span> | ||
<span ng-class="{'hide': $ctrl.showSpinner === true}" ng-if="$ctrl.subTitle" class="card-pf-subtitle">{{$ctrl.subTitle}}</span> |
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 the standard we use is ng-if instead of ng-class/hide, see comment above.
src/card/basic/card.html
Outdated
|
||
<div class="card-pf-body"> | ||
<div ng-show="$ctrl.showSpinner" ng-class="{'spinner spinner-lg': $ctrl.showSpinner}"></div> | ||
<div ng-transclude></div> |
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 should be ng-show="!$ctrl.showSpinner"
src/card/basic/card.html
Outdated
<div ng-transclude></div> | ||
</div> | ||
<div ng-if="$ctrl.footer" class="card-pf-footer"> | ||
<div ng-class="{'hide': $ctrl.showSpinner === true}" ng-if="$ctrl.footer" class="card-pf-footer"> |
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 the standard we use is ng-if instead of ng-class/hide, see comment above.
src/card/basic/card.html
Outdated
<div ng-transclude></div> | ||
</div> | ||
<div ng-if="$ctrl.footer" class="card-pf-footer"> | ||
<div ng-class="{'hide': $ctrl.showSpinner === true}" ng-if="$ctrl.footer" class="card-pf-footer"> |
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'd rather use ng-show than adding the 'hide' class
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.
👍
src/card/basic/card.html
Outdated
@@ -1,15 +1,15 @@ | |||
<div ng-class="$ctrl.showTopBorder === 'true' ? 'card-pf card-pf-accented' : 'card-pf'"> | |||
<div ng-if="$ctrl.showHeader()" ng-class="$ctrl.shouldShowTitlesSeparator ? 'card-pf-heading' : 'card-pf-heading-no-bottom'"> | |||
<div ng-if="$ctrl.showFilterInHeader()" ng-include="'card/basic/card-filter.html'"></div> | |||
<div ng-class="{'hide': $ctrl.showSpinner === true}" ng-if="$ctrl.showFilterInHeader()" ng-include="'card/basic/card-filter.html'"></div> |
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.
ng-show rather than adding the 'hide' class?
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.
Seems to be causing a lag with ng-if and ng-show.
test/card/basic/card.spec.js
Outdated
cardClass = angular.element(element).find('.spinner-lg'); | ||
expect(cardClass.length).toBe(1); | ||
}); | ||
|
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.
Might be better to test the binding. Use show-spinner="dataLoading" then change the value and test again.
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.
Sounds good. I'll go back to this
eae502d
to
9993661
Compare
After changing the |
9993661
to
5f8039a
Compare
Although I know in the issue uor guidance was to not have associated "Loading" text, I'm rethinking that decision. Reasoning is that we have a similar question that just came in about a content view loading state - and in that situation, i think we need "Loading". Thoughts on adding it here for consistency with what we should do in a view as well as consistency with No Data Available state having an icon/label pair as well @beanh66 @jeff-phillips-18 @jennyhaines ? |
@serenamarie125 that is fine with me. I was initially debating the label because I felt like it would be more consistent with the empty states we have. I can see where it is really necessary on larger views or cards. @jennyhaines would you be okay with that or would you rather see it optional maybe? |
be87236
to
7c05269
Compare
I believe this should be a feat rather than a fix. |
7c05269
to
4779b5c
Compare
No problem, will change to a feat. |
4779b5c
to
dfbec03
Compare
@dtaylor113 The text should be to the right of the spinner. There are instances where the body content may not present enough vertical space to show the spinner and text stacked. |
@jeff-phillips-18 I was thinking it would be centered under the icon, similar to the empty state. Could we do that when there is enough space and when there is not, maybe just hide the text? @serenamarie125 Thoughts? |
@beanh66 not sure we can tell if it will fit or not. I can't think of any way anyways. |
dfbec03
to
b0292fc
Compare
@jeff-phillips-18 Oh okay, got it. Well it looks a lot better being centered, I just didn't like the large separation between the icon/text originally :) FWIW @serenamarie125 had MIQ take the ... out of their version so I would recommend just sticking with "Loading" |
The ... is just example text. Applications can do what they will. |
b0292fc
to
3fb139e
Compare
3fb139e
to
658656f
Compare
@beanh66 I have removed the "..." from the example text and changed it to "Loading" to be more consistent |
Thanks, sorry for nit picking! 😆 |
Description
Adding a loading state spinner to pfCard to fix #658
Rawgit
PR Checklist
@beanh66 @jennyhaines @dtaylor113 @jeff-phillips-18 @serenamarie125