Skip to content

Commit

Permalink
feat(design): create tree component
Browse files Browse the repository at this point in the history
  • Loading branch information
xelaint committed Sep 14, 2021
1 parent 63448ad commit f3117ae
Show file tree
Hide file tree
Showing 40 changed files with 1,223 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/design-land/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const appRoutes: Routes = [
{ path: 'quantity-field', loadChildren: () => import('./quantity-field/quantity-field.module').then(m => m.DesignLandQuantityFieldModule) },
{ path: 'sidebar', loadChildren: () => import('./sidebar/sidebar.module').then(m => m.DesignLandSidebarModule) },
{ path: 'radio', loadChildren: () => import('./radio/radio.module').then(m => m.DesignLandRadioModule) },
{ path: 'tree', loadChildren: () => import('./tree/tree.module').then(m => m.DesignLandTreeModule) },
{ path: 'typography', loadChildren: () => import('./typography/typography.module').then(m => m.DesignLandTypographyModule) },
];

Expand Down
4 changes: 4 additions & 0 deletions apps/design-land/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Component,
Injector,
ComponentFactoryResolver,
ChangeDetectionStrategy,
} from '@angular/core';
import { createCustomElement } from '@angular/elements';

Expand All @@ -18,13 +19,15 @@ import { MEDIA_GALLERY_EXAMPLES } from '@daffodil/design/media-gallery/examples'
import { MODAL_EXAMPLES } from '@daffodil/design/modal/examples';
import { QUANTITY_FIELD_EXAMPLES } from '@daffodil/design/quantity-field/examples';
import { RADIO_EXAMPLES } from '@daffodil/design/radio/examples';
import { TREE_EXAMPLES } from '@daffodil/design/tree/examples';

import { createCustomElementFromExample } from './core/elements/create-element-from-example';

@Component({
selector: 'design-land-app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class DesignLandAppComponent {
constructor(
Expand All @@ -45,6 +48,7 @@ export class DesignLandAppComponent {
...MODAL_EXAMPLES,
...QUANTITY_FIELD_EXAMPLES,
...LIST_EXAMPLES,
...TREE_EXAMPLES,
].map((componentExample) => createCustomElementFromExample(componentExample, injector))
.map((customElement) => {
// Register the custom element with the browser.
Expand Down
21 changes: 21 additions & 0 deletions apps/design-land/src/app/tree/tree-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import {
Routes,
RouterModule,
} from '@angular/router';

import { DesignLandTreeComponent } from './tree.component';

export const treeRoutes: Routes = [
{ path: '', component: DesignLandTreeComponent },
];

@NgModule({
imports: [
RouterModule.forChild(treeRoutes),
],
exports: [
RouterModule,
],
})
export class DesignLandTreeRoutingModule {}
10 changes: 10 additions & 0 deletions apps/design-land/src/app/tree/tree.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<daff-article>
<h1 daffArticleTitle>Tree</h1>
<p daffArticleLead>Tree is used to display hierarchial data.</p>

<h2>Basic Tree</h2>
<design-land-example-viewer-container example="basic-tree"></design-land-example-viewer-container>

<h2>Nested Tree</h2>
<design-land-example-viewer-container example="nested-tree"></design-land-example-viewer-container>
</daff-article>
11 changes: 11 additions & 0 deletions apps/design-land/src/app/tree/tree.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
daff-accordion {
max-width: 800px;
}

.design-land-accordion-example {
margin-bottom: 40px;
}

a {
font-weight: 400;
}
31 changes: 31 additions & 0 deletions apps/design-land/src/app/tree/tree.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {
waitForAsync,
ComponentFixture,
TestBed,
} from '@angular/core/testing';

import { DesignLandTreeComponent } from './tree.component';

describe('DesignLandTreeComponent', () => {
let component: DesignLandTreeComponent;
let fixture: ComponentFixture<DesignLandTreeComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
DesignLandTreeComponent,
],
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(DesignLandTreeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
8 changes: 8 additions & 0 deletions apps/design-land/src/app/tree/tree.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'design-land-tree',
templateUrl: './tree.component.html',
styleUrls: ['./tree.component.scss'],
})
export class DesignLandTreeComponent {}
47 changes: 47 additions & 0 deletions apps/design-land/src/app/tree/tree.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { CommonModule } from '@angular/common';
import {
ComponentFactoryResolver,
Injector,
NgModule,
} from '@angular/core';
import { createCustomElement } from '@angular/elements';

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

import { DesignLandExampleViewerModule } from '../core/code-preview/container/example-viewer.module';
import { DesignLandTreeRoutingModule } from './tree-routing.module';
import { DesignLandTreeComponent } from './tree.component';

@NgModule({
declarations: [
DesignLandTreeComponent,
],
imports: [
CommonModule,
DesignLandTreeRoutingModule,
DesignLandExampleViewerModule,
DaffTreeModule,
DaffArticleModule,
],
})
export class DesignLandTreeModule {
constructor(
injector: Injector,
private componentFactoryResolver: ComponentFactoryResolver,
) {
TREE_EXAMPLES
.map((classConstructor) => ({
element: createCustomElement(classConstructor, { injector }),
class: classConstructor,
}))
.map((customElement) => {
// Register the custom element with the browser.
customElements.define(
this.componentFactoryResolver.resolveComponentFactory<unknown>(customElement.class).selector + '-example',
customElement.element,
);
});
}
}
2 changes: 2 additions & 0 deletions libs/design/src/scss/theming/_theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@import '../../molecules/paginator/paginator-theme';
@import '../../molecules/sidebar/sidebar/sidebar-theme';
@import '../../molecules/sidebar/sidebar-viewport/sidebar-viewport-theme';
@import '../../../tree/src/tree-item/tree-item-theme.scss';

//
// Generates the styles of a @daffodil/design theme.
Expand Down Expand Up @@ -49,4 +50,5 @@
@include daff-paginator-theme($theme);
@include daff-sidebar-theme($theme);
@include daff-sidebar-viewport-theme($theme);
@include daff-tree-item-theme($theme);
}
9 changes: 9 additions & 0 deletions libs/design/tree/examples/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/design/examples",
"deleteDestPath": false,
"lib": {
"entryFile": "src/index.ts",
"styleIncludePaths": ["../../src/scss"]
}
}
3 changes: 3 additions & 0 deletions libs/design/tree/examples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "@daffodil/design/tree/examples"
}
26 changes: 26 additions & 0 deletions libs/design/tree/examples/src/basic-tree/basic-tree.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<daff-tree>
<daff-tree-item>
<div daffTreeItemTitle>Foundations</div>
<a daff-tree-item [selected]="rla.isActive" routerLink="/tree" routerLinkActive #rla="routerLinkActive">
<div daffTreeItemTitle>Color</div>
</a>
<a daff-tree-item routerLink="/tree">
<div daffTreeItemTitle>Typography</div>
</a>
</daff-tree-item>
<daff-tree-item>
<div daffTreeItemTitle>Packages</div>
<daff-tree-item>
<div daffTreeItemTitle>@daffodil/authorizenet</div>
<a daff-tree-item>
<div daffTreeItemTitle>Installation</div>
</a>
</daff-tree-item>
<a daff-tree-item>
<div daffTreeItemTitle>@daffodil/cart</div>
</a>
<a daff-tree-item>
<div daffTreeItemTitle>@daffodil/category</div>
</a>
</daff-tree-item>
</daff-tree>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
// eslint-disable-next-line @angular-eslint/component-selector
selector: 'basic-tree',
templateUrl: './basic-tree.component.html',
})
export class BasicTreeComponent {}
21 changes: 21 additions & 0 deletions libs/design/tree/examples/src/basic-tree/basic-tree.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

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

