Skip to content

Commit 53997fc

Browse files
Merge pull request #12 from WildCodeSchool/feature/issue-23/create-single-input
feat: (issue-23) create reusable single input component
2 parents 950dca3 + 141e5eb commit 53997fc

File tree

14 files changed

+116
-18
lines changed

14 files changed

+116
-18
lines changed

package-lock.json

Lines changed: 14 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"private": true,
3131
"dependencies": {
3232
"@angular/animations": "^19.0.0",
33+
"@angular/cdk": "^19.1.5",
3334
"@angular/common": "^19.0.0",
3435
"@angular/compiler": "^19.0.0",
3536
"@angular/core": "^19.0.0",
@@ -39,7 +40,8 @@
3940
"@angular/router": "^19.0.0",
4041
"@ngrx/store": "^19.0.1",
4142
"@primeng/themes": "^19.0.6",
42-
"primeng": "^19.0.6",
43+
"primeicons": "^7.0.0",
44+
"primeng": "^19.0.8",
4345
"rxjs": "~7.8.0",
4446
"tslib": "^2.3.0",
4547
"zone.js": "~0.15.0"

public/LogoALAsso.png

-1.87 KB
Loading

src/app/app.routes.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { Routes } from '@angular/router';
22
import { ActivitiesHomeComponent } from './features/activity/pages/activities-home/activities-home.component';
3+
import { DemoComponent } from './features/activity/pages/demo/demo.component';
34

45
export const routes: Routes = [
56
{
67
path: '',
78
component: ActivitiesHomeComponent,
89
},
10+
{
11+
path: 'demo',
12+
component: DemoComponent,
13+
},
914
];
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<p-floatlabel [variant]="variant">
2+
@if (type === 'date') {
3+
<p-calendar [inputId]="'input_' + (label | lowercase)" [(ngModel)]="value" [disabled]="disabled" dateFormat="dd.mm.yy"> </p-calendar>
4+
} @else {
5+
<input pInputText [id]="'input_' + (label | lowercase)" [(ngModel)]="value" [type]="type" [disabled]="disabled" autocomplete="off" />
6+
}
7+
8+
<label [for]="'input_' + (label | lowercase)">{{ label }}</label>
9+
</p-floatlabel>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
p-floatlabel {
2+
input,
3+
::ng-deep p-calendar span input {
4+
width: 100%;
5+
font-size: 16px;
6+
background-color: var(--background-color-light);
7+
border: var(--grey-border);
8+
border-radius: 8px;
9+
transition: border-color 0.3s ease-in-out;
10+
color: black;
11+
12+
&:focus,
13+
&:hover,
14+
&:active {
15+
border-color: var(--primary-light-color) !important;
16+
outline: none;
17+
~ label {
18+
color: var(--primary-light-color);
19+
}
20+
}
21+
22+
label {
23+
transition: all 0.3s ease-in-out;
24+
color: var(--primary-light-color);
25+
}
26+
}
27+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Component, Input } from '@angular/core';
2+
import { CommonModule } from '@angular/common';
3+
import { InputTextModule } from 'primeng/inputtext';
4+
import { FloatLabelModule } from 'primeng/floatlabel';
5+
import { FormsModule } from '@angular/forms';
6+
import { CalendarModule } from 'primeng/calendar';
7+
8+
@Component({
9+
selector: 'app-input-field',
10+
standalone: true,
11+
imports: [CommonModule, InputTextModule, FloatLabelModule, CalendarModule, FormsModule],
12+
templateUrl: './input-field.component.html',
13+
styleUrls: ['./input-field.component.scss'],
14+
})
15+
export class InputFieldComponent {
16+
@Input() label: string = '';
17+
@Input() type: string = 'text';
18+
@Input() disabled: boolean = false;
19+
@Input() variant: 'in' | 'on' = 'in';
20+
value: string = '';
21+
}

src/app/features/activity/pages/activities-home/activities-home.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
<app-activity-card [activity]="activity"></app-activity-card>
1010
}
1111
</div>
12-
<div class="map-activities" [ngClass]="chosenNavigation !== 'Carte' ? 'hidden' : ''">
13-
<!--TODO: rajouter ici composant map pour la page activities-->
14-
</div>
12+
</div>
13+
<div class="map-activities" [ngClass]="chosenNavigation !== 'Carte' ? 'hidden' : ''">
14+
<!--TODO: rajouter ici composant map pour la page activities-->
1515
</div>
1616

1717
<div class="switch-map">

src/app/features/activity/pages/activities-home/activities-home.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import { AsyncPipe, NgClass } from '@angular/common';
12
import { Component, inject, OnInit } from '@angular/core';
2-
import { ActivityCardComponent } from '../../components/activity-card/activity-card.component';
3-
import { ActivityFacadeService } from '../../services/activity-facade.service';
4-
import { Activity } from '../../models/activity.model';
53
import { Observable } from 'rxjs';
6-
import { AsyncPipe, NgClass } from '@angular/common';
74
import { ToggleMenuComponent } from '../../../../common/components/toggle-menu/toggle-menu.component';
5+
import { ActivityCardComponent } from '../../components/activity-card/activity-card.component';
6+
import { Activity } from '../../models/activity.model';
7+
import { ActivityFacadeService } from '../../services/activity-facade.service';
88

99
@Component({
1010
selector: 'app-activities-home',
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="input-demo">
2+
<h3>Single Input Demo</h3>
3+
<app-input-field label="Nom" type="text"></app-input-field>
4+
<app-input-field label="Email" type="email"></app-input-field>
5+
<app-input-field label="Mot de passe" type="password"></app-input-field>
6+
<app-input-field label="Date de naissance" type="date"></app-input-field>
7+
</div>

0 commit comments

Comments
 (0)