Skip to content

Commit

Permalink
feat(docs): add capability to use playground module in the docs appli…
Browse files Browse the repository at this point in the history
…cation (#310)
  • Loading branch information
tibing-old-email authored and nnixaa committed Mar 22, 2018
1 parent aa46f65 commit 7676095
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 34 deletions.
2 changes: 1 addition & 1 deletion docs/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import { BlockHelperService } from './docs/utils/block-helper.service';
NbLayoutModule,
NbTabsetModule,
NbMenuModule.forRoot(),
NbThemeModule.forRoot({ name: 'default' }),
NbThemeModule.forRoot({ name: 'docs' }),
NbSidebarModule.forRoot(),
RouterModule.forRoot(routes, { useHash: true }),
],
Expand Down
4 changes: 4 additions & 0 deletions docs/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export const routes: Routes = [
component: NgdPageComponent,
}],
},
{
path: 'example',
loadChildren: '../../src/playground/playground.module#NbPlaygroundModule',
},
{
path: '**',
redirectTo: 'home',
Expand Down
16 changes: 14 additions & 2 deletions docs/app/styles/_themes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@
@import '../../../src/framework/theme/styles/themes';

// which themes you what to enable (empty to enable all - not recommended)
$nb-enabled-themes: (default);
$nb-enabled-themes: (docs, default);

// TODO remove
$nb-themes: nb-register-theme((
landing-font: Exo,
landing-golden: #ffd22d,
landing-red: #fc3b41,
landing-fg: #b7b7fe,
landing-fg-light: #e0e0ff,
landing-highlight: #42db7d,
landing-primary: #8a7fff,
landing-bg: #13113b,
), default, default);

$nb-themes: nb-register-theme((
font-main: Roboto,
Expand Down Expand Up @@ -113,5 +125,5 @@ $nb-themes: nb-register-theme((

tabs-font-size: 1.25rem,
tabs-active-font-weight: font-weight-normal
), default, default);
), docs, default);

4 changes: 4 additions & 0 deletions docs/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@
"exclude": [
"test.ts",
"**/*.spec.ts"
],
"include": [
"../docs/**/*",
"../src/playground/playground.module.ts"
]
}
8 changes: 4 additions & 4 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ import {
NbMenuTestComponent,
} from './menu-test/menu-test.component';
import { NbUserTestComponent } from './user-test/user-test.component';
import { NbDynamicToAddComponent, NbThemeDynamicTestComponent } from './layout-test/theme-dynamic-test.component';
import { NbThemeDynamicTestComponent } from './layout-test/theme-dynamic-test.component';
import { NbActionsTestComponent } from './actions-test/actions-test.component';
import { NbBootstrapTestComponent } from './bootstrap-test/bootstrap-test.component';
import { NbPopoverTestComponent } from './popover-test/popover-test.component';
import { NbContextMenuTestComponent } from './context-menu-test/context-menu-test.component';

import { routes } from './app.routes';
Expand All @@ -83,6 +82,8 @@ import { NbCardTestComponent } from './card-test/card-test.component';
import { NbAclTestComponent } from './acl-test/acl-test.component';
import { AuthGuard } from './auth-guard.service';
import { RoleProvider } from './role.provider';
import { NbDynamicToAddComponent } from './dynamic.component';
import { NbPlaygroundModule } from '../playground/playground.module';

