Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Page summary component (#130)
Browse files Browse the repository at this point in the history
* Added page summary component

* Visual regression tests and key info move behavior

* Unit tests
  • Loading branch information
Blackbaud-PaulCrowder authored Oct 6, 2016
1 parent 7cfd0eb commit 3f579ea
Show file tree
Hide file tree
Showing 51 changed files with 805 additions and 6 deletions.
69 changes: 69 additions & 0 deletions demo/src/page-summary/app.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<sky-page-summary>
<sky-page-summary-alert *ngIf="showAlert">
<sky-alert [alertType]="'info'">This is an alert.</sky-alert>
</sky-page-summary-alert>
<sky-page-summary-image *ngIf="showImage">
<sky-avatar [name]="name"></sky-avatar>
</sky-page-summary-image>
<sky-page-summary-title *ngIf="showTitle">
{{name}}
</sky-page-summary-title>
<sky-page-summary-subtitle *ngIf="showSubtitle">
Board member
</sky-page-summary-subtitle>
<sky-page-summary-status *ngIf="showStatus">
<sky-label labelType="success">Fundraiser</sky-label>
<sky-label>Inactive</sky-label>
</sky-page-summary-status>
<sky-page-summary-content *ngIf="showContent">
This is the arbitrary content section. You can display any kind of content to complement the content on a page. We recommend that you display content to support the key tasks of users of users who visit the page. We also recommend that you keep in mind the context of how users will use the content and limit the amount of content to avoid overloading the summary.
</sky-page-summary-content>
<sky-page-summary-key-info *ngIf="showKeyInfo">
<sky-key-info>
<sky-key-info-value>The key information</sky-key-info-value>
</sky-key-info>
<sky-key-info>
<sky-key-info-value>section highlights</sky-key-info-value>
</sky-key-info>
<sky-key-info>
<sky-key-info-value>important details</sky-key-info-value>
</sky-key-info>
</sky-page-summary-key-info>
</sky-page-summary>
<ul style="list-style: none">
<li>
<sky-checkbox [(ngModel)]="showTitle">
<sky-checkbox-label>Show title</sky-checkbox-label>
</sky-checkbox>
</li>
<li>
<sky-checkbox [(ngModel)]="showSubtitle">
<sky-checkbox-label>Show subtitle</sky-checkbox-label>
</sky-checkbox>
</li>
<li>
<sky-checkbox [(ngModel)]="showImage">
<sky-checkbox-label>Show image</sky-checkbox-label>
</sky-checkbox>
</li>
<li>
<sky-checkbox [(ngModel)]="showStatus">
<sky-checkbox-label>Show record status</sky-checkbox-label>
</sky-checkbox>
</li>
<li>
<sky-checkbox [(ngModel)]="showKeyInfo">
<sky-checkbox-label>Show key information</sky-checkbox-label>
</sky-checkbox>
</li>
<li>
<sky-checkbox [(ngModel)]="showContent">
<sky-checkbox-label>Show arbitrary content</sky-checkbox-label>
</sky-checkbox>
</li>
<li>
<sky-checkbox [(ngModel)]="showAlert">
<sky-checkbox-label>Show alert</sky-checkbox-label>
</sky-checkbox>
</li>
</ul>
46 changes: 46 additions & 0 deletions demo/src/page-summary/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Component, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';

import { SkyModule } from '../../../src/core';

import { Bootstrapper } from '../../bootstrapper';

@Component({
selector: 'sky-demo-app',
template: require('./app.component.html')
})
export class AppComponent {
public name = 'Robert C. Hernandez';

public showAlert = true;

public showImage = true;

public showTitle = true;

public showSubtitle = true;

public showStatus = true;

public showContent = true;

public showKeyInfo = true;
}

@NgModule({
imports: [
BrowserModule,
FormsModule,
SkyModule
],
declarations: [
AppComponent
],
bootstrap: [
AppComponent
]
})
class AppModule { }

Bootstrapper.bootstrapModule(AppModule);
3 changes: 3 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { SkyKeyInfoModule } from './modules/key-info';
import { SkyLabelModule } from './modules/label';
import { SkyModalModule } from './modules/modal';
import { SkyNavbarModule } from './modules/navbar';
import { SkyPageSummaryModule } from './modules/page-summary';
import { SkyRepeaterModule } from './modules/repeater';
import { SkyTabsModule } from './modules/tabs';
import { SkyTilesModule } from './modules/tiles';
Expand All @@ -27,6 +28,7 @@ import { SkyTilesModule } from './modules/tiles';
SkyLabelModule,
SkyModalModule,
SkyNavbarModule,
SkyPageSummaryModule,
SkyRepeaterModule,
SkyTabsModule,
SkyTilesModule
Expand All @@ -43,6 +45,7 @@ export * from './modules/key-info';
export * from './modules/label';
export * from './modules/modal';
export * from './modules/navbar';
export * from './modules/page-summary';
export * from './modules/repeater';
export * from './modules/tabs';
export * from './modules/tiles';
Expand Down
2 changes: 1 addition & 1 deletion src/modules/label/label.component.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<span class="sky-label" [ngClass]="'sky-label-' + labelType">
<span class="sky-label" [ngClass]="labelType ? 'sky-label-' + labelType : ''">
<ng-content></ng-content>
</span>
7 changes: 6 additions & 1 deletion src/modules/label/label.component.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
@import '../../scss/mixins';

.sky-label {
color: white;
background-color: $sky-color-gray-lightest;
color: $sky-color-gray;
display: inline;
border-radius: 10rem;
font-weight: 600;
Expand All @@ -12,17 +13,21 @@
}

.sky-label-success {
color: white;
background-color: $sky-color-green;
}

.sky-label-info {
color: white;
background-color: $sky-color-aqua;
}

.sky-label-warning {
color: white;
background-color: $sky-color-yellow;
}

.sky-label-danger {
color: white;
background-color: $sky-color-red;
}
2 changes: 1 addition & 1 deletion src/modules/label/label.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ import { Component, Input } from '@angular/core';
})
export class SkyLabelComponent {
@Input()
public labelType = 'info';
public labelType: string;
}
20 changes: 20 additions & 0 deletions src/modules/page-summary/fixtures/page-summary-fixtures.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { SkyPageSummaryModule } from '../';

