-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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 #14900 from primefaces/iconfield
Add IconField and InputIcon
- Loading branch information
Showing
69 changed files
with
1,074 additions
and
7 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 |
---|---|---|
|
@@ -118,5 +118,8 @@ | |
} | ||
} | ||
} | ||
}, | ||
"cli": { | ||
"analytics": false | ||
} | ||
} |
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,5 @@ | ||
@layer primeng { | ||
.p-icon-field { | ||
position: relative; | ||
} | ||
} |
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,37 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { ChangeDetectionStrategy, Component, Input, NgModule, ViewEncapsulation } from '@angular/core'; | ||
|
||
import { SharedModule } from 'primeng/api'; | ||
|
||
/** | ||
* IconField wraps an input and an icon. | ||
* @group Components | ||
*/ | ||
@Component({ | ||
selector: 'p-iconField', | ||
template: ` <span class="p-icon-field" [ngClass]="containerClass"><ng-content></ng-content> </span>`, | ||
styleUrl: './iconfield.css', | ||
encapsulation: ViewEncapsulation.None, | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class IconField { | ||
/** | ||
* Position of the icon. | ||
* @group Props | ||
*/ | ||
@Input() iconPosition: 'right' | 'left' = 'left'; | ||
|
||
get containerClass() { | ||
return { | ||
'p-icon-field-left': this.iconPosition === 'left', | ||
'p-icon-field-right': this.iconPosition === 'right' | ||
}; | ||
} | ||
} | ||
|
||
@NgModule({ | ||
imports: [CommonModule], | ||
exports: [IconField, SharedModule], | ||
declarations: [IconField] | ||
}) | ||
export class IconFieldModule {} |
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,2 @@ | ||
export * from './iconfield'; | ||
|
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 @@ | ||
@layer primeng { | ||
.p-fluid .p-icon-field-left, | ||
.p-fluid .p-icon-field-right { | ||
width: 100%; | ||
} | ||
} |
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 { CommonModule } from '@angular/common'; | ||
import { ChangeDetectionStrategy, Component, Input, NgModule, ViewEncapsulation } from '@angular/core'; | ||
import { SharedModule } from 'primeng/api'; | ||
|
||
/** | ||
* InputIcon displays an icon. | ||
* @group Components | ||
*/ | ||
@Component({ | ||
selector: 'p-inputIcon', | ||
template: `<span class="p-input-icon" [ngClass]="styleClass"><ng-content></ng-content></span>`, | ||
styleUrl: './inputicon.css', | ||
encapsulation: ViewEncapsulation.None, | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class InputIcon { | ||
/** | ||
* Style class of the element. | ||
* @group Props | ||
*/ | ||
@Input() styleClass: string | undefined; | ||
} | ||
|
||
@NgModule({ | ||
imports: [CommonModule], | ||
exports: [InputIcon, SharedModule], | ||
declarations: [InputIcon] | ||
}) | ||
export class InputIconModule {} |
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 './inputicon'; |
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,13 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'accessibility-doc', | ||
template: ` <app-docsectiontext> | ||
<h3>Screen Reader</h3> | ||
<p>IconField and InputIcon does not require any roles and attributes.</p> | ||
<h3>Keyboard Support</h3> | ||
<p>Components does not include any interactive elements.</p> | ||
</app-docsectiontext>` | ||
}) | ||
export class AccessibilityDoc {} |
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,43 @@ | ||
import { Component } from '@angular/core'; | ||
import { Code } from '../../domain/code'; | ||
|
||
@Component({ | ||
selector: 'basic-doc', | ||
template: ` | ||
<app-docsectiontext> | ||
<p> | ||
A group is created by wrapping the input and icon with the IconField component. Each icon is defined as a child of InputIcon component. In addition, position of the icon can be changed using iconPosition property that the default | ||
value is right and also left option is available. | ||
</p> | ||
</app-docsectiontext> | ||
<div class="card flex justify-content-center"> | ||
<p-iconField iconPosition="left"> | ||
<p-inputIcon styleClass="pi pi-search" /> | ||
<input type="text" pInputText /> | ||
</p-iconField> | ||
</div> | ||
<app-code [code]="code" selector="iconfield-basic-demo"></app-code> | ||
` | ||
}) | ||
export class BasicDoc { | ||
code: Code = { | ||
basic: `<p-iconField iconPosition="left"> | ||
<p-inputIcon styleClass="pi pi-search" /> | ||
<input type="text" pInputText /> | ||
</p-iconField>`, | ||
html: `<div class="card flex justify-content-center"> | ||
<p-iconField iconPosition="left"> | ||
<p-inputIcon styleClass="pi pi-search" /> | ||
<input type="text" pInputText /> | ||
</p-iconField> | ||
</div>`, | ||
typescript: ` | ||
import { Component } from '@angular/core'; | ||
@Component({ | ||
selector: 'iconField-basic-demo', | ||
templateUrl: './iconField-basic-demo.html' | ||
}) | ||
export class IconFieldBasicDemo {}` | ||
}; | ||
} |
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 { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule } from '@angular/router'; | ||
import { InputTextModule } from 'primeng/inputtext'; | ||
import { AppDocModule } from '../../layout/doc/app.doc.module'; | ||
import { AppCodeModule } from '../../layout/doc/app.code.component'; | ||
import { BasicDoc } from './basicdoc'; | ||
import { ImportDoc } from './importdoc'; | ||
import { IconFieldModule } from 'src/app/components/iconfield/iconfield'; | ||
import { InputIconModule } from 'src/app/components/inputicon/inputicon'; | ||
import { FormsModule } from '@angular/forms'; | ||
import { AccessibilityDoc } from './accessibilitydoc'; | ||
|
||
@NgModule({ | ||
imports: [CommonModule, RouterModule, AppCodeModule, AppDocModule, InputTextModule, IconFieldModule, InputIconModule, FormsModule], | ||
declarations: [BasicDoc, ImportDoc, AccessibilityDoc], | ||
exports: [AppDocModule] | ||
}) | ||
export class IconFieldDocModule {} |
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 @@ | ||
import { Component } from '@angular/core'; | ||
import { Code } from '../../domain/code'; | ||
|
||
@Component({ | ||
selector: 'import-doc', | ||
template: `<app-code [code]="code" [hideToggleCode]="true"></app-code> ` | ||
}) | ||
export class ImportDoc { | ||
code: Code = { | ||
typescript: `import { IconField } from 'primeng/iconfield';` | ||
}; | ||
} |
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
10 changes: 10 additions & 0 deletions
10
src/app/showcase/pages/iconfield/iconfielddemo-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,10 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { RouterModule } from '@angular/router'; | ||
import { IconFieldDemo } from './iconfielddemo'; | ||
|
||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild([{ path: '', component: IconFieldDemo }])], | ||
exports: [RouterModule] | ||
}) | ||
export class IconFieldDemoRoutingModule {} |
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 @@ | ||
<app-doc docTitle="Angular IconField Component" header="IconField" description="IconField wraps an input and an icon." [docs]="docs" [apiDocs]="['IconField', 'InputIcon']"></app-doc> |
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 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { NgModule } from '@angular/core'; | ||
import { IconFieldDemo } from './iconfielddemo'; | ||
import { IconFieldDocModule } from '../../doc/iconfield/iconfielddoc.module'; | ||
import { IconFieldDemoRoutingModule } from './iconfielddemo-routing.module'; | ||
|
||
|
||
@NgModule({ | ||
imports: [CommonModule, IconFieldDocModule, IconFieldDemoRoutingModule], | ||
declarations: [IconFieldDemo] | ||
}) | ||
export class IconFieldDemoModule {} |
Empty file.
Oops, something went wrong.