const NB_TEST_COMPONENTS = [
NbAppComponent,
Expand Down Expand Up @@ -113,12 +114,10 @@ const NB_TEST_COMPONENTS = [
NbSearchTestComponent,
NbSearchTestCustomizedComponent,
NbBootstrapTestComponent,
NbDynamicToAddComponent,
NbThemeDynamicTestComponent,
NbThemeBreakpointTestComponent,
NbActionsTestComponent,
NbFormsTestComponent,
NbPopoverTestComponent,
NbCheckboxTestComponent,
NbAclTestComponent,
NbContextMenuTestComponent,
Expand All @@ -143,6 +142,7 @@ const NB_TEST_COMPONENTS = [
NbPopoverModule,
NbContextMenuModule,
NbCheckboxModule,
NbPlaygroundModule,
NbAuthModule.forRoot({
forms: {
login: {
Expand Down
7 changes: 2 additions & 5 deletions src/app/app.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { NbSidebarTestComponent } from './sidebar-test/sidebar-test.component';
import { NbTabsetTestComponent } from './tabset-test/tabset-test.component';
import { NbUserTestComponent } from './user-test/user-test.component';
import { NbCardTestComponent } from './card-test/card-test.component';
import { NbPopoverTestComponent } from './popover-test/popover-test.component';
import {
NbAuthComponent,
NbLoginComponent,
Expand All @@ -54,8 +53,10 @@ import { AuthGuard } from './auth-guard.service';
import { NbCheckboxTestComponent } from './checkbox-test/checkbox-test.component';
import { NbAclTestComponent } from './acl-test/acl-test.component';
import { NbContextMenuTestComponent } from './context-menu-test/context-menu-test.component';
import { routes as playgroundRoutes } from '../playground/playground-routing.module';

export const routes: Routes = [
...playgroundRoutes,
{
path: '',
component: NbCardTestComponent,
Expand Down Expand Up @@ -251,10 +252,6 @@ export const routes: Routes = [
path: 'forms',
component: NbFormsTestComponent,
},
{
path: 'popover',
component: NbPopoverTestComponent,
},
{
path: 'acl',
component: NbAclTestComponent,
Expand Down
15 changes: 15 additions & 0 deletions src/app/dynamic.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, Input } from '@angular/core';

@Component({
selector: 'nb-dynamic-to-add',
template: `
<div>
<strong>hello from dynamically inserted component: {{text}}</strong>
</div>
`,
})
export class NbDynamicToAddComponent {

@Input()
text: string = '';
}
24 changes: 6 additions & 18 deletions src/app/layout-test/theme-dynamic-test.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,10 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { Component, Input, ComponentFactoryResolver } from '@angular/core';
import { Component, ComponentFactoryResolver } from '@angular/core';

import { NbThemeService } from '@nebular/theme';

@Component({
selector: 'nb-dynamic-to-add',
template: `
<div>
<strong>hello from dynamically inserted component: {{text}}</strong>
</div>
`,
})
export class NbDynamicToAddComponent {

@Input()
text: string = '';
}
import { NbDynamicToAddComponent } from '../dynamic.component';

@Component({
selector: 'nb-dynamic-test',
Expand All @@ -34,7 +21,7 @@ export class NbDynamicToAddComponent {
</nb-layout-header>
<nb-sidebar right>
Sidebar content
Sidebar content
</nb-sidebar>
<nb-layout-column>
Expand All @@ -51,10 +38,11 @@ export class NbDynamicToAddComponent {
&copy; Akveo 2017
</nb-layout-footer>
</nb-layout>
`,
`,
})
export class NbThemeDynamicTestComponent {
constructor(private themeService: NbThemeService, private componentFactoryResolver: ComponentFactoryResolver) {}
constructor(private themeService: NbThemeService, private componentFactoryResolver: ComponentFactoryResolver) {
}

addDynamicComponent() {
this.themeService.appendToLayoutTop(NbDynamicToAddComponent).subscribe(cRef => console.info(cRef));
Expand Down
1 change: 1 addition & 0 deletions src/playground/examples/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './popover-example.component';
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
*/

import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NbDynamicToAddComponent } from '../layout-test/theme-dynamic-test.component';
import { NbDynamicToAddComponent } from '../../app/dynamic.component';

@Component({
selector: 'nb-popover-test',
selector: 'nb-popover-example',
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<nb-layout>
<nb-layout-column>
<nb-card>
<nb-card-header>Content Type</nb-card-header>
<nb-card-body>
Expand Down Expand Up @@ -146,11 +145,12 @@ import { NbDynamicToAddComponent } from '../layout-test/theme-dynamic-test.compo
</button>
</nb-card-body>
</nb-card>
</nb-layout-column>
</nb-layout>
`,
})
export class NbPopoverTestComponent {
export class NbPopoverExampleComponent {

customPopoverComponent = NbDynamicToAddComponent;

Expand Down
28 changes: 28 additions & 0 deletions src/playground/playground-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { NbPopoverExampleComponent } from './examples';
import { NbPlaygroundComponent } from './playground.component';


export const routes: Routes = [
{
path: '',
component: NbPlaygroundComponent,
children: [
{ path: 'popover', component: NbPopoverExampleComponent },
],
},
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class NbPlaygroundRoutingModule {
}
22 changes: 22 additions & 0 deletions src/playground/playground.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { Component, OnInit } from '@angular/core';
import { NbThemeService } from '@nebular/theme';

@Component({
selector: 'nb-playground',
template: '<router-outlet></router-outlet>',
})

export class NbPlaygroundComponent implements OnInit {
constructor(private themeService: NbThemeService) {
}

ngOnInit() {
this.themeService.changeTheme('default');
}
}
50 changes: 50 additions & 0 deletions src/playground/playground.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* @license
* Copyright Akveo. All Rights Reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*/

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { NbCardModule, NbLayoutModule, NbPopoverModule } from '@nebular/theme';

import { NbPlaygroundRoutingModule } from './playground-routing.module';
import { NbPlaygroundComponent } from './playground.component';
import { NbPopoverExampleComponent } from './examples';
import { NbDynamicToAddComponent } from '../app/dynamic.component';

export const NB_MODULES = [
NbCardModule,
NbLayoutModule,
NbPopoverModule,
];

export const NB_EXAMPLE_COMPONENTS = [
NbPopoverExampleComponent,
];

export const NB_ENTRY_COMPONENTS = [
NbDynamicToAddComponent,
];

@NgModule({
imports: [
CommonModule,
NbPlaygroundRoutingModule,
...NB_MODULES,
],
exports: [
...NB_ENTRY_COMPONENTS,
...NB_EXAMPLE_COMPONENTS,
],
declarations: [
NbPlaygroundComponent,
...NB_ENTRY_COMPONENTS,
...NB_EXAMPLE_COMPONENTS,
],
entryComponents: [
...NB_ENTRY_COMPONENTS,
],
})
export class NbPlaygroundModule {
}

0 comments on commit 7676095

Please sign in to comment.