Skip to content

Commit 5be7c61

Browse files
feat: (issue-23) create reusable single input component
1 parent e767cec commit 5be7c61

File tree

7 files changed

+51
-6
lines changed

7 files changed

+51
-6
lines changed
Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,33 @@
11
<p-floatlabel [variant]="variant">
22
@if (type === 'date') {
3-
<p-calendar [inputId]="'input_' + (label | lowercase)" [(ngModel)]="value" [disabled]="disabled" dateFormat="dd.mm.yy"> </p-calendar>
3+
<p-calendar [inputId]="'input_' + label" [(ngModel)]="value" [disabled]="disabled" dateFormat="dd.mm.yy" ariaLabel="date"></p-calendar>
4+
} @else if (type === 'password') {
5+
<p-password
6+
[inputId]="'input_' + label"
7+
[(ngModel)]="value"
8+
[disabled]="disabled"
9+
[feedback]="showPasswordRules"
10+
[toggleMask]="true"
11+
autocomplete="off"
12+
ariaLabel="password">
13+
@if (showPasswordRules) {
14+
<ng-template #header>
15+
<div class="font-semibold text-xm mb-4">Choisir un mot de passe</div>
16+
</ng-template>
17+
<ng-template #footer>
18+
<p-divider></p-divider>
19+
<ul class="pl-2 ml-2 my-0 leading-normal">
20+
<li>Au moins une lettre minuscule</li>
21+
<li>Au moins une lettre majuscule</li>
22+
<li>Au moins un chiffre</li>
23+
<li>Minimum 8 caractères</li>
24+
</ul>
25+
</ng-template>
26+
}
27+
</p-password>
428
} @else {
5-
<input pInputText [id]="'input_' + (label | lowercase)" [(ngModel)]="value" [type]="type" [disabled]="disabled" autocomplete="off" />
29+
<input pInputText [id]="'input_' + label" [(ngModel)]="value" [type]="type" [disabled]="disabled" autocomplete="off" [ariaLabel]="label" />
630
}
731

8-
<label [for]="'input_' + (label | lowercase)">{{ label }}</label>
32+
<label [for]="'input_' + label">{{ label }}</label>
933
</p-floatlabel>

src/app/common/components/input-field/input-field.component.scss

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
p-floatlabel {
22
input,
3-
::ng-deep p-calendar span input {
3+
::ng-deep p-calendar span input,
4+
::ng-deep p-password div input {
45
width: 100%;
56
font-size: 16px;
6-
background-color: var(--background-color-light);
7+
background-color: var(--background-color-white);
78
border: var(--grey-border);
89
border-radius: 8px;
910
transition: border-color 0.3s ease-in-out;
@@ -24,4 +25,13 @@ p-floatlabel {
2425
color: var(--primary-light-color);
2526
}
2627
}
28+
29+
::ng-deep .p-password:has(.p-password-toggle-mask-icon) .p-password-input {
30+
padding-inline-end: 12px !important;
31+
}
32+
}
33+
34+
::ng-deep p-password div eyeicon svg.p-icon,
35+
::ng-deep p-password div eyeslashicon svg.p-icon {
36+
color: var(--icon-color);
2737
}

src/app/common/components/input-field/input-field.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { InputTextModule } from 'primeng/inputtext';
44
import { FloatLabelModule } from 'primeng/floatlabel';
55
import { FormsModule } from '@angular/forms';
66
import { CalendarModule } from 'primeng/calendar';
7+
import { PasswordModule } from 'primeng/password';
8+
import { DividerModule } from 'primeng/divider';
79

810
@Component({
911
selector: 'app-input-field',
1012
standalone: true,
11-
imports: [CommonModule, InputTextModule, FloatLabelModule, CalendarModule, FormsModule],
13+
imports: [CommonModule, InputTextModule, FloatLabelModule, CalendarModule, FormsModule, PasswordModule, DividerModule],
1214
templateUrl: './input-field.component.html',
1315
styleUrls: ['./input-field.component.scss'],
1416
})
@@ -17,5 +19,6 @@ export class InputFieldComponent {
1719
@Input() type: string = 'text';
1820
@Input() disabled: boolean = false;
1921
@Input() variant: 'in' | 'on' = 'in';
22+
@Input() showPasswordRules: boolean = false;
2023
value: string = '';
2124
}

src/app/features/activity/pages/demo/demo.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!-- TODO : SUPPRIMER CE FICHIER -->
2+
13
<div class="input-demo">
24
<h3>Single Input Demo</h3>
35
<app-input-field label="Nom" type="text"></app-input-field>

src/app/features/activity/pages/demo/demo.component.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
// TODO : SUPPRIMER CE FICHIER
2+
13
.input-demo {
24
display: flex;
35
flex-direction: column;
46
justify-content: center;
57
align-items: center;
68
height: 100%;
79
margin: 50px 0;
10+
gap: 25px;
811

912
h3 {
1013
color: var(--primary-light-color);

src/app/features/activity/pages/demo/demo.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// TODO : SUPPRIMER CE FICHIER
2+
13
import { Component } from '@angular/core';
24
import { InputFieldComponent } from 'src/app/common/components/input-field/input-field.component';
35

src/styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ body {
1616
--background-color-white: white;
1717
--background-color-light: #f8f8f8;
1818
--font-color: #505050;
19+
--icon-color: #d9d9d9;
1920

2021
--primary-dark-color: #13678a;
2122
--primary-light-color: #1385a8;

0 commit comments

Comments
 (0)