Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #346 from IgniteUI/PMiteva/dropdown-template
Create dropdown template
- Loading branch information
Showing
7 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
templates/angular/igx-ts/dropdown/default/files/src/app/__path__/__name__.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
:host { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
.drop-down-wrapper { | ||
margin: 10px; | ||
width: 200px; | ||
} | ||
button { | ||
width: 100%; | ||
} |
14 changes: 14 additions & 0 deletions
14
templates/angular/igx-ts/dropdown/default/files/src/app/__path__/__name__.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<p>igx-dropdown component.</p> | ||
<p>You can read more about configuring the igx-dropdown component in the | ||
<a href="https://github.com/IgniteUI/igniteui-angular/blob/master/projects/igniteui-angular/src/lib/drop-down/README.md" target="_blank">README</a> or the | ||
<a href="https://www.infragistics.com/products/ignite-ui-angular/angular/components/drop_down.html" target="_blank">official documentation</a>.</p> | ||
|
||
<div class="sample-wrapper drop-down-wrapper"> | ||
<button #button igxButton="raised" igxRipple (click)="toggleDropDown($event)">Toggle dropdown</button> | ||
<igx-drop-down #dropdown> | ||
<igx-drop-down-item *ngFor="let item of items" disabled={{item.disabled}} isHeader={{item.header}}> | ||
{{ item.field }} | ||
</igx-drop-down-item> | ||
</igx-drop-down> | ||
</div> | ||
|
27 changes: 27 additions & 0 deletions
27
templates/angular/igx-ts/dropdown/default/files/src/app/__path__/__name__.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { async, TestBed, ComponentFixture } from '@angular/core/testing'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { $(ClassName)Component } from './$(filePrefix).component'; | ||
import { IgxDropDownModule } from 'igniteui-angular'; | ||
|
||
describe('$(ClassName)Component', () => { | ||
let component: $(ClassName)Component; | ||
let fixture: ComponentFixture<$(ClassName)Component>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [$(ClassName)Component], | ||
imports: [ IgxComboModule, NoopAnimationsModule] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent($(ClassName)Component); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
47 changes: 47 additions & 0 deletions
47
templates/angular/igx-ts/dropdown/default/files/src/app/__path__/__name__.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; | ||
import { | ||
IgxDropDownComponent, | ||
ConnectedPositioningStrategy, | ||
OverlaySettings, | ||
PositionSettings, | ||
NoOpScrollStrategy, | ||
HorizontalAlignment, | ||
VerticalAlignment | ||
} from 'igniteui-angular'; | ||
import { data } from './local-data'; | ||
|
||
@Component({ | ||
selector: 'app-$(filePrefix)', | ||
templateUrl: './$(filePrefix).component.html', | ||
styleUrls: ['./$(filePrefix).component.css'] | ||
}) | ||
|
||
export class $(ClassName)Component implements OnInit { | ||
@ViewChild(IgxDropDownComponent) public igxDropDown: IgxDropDownComponent; | ||
@ViewChild('button') public button: ElementRef; | ||
|
||
private _positionSettings: PositionSettings = { | ||
horizontalStartPoint: HorizontalAlignment.Left, | ||
verticalStartPoint: VerticalAlignment.Bottom | ||
}; | ||
|
||
private _overlaySettings: OverlaySettings = { | ||
closeOnOutsideClick: true, | ||
modal: false, | ||
positionStrategy: new ConnectedPositioningStrategy(this._positionSettings), | ||
scrollStrategy: new NoOpScrollStrategy() | ||
}; | ||
public items: any[] = []; | ||
|
||
constructor() { } | ||
|
||
public ngOnInit() { | ||
this.items = data; | ||
this.igxDropDown.width = '200px'; | ||
} | ||
|
||
public toggleDropDown(eventArgs) { | ||
this._overlaySettings.positionStrategy.settings.target = eventArgs.target; | ||
this.igxDropDown.toggle(this._overlaySettings); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
templates/angular/igx-ts/dropdown/default/files/src/app/__path__/local-data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const data: any[] = [ | ||
{ field: "EU", header: true }, | ||
{ field: "Germany" }, | ||
{ field: "Bulgaria" }, | ||
{ field: "UK", disabled: true }, | ||
{ field: "NA", header: true }, | ||
{ field: "Canada" }, | ||
{ field: "USA" }, | ||
{ field: "Mexico" }, | ||
{ field: "SA", header: true }, | ||
{ field: "Brazil" }, | ||
{ field: "Colombia", disabled: true }, | ||
{ field: "Argentina" }]; | ||
|
||
export { data }; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { IgniteUIForAngularTemplate } from "../../../../../lib/templates/IgniteUIForAngularTemplate"; | ||
|
||
class IgxDropDownTemplate extends IgniteUIForAngularTemplate { | ||
constructor() { | ||
super(__dirname); | ||
this.components = ["Drop Down"]; | ||
this.controlGroup = "Data Entry & Display"; | ||
this.listInComponentTemplates = true; | ||
this.id = "dropdown"; | ||
this.projectType = "igx-ts"; | ||
this.name = "Drop Down"; | ||
this.description = "Basic IgxDropDown sample"; | ||
this.dependencies = [{ | ||
from: "igniteui-angular", | ||
import: ["IgxDropDownModule", "IgxButtonModule", "IgxToggleModule"] | ||
}]; | ||
} | ||
} | ||
module.exports = new IgxDropDownTemplate(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
import { BaseComponent } from "../../../../lib/BaseComponent"; | ||
|
||
class IgxDropDownComponent extends BaseComponent { | ||
/** | ||
* | ||
*/ | ||
constructor() { | ||
super(__dirname); | ||
this.name = "Drop Down"; | ||
this.group = "Data Entry & Display"; | ||
} | ||
} | ||
module.exports = new IgxDropDownComponent(); |