import { SkyPageSummaryTestComponent } from './page-summary.component.fixture';

@NgModule({
declarations: [
SkyPageSummaryTestComponent
],
imports: [
CommonModule,
SkyPageSummaryModule
],
exports: [
SkyPageSummaryTestComponent
]
})
export class SkyPageSummaryFixturesModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<sky-page-summary>
<sky-page-summary-key-info>
<div class="key-info-find-me"></div>
</sky-page-summary-key-info>
</sky-page-summary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Component } from '@angular/core';

@Component({
template: require('./page-summary.component.fixture.html')
})
export class SkyPageSummaryTestComponent { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<div id="screenshots-page-summary">
<sky-page-summary>
<sky-page-summary-alert *ngIf="showAlert">
<sky-alert [alertType]="'info'">This is an alert.</sky-alert>
</sky-page-summary-alert>
<sky-page-summary-image *ngIf="showImage">
<sky-avatar [name]="name"></sky-avatar>
</sky-page-summary-image>
<sky-page-summary-title *ngIf="showTitle">
{{name}}
</sky-page-summary-title>
<sky-page-summary-subtitle *ngIf="showSubtitle">
Board member
</sky-page-summary-subtitle>
<sky-page-summary-status *ngIf="showStatus">
<sky-label labelType="success">Fundraiser</sky-label>
<sky-label>Inactive</sky-label>
</sky-page-summary-status>
<sky-page-summary-content *ngIf="showContent">
This is the arbitrary content section. You can display any kind of content to complement the content on a page. We recommend that you display content to support the key tasks of users of users who visit the page. We also recommend that you keep in mind the context of how users will use the content and limit the amount of content to avoid overloading the summary.
</sky-page-summary-content>
<sky-page-summary-key-info *ngIf="showKeyInfo">
<sky-key-info>
<sky-key-info-value>The key information</sky-key-info-value>
</sky-key-info>
<sky-key-info>
<sky-key-info-value>section highlights</sky-key-info-value>
</sky-key-info>
<sky-key-info>
<sky-key-info-value>important details</sky-key-info-value>
</sky-key-info>
</sky-page-summary-key-info>
</sky-page-summary>
</div>
<div style="margin-top: 20px">
<input
type="text"
id="screenshots-page-summary-items"
[(ngModel)]="itemsToShow"
aria-hidden="true"
/>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import {
Component,
NgModule
} from '@angular/core';

import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';

import { SkyModule } from '../../../../src/core';

import { Bootstrapper } from '../../../../visual/bootstrapper';

@Component({
selector: 'sky-demo-app',
template: require('./page-summary.component.visual-fixture.html')
})
export class AppComponent {
public name = 'Robert C. Hernandez';

public showAlert = false;

public showImage = false;

public showTitle = false;

public showSubtitle = false;

public showStatus = false;

public showContent = false;

public showKeyInfo = false;

public get itemsToShow(): string {
return this._itemsToShow;
};

public set itemsToShow(value: string) {
let itemsToShow = value.split(',');

itemsToShow.forEach((itemToShow) => {
this['show' + itemToShow] = true;
});

this._itemsToShow = value;
}

private _itemsToShow = '';
}

@NgModule({
imports: [
BrowserModule,
FormsModule,
SkyModule
],
declarations: [
AppComponent
],
bootstrap: [
AppComponent
]
})
class AppModule { }

Bootstrapper.bootstrapModule(AppModule);
9 changes: 9 additions & 0 deletions src/modules/page-summary/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export * from './page-summary-alert';
export * from './page-summary-content';
export * from './page-summary-image';
export * from './page-summary-key-info';
export * from './page-summary-status';
export * from './page-summary-subtitle';
export * from './page-summary-title';
export * from './page-summary.component';
export * from './page-summary.module';
15 changes: 15 additions & 0 deletions src/modules/page-summary/page-summary-adapter.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ElementRef, Injectable } from '@angular/core';

