Skip to content

Commit

Permalink
feat(docs): popover docs
Browse files Browse the repository at this point in the history
  • Loading branch information
valorkin committed Dec 30, 2016
1 parent 8d3c2a8 commit e96dc5c
Show file tree
Hide file tree
Showing 31 changed files with 414 additions and 13 deletions.
2 changes: 2 additions & 0 deletions demo/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { DemoDatepickerModule } from './components/datepicker';
import { DemoDropdownModule } from './components/dropdown';
import { DemoModalModule } from './components/modal';
import { DemoPaginationModule } from './components/pagination';
import { DemoPopoverModule } from './components/popover/index';
import { DemoProgressbarModule } from './components/progressbar';
import { DemoRatingModule } from './components/rating';
import { DemoTabsModule } from './components/tabs';
Expand Down Expand Up @@ -55,6 +56,7 @@ import { ngdoc } from '../ng-api-doc';
DemoDropdownModule,
DemoModalModule,
DemoPaginationModule,
DemoPopoverModule,
DemoProgressbarModule,
DemoRatingModule,
DemoTabsModule,
Expand Down
6 changes: 6 additions & 0 deletions demo/src/app/app.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { TabsSectionComponent } from './components/tabs/tabs-section.component';
import { TimepickerSectionComponent } from './components/timepicker/timepicker-section.component';
import { TooltipSectionComponent } from './components/tooltip/tooltip-section.component';
import { TypeaheadSectionComponent } from './components/typeahead/typeahead-section.component';
import { PopoverSectionComponent } from './components/popover/popover-section.component';

export const routes = [
{
Expand Down Expand Up @@ -66,6 +67,11 @@ export const routes = [
data: ['Pagination'],
component: PaginationSectionComponent
},
{
path: 'popover',
data: ['Popover'],
component: PopoverSectionComponent
},
{
path: 'progressbar',
data: ['Progressbar'],
Expand Down
5 changes: 5 additions & 0 deletions demo/src/app/components/popover/demos/basic/basic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<button type="button" class="btn btn-primary"
popover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
Live demo
</button>

8 changes: 8 additions & 0 deletions demo/src/app/components/popover/demos/basic/basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-popover-basic',
templateUrl: './basic.html'
})
export class DemoPopoverBasicComponent {
}
4 changes: 4 additions & 0 deletions demo/src/app/components/popover/demos/config/config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<button type="button" class="btn btn-primary"
popover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
Preconfigured popover
</button>
16 changes: 16 additions & 0 deletions demo/src/app/components/popover/demos/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component } from '@angular/core';
import { PopoverConfig } from 'ng2-bootstrap';

// such override allows to keep some initial values

export function getAlertConfig(): PopoverConfig {
return Object.assign(new PopoverConfig(), {placement: 'right', container: 'body', triggers: 'focus'});
}

@Component({
selector: 'demo-popover-config',
templateUrl: './config.html',
providers: [{provide: PopoverConfig, useFactory: getAlertConfig}]
})
export class DemoPopoverConfigComponent {
}
13 changes: 13 additions & 0 deletions demo/src/app/components/popover/demos/container/container.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<div class="row panel" style="position: relative; overflow: hidden;">
<div class="card panel-body">
<button type="button" class="btn btn-danger"
popover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
Default popover
</button>
<button type="button" class="btn btn-success"
popover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
container="body">
Popover appended to body
</button>
</div>
</div>
8 changes: 8 additions & 0 deletions demo/src/app/components/popover/demos/container/container.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-popover-container',
templateUrl: './container.html'
})
export class DemoPopoverContainerComponent {
}
7 changes: 7 additions & 0 deletions demo/src/app/components/popover/demos/dismiss/dismiss.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<button type="button" class="btn btn-success"
popover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
popoverTitle="Dismissible popover"
triggers="focus">
Dismissible popover
</button>

8 changes: 8 additions & 0 deletions demo/src/app/components/popover/demos/dismiss/dismiss.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-popover-dismiss',
templateUrl: './dismiss.html'
})
export class DemoPopoverDismissComponent {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template #popTemplate>Here we go: <div [innerHtml]="html"></div></template>
<button type="button" class="btn btn-success"
[popover]="popTemplate" popoverTitle="Dynamic html inside">
Show me popover with html
</button>
10 changes: 10 additions & 0 deletions demo/src/app/components/popover/demos/dynamic-html/dynamic-html.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-popover-dynamic-html',
templateUrl: './dynamic-html.html'
})
export class DemoPopoverDynamicHtmlComponent {
public html:string = `
<span class="btn btn-danger">Never trust not sanitized HTML!!!</span>`;
}
10 changes: 10 additions & 0 deletions demo/src/app/components/popover/demos/dynamic/dynamic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<button type="button" class="btn btn-info"
[popover]="content" [popoverTitle]="title">
Simple binding
</button>

