-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(chips): Initial skeleton/demo. (#1855)
Create the initial Chips skeleton with a very basic working demo of static, styled chips. References #120.
- Loading branch information
1 parent
333474e
commit edf5cdf
Showing
17 changed files
with
250 additions
and
0 deletions.
There are no files selected for viewing
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,12 @@ | ||
<div class="chips-demo"> | ||
<section> | ||
<h3>Static Chips</h3> | ||
|
||
<md-chip-list> | ||
<md-chip>Basic Chip</md-chip> | ||
<md-chip class="selected md-primary">Primary</md-chip> | ||
<md-chip class="selected md-accent">Accent</md-chip> | ||
<md-chip class="selected md-warn">Warn</md-chip> | ||
</md-chip-list> | ||
</section> | ||
</div> |
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,2 @@ | ||
.chips-demo { | ||
} |
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,10 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'chips-demo', | ||
templateUrl: 'chips-demo.html', | ||
styleUrls: ['chips-demo.scss'] | ||
}) | ||
export class ChipsDemo { | ||
} |
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
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
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
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,7 @@ | ||
# md-chips | ||
|
||
`md-chips` provides a horizontal display of (optionally) selectable, addable, and removable, | ||
items and an input to create additional ones (again; optional). You can read more about chips | ||
in the [Material Design spec](https://material.google.com/components/chips.html). | ||
|
||
This is a placeholder README for the eventual chips component. |
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,29 @@ | ||
@import '../core/theming/theming'; | ||
|
||
@mixin md-chips-theme($theme) { | ||
$is-dark-theme: map-get($theme, is-dark); | ||
$primary: map-get($theme, primary); | ||
$accent: map-get($theme, accent); | ||
$warn: map-get($theme, warn); | ||
$background: map-get($theme, background); | ||
|
||
.md-chip { | ||
background-color: #e0e0e0; | ||
color: rgba(0, 0, 0, 0.87); | ||
} | ||
|
||
.md-chip.selected { | ||
&.md-primary { | ||
background-color: md-color($primary, 500); | ||
color: md-contrast($primary, 500); | ||
} | ||
&.md-accent { | ||
background-color: md-color($accent, 500); | ||
color: md-contrast($accent, 500); | ||
} | ||
&.md-warn { | ||
background-color: md-color($warn, 500); | ||
color: md-contrast($warn, 500); | ||
} | ||
} | ||
} |
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,53 @@ | ||
import {async, ComponentFixture, TestBed} from '@angular/core/testing'; | ||
import {Component, DebugElement} from '@angular/core'; | ||
import {By} from '@angular/platform-browser'; | ||
import {MdChipList, MdChipsModule} from './index'; | ||
|
||
describe('MdChip', () => { | ||
let fixture: ComponentFixture<any>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [MdChipsModule.forRoot()], | ||
declarations: [ | ||
StaticChipList | ||
] | ||
}); | ||
|
||
TestBed.compileComponents(); | ||
})); | ||
|
||
describe('basic behaviors', () => { | ||
let chipListDebugElement: DebugElement; | ||
let chipListNativeElement: HTMLElement; | ||
let chipListInstance: MdChipList; | ||
let testComponent: StaticChipList; | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(StaticChipList); | ||
fixture.detectChanges(); | ||
|
||
chipListDebugElement = fixture.debugElement.query(By.directive(MdChipList)); | ||
chipListNativeElement = chipListDebugElement.nativeElement; | ||
chipListInstance = chipListDebugElement.componentInstance; | ||
testComponent = fixture.debugElement.componentInstance; | ||
}); | ||
|
||
it('adds the `md-chip-list` class', () => { | ||
expect(chipListNativeElement.classList).toContain('md-chip-list'); | ||
}); | ||
}); | ||
}); | ||
|
||
@Component({ | ||
template: ` | ||
<md-chip-list> | ||
<md-chip>{{name}} 1</md-chip> | ||
<md-chip>{{name}} 2</md-chip> | ||
<md-chip>{{name}} 3</md-chip> | ||
</md-chip-list> | ||
` | ||
}) | ||
class StaticChipList { | ||
name: 'Test'; | ||
} |
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,44 @@ | ||
import { | ||
ChangeDetectionStrategy, | ||
Component, | ||
ElementRef, | ||
ModuleWithProviders, | ||
NgModule, | ||
ViewEncapsulation | ||
} from '@angular/core'; | ||
|
||
import {MdChip} from './chip'; | ||
|
||
@Component({ | ||
moduleId: module.id, | ||
selector: 'md-chip-list', | ||
template: `<ng-content></ng-content>`, | ||
host: { | ||
// Properties | ||
'tabindex': '0', | ||
'role': 'listbox', | ||
'class': 'md-chip-list' | ||
}, | ||
styleUrls: ['chips.css'], | ||
encapsulation: ViewEncapsulation.None, | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class MdChipList { | ||
constructor(private _elementRef: ElementRef) {} | ||
|
||
ngAfterContentInit(): void {} | ||
} | ||
|
||
@NgModule({ | ||
imports: [], | ||
exports: [MdChipList, MdChip], | ||
declarations: [MdChipList, MdChip] | ||
}) | ||
export class MdChipsModule { | ||
static forRoot(): ModuleWithProviders { | ||
return { | ||
ngModule: MdChipsModule, | ||
providers: [] | ||
}; | ||
} | ||
} |
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 {async, ComponentFixture, TestBed} from '@angular/core/testing'; | ||
import {Component, DebugElement} from '@angular/core'; | ||
import {By} from '@angular/platform-browser'; | ||
import {MdChip, MdChipsModule} from './index'; | ||
|
||
describe('MdChip', () => { | ||
let fixture: ComponentFixture<any>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [MdChipsModule.forRoot()], | ||
declarations: [ | ||
SingleChip | ||
] | ||
}); | ||
|
||
TestBed.compileComponents(); | ||
})); | ||
|
||
describe('basic behaviors', () => { | ||
let chipDebugElement: DebugElement; | ||
let chipNativeElement: HTMLElement; | ||
let chipInstance: MdChip; | ||
let testComponent: SingleChip; | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(SingleChip); | ||
fixture.detectChanges(); | ||
|
||
chipDebugElement = fixture.debugElement.query(By.directive(MdChip)); | ||
chipNativeElement = chipDebugElement.nativeElement; | ||
chipInstance = chipDebugElement.componentInstance; | ||
testComponent = fixture.debugElement.componentInstance; | ||
}); | ||
|
||
it('adds the `md-chip` class', () => { | ||
expect(chipNativeElement.classList).toContain('md-chip'); | ||
}); | ||
}); | ||
}); | ||
|
||
@Component({ | ||
template: `<md-chip>{{name}}</md-chip>` | ||
}) | ||
class SingleChip { | ||
name: 'Test'; | ||
} |
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,17 @@ | ||
import { Component, ElementRef, Renderer } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'md-chip, [md-chip]', | ||
template: `<ng-content></ng-content>`, | ||
host: { | ||
// Properties | ||
'class': 'md-chip', | ||
'tabindex': '-1', | ||
'role': 'option' | ||
} | ||
}) | ||
export class MdChip { | ||
constructor(protected _renderer: Renderer, protected _elementRef: ElementRef) {} | ||
|
||
ngAfterContentInit(): void {} | ||
} |
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 @@ | ||
$md-chip-vertical-padding: 8px; | ||
$md-chip-horizontal-padding: 12px; | ||
|
||
.md-chip-list { | ||
padding: $md-chip-horizontal-padding; | ||
} | ||
|
||
.md-chip { | ||
display: inline-block; | ||
padding: $md-chip-vertical-padding $md-chip-horizontal-padding | ||
$md-chip-vertical-padding $md-chip-horizontal-padding; | ||
border-radius: $md-chip-horizontal-padding * 2; | ||
|
||
font-size: 13px; | ||
line-height: 16px; | ||
} |
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,2 @@ | ||
export * from './chip-list'; | ||
export * from './chip'; |
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
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
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