Ajouts de styles et améliorations de code

ludo^2
Raphael LACOTE 8 months ago
parent 1af748e6f1
commit 1dc47e6b7a

@ -1,22 +1,16 @@
<!-- <app-book-menu></app-book-menu> -->
<h2>{{formattedDate}}</h2> <h2>{{formattedDate}}</h2>
<table> <table>
<tbody> <tbody>
<tr> <tr>
<th>LUN</th> <th *ngFor="let d of day">
<th>MAR</th> {{ d }}
<th>MER</th> </th>
<th>JEU</th>
<th>VEN</th>
<th>SAM</th>
<th>DIM</th>
</tr> </tr>
<tr> <tr>
<th *ngFor="let azerty of streaks"> <th *ngFor="let streak of streaks">
{{ azerty }} {{ streak }}
</th> </th>
</tr> </tr>
</tbody> </tbody>

@ -3,6 +3,7 @@ import { RouterModule } from '@angular/router';
import { UserMenuComponent } from '../user-menu/user-menu.component'; import { UserMenuComponent } from '../user-menu/user-menu.component';
import { UserService } from '../../services/user-service'; import { UserService } from '../../services/user-service';
import { NgFor } from '@angular/common'; import { NgFor } from '@angular/common';
import { DatePipe } from '@angular/common';
interface Streak { interface Streak {
day: string day: string
@ -12,7 +13,7 @@ interface Streak {
@Component({ @Component({
selector: 'app-user-accueil', selector: 'app-user-accueil',
standalone: true, standalone: true,
imports: [UserMenuComponent,RouterModule,NgFor], imports: [UserMenuComponent,RouterModule,NgFor,DatePipe],
templateUrl: './user-accueil.component.html', templateUrl: './user-accueil.component.html',
styleUrl: './user-accueil.component.css' styleUrl: './user-accueil.component.css'
}) })
@ -20,17 +21,13 @@ interface Streak {
export class UserAccueilComponent { export class UserAccueilComponent {
protected formattedDate : String protected formattedDate : String
protected streaks: Object[] protected streaks: Object[]
protected day: String[]
public constructor(us : UserService) { public constructor(us : UserService) {
const currentDate: Date = new Date this.formattedDate = this.getDate()
const options: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'long',
day: 'numeric'
}
this.formattedDate = currentDate.toLocaleDateString(undefined, options)
this.streaks = ["❌","❌","❌","❌","❌","❌","❌"] this.streaks = ["❌","❌","❌","❌","❌","❌","❌"]
this.day = ["L","M","M","J","V","S","D"]
let userConnecte = localStorage.getItem('UserConnecte') let userConnecte = localStorage.getItem('UserConnecte')
if(userConnecte == undefined) {return} if(userConnecte == undefined) {return}
@ -42,8 +39,10 @@ export class UserAccueilComponent {
if(streaks == undefined) {return} if(streaks == undefined) {return}
this.streaks = [] this.streaks = []
this.day = []
streaks.forEach(element => { streaks.forEach(element => {
let a : Streak = element as Streak let a : Streak = element as Streak
this.day.push(a["day"])
if(a["isPlayed"]){ if(a["isPlayed"]){
this.streaks.push("✅") this.streaks.push("✅")
} else { } else {
@ -53,4 +52,15 @@ export class UserAccueilComponent {
} }
public getDate(): String{
const currentDate: Date = new Date
const options: Intl.DateTimeFormatOptions = {
year: 'numeric',
month: 'long',
day: 'numeric'
}
return currentDate.toLocaleDateString(undefined, options)
}
} }

@ -0,0 +1,33 @@
nav[mat-tab-nav-bar] {
display: flex;
justify-content: space-between;
background-color: #333;
padding: 10px 0
}
mat-tab-link, button[mat-button] {
flex: 1;
text-align: center;
color: white;
background-color: #444;
border: none;
padding: 15px;
cursor: pointer;
transition: background-color 0.3s;
}
mat-tab-link:hover, button[mat-button]:hover {
background-color: #555;
}
a[mat-menu-item] {
text-align: center; /* Centrer le texte des éléments de menu */
padding: 10px; /* Espacement interne pour le menu */
display: block; /* Faire en sorte que le lien prenne toute la largeur */
color: #111; /* Couleur du texte du menu */
}
a[mat-menu-item]:hover {
background-color: #555; /* Couleur au survol pour le menu */
}

@ -1,9 +1,8 @@
<mat-menu #menu="matMenu"> <mat-menu #menu="matMenu">
<a mat-menu-item routerLink="/sudoku" routerLinkActive="active" ariaCurrentWhenActive="page">Sudoku</a> <a mat-menu-item routerLink="/sudoku" routerLinkActive="active" ariaCurrentWhenActive="page">Sudoku</a>
<a mat-menu-item routerLink="/morpion" routerLinkActive="active" ariaCurrentWhenActive="page" aria-disabled="true">Morpion</a> <a mat-menu-item>Morpion</a>
<a mat-menu-item routerLink="/echec" routerLinkActive="active" ariaCurrentWhenActive="page" aria-disabled="true">Echec</a> <a mat-menu-item>Jeu de l'oie</a>
<a mat-menu-item routerLink="/starars" routerLinkActive="active" ariaCurrentWhenActive="page" aria-disabled="true">Star Wars Rebellion</a> <a mat-menu-item>Star Wars Rebellion</a>
</mat-menu> </mat-menu>
<nav mat-tab-nav-bar> <nav mat-tab-nav-bar>
@ -11,5 +10,4 @@
<mat-tab-link label="Accueil" routerLink="/accueil" >Accueil</mat-tab-link> <mat-tab-link label="Accueil" routerLink="/accueil" >Accueil</mat-tab-link>
<mat-tab-link label="Classement" routerLink="/users">Classement</mat-tab-link> <mat-tab-link label="Classement" routerLink="/users">Classement</mat-tab-link>
<button mat-button [matMenuTriggerFor]="menu">Menu</button> <button mat-button [matMenuTriggerFor]="menu">Menu</button>
</nav> </nav>

@ -6,35 +6,40 @@ import { UserService } from '../../services/user-service';
import { MatTabsModule } from '@angular/material/tabs'; import { MatTabsModule } from '@angular/material/tabs';
import { RouterLink } from '@angular/router'; import { RouterLink } from '@angular/router';
import { MatTabNav } from '@angular/material/tabs'; import { MatTabNav } from '@angular/material/tabs';
import { SimpleChanges } from '@angular/core';
@Component({ @Component({
selector: 'app-book-menu', selector: 'app-book-menu',
standalone: true, standalone: true,
imports: [RouterModule, MatButtonModule, MatMenuModule,MatTabsModule,RouterLink,MatTabNav], imports: [RouterModule, MatButtonModule, MatMenuModule,MatTabsModule,RouterLink,MatTabNav],
templateUrl: './user-menu.component.html' templateUrl: './user-menu.component.html',
styleUrl: './user-menu.component.css'
}) })
export class UserMenuComponent { export class UserMenuComponent {
private Service : UserService; private service : UserService;
public userconnecte : String | undefined; public userconnecte : String | undefined;
public route : String | undefined; public route : String | undefined;
public constructor(us: UserService) { public constructor(us: UserService) {
this.Service = us this.service = us
this.reloadPseudo() this.reloadPseudo()
} }
public reloadPseudo(){ public reloadPseudo(){
let id = localStorage.getItem('UserConnecte'); let name = localStorage.getItem('UserConnecte');
if (typeof name === "string" && name !="undefined"){
this.userconnecte = name
// let id : number | undefined = this.service.getIdByUser(name)
// if(id == undefined) return
// this.route = "/user/" + id
// console.log(this.route)
if (typeof id === "string" && id !="undefined"){
let user = this.Service.getUserById(+id)
this.route = "/users/" + user?.id
this.userconnecte = user?.login
this.userconnecte = id
} else { } else {
this.userconnecte = "Pseudo"; this.userconnecte = "Pseudo";
this.route = "/users/0"; this.route = "/user/0";
} }
} }
} }

Loading…
Cancel
Save