-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
442 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
src/playground/with-layout/popover/components/dynamic.component.ts
This file was deleted.
Oops, something went wrong.
63 changes: 63 additions & 0 deletions
63
src/playground/with-layout/popover/components/dynamic.components.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Component, Input } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'nb-dynamic-to-add', | ||
template: ` | ||
<div> | ||
<strong>Hello from custom component: {{ text }}</strong> | ||
</div> | ||
`, | ||
}) | ||
export class DynamicToAddComponent { | ||
|
||
@Input() | ||
text: string = ''; | ||
} | ||
|
||
@Component({ | ||
selector: 'nb-popover-list', | ||
styles: [` | ||
nb-card { | ||
margin-bottom: 0; | ||
} | ||
`], | ||
template: ` | ||
<nb-card> | ||
<nb-card-header>Component Shopping list</nb-card-header> | ||
<nb-list> | ||
<nb-list-item>Apple</nb-list-item> | ||
<nb-list-item>Orange</nb-list-item> | ||
</nb-list> | ||
</nb-card> | ||
`, | ||
}) | ||
export class PopoverListComponent { | ||
} | ||
|
||
@Component({ | ||
selector: 'nb-popover-tabs', | ||
styles: [` | ||
nb-card { | ||
margin-bottom: 0; | ||
} | ||
`], | ||
template: ` | ||
<nb-card> | ||
<nb-card-header>Component Shopping list</nb-card-header> | ||
<nb-tabset> | ||
<nb-tab tabTitle="Fruits"> | ||
<nb-card> | ||
<nb-card-body>Fruits list</nb-card-body> | ||
</nb-card> | ||
</nb-tab> | ||
<nb-tab tabTitle="Vegetables"> | ||
<nb-card> | ||
<nb-card-body>Vegetables list</nb-card-body> | ||
</nb-card> | ||
</nb-tab> | ||
</nb-tabset> | ||
</nb-card> | ||
`, | ||
}) | ||
export class PopoverTabsComponent { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/playground/with-layout/popover/popover-dynamic-code.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<div class="popover"> | ||
<button [nbPopover]="componentList" nbPopoverPlacement="bottom" nbButton>Show popover</button> | ||
</div> | ||
|
||
<div> | ||
<h3>Change popover config via code</h3> | ||
<h4>Change Component</h4> | ||
<button nbButton size="small" status="success" (click)="changeComponent(componentList)">Use List Component</button> | ||
<button nbButton size="small" status="success" (click)="changeComponent(componentTabs)">Use Tabs Component</button> | ||
<button nbButton size="small" status="success" (click)="changeComponent(list)">Use List Template</button> | ||
<button nbButton size="small" status="success" (click)="changeComponent(tabs)">Use Tabs Template</button> | ||
<button nbButton size="small" status="success" (click)="changeComponent(textContent)">Use String</button> | ||
<button *ngIf="!interval" nbButton size="small" status="warning" (click)="startRuntimeChange()">Enable Runtime Change</button> | ||
<button *ngIf="interval" nbButton size="small" status="warning" (click)="stopRuntimeChange()">Disable Runtime Change</button> | ||
|
||
<div> | ||
<small>When "Runtime Change" is enabled, open the Popover to see a component change every 2 seconds.</small> | ||
</div> | ||
|
||
<h4>Change trigger</h4> | ||
<button nbButton size="small" status="success" (click)="changeTrigger('click')">Click Trigger</button> | ||
<button nbButton size="small" status="success" (click)="changeTrigger('hover')">Hover Trigger</button> | ||
<button nbButton size="small" status="success" (click)="changeTrigger('hint')">Hint Trigger</button> | ||
|
||
<h4>Change placement</h4> | ||
<button nbButton size="small" status="success" (click)="changePlacement('top')">Top Placement</button> | ||
<button nbButton size="small" status="success" (click)="changePlacement('right')">Right Placement</button> | ||
<button nbButton size="small" status="success" (click)="changePlacement('bottom')">Bottom Placement</button> | ||
<button nbButton size="small" status="success" (click)="changePlacement('left')">Left Placement</button> | ||
</div> | ||
|
||
<ng-template #tabs> | ||
<nb-card class="margin-bottom-0"> | ||
<nb-card-header>Template Shopping list</nb-card-header> | ||
<nb-tabset> | ||
<nb-tab tabTitle="Fruits"> | ||
<nb-card class="margin-bottom-0"> | ||
<nb-card-body>Fruits list</nb-card-body> | ||
</nb-card> | ||
</nb-tab> | ||
<nb-tab tabTitle="Vegetables"> | ||
<nb-card class="margin-bottom-0"> | ||
<nb-card-body>Vegetables list</nb-card-body> | ||
</nb-card> | ||
</nb-tab> | ||
</nb-tabset> | ||
</nb-card> | ||
</ng-template> | ||
|
||
<ng-template #list> | ||
<nb-card class="margin-bottom-0"> | ||
<nb-card-header>Template Shopping list</nb-card-header> | ||
<nb-list> | ||
<nb-list-item>Apple</nb-list-item> | ||
<nb-list-item>Orange</nb-list-item> | ||
</nb-list> | ||
</nb-card> | ||
</ng-template> |
92 changes: 92 additions & 0 deletions
92
src/playground/with-layout/popover/popover-dynamic-code.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* @license | ||
* Copyright Akveo. All Rights Reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*/ | ||
|
||
import { AfterViewInit, Component, OnDestroy, TemplateRef, ViewChild } from '@angular/core'; | ||
import { PopoverListComponent, PopoverTabsComponent } from './components/dynamic.components'; | ||
import { NbPopoverDirective } from '@nebular/theme'; | ||
|
||
|
||
@Component({ | ||
selector: 'nb-popover-dynamic-code', | ||
templateUrl: './popover-dynamic-code.component.html', | ||
styles: [` | ||
:host { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
.margin-bottom-0 { | ||
margin-bottom: 0; | ||
} | ||
.popover { | ||
display: flex; | ||
justify-content: center; | ||
padding: 12rem; | ||
} | ||
button { | ||
margin-right: 1rem; | ||
margin-top: 1rem; | ||
} | ||
`], | ||
}) | ||
export class PopoverDynamicCodeComponent implements OnDestroy, AfterViewInit { | ||
|
||
@ViewChild(NbPopoverDirective) popover: NbPopoverDirective; | ||
@ViewChild('tabs', { read: TemplateRef }) templateTabs: TemplateRef<any>; | ||
@ViewChild('list', { read: TemplateRef }) templateList: TemplateRef<any>; | ||
|
||
componentList = PopoverListComponent; | ||
componentTabs = PopoverTabsComponent; | ||
textContent = 'Hello World'; | ||
component: any = this.componentList; | ||
items = []; | ||
|
||
interval: any; | ||
|
||
ngAfterViewInit() { | ||
this.items = [ | ||
this.componentList, | ||
this.componentTabs, | ||
this.templateList, | ||
this.templateTabs, | ||
this.textContent, | ||
]; | ||
} | ||
|
||
startRuntimeChange() { | ||
if (!this.interval) { | ||
this.interval = setInterval(() => { | ||
const random = this.items[Math.floor(Math.random() * this.items.length)]; | ||
this.changeComponent(random); | ||
}, 2000); | ||
} | ||
} | ||
|
||
stopRuntimeChange() { | ||
if (this.interval) { | ||
clearInterval(this.interval); | ||
this.interval = null; | ||
} | ||
} | ||
|
||
changeComponent(component) { | ||
this.popover.content = component; | ||
this.popover.rebuild(); | ||
} | ||
|
||
changeTrigger(trigger) { | ||
this.popover.trigger = trigger; | ||
this.popover.rebuild(); | ||
} | ||
|
||
changePlacement(placement) { | ||
this.popover.position = placement; | ||
this.popover.rebuild(); | ||
} | ||
|
||
ngOnDestroy() { | ||
clearInterval(this.interval); | ||
} | ||
} |
Oops, something went wrong.