Skip to content

Commit 4b38389

Browse files
committed
Adding Styling
1 parent fbd7ff8 commit 4b38389

13 files changed

+1063
-28
lines changed

angular.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
}
2828
],
2929
"styles": [
30+
"@angular/material/prebuilt-themes/azure-blue.css",
3031
"src/styles.css"
3132
],
3233
"scripts": []
@@ -85,6 +86,7 @@
8586
}
8687
],
8788
"styles": [
89+
"@angular/material/prebuilt-themes/azure-blue.css",
8890
"src/styles.css"
8991
],
9092
"scripts": []

package-lock.json

Lines changed: 895 additions & 2 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
@@ -11,10 +11,12 @@
1111
"private": true,
1212
"dependencies": {
1313
"@angular/animations": "^18.0.0",
14+
"@angular/cdk": "^18.0.5",
1415
"@angular/common": "^18.0.0",
1516
"@angular/compiler": "^18.0.0",
1617
"@angular/core": "^18.0.0",
1718
"@angular/forms": "^18.0.0",
19+
"@angular/material": "^18.0.5",
1820
"@angular/platform-browser": "^18.0.0",
1921
"@angular/platform-browser-dynamic": "^18.0.0",
2022
"@angular/router": "^18.0.0",
@@ -35,4 +37,4 @@
3537
"karma-jasmine-html-reporter": "~2.1.0",
3638
"typescript": "~5.4.2"
3739
}
38-
}
40+
}

src/app/app.component.css

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.mat-toolbar {
2+
background-color: #007fff; /* Replace with your desired color */
3+
}
4+
5+
.mat-toolbar a {
6+
color: #ffffff; /* Ensures the text color is white or another light color for contrast */
7+
margin-right: 20px; /* Adds space between the links */
8+
text-transform: uppercase; /* Optional: transforms text to uppercase */
9+
font-size: 16px; /* Adjust font size as needed */
10+
text-decoration: none; /* Removes underline from the links */
11+
}
12+
13+
.mat-toolbar a:hover {
14+
color: black; /* Adds a hover effect with a different color */
15+
}
16+
17+
.mat-toolbar {
18+
padding: 10px 20px; /* Adds 10px padding vertically and 20px horizontally */
19+
}
20+
21+
/* styles.css or your component's css file */
22+
.active {
23+
font-weight: bold;
24+
color: #ffffff; /* Adjust the color based on your theme */
25+
}
26+
27+
.content-wrapper {
28+
padding: 20px; /* Adjust the padding as needed */
29+
}

src/app/app.component.html

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
<h1>Angular Router Sample</h1>
1+
<!-- app.component.html or your component's template -->
22

3-
<nav>
3+
<mat-toolbar color="primary">
44
<a
5-
class="button"
5+
mat-button
66
routerLink="/notes"
7-
routerLinkActive="activebutton"
8-
ariaCurrentWhenActive="page"
7+
routerLinkActive="active"
8+
[routerLinkActiveOptions]="{ exact: true }"
99
>
1010
Notes
1111
</a>
12-
|
1312
<a
14-
class="button"
13+
mat-button
1514
routerLink="/test"
16-
routerLinkActive="activebutton"
17-
ariaCurrentWhenActive="page"
15+
routerLinkActive="active"
16+
[routerLinkActiveOptions]="{ exact: true }"
1817
>
1918
Test
2019
</a>
21-
</nav>
20+
</mat-toolbar>
2221

23-
<router-outlet />
22+
<!-- Wrapper div for styling purposes -->
23+
<div class="content-wrapper">
24+
<router-outlet></router-outlet>
25+
</div>

src/app/app.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ import {
66
RouterLink,
77
RouterLinkActive,
88
} from '@angular/router';
9+
import { MatToolbarModule } from '@angular/material/toolbar';
910