@Injectable()
export class SkyPageSummaryAdapterService {
public updateKeyInfoLocation(elRef: ElementRef, isXS: boolean) {
let el = elRef.nativeElement;
let keyInfoContainerEl = el.querySelector('.sky-page-summary-key-info-container');

if (isXS) {
el.querySelector('.sky-page-summary-key-info-xs').appendChild(keyInfoContainerEl);
} else {
el.querySelector('.sky-page-summary-key-info-sm').appendChild(keyInfoContainerEl);
}
}
}
1 change: 1 addition & 0 deletions src/modules/page-summary/page-summary-alert/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './page-summary-alert.component';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import '../../../scss/mixins';

/deep/ .sky-alert {
margin-top: 0;
margin-bottom: $sky-margin-double;
line-height: initial;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'sky-page-summary-alert',
template: require('../../shared/simple-content.html'),
styles: [require('./page-summary-alert.component.scss')]
})
export class SkyPageSummaryAlertComponent { }
1 change: 1 addition & 0 deletions src/modules/page-summary/page-summary-content/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './page-summary-content.component';
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="sky-page-summary-content">
<ng-content></ng-content>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import '../../../scss/mixins';

.sky-page-summary-content {
margin-top: $sky-margin-double;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'sky-page-summary-content',
template: require('./page-summary-content.component.html'),
styles: [require('./page-summary-content.component.scss')]
})
export class SkyPageSummaryContentComponent { }
1 change: 1 addition & 0 deletions src/modules/page-summary/page-summary-image/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './page-summary-image.component';
Loading

0 comments on commit 3f579ea

Please sign in to comment.