Skip to content

Commit 3c98bbf

Browse files
fix: update TodoForm styling to match app form conventions
- External labels (text-xs font-semibold text-on-surface-variant) - subscriptSizing=dynamic to remove dead space below inputs - Aligned button to bottom of fields on sm+ screens - Remove MatLabel import (no longer needed) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4d02607 commit 3c98bbf

1 file changed

Lines changed: 59 additions & 37 deletions

File tree

libs/todo/src/lib/components/todo-form/todo-form.ts

Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
FormGroup,
66
Validators,
77
} from '@angular/forms';
8-
import { MatFormField, MatLabel, MatError } from '@angular/material/form-field';
8+
import { MatFormField, MatError } from '@angular/material/form-field';
99
import { MatInput } from '@angular/material/input';
1010
import { MatButton } from '@angular/material/button';
1111
import { MatIcon } from '@angular/material/icon';
@@ -17,49 +17,71 @@ import { CreateTodoRequest } from '../../models/todo';
1717
imports: [
1818
ReactiveFormsModule,
1919
MatFormField,
20-
MatLabel,
2120
MatError,
2221
MatInput,
2322
MatButton,
2423
MatIcon,
2524
],
2625
template: `
27-
<form class="flex flex-col gap-3" [formGroup]="form" (ngSubmit)="submit()">
28-
<div class="flex flex-col gap-3 sm:flex-row sm:items-start">
29-
<mat-form-field appearance="outline" class="flex-1">
30-
<mat-label>Title</mat-label>
31-
<input
32-
matInput
33-
formControlName="title"
34-
placeholder="What needs to be done?"
35-
autocomplete="off"
36-
/>
37-
@if (
38-
form.controls.title.hasError('required') &&
39-
form.controls.title.touched
40-
) {
41-
<mat-error>Title is required</mat-error>
42-
}
43-
</mat-form-field>
44-
<mat-form-field appearance="outline" class="flex-1">
45-
<mat-label>Description</mat-label>
46-
<input
47-
matInput
48-
formControlName="description"
49-
placeholder="Optional details…"
50-
autocomplete="off"
51-
/>
52-
</mat-form-field>
53-
<button
54-
mat-flat-button
55-
type="submit"
56-
class="h-14 shrink-0"
57-
[disabled]="form.invalid"
58-
>
59-
<mat-icon>add</mat-icon>
60-
Add
61-
</button>
26+
<form
27+
class="flex flex-col gap-4 sm:flex-row sm:items-end"
28+
[formGroup]="form"
29+
(ngSubmit)="submit()"
30+
>
31+
<div class="flex flex-1 flex-col gap-4 sm:flex-row sm:items-end">
32+
<div class="flex flex-1 flex-col gap-1.5">
33+
<label
34+
class="text-xs font-semibold text-on-surface-variant"
35+
for="todo-title"
36+
>
37+
Title
38+
</label>
39+
<mat-form-field
40+
appearance="outline"
41+
subscriptSizing="dynamic"
42+
class="w-full"
43+
>
44+
<input
45+
matInput
46+
id="todo-title"
47+
formControlName="title"
48+
placeholder="What needs to be done?"
49+
autocomplete="off"
50+
/>
51+
@if (
52+
form.controls.title.hasError('required') &&
53+
form.controls.title.touched
54+
) {
55+
<mat-error>Title is required</mat-error>
56+
}
57+
</mat-form-field>
58+
</div>
59+
<div class="flex flex-1 flex-col gap-1.5">
60+
<label
61+
class="text-xs font-semibold text-on-surface-variant"
62+
for="todo-description"
63+
>
64+
Description
65+
</label>
66+
<mat-form-field
67+
appearance="outline"
68+
subscriptSizing="dynamic"
69+
class="w-full"
70+
>
71+
<input
72+
matInput
73+
id="todo-description"
74+
formControlName="description"
75+
placeholder="Optional details…"
76+
autocomplete="off"
77+
/>
78+
</mat-form-field>
79+
</div>
6280
</div>
81+
<button mat-flat-button type="submit" [disabled]="form.invalid">
82+
<mat-icon>add</mat-icon>
83+
Add
84+
</button>
6385
</form>
6486
`,
6587
host: {

0 commit comments

Comments
 (0)