-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add user preference for theme * fix coalesce expression * fix css selectors * Run php-cs-fixer * fix node build * remove global install of node-gyp --------- Co-authored-by: emmachughes <emmachughes@users.noreply.github.com>
- Loading branch information
1 parent
0f179a8
commit 80fefe0
Showing
13 changed files
with
653 additions
and
5 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
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Configuration; | ||
|
||
final readonly class Themes | ||
{ | ||
/** | ||
* @return array<string> | ||
*/ | ||
public function all(): array | ||
{ | ||
return [ | ||
'edlib', | ||
'light', | ||
'dark', | ||
]; | ||
} | ||
|
||
public function getName(string $theme, string $locale): string|null | ||
{ | ||
return match ($theme) { | ||
'edlib' => 'Edlib', | ||
'light' => match ($locale) { | ||
'nb', 'no' => 'Bootstrap lys', | ||
default => 'Bootstrap Light', | ||
}, | ||
'dark' => match ($locale) { | ||
'nb', 'no' => 'Bootstrap mørk', | ||
default => 'Bootstrap Dark', | ||
}, | ||
default => null, | ||
}; | ||
} | ||
|
||
public function getDefault(): string | ||
{ | ||
return 'edlib'; | ||
} | ||
|
||
/** | ||
* @return array<string, string> | ||
*/ | ||
public function getTranslatedMap(string $locale): array | ||
{ | ||
return array_combine($this->all(), array_map( | ||
fn (string $key) => $this->getName($key, $locale) ?? $key, | ||
$this->all(), | ||
)); | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
sourcecode/hub/database/migrations/2023_08_31_080000_add_user_theme_setting.php
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class () extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::table('users', function (Blueprint $table) { | ||
$table->string('theme')->nullable(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::table('users', function (Blueprint $table) { | ||
$table->dropColumn('theme'); | ||
}); | ||
} | ||
}; |
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
Oops, something went wrong.