Skip to content

Commit

Permalink
feat(design): implement tree in left nav (#1824)
Browse files Browse the repository at this point in the history
  • Loading branch information
damienwebdev committed Jul 26, 2023
1 parent e15b6a2 commit 3aa4727
Show file tree
Hide file tree
Showing 7 changed files with 304 additions and 44 deletions.
44 changes: 1 addition & 43 deletions apps/design-land/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,48 +1,6 @@
<daff-sidebar-viewport class="design-land__viewport" (backdropClicked)="toggleOpen()">
<daff-sidebar class="design-land__sidebar" [mode]="mode$ | async" [open]="open">
<daff-link-set>
<div daffLinkSetHeading>Foundations</div>
<a daff-link-set-item routerLink="color">Color</a>
<a daff-link-set-item routerLink="typography">Typography</a>
<a daff-link-set-item routerLink="variables">Variables</a>
</daff-link-set>
<daff-link-set>
<div daffLinkSetHeading>Atoms</div>
<a daff-link-set-item routerLink="button">Button</a>
<a daff-link-set-item routerLink="checkbox">Checkbox</a>
<a daff-link-set-item routerLink="loading-icon">Loading Icon</a>
<a daff-link-set-item routerLink="image">Image</a>
<div daff-link-set-item>Form</div>
<daff-link-set>
<a daff-link-set-item routerLink="input">Input</a>
</daff-link-set>
<a daff-link-set-item routerLink="progress-indicator">Progress Indicator</a>
<a daff-link-set-item routerLink="radio">Radio</a>
</daff-link-set>
<daff-link-set>
<div daffLinkSetHeading>Molecules</div>
<a daff-link-set-item routerLink="accordion">Accordion</a>
<a daff-link-set-item routerLink="article">Article</a>
<a daff-link-set-item routerLink="callout">Callout</a>
<a daff-link-set-item routerLink="card">Card</a>
<a daff-link-set-item routerLink="container">Container</a>
<a daff-link-set-item routerLink="feature">Feature</a>
<a daff-link-set-item routerLink="form">Form</a>
<daff-link-set>
<a daff-link-set-item routerLink="quantity-field">Quantity Field</a>
</daff-link-set>
<a daff-link-set-item routerLink="hero">Hero</a>
<a daff-link-set-item routerLink="image-gallery">Image Gallery</a>
<a daff-link-set-item routerLink="link-set">Link Set</a>
<a daff-link-set-item routerLink="list">List</a>
<a daff-link-set-item routerLink="navbar">Navbar</a>
<a daff-link-set-item routerLink="media-gallery">Media Gallery</a>
<a daff-link-set-item routerLink="menu">Menu</a>
<a daff-link-set-item routerLink="modal">Modal</a>
<a daff-link-set-item routerLink="paginator">Paginator</a>
<a daff-link-set-item routerLink="qty-dropdown">Quantity Dropdown</a>
<a daff-link-set-item routerLink="sidebar">Sidebar</a>
</daff-link-set>
<design-land-nav></design-land-nav>
</daff-sidebar>
<nav daff-sidebar-viewport-nav daff-navbar>
<button daff-icon-button (click)="toggleOpen()" aria-label="Open Menu">
Expand Down
1 change: 0 additions & 1 deletion apps/design-land/src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

&__sidebar {
--daff-sidebar-side-fixed-top-shift: 64px;
padding: 24px;
}

&__content {
Expand Down
2 changes: 2 additions & 0 deletions apps/design-land/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { DaffThemeSwitchButtonModule } from '@daffodil/theme-switch';

import { DesignLandAppRoutingModule } from './app-routing.module';
import { DesignLandAppComponent } from './app.component';
import { DesignLandNavModule } from './core/nav/nav.module';

@NgModule({
imports: [
Expand All @@ -30,6 +31,7 @@ import { DesignLandAppComponent } from './app.component';
DaffNavbarModule,
DaffButtonModule,
FontAwesomeModule,
DesignLandNavModule,
],
declarations: [
DesignLandAppComponent,
Expand Down
10 changes: 10 additions & 0 deletions apps/design-land/src/app/core/nav/nav.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<ul daff-tree [tree]="tree" *ngIf="tree$ | async as tree">
<ng-template #daffTreeItemWithChildrenTpl let-node>
<button daffTreeItem [node]="node">{{ node.title }} </button>
</ng-template>

<ng-template #daffTreeItemTpl let-node>
<a daffTreeItem [node]="node" [routerLink]="node.url">{{ node.title }}</a>
</ng-template>
</ul>

25 changes: 25 additions & 0 deletions apps/design-land/src/app/core/nav/nav.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { HttpClient } from '@angular/common/http';
import {
ChangeDetectionStrategy,
Component,
Input,
OnInit,
} from '@angular/core';
import { Observable } from 'rxjs';

import { DaffTreeData } from '@daffodil/design/tree';

@Component({
selector: 'design-land-nav',
templateUrl: './nav.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DesignLandNavComponent implements OnInit {
tree$: Observable<DaffTreeData<unknown>>;

constructor(private http: HttpClient){}

ngOnInit() {
this.tree$ = this.http.get<DaffTreeData<unknown>>('/assets/nav.json');
}
}
22 changes: 22 additions & 0 deletions apps/design-land/src/app/core/nav/nav.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

import { DaffTreeModule } from '@daffodil/design/tree';

import { DesignLandNavComponent } from './nav.component';

@NgModule({
declarations: [
DesignLandNavComponent,
],
exports: [
DesignLandNavComponent,
],
imports: [
CommonModule,
RouterModule,
DaffTreeModule,
],
})
export class DesignLandNavModule { }
244 changes: 244 additions & 0 deletions apps/design-land/src/assets/nav.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
{
"title": "",
"url": "/",
"id": "root",
"items": [
{
"title": "Foundations",
"url": "/",
"id": "foundations",
"items": [
{
"title": "Color",
"url": "color",
"id": "color",
"items": [],
"data": {}
},
{
"title": "Typography",
"url": "typography",
"id": "typography",
"items": [],
"data": {}
},
{
"title": "Variables",
"url": "variables",
"id": "variables",
"items": [],
"data": {}
}
],
"data": {}
},
{
"title": "Atoms",
"url": "/",
"id": "atoms",
"items": [
{
"title": "Button",
"url": "button",
"id": "button",
"items": [],
"data": {}
},
{
"title": "Checkbox",
"url": "checkbox",
"id": "checkbox",
"items": [],
"data": {}
},
{
"title": "Loading Icon",
"url": "loading-icon",
"id": "loading-icon",
"items": [],
"data": {}
},
{
"title": "Image",
"url": "image",
"id": "image",
"items": [],
"data": {}
},
{
"title": "Form",
"url": "/",
"id": "form",
"items": [
{
"title": "Input",
"url": "input",
"id": "input",
"items": [],
"data": {}
}
],
"data": {}
},
{
"title": "Progress Indicator",
"url": "progress-indicator",
"id": "progress-indicator",
"items": [],
"data": {}
},
{
"title": "Radio",
"url": "radio",
"id": "radio",
"items": [],
"data": {}
}
],
"data": {}
},
{
"title": "Molecules",
"url": "/",
"id": "molecules",
"items": [
{
"title": "Accordion",
"url": "accordion",
"id": "accordion",
"items": [],
"data": {}
},
{
"title": "Article",
"url": "article",
"id": "article",
"items": [],
"data": {}
},
{
"title": "Callout",
"url": "callout",
"id": "callout",
"items": [],
"data": {}
},
{
"title": "Card",
"url": "card",
"id": "card",
"items": [],
"data": {}
},
{
"title": "Container",
"url": "container",
"id": "container",
"items": [],
"data": {}
},
{
"title": "Feature",
"url": "feature",
"id": "feature",
"items": [],
"data": {}
},
{
"title": "Form",
"url": "form",
"id": "form",
"items": [
{
"title": "Quantity Field",
"url": "quantity-field",
"id": "quantity-field",
"items": [],
"data": {}
}
],
"data": {}
},
{
"title": "Hero",
"url": "hero",
"id": "hero",
"items": [],
"data": {}
},
{
"title": "Image Gallery",
"url": "image-gallery",
"id": "image-gallery",
"items": [],
"data": {}
},
{
"title": "Link Set",
"url": "link-set",
"id": "link-set",
"items": [],
"data": {}
},
{
"title": "List",
"url": "list",
"id": "list",
"items": [],
"data": {}
},
{
"title": "Navbar",
"url": "navbar",
"id": "navbar",
"items": [],
"data": {}
},
{
"title": "Media Gallery",
"url": "media-gallery",
"id": "media-gallery",
"items": [],
"data": {}
},
{
"title": "Menu",
"url": "menu",
"id": "menu",
"items": [],
"data": {}
},
{
"title": "Modal",
"url": "modal",
"id": "modal",
"items": [],
"data": {}
},
{
"title": "Paginator",
"url": "paginator",
"id": "paginator",
"items": [],
"data": {}
},
{
"title": "Quantity Dropdown",
"url": "qty-dropdown",
"id": "qty-dropdown",
"items": [],
"data": {}
},
{
"title": "Sidebar",
"url": "sidebar",
"id": "sidebar",
"items": [],
"data": {}
}
],
"data": {}
}
],
"data": {}
}

0 comments on commit 3aa4727

Please sign in to comment.