Add Comic Mono to the list (#1330)

* Add Comic Mono to list and make default

* Update preview

* Create folder if missing.

* match composer lock from pr
This commit is contained in:
Charles 2025-05-03 08:21:02 -04:00 committed by GitHub
parent 82ef6c1408
commit a5ffff8c8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 7 deletions

View File

@ -377,7 +377,15 @@ class EditProfile extends BaseEditProfile
Select::make('console_font') Select::make('console_font')
->label(trans('profile.font')) ->label(trans('profile.font'))
->options(function () { ->options(function () {
$fonts = []; $fonts = [
'ComicMono' => 'ComicMono ( Default )', //default
];
if (!File::exists(public_path('storage/fonts'))) {
File::makeDirectory(public_path('storage/fonts'));
$this->fillForm();
}
foreach (File::allFiles(public_path('storage/fonts')) as $file) { foreach (File::allFiles(public_path('storage/fonts')) as $file) {
if ($file->getExtension() === 'ttf') { if ($file->getExtension() === 'ttf') {
$name = pathinfo($file->getFilename(), PATHINFO_FILENAME); $name = pathinfo($file->getFilename(), PATHINFO_FILENAME);
@ -388,14 +396,29 @@ class EditProfile extends BaseEditProfile
return $fonts; return $fonts;
}) })
->reactive() ->reactive()
->default('ComicMono')
->afterStateUpdated(fn ($state, callable $set) => $set('font_preview', $state)), ->afterStateUpdated(fn ($state, callable $set) => $set('font_preview', $state)),
Placeholder::make('font_preview') Placeholder::make('font_preview')
->label('Preview') ->label('Preview')
->content(function (Get $get) { ->content(function (Get $get) {
$fontName = $get('console_font') ?? 'No font selected.'; $fontName = $get('console_font') ?? 'No font selected.';
$fontUrl = asset("storage/fonts/{$fontName}.ttf");
$fontSize = $get('console_font_size') . 'px'; $fontSize = $get('console_font_size') . 'px';
$fontUrl = asset("storage/fonts/{$fontName}.ttf");
if ($fontName === 'ComicMono') {
return new HtmlString(<<<HTML
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/comic-mono@0.0.1/index.css">
<style>
.preview-text {
font-family: Comic Mono;
font-size: $fontSize;
margin-top: 10px;
display: block;
}
</style>
<span class="preview-text">The quick blue pelican jumps over the lazy pterodactyl. :)</span>
HTML);
}
return new HtmlString(<<<HTML return new HtmlString(<<<HTML
<style> <style>

4
composer.lock generated
View File

@ -4,11 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
<<<<<<< HEAD
"content-hash": "27da5be2bf613398e6fa75cdf8131bf7", "content-hash": "27da5be2bf613398e6fa75cdf8131bf7",
=======
"content-hash": "5c5a89d4207dd9efb7a8c3a410aa838c",
>>>>>>> main
"packages": [ "packages": [
{ {
"name": "abdelhamiderrahmouni/filament-monaco-editor", "name": "abdelhamiderrahmouni/filament-monaco-editor",