diff --git a/app/Http/Controllers/ProfileUserController.php b/app/Http/Controllers/ProfileUserController.php index 7a06f489..55c4b11c 100644 --- a/app/Http/Controllers/ProfileUserController.php +++ b/app/Http/Controllers/ProfileUserController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use App\Http\Requests\Auth\ProfileUserPasswordResetRequest; +use App\Http\Requests\Auth\ThemeChangeRequest; use App\Http\Resources\UserResource; use Illuminate\Contracts\Hashing\Hasher; use Illuminate\Http\RedirectResponse; @@ -37,4 +38,16 @@ public function update(ProfileUserPasswordResetRequest $request, Hasher $hasher) return redirect()->back() ->with("status", "Zaktualizowano hasło"); } + + public function updateTheme(ThemeChangeRequest $request): RedirectResponse + { + $validated = $request->validated(); + + $user = $request->user(); + $user->theme = $validated["theme"]; + $user->save(); + + return redirect()->back() + ->with("status", "Zaktualizowano motyw"); + } } diff --git a/app/Http/Requests/Auth/ThemeChangeRequest.php b/app/Http/Requests/Auth/ThemeChangeRequest.php new file mode 100644 index 00000000..cbfa323b --- /dev/null +++ b/app/Http/Requests/Auth/ThemeChangeRequest.php @@ -0,0 +1,22 @@ + "required|string|max:255", + ]; + } +} diff --git a/app/Http/Requests/UserRequest.php b/app/Http/Requests/UserRequest.php index b97c3d16..3c7223d1 100644 --- a/app/Http/Requests/UserRequest.php +++ b/app/Http/Requests/UserRequest.php @@ -20,6 +20,7 @@ public function rules(): array "name" => ["required", "string", "max:255"], "surname" => ["required", "string", "max:255"], "school_id" => ["required", "integer", "exists:schools,id"], + "theme" => "nullable|string|max:255", ]; } } diff --git a/app/Http/Resources/UserResource.php b/app/Http/Resources/UserResource.php index 941162c2..a1becf75 100644 --- a/app/Http/Resources/UserResource.php +++ b/app/Http/Resources/UserResource.php @@ -23,6 +23,7 @@ public function toArray(Request $request): array "isAnonymized" => $this->is_anonymized, "isAdmin" => $this->hasRole("admin"), "isSuperAdmin" => $this->hasRole("super_admin"), + "theme" => $this->theme, ]; } } diff --git a/database/migrations/2024_11_25_214101_add_theme_to_users_table.php b/database/migrations/2024_11_25_214101_add_theme_to_users_table.php new file mode 100644 index 00000000..6abdc641 --- /dev/null +++ b/database/migrations/2024_11_25_214101_add_theme_to_users_table.php @@ -0,0 +1,23 @@ +string("theme")->default("theme-witelon")->after("email"); + }); + } + + public function down(): void + { + Schema::table("users", function (Blueprint $table): void { + $table->dropColumn("theme"); + }); + } +}; diff --git a/resources/css/app.css b/resources/css/app.css index 0a3647ec..77274f23 100644 --- a/resources/css/app.css +++ b/resources/css/app.css @@ -7,6 +7,18 @@ font-family: 'Poppins', sans-serif; } +.theme-witelon { + --color-primary: 38 44 137; + --color-primary-bright: 37 43 174; + --color-primary-dark: 20 22 71; +} + +.theme-tauron { + --color-primary: 228 0 125; + --color-primary-bright: 245 13 147; + --color-primary-dark: 176 4 96; +} + .v-enter-active, .v-leave-active { transition: opacity 0.3s ease; diff --git a/resources/js/Layouts/BaseLayout.vue b/resources/js/Layouts/BaseLayout.vue index 96abd0eb..2352857f 100644 --- a/resources/js/Layouts/BaseLayout.vue +++ b/resources/js/Layouts/BaseLayout.vue @@ -3,12 +3,19 @@ import Header from '@/components/Common/Header.vue' import Footer from '@/components/Common/Footer.vue' import BackgroundEffect from '@/components/Common/BackgroundEffect.vue' import Banner from '@/components/Common/Banner.vue' -import {ref, watch} from 'vue' +import {onMounted, ref, watch} from 'vue' import {type PageProps} from '@/Types/PageProps' const props = defineProps<{ pages: Page[] } & PageProps>() const status = ref(props.flash.status) +onMounted(()=>{ + const themeClass = props.user?.theme + if (themeClass) { + document.documentElement.classList.add(themeClass) + } +}) + watch(() => props.flash, flash => { status.value = flash.status }, { immediate: true }) @@ -20,7 +27,7 @@ watch(() => props.flash, flash => {
-
+
diff --git a/resources/js/Pages/Admin/QuizDemo.vue b/resources/js/Pages/Admin/QuizDemo.vue index 0a3f0043..b9dd7252 100644 --- a/resources/js/Pages/Admin/QuizDemo.vue +++ b/resources/js/Pages/Admin/QuizDemo.vue @@ -1,5 +1,5 @@ + + diff --git a/resources/js/components/Home/AuthBanner.vue b/resources/js/components/Home/AuthBanner.vue index 3bd1e561..ac5bc996 100644 --- a/resources/js/components/Home/AuthBanner.vue +++ b/resources/js/components/Home/AuthBanner.vue @@ -49,7 +49,7 @@ function gotoLoginSection() {