Skip to content

Commit

Permalink
fix: tab routing EDITOR-267
Browse files Browse the repository at this point in the history
  • Loading branch information
felixroos committed Apr 26, 2019
1 parent 09a2298 commit b0c6065
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/lib/utility/tabs/tabs.component.ts
Expand Up @@ -28,7 +28,7 @@ export class TabsComponent implements AfterContentInit {
if (!url || !this.tabs) {
return;
}
const paths = url.split('/');
const paths = new URL(url, window.location.origin).pathname.split('/');
const match = this.tabs.find((tab) => paths[paths.length - 1].indexOf(tab.route) !== -1);
if (match) {
this.select(match, true);
Expand Down
31 changes: 26 additions & 5 deletions src/app/demo.routes.ts
Expand Up @@ -178,11 +178,32 @@ export const demoRoutes: Routes = [
},
{
path: 'tabs',
component: TabsDemoComponent,
data: {
paths: ['tabs/tabs-demo.component.html', 'tabs/tabs-demo.component.ts'],
links: ['components/TabsComponent.html#readme', 'modules/UtilityModule.html'] // TODO: enhance readme
}
children: [
{
path: '',
component: TabsDemoComponent,
data: {
paths: ['tabs/tabs-demo.component.html', 'tabs/tabs-demo.component.ts'],
links: ['components/TabsComponent.html#readme', 'modules/UtilityModule.html'] // TODO: enhance readme
}
},
{
path: 'foo',
component: TabsDemoComponent,
data: {
paths: ['tabs/tabs-demo.component.html', 'tabs/tabs-demo.component.ts'],
links: ['components/TabsComponent.html#readme', 'modules/UtilityModule.html'] // TODO: enhance readme
}
},
{
path: 'bar',
component: TabsDemoComponent,
data: {
paths: ['tabs/tabs-demo.component.html', 'tabs/tabs-demo.component.ts'],
links: ['components/TabsComponent.html#readme', 'modules/UtilityModule.html'] // TODO: enhance readme
}
},
]
},
{
path: 'login-form',
Expand Down
8 changes: 7 additions & 1 deletion src/app/tabs/tabs-demo.component.html
@@ -1,6 +1,6 @@
<h2>Tabs</h2>

<ec-tabs>
<ec-tabs>
<ec-tab label="Bench">
<img src="https://unsplash.it/300/400">
</ec-tab>
Expand All @@ -13,4 +13,10 @@ <h2>Tabs</h2>
<ec-tab label="Desert">
<img src="https://unsplash.it/200/100">
</ec-tab>
<ec-tab label="foo" route="foo">
<img src="https://unsplash.it/200/100">
</ec-tab>
<ec-tab label="bar" route="bar">
<img src="https://unsplash.it/200/100">
</ec-tab>
</ec-tabs>

0 comments on commit b0c6065

Please sign in to comment.