Skip to content
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

chore(info-card): clean up info card example #190

Merged
merged 8 commits into from
Nov 16, 2017
Binary file removed .DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,57 +1,77 @@
<div class="padding-15">
<div class="row">
<div class="row">
<div class="col-xs-12">
<h4>Info Card Component Example</h4>
<hr>
</div>
</div>
<div class="cards-pf pfng-isc-ex-container">
<div class="padding-top-10">
<div class="col-xs-12">
<h4>Info Card Component Example</h4>
<hr/>
<h5>Restrictive Width Container Example</h5>
</div>
</div>
<div class="cards-pf">
<div class="row row-cards-pf">
<div class="col-sm-4">
<label>With top border, Icon Class, Href</label>
<pfng-info-status-card
[config]="card1Config">
</pfng-info-status-card>
</div>
<div class="pfng-restrictive-width-container">
<div class="row-cards-pf">
<label>With top border, Icon Class, Href</label>
<pfng-info-status-card
[config]="card1Config">
</pfng-info-status-card>
</div>
</div>
<div class="cards-pf">
<div class="row row-cards-pf">
<div class="col-sm-4">
<label>No Top Border, Icon Image, No Title, No Html Content</label>
<pfng-info-status-card
[config]="card2Config">
</pfng-info-status-card>
</div>
<div class="row-cards-pf">
<label>No Top Border, Icon Image, No Title, No Html Content</label>
<pfng-info-status-card
[config]="card2Config">
</pfng-info-status-card>
</div>
</div>
<div class="cards-pf">
<div class="row row-cards-pf">
<div class="col-sm-4">
<label>With HTML</label>
<pfng-info-status-card
[config]="card3Config">
</pfng-info-status-card>
</div>
<div class="row-cards-pf">
<label>With HTML</label>
<pfng-info-status-card
[config]="card3Config">
</pfng-info-status-card>
</div>
</div>
<div class="row padding-bottom-15 padding-top-15">
<div class="padding-top-10">
<div class="col-xs-12">
<h4>Code</h4>
<hr/>
<h5>Fluid Width Container Example</h5>
</div>
</div>
<div class="container-fluid pfng-fluid-width-container">
<div class="col-lg-4">
<label>With top border, Icon Class, Href</label>
<pfng-info-status-card
[config]="card1Config">
</pfng-info-status-card>
</div>
<div class="col-lg-4">
<label>With HTML</label>
<pfng-info-status-card
[config]="card3Config">
</pfng-info-status-card>
</div>
<div class="col-lg-4">
<label>No Top Border, Icon Image, No Title, No Html Content</label>
<pfng-info-status-card
[config]="card2Config">
</pfng-info-status-card>
</div>
</div>
<div>
<tabset>
<tab heading="api">
<iframe class="demoframe" src="docs/classes/cardcomponent.html"></iframe>
</tab>
<tab heading="html">
<include-content src="src/app/card/info-status-card/examples/info-status-card-example.component.html"></include-content>
</tab>
<tab heading="typescript">
<include-content src="src/app/card/info-status-card/examples/info-status-card-example.component.ts"></include-content>
</tab>
</tabset>
</div>
<div class="row padding-bottom-15 padding-top-15">
<div class="col-xs-12">
<h4>Code</h4>
<hr>
</div>
</div>
<div>
<tabset>
<tab heading="api">
<iframe class="demoframe" src="docs/classes/cardcomponent.html"></iframe>
</tab>
<tab heading="html">
<include-content src="src/app/card/info-status-card/examples/info-status-card-example.component.html"></include-content>
</tab>
<tab heading="typescript">
<include-content src="src/app/card/info-status-card/examples/info-status-card-example.component.ts"></include-content>
</tab>
</tabset>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@import '../../../../../node_modules/patternfly/dist/less/color-variables.less';
@bottomMargin: 12px;
.pfng-isc-ex-container {
padding-bottom: 20px;
h5 {
border-bottom: 1px dashed darken(@color-pf-blue-300, 15%);
padding-bottom: 16px;
}
.row-cards-pf {
margin-left: 0;
margin-right: 0;
margin-bottom: @bottomMargin;
&:first-child {
padding-top: 0;
}
}
.pfng-restrictive-width-container {
display: inline-block;
}
.pfng-fluid-width-container {
[class*='col-'] {
margin-bottom: @bottomMargin;
padding: 0;
}
}
.pfng-card-info-status {
@supports not (word-break: break-word) {
word-break: break-all;
}
@supports (word-break: break-word) {
word-break: break-word;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { InfoStatusCardConfig } from '../info-status-card-config';
@Component({
encapsulation: ViewEncapsulation.None,
selector: 'info-status-card-example',
styleUrls: ['./info-status-card-example.component.less'],
templateUrl: './info-status-card-example.component.html'
})

Expand All @@ -31,13 +32,13 @@ export class InfoStatusCardExampleComponent implements OnInit {
card2Config: InfoStatusCardConfig = {
showTopBorder: false,
htmlContent: false,
iconImageSrc: '//www.patternfly.org/assets/img/redhat.svg',
iconImageSrc: '//www.patternfly.org/assets/img/patternfly-orb.svg',
info: [
'Infastructure: VMware',
'Vmware: 1 CPU (1 socket x 1 core), 1024 MB',
'12 Snapshots',
'Drift History: 1',
'<strong>No htmlContent</strong>'
'<b>No htmlContent</b>'
]

};
Expand Down
12 changes: 6 additions & 6 deletions src/app/card/info-status-card/info-status-card.component.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div class="card-pf card-pf-info-status" [class.card-pf-accented]="config.showTopBorder">
<div class="card-pf-info-image">
<div class="card-pf pfng-card-info-status" [class.card-pf-accented]="config.showTopBorder">
<div class="pfng-card-info-image">
<img *ngIf="config.iconImageSrc" src="{{config.iconImageSrc}}" alt="" class="info-img">
<span class="info-icon {{config.iconStyleClass}}"></span>
</div>
<div class="card-pf-info-content">
<h2 *ngIf="config.title" class="card-pf-title">
<div class="pfng-card-info-content">
<h2 *ngIf="config.title" class="pfng-card-title">
<a *ngIf="config.href" href="{{config.href}}">
<span>{{config.title}}</span>
</a>
Expand All @@ -15,10 +15,10 @@ <h2 *ngIf="config.title" class="card-pf-title">
<ng-container *ngIf="config.htmlContent !== undefined">
<div *ngIf="config.htmlContent; then showHtmlContent else showPlainTextContent"></div>
<ng-template #showHtmlContent>
<div [innerHTML]="item" class="card-pf-info-item" *ngFor="let item of config.info"></div>
<div [innerHTML]="item" class="pfng-card-info-item" *ngFor="let item of config.info"></div>
</ng-template>
<ng-template #showPlainTextContent>
<div class="card-pf-info-item" *ngFor="let item of config.info">
<div class="pfng-card-info-item" *ngFor="let item of config.info">
{{item}}
</div>
</ng-template>
Expand Down
8 changes: 4 additions & 4 deletions src/app/card/info-status-card/info-status-card.component.less
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.card-pf-info-status {
.pfng-card-info-status {
display: flex;
margin: 0 10px;
.card-pf-info-image {
.pfng-card-info-image {
display: flex;
align-items: center;
justify-content: center;
Expand All @@ -14,9 +14,9 @@
max-height: 50px;
}
}
.card-pf-info-content {
.pfng-card-info-content {
margin: 10px 0;
.card-pf-title {
.pfng-card-title {
margin-top: 10px;
margin-bottom: 15px;
}
Expand Down
10 changes: 5 additions & 5 deletions src/app/card/info-status-card/info-status-card.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ describe('Info Status Card Component - ', () => {
it('should set the title, title link, and icons class', () => {
Object.assign(infoCard, cardConfig);
fixture.detectChanges();
let numTitles = fixture.debugElement.queryAll(By.css('.card-pf-title')).length;
let numTitleLinks = fixture.debugElement.queryAll(By.css('.card-pf-title a[href]')).length;
let numTitles = fixture.debugElement.queryAll(By.css('.pfng-card-title')).length;
let numTitleLinks = fixture.debugElement.queryAll(By.css('.pfng-card-title a[href]')).length;
let hasIconStyleClass = fixture.debugElement.queryAll(By.css('.info-icon.fa.fa-shield')).length;
expect(numTitles).toBe(1);
expect(numTitleLinks).toBe(1);
Expand All @@ -77,14 +77,14 @@ describe('Info Status Card Component - ', () => {
cardConfig.href = null;
Object.assign(infoCard, cardConfig);
fixture.detectChanges();
let numTitleLinks = fixture.debugElement.queryAll(By.css('.card-pf-title a')).length;
let numTitleLinks = fixture.debugElement.queryAll(By.css('.pfng-card-title a')).length;
expect(numTitleLinks).toBe(0);
});

it('should set three info elements', () => {
Object.assign(infoCard, cardConfig);
fixture.detectChanges();
let numInfoElements = fixture.debugElement.queryAll(By.css('.card-pf-info-item')).length;
let numInfoElements = fixture.debugElement.queryAll(By.css('.pfng-card-info-item')).length;
expect(numInfoElements).toBe(4);
});

Expand Down Expand Up @@ -114,7 +114,7 @@ describe('Info Status Card Component - ', () => {
cardConfig.iconImageSrc = '//www.patternfly.org/assets/img/redhat.svg',
Object.assign(infoCard, cardConfig);
fixture.detectChanges();
let hasIconImg = fixture.debugElement.queryAll(By.css('.card-pf-info-image .info-img')).length;
let hasIconImg = fixture.debugElement.queryAll(By.css('.pfng-card-info-image .info-img')).length;
expect(hasIconImg).toBe(1);
});

Expand Down
9 changes: 6 additions & 3 deletions src/app/card/info-status-card/info-status-card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import {
Component,
Input,
OnInit,
DoCheck
DoCheck,
ViewEncapsulation
} from '@angular/core';

import { cloneDeep, defaults, isEqual } from 'lodash';
Expand All @@ -13,9 +14,11 @@ import { InfoStatusCardConfig } from './info-status-card-config';
* Info Status Card Component
*/
@Component({
encapsulation: ViewEncapsulation.None,
selector: 'pfng-info-status-card',
templateUrl: './info-status-card.component.html',
styleUrls: ['./info-status-card.component.less']
styleUrls: ['./info-status-card.component.less'],
templateUrl: './info-status-card.component.html'

})

export class InfoStatusCardComponent implements OnInit, DoCheck {
Expand Down