-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05ca73b
commit bfd4bd8
Showing
12 changed files
with
373 additions
and
1 deletion.
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,21 @@ | ||
.p-chip { | ||
display: inline-flex; | ||
align-items: center; | ||
} | ||
|
||
.p-chip-text { | ||
line-height: 1.5; | ||
} | ||
|
||
.p-chip-icon.pi { | ||
line-height: 1.5; | ||
} | ||
|
||
.pi-chip-remove-icon { | ||
line-height: 1.5; | ||
cursor: pointer; | ||
} | ||
|
||
.p-chip img { | ||
border-radius: 50%; | ||
} |
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,23 @@ | ||
import { TestBed, ComponentFixture } from '@angular/core/testing'; | ||
import { Chip, ChipModule } from './chip'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
describe('Chip', () => { | ||
|
||
let button: Chip; | ||
let fixture: ComponentFixture<Chip>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
NoopAnimationsModule | ||
], | ||
declarations: [ | ||
ChipModule | ||
] | ||
}); | ||
|
||
fixture = TestBed.createComponent(Chip); | ||
button = fixture.componentInstance; | ||
}); | ||
}); |
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,57 @@ | ||
import { NgModule, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
@Component({ | ||
selector: 'p-chip', | ||
template: ` | ||
<div [ngClass]="containerClass()" [class]="styleClass" [ngStyle]="style" *ngIf="visible"> | ||
<ng-content></ng-content> | ||
<img [src]="image" *ngIf="image;else iconTemplate"> | ||
<ng-template #iconTemplate><span *ngIf="icon" [class]="icon" [ngClass]="'p-chip-icon'"></span></ng-template> | ||
<div class="p-chip-text" *ngIf="label">{{label}}</div> | ||
<span *ngIf="removable" tabindex="0" [class]="removeIcon" [ngClass]="'pi-chip-remove-icon'" (click)="close($event)" (keydown.enter)="close($event)"></span> | ||
</div> | ||
`, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
encapsulation: ViewEncapsulation.None, | ||
styleUrls: ['./chip.css'] | ||
}) | ||
export class Chip { | ||
|
||
@Input() label: string; | ||
|
||
@Input() icon: string; | ||
|
||
@Input() image: string; | ||
|
||
@Input() style: any; | ||
|
||
@Input() styleClass: string; | ||
|
||
@Input() removable: boolean; | ||
|
||
@Input() removeIcon: string = "pi pi-times-circle"; | ||
|
||
@Output() remove: EventEmitter<any> = new EventEmitter(); | ||
|
||
visible: boolean = true; | ||
|
||
containerClass() { | ||
return { | ||
'p-chip p-component': true, | ||
'p-chip-image': this.image != null | ||
}; | ||
} | ||
|
||
close(event) { | ||
this.visible = false; | ||
this.remove.emit(event) | ||
} | ||
} | ||
|
||
@NgModule({ | ||
imports: [CommonModule], | ||
exports: [Chip], | ||
declarations: [Chip] | ||
}) | ||
export class ChipModule { } |
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,6 @@ | ||
{ | ||
"$schema": "ng-packagr/ng-package.schema.json", | ||
"lib": { | ||
"entryFile": "public_api.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 @@ | ||
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
15 changes: 15 additions & 0 deletions
15
src/app/showcase/components/chip/chipdemo-routing.module.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,15 @@ | ||
import {NgModule} from '@angular/core'; | ||
import {RouterModule} from '@angular/router' | ||
import {ChipDemo} from './chipdemo'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
RouterModule.forChild([ | ||
{path:'',component: ChipDemo} | ||
]) | ||
], | ||
exports: [ | ||
RouterModule | ||
] | ||
}) | ||
export class ChipDemoRoutingModule {} |
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,210 @@ | ||
<div class="content-section introduction"> | ||
<div class="feature-intro"> | ||
<h1>Chip</h1> | ||
<p>Chip represents entities using icons, labels and images.</p> | ||
</div> | ||
</div> | ||
|
||
<div class="content-section implementation"> | ||
<div class="card"> | ||
<h5>Basic</h5> | ||
<div class="p-d-flex p-ai-center"> | ||
<p-chip label="Action" styleClass="p-mr-2"></p-chip> | ||
<p-chip label="Comedy" styleClass="p-mr-2"></p-chip> | ||
<p-chip label="Mystery" styleClass="p-mr-2"></p-chip> | ||
<p-chip label="Thriller" [removable]="true"></p-chip> | ||
</div> | ||
|
||
<h5>Icon</h5> | ||
<div class="p-d-flex p-ai-center"> | ||
<p-chip label="Apple" icon="pi pi-apple" styleClass="p-mr-2"></p-chip> | ||
<p-chip label="Facebook" icon="pi pi-facebook" styleClass="p-mr-2"></p-chip> | ||
<p-chip label="Google" icon="pi pi-google" styleClass="p-mr-2"></p-chip> | ||
<p-chip label="Microsoft" icon="pi pi-microsoft" [removable]="true"></p-chip> | ||
</div> | ||
|
||
<h5>Image</h5> | ||
<div class="p-d-flex p-ai-center"> | ||
<p-chip label="Amy Elsner" image="assets/showcase/images/demo/avatar/amyelsner.png" styleClass="p-mr-2"></p-chip> | ||
<p-chip label="Asiya Javayant" image="assets/showcase/images/demo/avatar/asiyajavayant.png" styleClass="p-mr-2"></p-chip> | ||
<p-chip label="Onyama Limba" image="assets/showcase/images/demo/avatar/onyamalimba.png" styleClass="p-mr-2"></p-chip> | ||
<p-chip label="Xuxue Feng" image="assets/showcase/images/demo/avatar/xuxuefeng.png" [removable]="true"></p-chip> | ||
</div> | ||
|
||
<h5>Styling</h5> | ||
<div class="p-d-flex p-ai-center"> | ||
<p-chip label="Action" styleClass="p-mr-2 custom-chip"></p-chip> | ||
<p-chip label="Comedy" styleClass="p-mr-2 custom-chip"></p-chip> | ||
<p-chip label="Onyama Limba" image="assets/showcase/images/demo/avatar/onyamalimba.png" styleClass="p-mr-2 custom-chip"></p-chip> | ||
<p-chip label="Xuxue Feng" image="assets/showcase/images/demo/avatar/xuxuefeng.png" [removable]="true" styleClass="custom-chip"></p-chip> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="content-section documentation"> | ||
<p-tabView> | ||
<p-tabPanel header="Documentation"> | ||
<h5>Getting Started</h5> | ||
<p>Content of the badge is specified using the <i>value</i> property.</p> | ||
|
||
<h5>Positioning</h5> | ||
<p>A badge can easily be positioned relative to another element by wrapping it.</p> | ||
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces> | ||
<p-badge [value]="2"></p-badge> | ||
</app-code> | ||
|
||
<h5>Tags</h5> | ||
<p>Tags are optimized for text rather than number and used with the <i>.p-tag</i> class. For more rounded styling like pills, add the <i>.p-tag-rounded</i> class</p> | ||
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces> | ||
<span class="p-tag">New</span> | ||
<span class="p-tag p-tag-rounded">New</span> | ||
</app-code> | ||
|
||
<h5>Severities</h5> | ||
<p>Different options are available as severity levels with.</p> | ||
|
||
<ul> | ||
<li>.p-badge-secondary</li> | ||
<li>.p-badge-success</li> | ||
<li>.p-badge-info</li> | ||
<li>.p-badge-warning</li> | ||
<li>.p-badge-danger</li> | ||
</ul> | ||
|
||
<h5>Positoning</h5> | ||
<p>A badge can easily be positioned relative to another element when both are wrapped inside an element with <i>p-overlay-badge</i> class.</p> | ||
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces> | ||
<span class="p-overlay-badge"> | ||
<i class="pi pi-bell" style="font-size: 2em"></i> | ||
<span class="p-badge">2</span> | ||
</span> | ||
|
||
<span class="p-overlay-badge"> | ||
<p-button label="New"></p-button> | ||
<span class="p-badge p-badge-warning">5</span> | ||
</span> | ||
</app-code> | ||
|
||
<h5>Inline Button Badges</h5> | ||
<p>Buttons provide integrated badge support with the <i>badge</i> and <i>badgeClass</i> properties.</p> | ||
|
||
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces> | ||
<p-button label="Emails" badge="8"></p-button> | ||
<p-button label="Messages" icon="pi pi-users" styleClass="p-button-warning" badge="8" badgeClass="p-badge-danger"></p-button> | ||
</app-code> | ||
|
||
<h5>Sizes</h5> | ||
<p>Badge sizes are adjusted with additional classes.</p> | ||
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces> | ||
<span class="p-badge">2</span> | ||
<span class="p-badge p-badge-l p-badge-sucess">4</span> | ||
<span class="p-badge p-badge-xl p-badge-warning">6</span> | ||
</app-code> | ||
|
||
<p>In addition, when placed inside another element, badge sizes can also derive their size from their parent.</p> | ||
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces> | ||
<h1>Heading 1 <span class="p-tag p-tag-success">New</span></h1> | ||
<h2>Heading 2 <span class="p-tag p-tag-success">New</span></h2> | ||
</app-code> | ||
|
||
<h5>Styling</h5> | ||
<p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming</a> page.</p> | ||
<div class="doc-tablewrapper"> | ||
<table class="doc-table"> | ||
<thead> | ||
<tr> | ||
<th>Name</th> | ||
<th>Element</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>p-badge</td> | ||
<td>Badge element</td> | ||
</tr> | ||
<tr> | ||
<td>p-tag</td> | ||
<td>Tag element</td> | ||
</tr> | ||
<tr> | ||
<td>p-tag-rounded</td> | ||
<td>Rounded tag element</td> | ||
</tr> | ||
<tr> | ||
<td>p-overlay-badge</td> | ||
<td>Wrapper of a badge and its target.</td> | ||
</tr> | ||
<tr> | ||
<td>p-badge-lg</td> | ||
<td>Large badge element</td> | ||
</tr> | ||
<tr> | ||
<td>p-badge-xl</td> | ||
<td>Extra large badge element</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
|
||
<h5>Dependencies</h5> | ||
<p>None.</p> | ||
</p-tabPanel> | ||
|
||
<p-tabPanel header="Source"> | ||
<a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/badge" class="btn-viewsource" target="_blank"> | ||
<span>View on GitHub</span> | ||
</a> | ||
|
||
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces> | ||
<h5>Numbers</h5> | ||
<div class="badges"> | ||
<span class="p-badge">2</span> | ||
<span class="p-badge p-badge-success">8</span> | ||
<span class="p-badge p-badge-info">4</span> | ||
<span class="p-badge p-badge-warning">12</span> | ||
<span class="p-badge p-badge-danger">3</span> | ||
</div> | ||
|
||
<h5>Tags</h5> | ||
<div class="badges"> | ||
<span class="p-tag">Primary</span> | ||
<span class="p-tag p-tag-success">Success</span> | ||
<span class="p-tag p-tag-info">Info</span> | ||
<span class="p-tag p-tag-warning">Warning</span> | ||
<span class="p-tag p-tag-danger">Danger</span> | ||
</div> | ||
|
||
<h5>Pills</h5> | ||
<div class="badges"> | ||
<span class="p-tag p-tag-rounded">Primary</span> | ||
<span class="p-tag p-tag-rounded p-tag-success">Success</span> | ||
<span class="p-tag p-tag-rounded p-tag-info">Info</span> | ||
<span class="p-tag p-tag-rounded p-tag-warning">Warning</span> | ||
<span class="p-tag p-tag-rounded p-tag-danger">Danger</span> | ||
</div> | ||
|
||
<h5>Positioned Badge</h5> | ||
<span class="p-overlay-badge p-mr-5"> | ||
<i class="pi pi-bell" style="font-size: 2em"></i> | ||
<span class="p-badge">2</span> | ||
</span> | ||
|
||
<span class="p-overlay-badge"> | ||
<p-button label="New"></p-button> | ||
<span class="p-badge p-badge-warning">5</span> | ||
</span> | ||
|
||
<h5>Inline Button Badge</h5> | ||
<p-button label="Emails" badge="8" styleClass="p-mr-2" ></p-button> | ||
<p-button label="Messages" icon="pi pi-users" styleClass="p-button-warning" badge="8" badgeClass="p-badge-danger" ></p-button> | ||
|
||
<h5>Sizes</h5> | ||
<div class="badges"> | ||
<span class="p-badge">2</span> | ||
<span class="p-badge p-badge-lg p-badge-sucess">4</span> | ||
<span class="p-badge p-badge-xl p-badge-warning">6</span> | ||
</div> | ||
</app-code> | ||
</p-tabPanel> | ||
</p-tabView> | ||
</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,25 @@ | ||
import {NgModule} from '@angular/core'; | ||
import {CommonModule} from '@angular/common'; | ||
import {ChipDemo} from './chipdemo'; | ||
import {ChipDemoRoutingModule} from './chipdemo-routing.module'; | ||
import {ButtonModule} from 'primeng/button'; | ||
import {PanelModule} from 'primeng/panel'; | ||
import {TabViewModule} from 'primeng/tabview'; | ||
import {AppCodeModule} from '../../app.code.component'; | ||
import { ChipModule } from 'primeng/chip'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
ChipDemoRoutingModule, | ||
ButtonModule, | ||
PanelModule, | ||
TabViewModule, | ||
ChipModule, | ||
AppCodeModule | ||
], | ||
declarations: [ | ||
ChipDemo | ||
] | ||
}) | ||
export class ChipDemoModule {} |
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,4 @@ | ||
:host ::ng-deep .p-chip.custom-chip { | ||
background: var(--primary-color); | ||
color: var(--primary-color-text); | ||
} |
Oops, something went wrong.