Skip to content

Commit

Permalink
feat(docs): new aside menu (#2851)
Browse files Browse the repository at this point in the history
* refactor(demo pages): new add-nav and content dynamic loading [WIP]

* refactor(demo pages): new add-nav and content dynamic loading [WIP]

* refactor(demo pages): new add-nav and content dynamic loading [WIP]

* refactor(demo pages): new add-nav and content dynamic loading [WIP]

* refactor(demo pages): new add-nav and content dynamic loading [WIP]

* refactor(demo pages): new add-nav and content dynamic loading [WIP]

* refactor(demo pages): new add-nav and content dynamic loading [WIP]

* WIP feat(docs): new aside menu

* WIP feat(docs): new aside menu

* WIP feat(docs): new aside menu

* WIP feat(docs): new aside menu

* WIP feat(docs): new aside menu

* WIP feat(docs): new aside menu

* WIP feat(docs): new aside menu

* WIP feat(docs): new aside menu

* chore(docs): added docs-section component

* chore(demo): made docs section to run on push

* chore(demo): unified demo section component

* feat(docs): New content management and generation logic for demo pages

* feat(docs): New content management and generation logic for demo pages

* feat(docs): New content management and generation logic for demo pages
  • Loading branch information
EvilAlexei authored and valorkin committed Oct 27, 2017
1 parent a86e549 commit 4e3e456
Show file tree
Hide file tree
Showing 145 changed files with 3,172 additions and 2,356 deletions.
2 changes: 1 addition & 1 deletion demo/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
PageScrollService
} from 'ng2-page-scroll';
import { DOCUMENT } from '@angular/common';
import { Analytics } from './api-docs/analytics/analytics';
import { Analytics } from './docs/api-docs/analytics/analytics';

PageScrollConfig.defaultDuration = 11;
PageScrollConfig.defaultScrollOffset = 70;
Expand Down
13 changes: 5 additions & 8 deletions demo/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,27 @@ import { RouterModule } from '@angular/router';
import { Ng2PageScrollModule } from 'ng2-page-scroll/ng2-page-scroll';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { ngdoc } from '../ng-api-doc';
import { NgApiDoc } from './api-docs/api-docs.model';
import { NgApiDoc } from './docs/api-docs/api-docs.model';

import { NgApiDocModule } from './api-docs/index';
import { AppComponent } from './app.component';
import { routes } from './app.routing';
import { LandingComponent } from './common/landing/landing.component';
import { DocumentationComponent } from './common/documentation/documentation.component';
import { TopMenuComponent } from './common/top-menu/top-menu.component';
import { GettingStartedComponent } from './common/getting-started/getting-started.component';

import { ThemeStorage } from './theme/theme-storage';
import { StyleManager } from './theme/style-manager';
import { SharedModule } from './shared/shared.module';
import { DocsModule } from './docs';

