Skip to content

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

Merged
merged 1 commit into from
Oct 27, 2017

Conversation

amarie401
Copy link
Contributor

@amarie401 amarie401 commented Oct 25, 2017

Description

Adding a loading state spinner to pfCard to fix #658

Rawgit

PR Checklist

  • Unit tests are included
  • Screenshots are attached (if there are visual changes in the UI)
  • A Designer (@beanh66) is assigned as a reviewer (if there are visual changes in the UI)

loadingstate

@beanh66 @jennyhaines @dtaylor113 @jeff-phillips-18 @serenamarie125

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 54.406% when pulling 82c92ca on amarie401:card-loading-state into c4193f1 on patternfly:master.

@@ -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%">
Copy link
Member

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.

Copy link
Member

@dtaylor113 dtaylor113 left a 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.

@dtaylor113
Copy link
Member

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.

@beanh66
Copy link
Member

beanh66 commented Oct 25, 2017

@dtaylor113 Agreed, I would think filters and actions should be hidden as well, thanks!

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 54.406% when pulling 6d25b74 on amarie401:card-loading-state into c4193f1 on patternfly:master.

@@ -91,6 +92,7 @@ angular.module('patternfly.card').component('pfCard', {
subTitle: '@?',
showTopBorder: '@?',
showTitlesSeparator: '@?',
showSpinner: '@?',
Copy link
Member

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'

@@ -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';
}
};
Copy link
Member

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

Copy link
Contributor Author

@amarie401 amarie401 Oct 25, 2017

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..

Copy link
Member

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).


<div class="card-pf-body">
<div ng-class="{'spinner spinner-lg': $ctrl.showSpinner === 'true'}"></div>
Copy link
Member

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


<div class="card-pf-body">
<div ng-class="{'spinner spinner-lg': $ctrl.showSpinner === 'true'}"></div>
<div ng-transclude></div>
Copy link
Member

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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 54.406% when pulling 208898e on amarie401:card-loading-state into c4193f1 on patternfly:master.

@@ -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%">
Copy link
Member

@dtaylor113 dtaylor113 Oct 25, 2017

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

@@ -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)) {
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay no prob!

@@ -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>
Copy link
Member

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.


<div class="card-pf-body">
<div ng-show="$ctrl.showSpinner" ng-class="{'spinner spinner-lg': $ctrl.showSpinner}"></div>
Copy link
Member

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.

<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>
Copy link
Member

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.


<div class="card-pf-body">
<div ng-show="$ctrl.showSpinner" ng-class="{'spinner spinner-lg': $ctrl.showSpinner}"></div>
<div ng-transclude></div>
Copy link
Member

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"

<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">
Copy link
Member

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.

<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">
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -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>
Copy link
Member

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?

Copy link
Contributor Author

@amarie401 amarie401 Oct 25, 2017

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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 54.406% when pulling eae502d on amarie401:card-loading-state into c4193f1 on patternfly:master.

cardClass = angular.element(element).find('.spinner-lg');
expect(cardClass.length).toBe(1);
});

Copy link
Member

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.

Copy link
Contributor Author

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

@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 54.855% when pulling 9993661 on amarie401:card-loading-state into c4193f1 on patternfly:master.

@amarie401
Copy link
Contributor Author

amarie401 commented Oct 25, 2017

After changing the ng-class to ng-if I noticed there is a bit of lag now and the icon is still there for a few seconds even after the data loads. I tried changing them to ng-show instead and the lag is still present. Not sure if this is a big issue or not @jeff-phillips-18 @dtaylor113

loading-state-2

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.5%) to 54.381% when pulling 5f8039a on amarie401:card-loading-state into c4193f1 on patternfly:master.

@serenamarie125
Copy link
Member

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 ?

@beanh66
Copy link
Member

beanh66 commented Oct 26, 2017

@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?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 54.4% when pulling e712c0c on amarie401:card-loading-state into c4193f1 on patternfly:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 54.4% when pulling 7c05269 on amarie401:card-loading-state into c4193f1 on patternfly:master.

@jeff-phillips-18
Copy link
Member

I believe this should be a feat rather than a fix.

@amarie401
Copy link
Contributor Author

No problem, will change to a feat.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 54.4% when pulling dfbec03 on amarie401:card-loading-state into c4193f1 on patternfly:master.

@jeff-phillips-18
Copy link
Member

@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.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 54.4% when pulling dfbec03 on amarie401:card-loading-state into c4193f1 on patternfly:master.

@beanh66
Copy link
Member

beanh66 commented Oct 26, 2017

@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?

@jeff-phillips-18
Copy link
Member

@beanh66 not sure we can tell if it will fit or not. I can't think of any way anyways.

@jeff-phillips-18
Copy link
Member

This is what we have now:
image

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 54.436% when pulling b0292fc on amarie401:card-loading-state into c4193f1 on patternfly:master.

@beanh66
Copy link
Member

beanh66 commented Oct 26, 2017

@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"

@jeff-phillips-18
Copy link
Member

The ... is just example text. Applications can do what they will.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 54.436% when pulling 3fb139e on amarie401:card-loading-state into c4193f1 on patternfly:master.

@amarie401
Copy link
Contributor Author

@beanh66 I have removed the "..." from the example text and changed it to "Loading" to be more consistent

@beanh66
Copy link
Member

beanh66 commented Oct 26, 2017

Thanks, sorry for nit picking! 😆

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 54.436% when pulling 658656f on amarie401:card-loading-state into c4193f1 on patternfly:master.

@dtaylor113 dtaylor113 merged commit 254e74a into patternfly:master Oct 27, 2017
@amarie401 amarie401 changed the title fix(pfCard): Add loading state for pfCard feat(pfCard): Add loading state for pfCard Nov 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The base dashboard card should have a loading state
6 participants