Fix missing font (#1404)
Co-authored-by: RMartinOscar <40749467+RMartinOscar@users.noreply.github.com>
This commit is contained in:
parent
bd2a00760d
commit
af609994b6
@ -32,6 +32,7 @@ use Filament\Forms\Components\Textarea;
|
|||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\ToggleButtons;
|
use Filament\Forms\Components\ToggleButtons;
|
||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
|
use Filament\Forms\Set;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Pages\Auth\EditProfile as BaseEditProfile;
|
use Filament\Pages\Auth\EditProfile as BaseEditProfile;
|
||||||
use Filament\Support\Colors\Color;
|
use Filament\Support\Colors\Color;
|
||||||
@ -402,30 +403,38 @@ class EditProfile extends BaseEditProfile
|
|||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
->default('monospace')
|
->default('monospace')
|
||||||
->afterStateUpdated(fn ($state, callable $set) => $set('font_preview', $state)),
|
->afterStateUpdated(fn ($state, Set $set) => $set('font_preview', $state)),
|
||||||
Placeholder::make('font_preview')
|
Placeholder::make('font_preview')
|
||||||
->label(trans('profile.font_preview'))
|
->label(trans('profile.font_preview'))
|
||||||
->columnSpan(2)
|
->columnSpan(2)
|
||||||
->content(function (Get $get) {
|
->content(function (Get $get) {
|
||||||
$fontName = $get('console_font') ?? 'monospace';
|
$fontName = $get('console_font') ?? 'monospace';
|
||||||
$fontSize = $get('console_font_size') . 'px';
|
$fontSize = $get('console_font_size') . 'px';
|
||||||
$fontUrl = asset("storage/fonts/{$fontName}.ttf");
|
$style = <<<CSS
|
||||||
|
.preview-text {
|
||||||
|
font-family: $fontName;
|
||||||
|
font-size: $fontSize;
|
||||||
|
margin-top: 10px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
CSS;
|
||||||
|
if ($fontName !== 'monospace') {
|
||||||
|
$fontUrl = asset("storage/fonts/$fontName.ttf");
|
||||||
|
$style = <<<CSS
|
||||||
|
@font-face {
|
||||||
|
font-family: $fontName;
|
||||||
|
src: url("$fontUrl");
|
||||||
|
}
|
||||||
|
$style
|
||||||
|
CSS;
|
||||||
|
}
|
||||||
|
|
||||||
return new HtmlString(<<<HTML
|
return new HtmlString(<<<HTML
|
||||||
<style>
|
<style>
|
||||||
@font-face {
|
{$style}
|
||||||
font-family: "CustomPreviewFont";
|
</style>
|
||||||
src: url("$fontUrl");
|
<span class="preview-text">The quick blue pelican jumps over the lazy pterodactyl. :)</span>
|
||||||
}
|
HTML);
|
||||||
.preview-text {
|
|
||||||
font-family: "CustomPreviewFont";
|
|
||||||
font-size: $fontSize;
|
|
||||||
margin-top: 10px;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<span class="preview-text">The quick blue pelican jumps over the lazy pterodactyl. :)</span>
|
|
||||||
HTML);
|
|
||||||
}),
|
}),
|
||||||
TextInput::make('console_graph_period')
|
TextInput::make('console_graph_period')
|
||||||
->label(trans('profile.graph_period'))
|
->label(trans('profile.graph_period'))
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
$userFontSize = auth()->user()->getCustomization()['console_font_size'] ?? 14;
|
$userFontSize = auth()->user()->getCustomization()['console_font_size'] ?? 14;
|
||||||
$userRows = auth()->user()->getCustomization()['console_rows'] ?? 30;
|
$userRows = auth()->user()->getCustomization()['console_rows'] ?? 30;
|
||||||
@endphp
|
@endphp
|
||||||
@if($userFont)
|
@if($userFont !== "monospace")
|
||||||
<link rel="preload" href="{{ asset("storage/fonts/{$userFont}.ttf") }}" as="font" crossorigin>
|
<link rel="preload" href="{{ asset("storage/fonts/{$userFont}.ttf") }}" as="font" crossorigin>
|
||||||
<style>
|
<style>
|
||||||
@font-face {
|
@font-face {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user