Skip to content

Commit

Permalink
docs(accordion): create documentation for accordion (#1474)
Browse files Browse the repository at this point in the history
  • Loading branch information
natali-abyss authored and valorkin committed Jan 11, 2017
1 parent 1309cea commit 8f1ed89
Show file tree
Hide file tree
Showing 16 changed files with 257 additions and 67 deletions.
60 changes: 45 additions & 15 deletions demo/src/app/components/accordion/accordion-section.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,66 @@ let titleDoc = require('html!markdown!./docs/usage.md');
<h2>Contents</h2>
<ul>
<li><a pageScroll href="#usage">Usage</a></li>
<li><a pageScroll href="#examples">Examples</a>
<li><a routerLink="." fragment="usage">Usage</a></li>
<li><a routerLink="." fragment="examples">Examples</a>
<ul>
<!--<li><a pageScroll href="#link-color">Link color</a></li>-->
<li><a routerLink="." fragment="simple">Simple accordion</a></li>
<li><a routerLink="." fragment="disabled">Disabled</a></li>
<li><a routerLink="." fragment="dynamic">Dynamic accordion</a></li>
<li><a routerLink="." fragment="one-time">Open only one at a time</a></li>
<li><a routerLink="." fragment="styling">Styling</a></li>
<li><a routerLink="." fragment="config">Configuring defaults</a></li>
</ul>
</li>
<li><a pageScroll href="#api-reference">API Reference</a>
<li><a routerLink="." fragment="api-reference">API Reference</a>
<ul>
<li><a pageScroll href="#accordion-panel-component">AccordionPanelComponent</a></li>
<li><a pageScroll href="#accordion-config">AccordionConfig</a></li>
<li><a routerLink="." fragment="accordion-panel-component">AccordionPanelComponent</a></li>
<li><a routerLink="." fragment="accordion-config">AccordionConfig</a></li>
</ul>
</li>
</ul>
<h2 id="usage">Usage</h2>
<h2 routerLink="." fragment="usage" id="usage">Usage</h2>
<p [innerHtml]="titleDoc"></p>
<h2 id="examples">Examples</h2>
<h2 routerLink="." fragment="examples" id="examples">Examples</h2>
<!-- basic -->
<p>Click headers to expand/collapse content that is broken into logical sections, much like tabs.</p>
<ng-sample-box [ts]="demos.old.component" [html]="demos.old.html">
<accordion-demo></accordion-demo>
<h2 routerLink="." fragment="simple" id="simple">Simple accordion</h2>
<ng-sample-box [ts]="demos.basic.component" [html]="demos.basic.html">
<demo-accordion-basic></demo-accordion-basic>
</ng-sample-box>
<h2 id="api-reference">API Reference</h2>
<ng-api-doc id="accordion-panel-component" directive="AccordionPanelComponent"></ng-api-doc>
<ng-api-doc-config id="accordion-config" type="AccordionConfig"></ng-api-doc-config>
<h2 routerLink="." fragment="disabled" id="disabled">Disabled</h2>
<ng-sample-box [ts]="demos.disabled.component" [html]="demos.disabled.html">
<demo-accordion-disabled></demo-accordion-disabled>
</ng-sample-box>
<h2 routerLink="." fragment="dynamic" id="dynamic">Dynamic accordion</h2>
<ng-sample-box [ts]="demos.dynamic.component" [html]="demos.dynamic.html">
<demo-accordion-dynamic></demo-accordion-dynamic>
</ng-sample-box>
<h2 routerLink="." fragment="one-time" id="one-time">Open only one at a time</h2>
<ng-sample-box [ts]="demos.oneAtATime.component" [html]="demos.oneAtATime.html">
<demo-accordion-one-time></demo-accordion-one-time>
</ng-sample-box>
<h2 routerLink="." fragment="styling" id="styling">Styling</h2>
<ng-sample-box [ts]="demos.styling.component" [html]="demos.styling.html">
<demo-accordion-styling></demo-accordion-styling>
</ng-sample-box>
<h2 routerLink="." fragment="config" id="config">Configuring defaults</h2>
<ng-sample-box [ts]="demos.config.component" [html]="demos.config.html">
<demo-accordion-config></demo-accordion-config>
</ng-sample-box>
<h2 routerLink="." fragment="api-reference" id="api-reference">API Reference</h2>
<ng-api-doc routerLink="." fragment="accordion-panel-component" id="accordion-panel-component" directive="AccordionPanelComponent"></ng-api-doc>
<ng-api-doc-config routerLink="." fragment="accordion-config" id="accordion-config" type="AccordionConfig"></ng-api-doc-config>
</demo-section>`
})
export class AccordionSectionComponent {
Expand Down

This file was deleted.

19 changes: 19 additions & 0 deletions demo/src/app/components/accordion/demos/basic/basic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<accordion>
<accordion-group heading="Static Header, initially expanded">
This content is straight in the template.
</accordion-group>
<accordion-group #group>
<div accordion-heading>
I can have markup, too!
<i class="pull-right float-xs-right glyphicon"
[ngClass]="{'glyphicon-chevron-down': group?._isOpen, 'glyphicon-chevron-right': !group?._isOpen}"></i>
</div>
This is just some content to illustrate fancy headings.
</accordion-group>
<accordion-group heading="Content 1">
<p>Content 1</p>
</accordion-group>
<accordion-group heading="Content 2">
<p>Content 2</p>
</accordion-group>
</accordion>
9 changes: 9 additions & 0 deletions demo/src/app/components/accordion/demos/basic/basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-accordion-basic',
templateUrl: './basic.html'
})
export class DemoAccordionBasicComponent {

}
11 changes: 11 additions & 0 deletions demo/src/app/components/accordion/demos/config/config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<accordion>
<accordion-group heading="Header">
This content is straight in the template.
</accordion-group>
<accordion-group heading="Content 1">
<p>Content 1</p>
</accordion-group>
<accordion-group heading="Content 2">
<p>Content 2</p>
</accordion-group>
</accordion>
16 changes: 16 additions & 0 deletions demo/src/app/components/accordion/demos/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component } from '@angular/core';
import { AccordionConfig } from 'ng2-bootstrap';

// such override allows to keep some initial values

export function getAccordionConfig(): AccordionConfig {
return Object.assign(new AccordionConfig(), {closeOthers: true});
}

@Component({
selector: 'demo-accordion-config',
templateUrl: './config.html',
providers: [{provide: AccordionConfig, useFactory: getAccordionConfig}]
})
export class DemoAccordionConfigComponent {
}
19 changes: 19 additions & 0 deletions demo/src/app/components/accordion/demos/disabled/disabled.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<p>
<button type="button" class="btn btn-primary btn-sm" (click)="status.isFirstDisabled = ! status.isFirstDisabled">
Enable / Disable first panel
</button>
</p>

<accordion>
<accordion-group heading="Static Header, initially expanded"
[isOpen]="status.isFirstOpen"
[isDisabled]="status.isFirstDisabled">
This content is straight in the template.
</accordion-group>
<accordion-group heading="Content 1">
<p>accordion 1</p>
</accordion-group>
<accordion-group heading="Content 2">
<p>accordion 2</p>
</accordion-group>
</accordion>
12 changes: 12 additions & 0 deletions demo/src/app/components/accordion/demos/disabled/disabled.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-accordion-disabled',
templateUrl: './disabled.html'
})
export class DemoAccordionDisabledComponent {
public status: Object = {
isFirstOpen: true,
isFirstDisabled: false
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,11 @@
<button type="button" class="btn btn-primary btn-sm"
(click)="group.isOpen = !group.isOpen">Toggle last panel
</button>
<button type="button" class="btn btn-primary btn-sm"
(click)="status.isFirstDisabled = ! status.isFirstDisabled">Enable /
Disable first panel
</button>
</p>

<div class="checkbox">
<label>
<input type="checkbox" [(ngModel)]="oneAtATime">
Open only one at a time
</label>
</div>

<accordion [closeOthers]="oneAtATime">
<accordion>
<accordion-group heading="Static Header, initially expanded"
[isOpen]="status.isFirstOpen"
[isDisabled]="status.isFirstDisabled">
[isOpen]="status.isFirstOpen">
This content is straight in the template.
</accordion-group>
<accordion-group *ngFor="let group of groups" [heading]="group.title">
Expand All @@ -33,9 +21,9 @@
</accordion-group>
<accordion-group #group [isOpen]="status.open">
<div accordion-heading>
I can have markup, too!
<i class="pull-right float-xs-right glyphicon"
[ngClass]="{'glyphicon-chevron-down': group?._isOpen, 'glyphicon-chevron-right': !group?._isOpen}"></i>
I can have markup, too!
<i class="pull-right float-xs-right glyphicon"
[ngClass]="{'glyphicon-chevron-down': group?._isOpen, 'glyphicon-chevron-right': !group?._isOpen}"></i>
</div>
This is just some content to illustrate fancy headings.
</accordion-group>
Expand Down
28 changes: 28 additions & 0 deletions demo/src/app/components/accordion/demos/dymanic/dynamic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-accordion-dynamic',
templateUrl: './dynamic.html'
})
export class DemoAccordionDynamicComponent {
public items: string[] = ['Item 1', 'Item 2', 'Item 3'];

public status: Object = {
isFirstOpen: true
};

public groups: any[] = [
{
title: 'Dynamic Group Header - 1',
content: 'Dynamic Group Body - 1'
},
{
title: 'Dynamic Group Header - 2',
content: 'Dynamic Group Body - 2'
}
];

public addItem(): void {
this.items.push(`Items ${this.items.length + 1}`);
}
}
36 changes: 31 additions & 5 deletions demo/src/app/components/accordion/demos/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
import { AccordionDemoComponent } from './accordion-demo.component';
import { DemoAccordionBasicComponent } from './basic/basic';
import { DemoAccordionDisabledComponent } from './disabled/disabled';
import { DemoAccordionStylingComponent } from './styling/styling';
import { DemoAccordionOneAtATimeComponent } from './one-at-a-time/one-at-a-time';
import { DemoAccordionDynamicComponent } from './dymanic/dynamic';
import { DemoAccordionConfigComponent } from './config/config';

export const DEMO_COMPONENTS = [
AccordionDemoComponent
DemoAccordionBasicComponent, DemoAccordionDisabledComponent, DemoAccordionStylingComponent,
DemoAccordionOneAtATimeComponent, DemoAccordionDynamicComponent, DemoAccordionConfigComponent
];

export const DEMOS = {
old: {
component: require('!!raw?lang=typescript!./accordion-demo.component'),
html: require('!!raw?lang=markup!./accordion-demo.component.html')
basic: {
component: require('!!raw?lang=typescript!./basic/basic'),
html: require('!!raw?lang=markup!./basic/basic.html')
},
disabled: {
component: require('!!raw?lang=typescript!./disabled/disabled'),
html: require('!!raw?lang=markup!./disabled/disabled.html')
},
dynamic: {
component: require('!!raw?lang=typescript!./dymanic/dynamic'),
html: require('!!raw?lang=markup!./dymanic/dynamic.html')
},
oneAtATime: {
component: require('!!raw?lang=typescript!./one-at-a-time/one-at-a-time'),
html: require('!!raw?lang=markup!./one-at-a-time/one-at-a-time.html')
},
config: {
component: require('!!raw?lang=typescript!./config/config'),
html: require('!!raw?lang=markup!./config/config.html')
},
styling: {
component: require('!!raw?lang=typescript!./styling/styling'),
html: require('!!raw?lang=markup!./styling/styling.html')
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<div class="checkbox">
<label>
<input type="checkbox" [(ngModel)]="oneAtATime">
Open only one at a time
</label>
</div>

<accordion [closeOthers]="oneAtATime">
<accordion-group heading="Header">
This content is straight in the template.
</accordion-group>
<accordion-group heading="Content 1">
<p>Content 1</p>
</accordion-group>
<accordion-group heading="Content 2">
<p>Content 2</p>
</accordion-group>
</accordion>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-accordion-one-time',
templateUrl: './one-at-a-time.html'
})
export class DemoAccordionOneAtATimeComponent {
public oneAtATime: boolean = true;

}
13 changes: 13 additions & 0 deletions demo/src/app/components/accordion/demos/styling/styling.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<accordion>
<accordion-group heading="Static Header, initially expanded"
[panelClass]="customClass"
[isOpen]="isFirstOpen">
This content is straight in the template.
</accordion-group>
<accordion-group heading="Content 1">
<p>accordion 1</p>
</accordion-group>
<accordion-group heading="Content 2" panelClass="customClass">
<p>accordion 2</p>
</accordion-group>
</accordion>
11 changes: 11 additions & 0 deletions demo/src/app/components/accordion/demos/styling/styling.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-accordion-styling',
templateUrl: './styling.html'
})

export class DemoAccordionStylingComponent {
public customClass: string = 'customClass';
public isFirstOpen: boolean = true;
}
10 changes: 10 additions & 0 deletions demo/src/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,16 @@ pre {
background-color: #50ff50;
}

.card.customClass,
.card.customClass .card-header,
.panel.customClass {
background-color: #5bc0de;
color: #fff;
}
.panel.customClass .panel-body {
background-color: #337aa7;
}

.app-footer {
padding: 3rem 2rem;
margin-top: 3rem;
Expand Down

0 comments on commit 8f1ed89

Please sign in to comment.