Skip to content

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

Merged
merged 1 commit into from
Nov 14, 2017

Conversation

amarie401
Copy link
Contributor

@amarie401 amarie401 commented Nov 3, 2017

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)

loading-info

loading-agg

loading-trends

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)
  • A CSS rep (@cshinn) is assigned as a reviewer (if there are visual changes in the UI)

dtaylor113
dtaylor113 previously approved these changes Nov 3, 2017
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.

LGTM. Nice job!

@cshinn
Copy link
Member

cshinn commented Nov 3, 2017

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

@dtaylor113
Copy link
Member

@amarie401 what's the -22px position on the spinner container for?

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.

cshinn
cshinn previously approved these changes Nov 3, 2017
@jeff-phillips-18
Copy link
Member

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.

@beanh66
Copy link
Member

beanh66 commented Nov 3, 2017

+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

@dtaylor113
Copy link
Member

Wondering if, at minimum, we should all the consumer to set the card height when loading

Ok, we could add a defaultCardHeight or a loadingCardHeight to the main status configuration obj.

@amarie401 amarie401 dismissed stale reviews from cshinn and dtaylor113 via 7e977f5 November 6, 2017 15:37
@amarie401 amarie401 force-pushed the pf-cards-loading branch 4 times, most recently from 15e6107 to 8499e0b Compare November 6, 2017 20:49
@amarie401
Copy link
Contributor Author

amarie401 commented Nov 6, 2017

I have added a loadingCardHeight option to the config for consumers to set the card height

AggStatus
loading-state-height

InfoStatus
loading-height-2

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

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.

Copy link
Contributor Author

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

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

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

@dtaylor113
Copy link
Member

Looking good, although the loading icon doesn't appear to be centered:

infoStatusCard:
image

aggregateStatusCard:
image

Seems like there is more space above the spinners than there is below the spinners.

@amarie401
Copy link
Contributor Author

amarie401 commented Nov 6, 2017

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

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.

Copy link
Member

Choose a reason for hiding this comment

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

good point. spinnerCardHeight?

Copy link
Contributor Author

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

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.

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

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.

@amarie401
Copy link
Contributor Author

I have changed the name from loadingCardHeight to spinnerCardHeight for better correlation, unhid the title when loading and updated the ng-style to make the spinnerHeight more dynamic. @dtaylor113 are you still seeing the icon not being centered?

@beanh66
Copy link
Member

beanh66 commented Nov 7, 2017

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

@dtaylor113
Copy link
Member

The info status card should likely show the title and the icon just not the status information.

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.

@jeff-phillips-18
Copy link
Member

The application can leave those values unset if that be the case. Can we try that scenario as well?

@jeff-phillips-18
Copy link
Member

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.

@dtaylor113
Copy link
Member

@jeff-phillips-18
Copy link
Member

@dtaylor113 The PR for this is still up in patternfly-design: patternfly/patternfly-design#483

@dtaylor113
Copy link
Member

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

@jeff-phillips-18
Copy link
Member

jeff-phillips-18 commented Nov 8, 2017

So this seems to be a case of implementation before official PF html/css/less.

Yeah, feel free to implement in PF first 😉

@dtaylor113
Copy link
Member

Still not exactly centered. 'with HTML' card doesn't initially set icon or title. 'Loading State' card does initially set icon and title:

loading

@amarie401
Copy link
Contributor Author

amarie401 commented Nov 8, 2017

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?

@dtaylor113
Copy link
Member

Hi, pushed latest changes. The infoStatusCard spinner icon is now centered within the card, with and without titles/icons:

image

dtaylor113
dtaylor113 previously approved these changes Nov 10, 2017
beanh66
beanh66 previously approved these changes Nov 10, 2017
Copy link
Member

@beanh66 beanh66 left a 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":"#"
}
]
};
};

Copy link
Member

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

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

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

@amarie401 amarie401 dismissed stale reviews from beanh66 and dtaylor113 via 1dfcade November 13, 2017 15:10
* @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.
Copy link
Member

Choose a reason for hiding this comment

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

Need to document spinnerCardHeight

@amarie401
Copy link
Contributor Author

With @jeff-phillips-18 changes

aggStatus:

jeff-changes-agg

infoStat:

jeff-changes-infostat

@jeff-phillips-18
Copy link
Member

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.

@amarie401
Copy link
Contributor Author

amarie401 commented Nov 13, 2017

@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 :)

@dtaylor113 dtaylor113 merged commit 02054a8 into patternfly:master Nov 14, 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.

Add loading state to other pfCards
5 participants