import { BasicTreeComponent } from './basic-tree.component';


@NgModule({
declarations: [
BasicTreeComponent,
],
exports: [
BasicTreeComponent,
],
imports: [
DaffTreeModule,
RouterModule,
],
})
export class BasicTreeModule { }
1 change: 1 addition & 0 deletions libs/design/tree/examples/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './public_api';
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<daff-tree>
<daff-tree-item>
<div daffTreeItemTitle>Design</div>
<daff-tree-item>
<div daffTreeItemTitle>Foundations</div>
<a daff-tree-item [selected]="rla.isActive" routerLink="/tree" routerLinkActive #rla="routerLinkActive">
<div daffTreeItemTitle>Color</div>
</a>
<a daff-tree-item routerLink="/tree">
<div daffTreeItemTitle>Typography</div>
</a>
</daff-tree-item>
<daff-tree-item>
<div daffTreeItemTitle>Components</div>
<daff-tree-item>
<div daffTreeItemTitle>Atoms</div>
<a daff-tree-item>
<div daffTreeItemTitle>Button</div>
</a>
<a daff-tree-item>
<div daffTreeItemTitle>Forms</div>
<a daff-tree-item>
<div daffTreeItemTitle>Checkbox</div>
</a>
<a daff-tree-item>
<div daffTreeItemTitle>Form Field</div>
</a>
<a daff-tree-item>
<div daffTreeItemTitle>Input</div>
</a>
<a daff-tree-item>
<div daffTreeItemTitle>Radio</div>
</a>
<a daff-tree-item>
<div daffTreeItemTitle>Select</div>
</a>
<a daff-tree-item>
<div daffTreeItemTitle>Textarea</div>
</a>
</a>
</daff-tree-item>
</daff-tree-item>
</daff-tree-item>
</daff-tree>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
// eslint-disable-next-line @angular-eslint/component-selector
selector: 'nested-tree',
templateUrl: './nested-tree.component.html',
})
export class NestedTreeComponent {}
21 changes: 21 additions & 0 deletions libs/design/tree/examples/src/nested-tree/nested-tree.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';

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

import { NestedTreeComponent } from './nested-tree.component';


@NgModule({
declarations: [
NestedTreeComponent,
],
exports: [
NestedTreeComponent,
],
imports: [
DaffTreeModule,
RouterModule,
],
})
export class NestedTreeModule { }
9 changes: 9 additions & 0 deletions libs/design/tree/examples/src/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { BasicTreeComponent } from './basic-tree/basic-tree.component';
import { NestedTreeComponent } from './nested-tree/nested-tree.component';
export { BasicTreeModule } from './basic-tree/basic-tree.module';
export { NestedTreeModule } from './nested-tree/nested-tree.module';

export const TREE_EXAMPLES = [
BasicTreeComponent,
NestedTreeComponent,
];
9 changes: 9 additions & 0 deletions libs/design/tree/ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/design/tree",
"deleteDestPath": false,
"lib": {
"entryFile": "src/index.ts",
"styleIncludePaths": ["../src/scss"]
}
}
3 changes: 3 additions & 0 deletions libs/design/tree/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "@daffodil/design/tree"
}
Loading

0 comments on commit f3117ae

Please sign in to comment.