Skip to content

Commit 1bf623b

Browse files
committed
feat: enhance NewTicket component with Control component integration and update styles
1 parent 8dabbbe commit 1bf623b

File tree

7 files changed

+59
-55
lines changed

7 files changed

+59
-55
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
<p>control works!</p>
1+
<p class="control">
2+
<label for="request">{{label()}}</label>
3+
<ng-content select="input, textarea"></ng-content>
4+
</p>
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
import { Component } from '@angular/core';
1+
import { Component, input, ViewEncapsulation } from '@angular/core';
22

33
@Component({
44
selector: 'app-control',
55
standalone: true,
66
imports: [],
77
templateUrl: './control.component.html',
8-
styleUrl: './control.component.css'
8+
styleUrl: './control.component.css',
9+
encapsulation: ViewEncapsulation.Emulated
910
})
1011
export class ControlComponent {
12+
label = input.required<string>();
13+
for = input.required<string>();
1114

1215
}
Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,3 @@
1-
#tickets {
2-
display: flex;
3-
flex-direction: column;
4-
gap: 1.5rem;
5-
}
6-
7-
#tickets ul {
8-
list-style: none;
9-
margin: 0;
10-
padding: 0;
1+
#new-ticket {
112
width: 15rem;
12-
}
13-
14-
#tickets li {
15-
margin: 0.5rem 0;
16-
}
17-
18-
#tickets p {
19-
margin: 0;
20-
color: #4f4b53;
21-
}
22-
23-
#tickets h2 {
24-
margin: 0;
25-
font-size: 1.1rem;
26-
color: #38343c;
27-
}
28-
29-
@media (min-width: 768px) {
30-
#tickets {
31-
flex-direction: row;
32-
}
33-
}
34-
35-
#new-ticket {
36-
width: 15rem;
37-
}
38-
39-
3+
}

06-cmp-deep-dive/01-starting-project/src/app/dashboard/tickets/new-ticket/new-ticket.component.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
<form id="ticket">
2-
<p>
3-
<label for="title">Title</label>
4-
<input name="title" id="title" type="text">
5-
</p>
6-
<p>
7-
<label for="request">Request</label>
8-
<textarea name="request" id="request" rows="3"></textarea>
9-
</p>
1+
<form>
2+
<app-control label="Title" for="title">
3+
<input name="title" id="title" type="text">
4+
</app-control>
5+
<app-control label="Request" for="request">
6+
<textarea name="request" id="request" rows="3"></textarea>
7+
</app-control>
108
<p>
119
<app-button buttonTitle="Submit"></app-button>
1210
</p>

06-cmp-deep-dive/01-starting-project/src/app/dashboard/tickets/new-ticket/new-ticket.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { Component } from '@angular/core';
1+
import { Component, ViewEncapsulation } from '@angular/core';
22
import { ButtonComponent } from "../../shared/button/button.component";
3+
import { ControlComponent } from "../../shared/control/control.component";
34

45
@Component({
56
selector: 'app-new-ticket',
67
standalone: true,
7-
imports: [ButtonComponent],
8+
imports: [ButtonComponent, ControlComponent],
89
templateUrl: './new-ticket.component.html',
9-
styleUrl: './new-ticket.component.css'
10+
styleUrl: './new-ticket.component.css',
11+
encapsulation: ViewEncapsulation.Emulated
1012
})
1113
export class NewTicketComponent {
1214

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#tickets {
2+
display: flex;
3+
flex-direction: column;
4+
gap: 1.5rem;
5+
}
6+
7+
#tickets ul {
8+
list-style: none;
9+
margin: 0;
10+
padding: 0;
11+
width: 15rem;
12+
}
13+
14+
#tickets li {
15+
margin: 0.5rem 0;
16+
}
17+
18+
#tickets p {
19+
margin: 0;
20+
color: #4f4b53;
21+
}
22+
23+
#tickets h2 {
24+
margin: 0;
25+
font-size: 1.1rem;
26+
color: #38343c;
27+
}
28+
29+
@media (min-width: 768px) {
30+
#tickets {
31+
flex-direction: row;
32+
}
33+
}

06-cmp-deep-dive/01-starting-project/src/app/dashboard/tickets/tickets.component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component } from '@angular/core';
1+
import { Component, ViewEncapsulation } from '@angular/core';
22
import { DashboardItemComponent } from "../dashboard-item/dashboard-item.component";
33
import { NewTicketComponent } from "./new-ticket/new-ticket.component";
44

@@ -7,7 +7,8 @@ import { NewTicketComponent } from "./new-ticket/new-ticket.component";
77
standalone: true,
88
imports: [DashboardItemComponent, NewTicketComponent],
99
templateUrl: './tickets.component.html',
10-
styleUrl: './tickets.component.css'
10+
styleUrl: './tickets.component.css',
11+
encapsulation: ViewEncapsulation.Emulated
1112
})
1213
export class TicketsComponent {
1314

0 commit comments

Comments
 (0)