Added colors with persistence based on local storage

This commit was merged in pull request #10.
This commit is contained in:
2026-01-30 23:40:07 +01:00
parent 79bddf9f39
commit 215d90767e
6 changed files with 94 additions and 21 deletions

View File

@@ -4,14 +4,22 @@
</button> </button>
@if (showControls) { @if (showControls) {
<div class="controls"> <div class="controls">
<mat-button-toggle-group vertical multiple> <mat-button-toggle-group vertical multiple class="generator-toggles">
<mat-button-toggle [checked]="showRegon" (change)="showRegon = $event.source.checked">REGON</mat-button-toggle> <mat-button-toggle [checked]="showRegon" (change)="showRegon = $event.source.checked">REGON</mat-button-toggle>
<mat-button-toggle [checked]="showNip" (change)="showNip = $event.source.checked">NIP</mat-button-toggle> <mat-button-toggle [checked]="showNip" (change)="showNip = $event.source.checked">NIP</mat-button-toggle>
<mat-button-toggle [checked]="showPesel" (change)="showPesel = $event.source.checked">PESEL</mat-button-toggle> <mat-button-toggle [checked]="showPesel" (change)="showPesel = $event.source.checked">PESEL</mat-button-toggle>
<mat-button-toggle [checked]="showIdentityCard" (change)="showIdentityCard = $event.source.checked">DOWÓD</mat-button-toggle> <mat-button-toggle [checked]="showIdentityCard" (change)="showIdentityCard = $event.source.checked">DOWÓD</mat-button-toggle>
<mat-button-toggle [checked]="showMobile" (change)="showMobile = $event.source.checked">MOBILNY</mat-button-toggle> <mat-button-toggle [checked]="showMobile" (change)="showMobile = $event.source.checked">KOMÓRA</mat-button-toggle>
<mat-button-toggle [checked]="showIban" (change)="showIban = $event.source.checked">IBAN</mat-button-toggle> <mat-button-toggle [checked]="showIban" (change)="showIban = $event.source.checked">IBAN</mat-button-toggle>
</mat-button-toggle-group> </mat-button-toggle-group>
<mat-button-toggle-group vertical class="theme-toggles">
@for (theme of themes; track theme.value) {
<mat-button-toggle [checked]="selectedTheme === theme.value" (change)="setTheme(theme.value)">
{{theme.name}}
</mat-button-toggle>
}
</mat-button-toggle-group>
</div> </div>
} }
<div class="generators"> <div class="generators">

View File