@NgModule({
declarations: [
AppComponent,
GettingStartedComponent,
TopMenuComponent,
LandingComponent,
DocumentationComponent
LandingComponent
],
imports: [
SharedModule,
NgApiDocModule,
DocsModule,
BrowserModule,
FormsModule,
HttpModule,
Expand Down
9 changes: 9 additions & 0 deletions demo/src/app/common/add-nav/add-nav.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<ul *ngIf="componentContent" (click)="goToSection($event)">
<li *ngFor="let item of componentContent">
<a routerLink="." [fragment]="item.anchor" [attr.data-anchor]="item.anchor">{{ item.name }}</a>
<ul *ngIf="item.content && item.content.length">
<li *ngFor="let subItem of item.content">
<a routerLink="." [fragment]="subItem.anchor" [attr.data-anchor]="item.anchor">{{ subItem.title }}</a>
</ul>
</li>
</ul>
25 changes: 19 additions & 6 deletions demo/src/app/common/add-nav/add-nav.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { routes } from '../../app.routing';
import { StyleManager } from '../../theme/style-manager';
import { ThemeStorage } from '../../theme/theme-storage';
import { Component, Inject, Input } from '@angular/core';
import { DOCUMENT } from '@angular/common';

import { ContentSection } from '../../docs/models/content-section.model';

@Component({
selector: 'add-nav',
templateUrl: './add-nav.component.html'
})
export class AddNavComponent {
constructor() {}
@Input() componentContent: ContentSection[];

constructor(@Inject(DOCUMENT) private document: Document) { }

goToSection(event): void {
const item: HTMLElement = event.target;

if (item.dataset.anchor) {
const anchor: string = item.dataset.anchor;
const target: HTMLElement = this.document.getElementById(anchor);
const header: HTMLElement = this.document.getElementById('header');
const headerIndent: number = header.offsetHeight + 6;
this.document.body.scrollTop = target.offsetTop - headerIndent;
}
}
}
13 changes: 0 additions & 13 deletions demo/src/app/common/documentation/documentation.component.html

This file was deleted.

7 changes: 0 additions & 7 deletions demo/src/app/common/documentation/documentation.component.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
// todo: add more samples https://jqueryui.com/accordion/#default
// todo: add more samples http://getbootstrap.com/components/#panels-alternatives

import { Component } from '@angular/core';
import { DEMOS } from './demos';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { demoComponentContent } from './accordion-section.list';
import { ContentSection } from '../../docs/models/content-section.model';

// webpack html imports
let titleDoc = require('html-loader!markdown-loader!./docs/usage.md');

@Component({
selector: 'accordion-section',
templateUrl: './accordion-section.components.html'
templateUrl: './accordion-section.components.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AccordionSectionComponent {
name = 'Accordion';
src = 'https://github.com/valor-software/ngx-bootstrap/tree/development/src/accordion';
titleDoc: string = titleDoc;
demos: any = DEMOS;
componentContent: ContentSection[] = demoComponentContent;
}
Original file line number Diff line number Diff line change
@@ -1,67 +1,7 @@
<demo-section [name]="name" [src]="src">
<demo-section [name]="name" [src]="src" [componentContent]="componentContent">
<p>Displays collapsible content panels for presenting information in a limited amount of space</p>
<p>The <strong>accordion component</strong> builds on top of the collapse directive to provide a list of items, with collapsible bodies that are collapsed or expanded by clicking on the item's header.</p>
<p>The <strong>accordion component</strong> builds on top of the collapse directive to provide a list
of items, with collapsible bodies that are collapsed or expanded by clicking on the item's header.</p>

<h2>Contents</h2>
<ul>
<li><a routerLink="." fragment="usage">Usage</a></li>
<li><a routerLink="." fragment="examples">Examples</a>
<ul>
<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 routerLink="." fragment="api-reference">API Reference</a>
<ul>
<li><a routerLink="." fragment="accordion-panel-component">AccordionPanelComponent</a></li>
<li><a routerLink="." fragment="accordion-config">AccordionConfig</a></li>
</ul>
</li>
</ul>

<h2 routerLink="." fragment="usage" id="usage">Usage</h2>

<p [innerHtml]="titleDoc"></p>

<h2 routerLink="." fragment="examples" id="examples">Examples</h2>

<p>Click headers to expand/collapse content that is broken into logical sections, much like tabs.</p>

<h3 routerLink="." fragment="simple" id="simple">Simple accordion</h3>
<ng-sample-box [ts]="demos.basic.component" [html]="demos.basic.html">
<demo-accordion-basic></demo-accordion-basic>
</ng-sample-box>

<h3 routerLink="." fragment="disabled" id="disabled">Disabled</h3>
<ng-sample-box [ts]="demos.disabled.component" [html]="demos.disabled.html">
<demo-accordion-disabled></demo-accordion-disabled>
</ng-sample-box>

<h3 routerLink="." fragment="dynamic" id="dynamic">Dynamic accordion</h3>
<ng-sample-box [ts]="demos.dynamic.component" [html]="demos.dynamic.html">
<demo-accordion-dynamic></demo-accordion-dynamic>
</ng-sample-box>

<h3 routerLink="." fragment="one-time" id="one-time">Open only one at a time</h3>
<ng-sample-box [ts]="demos.oneAtATime.component" [html]="demos.oneAtATime.html">
<demo-accordion-one-time></demo-accordion-one-time>
</ng-sample-box>

<h3 routerLink="." fragment="styling" id="styling">Styling</h3>
<ng-sample-box [ts]="demos.styling.component" [html]="demos.styling.html" [style]="demos.styling.css">
<demo-accordion-styling></demo-accordion-styling>
</ng-sample-box>

<h3 routerLink="." fragment="config" id="config">Configuring defaults</h3>
<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>
<docs-section [content]="componentContent"></docs-section>
</demo-section>
96 changes: 96 additions & 0 deletions demo/src/app/components/+accordion/accordion-section.list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { DemoAccordionBasicComponent } from './demos/basic/basic';
import { DemoAccordionDisabledComponent } from './demos/disabled/disabled';
import { DemoAccordionDynamicComponent } from './demos/dymanic/dynamic';
import { DemoAccordionOneAtATimeComponent } from './demos/one-at-a-time/one-at-a-time';
import { DemoAccordionStylingComponent } from './demos/styling/styling';
import { DemoAccordionConfigComponent } from './demos/config/config';

import { ContentSection } from '../../docs/models/content-section.model';
import { DemoTopSectionComponent } from '../../docs/demo-section-components/demo-top-section/index';
import { ExamplesComponent } from '../../docs/demo-section-components/demo-examples-section/index';
import { ApiSectionsComponent } from '../../docs/demo-section-components/demo-api-section/index';

import {
NgApiDocComponent,
NgApiDocConfigComponent
} from '../../docs/api-docs';

export const demoComponentContent: ContentSection[] = [
{
name: 'Usage',
anchor: 'usage',
outlet: DemoTopSectionComponent,
content: {
doc: require('html-loader!markdown-loader!./docs/usage.md')
}
},
{
name: 'Examples',
anchor: 'examples',
outlet: ExamplesComponent,
content: [
{
title: 'Simple accordion',
anchor: 'simple-accordion',
description: `<p>Click headers to expand/collapse content that is broken into logical sections, much
like tabs.</p>`,
component: require('!!raw-loader?lang=typescript!./demos/basic/basic'),
html: require('!!raw-loader?lang=markup!./demos/basic/basic.html'),
outlet: DemoAccordionBasicComponent
},
{
title: 'Disabled',
anchor: 'disabled',
component: require('!!raw-loader?lang=typescript!./demos/disabled/disabled'),
html: require('!!raw-loader?lang=markup!./demos/disabled/disabled.html'),
outlet: DemoAccordionDisabledComponent
},
{
title: 'Dynamic accordion',
anchor: 'dynamic-accordion',
component: require('!!raw-loader?lang=typescript!./demos/dymanic/dynamic'),
html: require('!!raw-loader?lang=markup!./demos/dymanic/dynamic.html'),
outlet: DemoAccordionDynamicComponent
},
{
title: 'Open only one at a time',
anchor: 'one-time',
component: require('!!raw-loader?lang=typescript!./demos/one-at-a-time/one-at-a-time'),
html: require('!!raw-loader?lang=markup!./demos/one-at-a-time/one-at-a-time.html'),
outlet: DemoAccordionOneAtATimeComponent
},
{
title: 'Styling',
anchor: 'styling',
component: require('!!raw-loader?lang=typescript!./demos/styling/styling'),
html: require('!!raw-loader?lang=markup!./demos/styling/styling.html'),
css: require('!!raw-loader?lang=markup!./demos/styling/styling.css'),
outlet: DemoAccordionStylingComponent
},
{
title: 'Configuring defaults',
anchor: 'config',
component: require('!!raw-loader?lang=typescript!./demos/config/config'),
html: require('!!raw-loader?lang=markup!./demos/config/config.html'),
outlet: DemoAccordionConfigComponent
}
]
},
{
name: 'API Reference',
anchor: 'api-reference',
outlet: ApiSectionsComponent,
content: [
{
title: 'AccordionPanelComponent',
anchor: 'AccordionPanelComponent',
outlet: NgApiDocComponent
},
{
title: 'AccordionConfig',
anchor: 'AccordionConfig',
outlet: NgApiDocConfigComponent
}
]
}
];
12 changes: 8 additions & 4 deletions demo/src/app/components/+accordion/demo-accordion.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@ import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';
import { AccordionModule } from 'ngx-bootstrap/accordion';

import { SharedModule } from '../../shared';
import { DocsModule } from '../../docs';
import { AccordionSectionComponent } from './accordion-section.component';
import { DEMO_COMPONENTS } from './demos';

import { routes } from './demo-accordion.routes';

@NgModule({
declarations: [AccordionSectionComponent, ...DEMO_COMPONENTS],
declarations: [
AccordionSectionComponent,
...DEMO_COMPONENTS
],
imports: [
AccordionModule.forRoot(),
CommonModule,
FormsModule,
SharedModule,
DocsModule,
RouterModule.forChild(routes)
],
exports: [AccordionSectionComponent]
exports: [AccordionSectionComponent],
entryComponents: [...DEMO_COMPONENTS]
})
export class DemoAccordionModule {
static routes: any = routes;
Expand Down
28 changes: 0 additions & 28 deletions demo/src/app/components/+accordion/demos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,3 @@ export const DEMO_COMPONENTS = [
DemoAccordionDynamicComponent,
DemoAccordionConfigComponent
];

export const DEMOS = {
basic: {
component: require('!!raw-loader?lang=typescript!./basic/basic'),
html: require('!!raw-loader?lang=markup!./basic/basic.html')
},
disabled: {
component: require('!!raw-loader?lang=typescript!./disabled/disabled'),
html: require('!!raw-loader?lang=markup!./disabled/disabled.html')
},
dynamic: {
component: require('!!raw-loader?lang=typescript!./dymanic/dynamic'),
html: require('!!raw-loader?lang=markup!./dymanic/dynamic.html')
},
oneAtATime: {
component: require('!!raw-loader?lang=typescript!./one-at-a-time/one-at-a-time'),
html: require('!!raw-loader?lang=markup!./one-at-a-time/one-at-a-time.html')
},
config: {
component: require('!!raw-loader?lang=typescript!./config/config'),
html: require('!!raw-loader?lang=markup!./config/config.html')
},
styling: {
component: require('!!raw-loader?lang=typescript!./styling/styling'),
html: require('!!raw-loader?lang=markup!./styling/styling.html'),
css: require('!!raw-loader?lang=markup!./styling/styling.css')
}
};
Loading

0 comments on commit 4e3e456

Please sign in to comment.