Skip to content

Commit 63f20a4

Browse files
wip: add reusable single input (demo)
1 parent f25c9d5 commit 63f20a4

File tree

9 files changed

+137
-12
lines changed

9 files changed

+137
-12
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"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<p-floatlabel [variant]="variant">
2+
<input pInputText id="input_{{ label | lowercase }}" [(ngModel)]="value" [type]="type" [disabled]="disabled" autocomplete="off" />
3+
<label for="input_{{ label | lowercase }}">{{ label }}</label>
4+
</p-floatlabel>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
p-floatlabel {
2+
width: 100%;
3+
}
4+
5+
input {
6+
width: 100%;
7+
padding: 15px;
8+
font-size: 16px;
9+
background-color: var(--background-color-light);
10+
border: var(--grey-border);
11+
border-radius: 8px;
12+
transition: border-color 0.3s ease-in-out;
13+
14+
&:focus,
15+
&:hover,
16+
&:active {
17+
border-color: var(--primary-light-color) !important;
18+
outline: none;
19+
~ label {
20+
color: var(--primary-light-color);
21+
}
22+
}
23+
24+
label {
25+
transition: all 0.3s ease-in-out;
26+
color: var(--primary-light-color);
27+
}
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { InputFieldComponent } from './input-field.component';
4+
5+
describe('InputFieldComponent', () => {
6+
let component: InputFieldComponent;
7+
let fixture: ComponentFixture<InputFieldComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [InputFieldComponent]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(InputFieldComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
7+
@Component({
8+
selector: 'app-input-field',
9+
standalone: true,
10+
imports: [CommonModule, InputTextModule, FloatLabelModule, FormsModule],
11+
templateUrl: './input-field.component.html',
12+
styleUrls: ['./input-field.component.scss'],
13+
})
14+
export class InputFieldComponent {
15+
@Input() label: string = '';
16+
@Input() type: string = 'text';
17+
@Input() disabled: boolean = false;
18+
@Input() variant: 'in' | 'over' | 'on' = 'in';
19+
value: string = '';
20+
}
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
<div class="activities-home">
2-
@for (activity of activities$ | async; track activity.id) {
2+
<div class="activities-home__header">
3+
<h3>Demo Input Single</h3>
4+
<div class="activities-home__header__inputs">
5+
<app-input-field label="Nom"></app-input-field>
6+
<app-input-field label="Prénom"></app-input-field>
7+
</div>
8+
</div>
9+
10+
<div class="activities-home__list">
11+
@for (activity of activities$ | async; track activity.id) {
312
<app-activity-card [activity]="activity"></app-activity-card>
4-
}
13+
}
14+
</div>
515
</div>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
.activities-home {
22
display: flex;
3+
flex-direction: column;
34
flex-wrap: wrap;
45
justify-content: space-around;
56
background-color: var(--background-color-light);
7+
8+
&__header {
9+
display: flex;
10+
flex-direction: column;
11+
text-align: center;
12+
margin-bottom: 50px;
13+
h3 {
14+
font-size: 1.5rem;
15+
color: var(--primary-light-color);
16+
}
17+
18+
&__inputs {
19+
display: flex;
20+
flex-direction: column;
21+
align-items: center;
22+
gap: 1rem;
23+
24+
.input-field {
25+
width: 200px;
26+
}
27+
}
28+
}
29+
30+
&__list {
31+
display: flex;
32+
flex-wrap: wrap;
33+
justify-content: space-around;
34+
gap: 1rem;
35+
padding: 1rem;
36+
}
637
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { ActivityFacadeService } from '../../services/activity-facade.service';
44
import { Activity } from '../../models/activity.model';
55
import { Observable } from 'rxjs';
66
import { AsyncPipe } from '@angular/common';
7+
import { InputFieldComponent } from '../../../../common/components/input-field/input-field.component';
78

89
@Component({
910
selector: 'app-activities-home',
10-
imports: [ActivityCardComponent, AsyncPipe],
11+
imports: [ActivityCardComponent, AsyncPipe, InputFieldComponent],
1112
templateUrl: './activities-home.component.html',
1213
styleUrl: './activities-home.component.scss',
1314
standalone: true,

0 commit comments

Comments
 (0)