@@ -3,9 +3,9 @@
top: 10px; top: 10px;
right: 10px; right: 10px;
z-index: 11; z-index: 11;
background: rgba(255, 255, 255, 0.15); background: rgba(0, 0, 0, 0.4);
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2); border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 50%; border-radius: 50%;
width: 40px; width: 40px;
height: 40px; height: 40px;
@@ -24,7 +24,7 @@
} }
&:hover { &:hover {
background-color: rgba(255, 255, 255, 0.3); background-color: rgba(255, 255, 255, 0.2);
transform: rotate(30deg); transform: rotate(30deg);
} }
@@ -37,8 +37,9 @@
.controls { .controls {
display: flex; display: flex;
flex-direction: column; flex-direction: row;
align-items: flex-end; align-items: flex-start;
gap: 10px;
padding: 0; padding: 0;
position: fixed; position: fixed;
top: 60px; top: 60px;
@@ -52,21 +53,22 @@
} }
mat-button-toggle-group { mat-button-toggle-group {
background: rgba(255, 255, 255, 0.15); background: rgba(0, 0, 0, 0.4);
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2); border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px; border-radius: 8px;
box-shadow: 0 4px 16px 0 rgba(0, 38, 135, 0.2); box-shadow: 0 4px 16px 0 var(--shadow-color);
overflow: hidden; overflow: hidden;
flex-direction: column; flex-direction: column;
transition: box-shadow 0.5s ease;
} }
mat-button-toggle { mat-button-toggle {
color: white; color: white;
font-family: 'Comfortaa', sans-serif; font-family: 'Comfortaa', sans-serif;
border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important; border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
border-left: none !important; border-left: none !important;
background-color: rgba(51, 98, 188, 0.4); background-color: rgba(0, 0, 0, 0.2);
width: 100%; width: 100%;
&:last-child { &:last-child {
@@ -74,8 +76,9 @@
} }
&.mat-button-toggle-checked { &.mat-button-toggle-checked {
background-color: rgba(255, 255, 255, 0.3); background-color: rgba(255, 255, 255, 0.2);
color: white; color: white;
font-weight: bold;
} }
&:hover { &:hover {

View File

@@ -17,17 +17,49 @@ export class AppComponent implements OnInit {
showControls = false; showControls = false;
isInitialVisible = true; isInitialVisible = true;
selectedTheme = '';
themes = [
{ name: 'BŁĘKITNY', value: '' },
{ name: 'AMARANTOWY', value: 'theme-light-blue' },
{ name: 'MIEDZIANY', value: 'theme-light-orange' },
{ name: 'ŁOSOSIOWY', value: 'theme-light-pink' },
{ name: 'OLIWKOWY', value: 'theme-dark-grey' }
];
constructor(private cdr: ChangeDetectorRef, private eRef: ElementRef) { constructor(private cdr: ChangeDetectorRef, private eRef: ElementRef) {
} }
ngOnInit(): void { ngOnInit(): void {
const savedTheme = localStorage.getItem('selectedTheme');
if (savedTheme) {
this.selectedTheme = savedTheme;
this.applyTheme(savedTheme);
}
setTimeout(() => { setTimeout(() => {
this.isInitialVisible = false; this.isInitialVisible = false;
this.cdr.detectChanges(); this.cdr.detectChanges();
}, 3000); }, 3000);
} }
setTheme(theme: string) {
this.selectedTheme = theme;
localStorage.setItem('selectedTheme', theme);
this.applyTheme(theme);
}
private applyTheme(theme: string) {
const body = document.body;
this.themes.forEach(t => {
if (t.value) {
body.classList.remove(t.value);
}
});
if (theme) {
body.classList.add(theme);
}
}
@HostListener('document:click', ['$event']) @HostListener('document:click', ['$event'])
clickout(event: Event) { clickout(event: Event) {
const settingsButton = this.eRef.nativeElement.querySelector('.settings-button'); const settingsButton = this.eRef.nativeElement.querySelector('.settings-button');

View File

@@ -1,6 +1,6 @@
<div class="generator"> <div class="generator">
<div class="title"> <div class="title">
<span>DOWÓD OSOBISTY</span> <span>DOWÓD</span>
</div> </div>
<div class="container"> <div class="container">
<input type="text" [formControl]="valueField" /> <input type="text" [formControl]="valueField" />

View File

@@ -1,6 +1,6 @@
<div class="generator"> <div class="generator">
<div class="title"> <div class="title">
<span>KOMÓRKA</span> <span>KOMÓRA</span>
<div class="titleButtons"> <div class="titleButtons">
</div> </div>
</div> </div>

View File

@@ -1,3 +1,28 @@
:root {
--primary-gradient: linear-gradient(to bottom, #3362bc, #4f7cd1, #3362bc);
--shadow-color: rgba(1, 29, 96, 0.37);
}
.theme-light-blue {
--primary-gradient: linear-gradient(to bottom, #2a0f39, #491375, #241345);
--shadow-color: rgb(10, 1, 43);
}
.theme-light-orange {
--primary-gradient: linear-gradient(to bottom, #673e1b, #9c6b37, #633718);
--shadow-color: rgb(43, 19, 1);
}
.theme-light-pink {
--primary-gradient: linear-gradient(to bottom, #78424c, #7a4d54, #90505a);
--shadow-color: rgb(32, 16, 18);
}
.theme-dark-grey {
--primary-gradient: linear-gradient(to bottom, #2f4f37, #456c37, #2f4f37);
--shadow-color: rgba(0, 0, 0, 0.5);
}
@font-face { @font-face {
font-family: 'Comfortaa'; font-family: 'Comfortaa';
src: url('assets/Comfortaa-VariableFont_wght.ttf'); src: url('assets/Comfortaa-VariableFont_wght.ttf');
@@ -14,6 +39,7 @@ body {
border: none; border: none;
font-size: 150%; font-size: 150%;
font-family: 'Comfortaa', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-family: 'Comfortaa', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
transition: background 0.5s ease;
} }
.gradient { .gradient {
@@ -23,7 +49,8 @@ body {
right: 0; right: 0;
bottom: 0; bottom: 0;
z-index: -1; z-index: -1;
background-image: linear-gradient(to bottom, #3362bc, #3d6cc7, #4776d1, #5181dc, #5a8be7, #5a8be7, #5b8ae7, #5b8ae7, #527fdc, #4975d1, #406ac7, #3760bc); background-image: var(--primary-gradient);
transition: background-image 0.5s ease;
} }
.generators { .generators {
@@ -38,9 +65,10 @@ body {
.generator { .generator {
margin: 1em; margin: 1em;
background: rgba( 255, 255, 255, 0.15 ); background: rgba( 255, 255, 255, 0.15 );
box-shadow: 0 8px 32px 0 rgba( 0, 38, 135, 0.37 ); box-shadow: 0 8px 32px 0 var(--shadow-color);
border-radius: 3px; border-radius: 3px;
border: 1px solid rgba( 255, 255, 255, 0.18 ); border: 1px solid rgba( 255, 255, 255, 0.18 );
transition: box-shadow 0.5s ease;
} }
.container { .container {
@@ -138,9 +166,10 @@ input[type="text"] {
color: white; color: white;
background: rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.15);
box-shadow: 0 8px 32px 0 rgba( 0, 38, 135, 0.37 ); box-shadow: 0 8px 32px 0 var(--shadow-color);
border-radius: 3px; border-radius: 3px;
border: 1px solid rgba(255, 255, 255, 0.20); border: 1px solid rgba(255, 255, 255, 0.20);
transition: box-shadow 0.5s ease;
&.ng-valid { &.ng-valid {
border-bottom: 3px solid #87e17a border-bottom: 3px solid #87e17a
@@ -165,9 +194,10 @@ input[type="number"] {
color: white; color: white;
background: rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.15);
box-shadow: 0 8px 32px 0 rgba( 0, 38, 135, 0.37 ); box-shadow: 0 8px 32px 0 var(--shadow-color);
border-radius: 3px; border-radius: 3px;
border: 1px solid rgba(255, 255, 255, 0.20); border: 1px solid rgba(255, 255, 255, 0.20);
transition: box-shadow 0.5s ease;
} }
input::-webkit-outer-spin-button, input::-webkit-outer-spin-button,