1011
@Component({
1112
selector: 'app-root',
1213
standalone: true,
13-
imports: [CommonModule, RouterOutlet, RouterLink, RouterLinkActive],
14+
imports: [
15+
CommonModule,
16+
RouterOutlet,
17+
RouterLink,
18+
RouterLinkActive,
19+
MatToolbarModule,
20+
],
1421
templateUrl: './app.component.html',
1522
styleUrl: './app.component.css',
1623
})

src/app/app.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
22
import { provideRouter } from '@angular/router';
33
import { provideHttpClient } from '@angular/common/http';
44
import { routes } from './app.routes';
5+
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
56

67
export const appConfig: ApplicationConfig = {
78
providers: [
89
provideZoneChangeDetection({ eventCoalescing: true }),
910
provideRouter(routes),
10-
provideHttpClient(),
11+
provideHttpClient(), provideAnimationsAsync(),
1112
],
1213
};

src/app/notes/notes.component.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
.mat-card {
2+
margin: 20px;
3+
}
4+
5+
.mat-form-field {
6+
width: 100%; /* Full width for the input field */
7+
}
8+
9+
/* Additional styles for layout */
10+
button {
11+
margin-left: 10px; /* Ensures spacing between buttons */
12+
}
13+
14+
.mat-card-actions {
15+
display: flex;
16+
align-items: center;
17+
justify-content: space-between;
18+
}

src/app/notes/notes.component.html

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1-
<h3>Notes</h3>
2-
<ul>
3-
<li *ngFor="let note of notes">
4-
{{ note.content }}
5-
<button (click)="deleteNote(note.id)">Delete</button>
6-
<button (click)="prepareUpdate(note)">Update to 'Updated Note'</button>
7-
</li>
8-
</ul>
1+
<!-- Main Application Title -->
2+
<h1>Notes Application</h1>
93

10-
<input type="text" [(ngModel)]="newNoteContent" />
11-
<button (click)="addNote()">Add Note</button>
4+
<!-- Add Notes Section -->
5+
6+
<div style="display: flex; align-items: center">
7+
<mat-form-field appearance="fill" style="flex: 1">
8+
<mat-label>Add new note</mat-label>
9+
<input matInput [(ngModel)]="newNoteContent" />
10+
</mat-form-field>
11+
<button mat-flat-button (click)="addNote()" style="margin: 8px">
12+
Add Note
13+
</button>
14+
</div>
15+
16+
<!-- Notes List -->
17+
<div *ngFor="let note of notes" style="margin-bottom: 20px">
18+
<mat-card>
19+
<mat-card-content
20+
style="display: flex; justify-content: space-between; align-items: center"
21+
>
22+
<span>{{ note.content }}</span>
23+
<div>
24+
<button mat-button color="warn" (click)="deleteNote(note.id)">
25+
Delete
26+
</button>
27+
<button mat-button color="primary" (click)="prepareUpdate(note)">
28+
Update
29+
</button>
30+
</div>
31+
</mat-card-content>
32+
</mat-card>
33+
</div>

src/app/notes/notes.component.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { FormsModule } from '@angular/forms';
33
import { NgFor } from '@angular/common';
44
import { ApiService } from '../api.service';
55

6+
import { MatListModule } from '@angular/material/list';
7+
import { MatButtonModule } from '@angular/material/button';
8+
import { MatInputModule } from '@angular/material/input';
9+
import { MatFormFieldModule } from '@angular/material/form-field';
10+
import { MatCardModule } from '@angular/material/card';
11+
612
export interface Note {
713
id: number;
814
content: string;
@@ -13,7 +19,15 @@ export interface Note {
1319
templateUrl: './notes.component.html',
1420
styleUrls: ['./notes.component.css'],
1521
standalone: true,
16-
imports: [NgFor, FormsModule], // Include FormsModule here
22+
imports: [
23+
NgFor,
24+
FormsModule,
25+
MatListModule,
26+
MatButtonModule,
27+
MatInputModule,
28+
MatFormFieldModule,
29+
MatCardModule,
30+
],
1731
})
1832
export class NotesComponent implements OnInit {
1933
notes: Note[] = [];

0 commit comments

Comments
 (0)