File tree 7 files changed +19
-25
lines changed
7 files changed +19
-25
lines changed Original file line number Diff line number Diff line change 1
- < app-header [ngStyle] ="setFont () "> </ app-header >
2
- < div class ="content " [ngStyle] ="setFont () ">
1
+ < app-header [ngStyle] ="setStyle () "> </ app-header >
2
+ < div class ="content " [ngStyle] ="setStyle () ">
3
3
< router-outlet > </ router-outlet >
4
4
</ div >
Original file line number Diff line number Diff line change 1
1
import { Component } from "@angular/core" ;
2
2
import { UserService } from "../services/user.service" ;
3
- import fonts from "../fonts" ;
3
+ import { BASE_FONT_SIZE , DEFAULT_FONT_SIZE } from "../fonts" ;
4
4
5
5
@Component ( {
6
6
selector : "app-root" ,
@@ -10,25 +10,26 @@ import fonts from "../fonts";
10
10
export class AppComponent
11
11
{
12
12
title = "starter-quiz" ;
13
- fontSizes = [ '22px' , '25px' , '28px' ] ;
14
13
public fontSize : string ;
15
14
public font : string ;
16
15
constructor ( private userService : UserService )
17
16
{
18
17
}
19
18
19
+ toPixels ( n : number ) : string {
20
+ return n * 3 + BASE_FONT_SIZE + 'px' ;
21
+ }
22
+
20
23
ngOnInit ( ) {
21
24
this . userService . currentUser
22
25
. subscribe ( user =>
23
26
{
24
- this . fontSize = this . fontSizes [ user ?. fontSize ?? 1 ] ;
27
+ this . fontSize = this . toPixels ( user ?. fontSize ?? DEFAULT_FONT_SIZE ) ;
25
28
this . font = user ?. font ?? "Arial" ;
26
-
27
- document . querySelector ( 'html' ) . style . fontSize = this . fontSize ;
28
29
} ) ;
29
30
}
30
31
31
- setFont ( ) {
32
- return { 'font-family' : this . font } ;
32
+ setStyle ( ) {
33
+ return { 'font-family' : this . font , 'font-size' : this . fontSize } ;
33
34
}
34
35
}
Original file line number Diff line number Diff line change 1
1
< div class ="header d-flex justify-content-between " *ngIf ="user != null ">
2
2
3
-
4
3
< div class ="epsilon p-2 ">
5
4
< button class ="btn btn-xs btn-green " (click) ="accueil() ">
6
5
< i class ="bi-house "> </ i >
15
14
</ div >
16
15
17
16
< div class ="epsilon ml-auto p-2 d-flex align-items-center ">
18
- <!-- Changer la taille de police-->
19
- <!-- <button class="btn btn-xs btn-green ml-3" (click)="changeFont(true)">-->
20
- <!-- <i class="bi-plus"></i>-->
21
- <!-- <span>Augmenter</span>-->
22
- <!-- </button>-->
23
- <!-- <button class="btn btn-xs btn-green" (click)="changeFont(false)">-->
24
- <!-- <i class="bi-dash"></i>-->
25
- <!-- <span>Diminuer</span>-->
26
- <!-- </button>-->
27
17
< button class ="btn btn-xs btn-green " (click) ="toggleParams() ">
28
18
< i class ="bi-file-earmark-font "> </ i >
29
19
< span > Taille et Police</ span >
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import { UserService } from "../../services/user.service";
3
3
import { User } from "../../models/user.model" ;
4
4
import { Router } from "@angular/router" ;
5
5
import { FormControl } from "@angular/forms" ;
6
- import fonts from "../../fonts" ;
6
+ import { fonts } from "../../fonts" ;
7
7
8
8
9
9
@Component ( {
Original file line number Diff line number Diff line change 1
- export default [ "Arial" , "Noto Sans JP" ] ;
1
+ export let fonts = [ "Arial" , "Noto Sans JP" ] ;
2
+ export let MAX_FONT_SIZE = 6 ;
3
+ export let DEFAULT_FONT_SIZE = 1 ;
4
+ export let BASE_FONT_SIZE = 22 ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { User } from "../models/user.model";
4
4
import { HttpClient } from "@angular/common/http" ;
5
5
import { map } from "rxjs/operators" ;
6
6
import { Observable } from "rxjs/Rx" ;
7
- import fonts from "../fonts" ;
7
+ import { DEFAULT_FONT_SIZE , fonts , MAX_FONT_SIZE } from "../fonts" ;
8
8
9
9
@Injectable ( {
10
10
providedIn : "root"
@@ -110,15 +110,15 @@ export class UserService
110
110
111
111
if ( p )
112
112
{
113
- if ( this . user . fontSize >= 2 )
113
+ if ( this . user . fontSize >= MAX_FONT_SIZE )
114
114
{
115
115
return ;
116
116
}
117
117
this . user . fontSize ++ ;
118
118
}
119
119
else
120
120
{
121
- if ( this . user . fontSize <= 0 )
121
+ if ( this . user . fontSize <= DEFAULT_FONT_SIZE )
122
122
{
123
123
return ;
124
124
}
You can’t perform that action at this time.
0 commit comments