Skip to content

Commit

Permalink
feat(chips): added Chip component
Browse files Browse the repository at this point in the history
  • Loading branch information
Lee Nathan authored and brandyscarney committed Aug 24, 2016
1 parent 57eda7f commit 421f637
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/components/chip/chip.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Directive, ElementRef, Renderer, Attribute } from '@angular/core';

import { Config } from '../../config/config';

/**
* @name Chip
* @module ionic
* @description
* Chips represent complex entities in small blocks, such as a contact.
* @see {@link /docs/v2/components/#chips Chips Component Docs}
**/

@Directive({
selector: 'ion-chip'
})
export class Chip {

constructor(
config: Config,
private _elementRef: ElementRef,
private _renderer: Renderer
) {
let element = _elementRef.nativeElement;

this._readAttrs(element);
}

/**
* @private
*/
private _readAttrs(element: HTMLElement) {
let elementAttrs = element.attributes;
let attrName: string;

console.info("mushroom");

for (let i = 0, l = elementAttrs.length; i < l; i++) {
if (elementAttrs[i].value !== '') continue;

attrName = elementAttrs[i].name;

// Ignore attributes item-left, item-right
if (attrName.indexOf('item') === -1) {
this._setClass(attrName);
}
}
}

/**
* @private
*/
private _setClass(color: string) {
this._renderer.setElementClass(this._elementRef.nativeElement, 'chip-' + color, true);
}
}
3 changes: 3 additions & 0 deletions src/config/directives.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { NavPush } from '../components/nav/nav-push';
import { NavbarTemplate, Navbar } from '../components/navbar/navbar';
import { ShowWhen, HideWhen } from '../components/show-hide-when/show-hide-when';
import { Typography } from '../components/typography/typography';
import { Chip } from '../components/chip/chip';

/**
* @private
Expand All @@ -67,6 +68,7 @@ import { Typography } from '../components/typography/typography';
* - MenuClose
* - Badge
* - Button
* - Chip
* - Content
* - Scroll
* - InfiniteScroll
Expand Down Expand Up @@ -131,6 +133,7 @@ export const IONIC_DIRECTIVES: any[] = [
Backdrop,
Badge,
Button,
Chip,
Content,
Scroll,
InfiniteScroll,
Expand Down

0 comments on commit 421f637

Please sign in to comment.