This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Moved logic for updating theme preference to user.service - Created types for user settings and color modes - Updated list style
- Loading branch information
Showing
14 changed files
with
188 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,5 @@ public enum ColorMode { | |
GRASSLAND, | ||
SUNSET, | ||
DEVELOPER, | ||
DARK_BV, | ||
AUTUMN | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
...tend/src/app/dashboard/user-settings/user-settings-item/user-settings-item.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
<div class="wrapper" #wrapper> | ||
<mat-card | ||
appearance="outlined" | ||
routerLinkActive="selected" | ||
(click)="switchColor()" | ||
class="settingscard" | ||
|
||
(click)="onSelect.emit()" | ||
(keyup.enter)="onSelect.emit()" | ||
[class.selected]="isSelected" | ||
tabindex="0" | ||
class="settings-card" | ||
> | ||
<div class="ripple-container" mat-ripple [matRippleTrigger]="wrapper"></div> | ||
|
||
<mat-card-content> | ||
<div class="cardcontent-container"> | ||
<p class="colorcard" [style.background]="'var(--'+color+'-primary)'"></p> | ||
{{color}} | ||
</div> | ||
<div class="cardcontent-container"> | ||
<div class="colorcard" [style.background-color]="'var(--' + colorMode.toLowerCase() + '-primary-preview)'"></div> | ||
{{ colorMode | titlecase }} | ||
</div> | ||
</mat-card-content> | ||
</mat-card> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 9 additions & 24 deletions
33
frontend/src/app/dashboard/user-settings/user-settings-item/user-settings-item.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,20 @@ | ||
import {Component, Input, ViewChild} from '@angular/core'; | ||
import {EventOverview} from "../../../../model/event"; | ||
import {User} from "../../../../model/user"; | ||
import {HttpClient} from "@angular/common/http"; | ||
import {UserService} from "../../../../services/user.service"; | ||
import {iconButton} from "material-components-web/index"; | ||
import {Component, EventEmitter, Input, Output} from '@angular/core'; | ||
import {ColorMode} from "../../../../model/user"; | ||
|
||
@Component({ | ||
selector: 'app-user-settings-item', | ||
templateUrl: './user-settings-item.component.html', | ||
styleUrl: './user-settings-item.component.scss' | ||
}) | ||
export class UserSettingsItemComponent { | ||
constructor( | ||
public userService: UserService, | ||
private http: HttpClient | ||
) {} | ||
|
||
@Input() | ||
color!: string; | ||
colorMode!: ColorMode; | ||
|
||
@Input() | ||
isSelected = false; | ||
|
||
@Output() | ||
onSelect = new EventEmitter(); | ||
|
||
//switch color on change | ||
switchColor() { | ||
document.documentElement.setAttribute("theme", this.color); | ||
console.log("curr ColorMode: "+document.documentElement.getAttribute("theme")) | ||
let colormode:string=this.color.replace("-","_").toUpperCase(); | ||
this.http.put("http://localhost:8080/user/self", { | ||
"settings": { | ||
"colorMode" : colormode | ||
} | ||
},{withCredentials: true}).subscribe(result =>{ | ||
console.log(result); | ||
}) | ||
} | ||
} |
42 changes: 31 additions & 11 deletions
42
frontend/src/app/dashboard/user-settings/user-settings.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,42 @@ | ||
<h1 mat-dialog-title class="prim-color">Einstellungen</h1> | ||
<p class="subTitle" mat-dialog-title>Wähle ein Farbschema aus.</p> | ||
<h2 mat-dialog-title class="prim-color"> | ||
Einstellungen | ||
<button mat-icon-button class="close-button" matDialogClose tabindex="-1"> | ||
<mat-icon>close</mat-icon> | ||
</button> | ||
</h2> | ||
<mat-dialog-content> | ||
<p class="subTitle">Day Theme</p> | ||
<mat-divider></mat-divider> | ||
<ul class="color-list"> | ||
<p>Wähle ein Farbschema aus</p> | ||
|
||
@if (userService.user | async; as user) { | ||
<h4 class="section-title">Day Theme</h4> | ||
<ul class="color-list"> | ||
@for (color of lightColors; track color) { | ||
<li> | ||
<app-user-settings-item [color]="color"></app-user-settings-item> | ||
<app-user-settings-item | ||
[colorMode]="color" | ||
[isSelected]="user.settings.colorMode === color" | ||
(onSelect)="selectColorMode(color)" | ||
></app-user-settings-item> | ||
</li> | ||
} | ||
</ul> | ||
<p class="subTitle">Night Theme</p> | ||
<mat-divider></mat-divider> | ||
<ul class="color-list"> | ||
</ul> | ||
|
||
<h4 class="section-title">Night Theme</h4> | ||
<ul class="color-list"> | ||
@for (color of darkColors; track color) { | ||
<li> | ||
<app-user-settings-item [color]="color"></app-user-settings-item> | ||
<app-user-settings-item | ||
[colorMode]="color" | ||
[isSelected]="user.settings.colorMode === color" | ||
(onSelect)="selectColorMode(color)" | ||
></app-user-settings-item> | ||
</li> | ||
} | ||
</ul> | ||
} @else { | ||
<div class="loading-container"> | ||
<mat-spinner></mat-spinner> | ||
<p>Profil wird geladen...</p> | ||
</div> | ||
} | ||
</mat-dialog-content> |
25 changes: 21 additions & 4 deletions
25
frontend/src/app/dashboard/user-settings/user-settings.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,38 @@ | ||
.close-button { | ||
float: right; | ||
margin-top: 8px; | ||
} | ||
|
||
.container { | ||
overflow-y: auto; | ||
height: 100%; | ||
} | ||
|
||
.color-list { | ||
list-style: none; | ||
padding: 0; | ||
margin: 0; | ||
|
||
|
||
li:not(:last-child) { | ||
margin-bottom: var(--size-12); | ||
margin-bottom: 2px; | ||
} | ||
} | ||
.prim-color{ | ||
|
||
.prim-color { | ||
color: var(--primary-color); | ||
} | ||
.subTitle{ | ||
|
||
.section-title { | ||
color: var(--secondary-color); | ||
margin-top: var(--size-24); | ||
} | ||
|
||
.loading-container { | ||
text-align: center; | ||
padding: var(--size-12); | ||
|
||
mat-spinner { | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
} |
21 changes: 16 additions & 5 deletions
21
frontend/src/app/dashboard/user-settings/user-settings.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
import { Component } from '@angular/core'; | ||
import {MatDialogModule} from "@angular/material/dialog"; | ||
import {Component} from '@angular/core'; | ||
import {UserService} from "../../../services/user.service"; | ||
import {ColorMode} from "../../../model/user"; | ||
|
||
@Component({ | ||
selector: 'app-user-settings', | ||
templateUrl: './user-settings.component.html', | ||
styleUrl: './user-settings.component.scss' | ||
}) | ||
export class UserSettingsComponent { | ||
lightColors:string[]=["light", "water", "sunset", "grassland"] | ||
darkColors :string[] = ["dark", "developer","autumn"]; | ||
lightColors = [ColorMode.LIGHT, ColorMode.WATER, ColorMode.SUNSET, ColorMode.GRASSLAND]; | ||
darkColors = [ColorMode.DARK, ColorMode.DEVELOPER, ColorMode.AUTUMN]; | ||
|
||
} | ||
isLoading = false; | ||
|
||
constructor(public userService: UserService) { | ||
} | ||
|
||
selectColorMode(colorMode: ColorMode) { | ||
this.isLoading = true; | ||
this.userService.applyThemeAttribute(colorMode); | ||
this.userService.updateTheme(colorMode).subscribe(() => { | ||
this.isLoading = false; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.