From 215d90767e725b2f038c4ea07c6d0e27cac8b070 Mon Sep 17 00:00:00 2001 From: mastah Date: Fri, 30 Jan 2026 23:40:07 +0100 Subject: [PATCH] Added colors with persistence based on local storage --- src/app/components/app/app.component.html | 12 +++++- src/app/components/app/app.component.scss | 25 ++++++----- src/app/components/app/app.component.ts | 32 ++++++++++++++ .../identitycard/identitycard.component.html | 2 +- .../components/mobile/mobile.component.html | 2 +- src/styles.scss | 42 ++++++++++++++++--- 6 files changed, 94 insertions(+), 21 deletions(-) diff --git a/src/app/components/app/app.component.html b/src/app/components/app/app.component.html index 6c578e3..3ffd704 100644 --- a/src/app/components/app/app.component.html +++ b/src/app/components/app/app.component.html @@ -4,14 +4,22 @@ @if (showControls) {
- + REGON NIP PESEL DOWÓD - MOBILNY + KOMÓRA IBAN + + + @for (theme of themes; track theme.value) { + + {{theme.name}} + + } +
}
diff --git a/src/app/components/app/app.component.scss b/src/app/components/app/app.component.scss index 263d3a0..117e2e8 100644 --- a/src/app/components/app/app.component.scss +++ b/src/app/components/app/app.component.scss @@ -3,9 +3,9 @@ top: 10px; right: 10px; z-index: 11; - background: rgba(255, 255, 255, 0.15); + background: rgba(0, 0, 0, 0.4); 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%; width: 40px; height: 40px; @@ -24,7 +24,7 @@ } &:hover { - background-color: rgba(255, 255, 255, 0.3); + background-color: rgba(255, 255, 255, 0.2); transform: rotate(30deg); } @@ -37,8 +37,9 @@ .controls { display: flex; - flex-direction: column; - align-items: flex-end; + flex-direction: row; + align-items: flex-start; + gap: 10px; padding: 0; position: fixed; top: 60px; @@ -52,21 +53,22 @@ } mat-button-toggle-group { - background: rgba(255, 255, 255, 0.15); + background: rgba(0, 0, 0, 0.4); 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; - box-shadow: 0 4px 16px 0 rgba(0, 38, 135, 0.2); + box-shadow: 0 4px 16px 0 var(--shadow-color); overflow: hidden; flex-direction: column; + transition: box-shadow 0.5s ease; } mat-button-toggle { color: white; 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; - background-color: rgba(51, 98, 188, 0.4); + background-color: rgba(0, 0, 0, 0.2); width: 100%; &:last-child { @@ -74,8 +76,9 @@ } &.mat-button-toggle-checked { - background-color: rgba(255, 255, 255, 0.3); + background-color: rgba(255, 255, 255, 0.2); color: white; + font-weight: bold; } &:hover { diff --git a/src/app/components/app/app.component.ts b/src/app/components/app/app.component.ts index a92b09d..359bc4e 100644 --- a/src/app/components/app/app.component.ts +++ b/src/app/components/app/app.component.ts @@ -17,17 +17,49 @@ export class AppComponent implements OnInit { showControls = false; 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) { } ngOnInit(): void { + const savedTheme = localStorage.getItem('selectedTheme'); + if (savedTheme) { + this.selectedTheme = savedTheme; + this.applyTheme(savedTheme); + } setTimeout(() => { this.isInitialVisible = false; this.cdr.detectChanges(); }, 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']) clickout(event: Event) { const settingsButton = this.eRef.nativeElement.querySelector('.settings-button'); diff --git a/src/app/components/identitycard/identitycard.component.html b/src/app/components/identitycard/identitycard.component.html index 3356630..057e784 100644 --- a/src/app/components/identitycard/identitycard.component.html +++ b/src/app/components/identitycard/identitycard.component.html @@ -1,6 +1,6 @@
- DOWÓD OSOBISTY + DOWÓD
diff --git a/src/app/components/mobile/mobile.component.html b/src/app/components/mobile/mobile.component.html index 73d80f8..59ad952 100644 --- a/src/app/components/mobile/mobile.component.html +++ b/src/app/components/mobile/mobile.component.html @@ -1,6 +1,6 @@
- KOMÓRKA + KOMÓRA
diff --git a/src/styles.scss b/src/styles.scss index a0f2da4..8441454 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -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-family: 'Comfortaa'; src: url('assets/Comfortaa-VariableFont_wght.ttf'); @@ -14,6 +39,7 @@ body { border: none; font-size: 150%; font-family: 'Comfortaa', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + transition: background 0.5s ease; } .gradient { @@ -23,7 +49,8 @@ body { right: 0; bottom: 0; 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 { @@ -38,9 +65,10 @@ body { .generator { margin: 1em; 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: 1px solid rgba( 255, 255, 255, 0.18 ); + transition: box-shadow 0.5s ease; } .container { @@ -138,9 +166,10 @@ input[type="text"] { color: white; 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: 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 { border-bottom: 3px solid #87e17a @@ -165,9 +194,10 @@ input[type="number"] { color: white; 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: 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,