<template #popTemplate>Just another: {{content}}</template>
<button type="button" class="btn btn-warning"
[popover]="popTemplate" popoverTitle="Template ref content inside">
TemplateRef binding
</button>
10 changes: 10 additions & 0 deletions demo/src/app/components/popover/demos/dynamic/dynamic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-popover-dynamic',
templateUrl: './dynamic.html'
})
export class DemoPopoverDynamicComponent {
public title:string = 'Welcome word';
public content: string = 'Vivamus sagittis lacus vel augue laoreet rutrum faucibus.';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<button type="button" class="btn btn-default btn-secondary"
popover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
popoverTitle="Popover on left"
placement="left">
Popover on left
</button>

<button type="button" class="btn btn-default btn-secondary"
popover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
popoverTitle="Popover on top"
placement="top">
Popover on top
</button>

<button type="button" class="btn btn-default btn-secondary"
popover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
popoverTitle="Popover on bottom"
placement="bottom">
Popover on bottom
</button>

<button type="button" class="btn btn-default btn-secondary"
popover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
popoverTitle="Popover on right"
placement="right">
Popover on right
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-popover-four-directions',
templateUrl: './four-directions.html'
})
export class DemoPopoverFourDirectionsComponent {
}
48 changes: 48 additions & 0 deletions demo/src/app/components/popover/demos/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { DemoPopoverBasicComponent } from './basic/basic';
import { DemoPopoverFourDirectionsComponent } from './four-directions/four-directions';
import { DemoPopoverDismissComponent } from './dismiss/dismiss';
import { DemoPopoverDynamicComponent } from './dynamic/dynamic';
import { DemoPopoverDynamicHtmlComponent } from './dynamic-html/dynamic-html';
import { DemoPopoverContainerComponent } from './container/container';
import { DemoPopoverConfigComponent } from './config/config';

export const DEMO_COMPONENTS = [
DemoPopoverBasicComponent,
DemoPopoverFourDirectionsComponent,
DemoPopoverDismissComponent,
DemoPopoverDynamicComponent,
DemoPopoverDynamicHtmlComponent,
DemoPopoverContainerComponent,
DemoPopoverConfigComponent
];

export const DEMOS = {
basic: {
component: require('!!raw?lang=typescript!./basic/basic.ts'),
html: require('!!raw?lang=markup!./basic/basic.html')
},
forDirections: {
component: require('!!raw?lang=typescript!./four-directions/four-directions.ts'),
html: require('!!raw?lang=markup!./four-directions/four-directions.html')
},
dismiss: {
component: require('!!raw?lang=typescript!./dismiss/dismiss.ts'),
html: require('!!raw?lang=markup!./dismiss/dismiss.html')
},
dynamic: {
component: require('!!raw?lang=typescript!./dynamic/dynamic.ts'),
html: require('!!raw?lang=markup!./dynamic/dynamic.html')
},
dynamicHtml: {
component: require('!!raw?lang=typescript!./dynamic-html/dynamic-html.ts'),
html: require('!!raw?lang=markup!./dynamic-html/dynamic-html.html')
},
container: {
component: require('!!raw?lang=typescript!./container/container.ts'),
html: require('!!raw?lang=markup!./container/container.html')
},
config: {
component: require('!!raw?lang=typescript!./config/config.ts'),
html: require('!!raw?lang=markup!./config/config.html')
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<style>
.alert-md-color {
background-color: #7B1FA2;
border-color: #4A148C;
color: #fff;
}
</style>
<alert type="md-color">
<strong>Well done!</strong> You successfully read this important alert message.
</alert>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Component, ViewEncapsulation } from '@angular/core';

@Component({
selector: 'demo-alert-styling-global',
templateUrl: './styling-global.html',
encapsulation: ViewEncapsulation.None
})
export class DemoAlertStylingGlobalComponent {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<alert type="md-local">
<strong>Well done!</strong> You successfully read this important alert message.
</alert>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-alert-styling-local',
templateUrl: './styling-local.html',
/* tslint:disable no-unused-css*/
styles: [`
:host >>> .alert-md-local {
background-color: #009688;
border-color: #00695C;
color: #fff;
}
`]
})
export class DemoAlertStylingLocalComponent {
}
5 changes: 5 additions & 0 deletions demo/src/app/components/popover/demos/triggers/basic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<button type="button" class="btn btn-primary"
popover="Vivamus sagittis lacus vel augue laoreet rutrum faucibus.">
Live demo
</button>

8 changes: 8 additions & 0 deletions demo/src/app/components/popover/demos/triggers/basic.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'demo-popover-basic',
templateUrl: './basic.html'
})
export class DemoPopoverBasicComponent {
}
11 changes: 11 additions & 0 deletions demo/src/app/components/popover/docs/title.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```typescript
// RECOMMENDED
import { PopoverModule } from 'ng2-bootstrap/popover';
// or
import { PopoverModule } from 'ng2-bootstrap';

@NgModule({
imports: [PopoverModule.forRoot(),...]
})
export class AppModule(){}
```
22 changes: 22 additions & 0 deletions demo/src/app/components/popover/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { PopoverModule } from 'ng2-bootstrap';
import { SharedModule } from '../../shared';
import { DEMO_COMPONENTS } from './demos/index';
import { PopoverSectionComponent } from './popover-section.component';

@NgModule({
declarations: [
PopoverSectionComponent,
...DEMO_COMPONENTS
],
imports: [
CommonModule,
FormsModule,
SharedModule,
PopoverModule.forRoot()
],
exports: [PopoverSectionComponent]
})
export class DemoPopoverModule {}
Loading

0 comments on commit e96dc5c

Please sign in to comment.