Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h4>Documentation</h4>
<h4>Basic</h4>
<ul>
<li>
<a routerLink="10k-rows">10k Rows</a>
<a routerLink="ten-k-rows">10k Rows</a>
</li>
<li>
<a routerLink="full-screen">Full Screen</a>
Expand Down
8 changes: 7 additions & 1 deletion src/app/app-routing.module.ts → src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { Routes } from '@angular/router';

// Route paths must match their component selectors without the `-demo` suffix.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have some sort of linting for this? We don't really test our demo app, meaning errors will only be noticed during runtime/by the reader.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My plan is to generate this file in the future. I guess this is easier than to lint it?

export const routes: Routes = [
{
path: '',
redirectTo: 'fluid-row-height',
pathMatch: 'full'
},
{
path: 'fluid-row-height',
data: { title: 'Fluid Row Height', sourcePath: 'basic/fluid-row-height.component.ts' },
loadComponent: () =>
import('./basic/fluid-row-height.component').then(c => c.FluidRowHeightComponent)
},
// Basic
{
path: '10k-rows',
path: 'ten-k-rows',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this change doesn't make much sense. Everything is called 10k-rows (file, title, ...), so why do we suddenly call it ten-k? We should align this here, no hard feelings into which direction.

data: { title: '10k Rows', sourcePath: 'basic/10k-rows.component.ts' },
loadComponent: () => import('./basic/10k-rows.component').then(c => c.TenKRowsComponent)
},
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { bootstrapApplication } from '@angular/platform-browser';
import { provideRouter, withHashLocation } from '@angular/router';
import { providedNgxDatatableConfig } from '@siemens/ngx-datatable';

import { routes } from './app/app-routing.module';
import { AppComponent } from './app/app.component';
import { routes } from './app/app.routes';

bootstrapApplication(AppComponent, {
providers: [
Expand Down
56 changes: 19 additions & 37 deletions src/main.web-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ import { createCustomElement } from '@angular/elements';
import { createApplication } from '@angular/platform-browser';
import { providedNgxDatatableConfig } from '@siemens/ngx-datatable';

import { routes } from './app/app.routes';
import { DATA_ASSETS_URL } from './app/data.service';

const exampleLoaders = new Map(
routes.flatMap(route =>
route.path && route.loadComponent ? [[route.path, route.loadComponent] as const] : []
)
);

declare global {
interface Window {
loadDatatableExample(example: string): Promise<void>;
Expand All @@ -27,44 +34,19 @@ createApplication({
})
.then(appRef => {
window.loadDatatableExample = async example => {
switch (example) {
case 'fluid-row-height': {
registerExample(
'ngx-datatable-fluid-row-height',
await import('./app/basic/fluid-row-height.component').then(
c => c.FluidRowHeightComponent
),
appRef
);
return;
}
case 'standard-column': {
registerExample(
'ngx-datatable-standard-column',
await import('./app/columns/fixed-column.component').then(c => c.FixedColumnComponent),
appRef
);
return;
}
case 'flex-column': {
registerExample(
'ngx-datatable-flex-column',
await import('./app/columns/flex-column.component').then(c => c.FlexColumnComponent),
appRef
);
return;
}
case 'force-column': {
registerExample(
'ngx-datatable-force-column',
await import('./app/columns/force-column.component').then(c => c.ForceColumnComponent),
appRef
);
return;
}
default:
throw new Error(`Unknown datatable example: ${example}`);
const loadComponent = exampleLoaders.get(example);
if (!loadComponent) {
throw new Error(`Unknown datatable example: ${example}`);
}

const componentPromise = loadComponent();
if (!(componentPromise instanceof Promise)) {
throw new Error(`Invalid datatable example component: ${example}`);
}

const componentResult = await componentPromise;
const component = 'default' in componentResult ? componentResult.default : componentResult;
registerExample(`ngx-datatable-${example}`, component, appRef);
};

window.dispatchEvent(new Event('ngx-datatable-examples-ready'));
Expand Down
Loading