This commit is contained in:
Zep Fietje
2023-07-31 14:42:19 +02:00
parent 84afc31a41
commit 88e711398e
13 changed files with 13 additions and 71 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ export default {
theme: {
extend: {
fontFamily: {
sans: ['Be Vietnam Pro', 'sans-serif'],
sans: ['Inter', 'sans-serif'],
},
fontWeight: {
normal: 300,
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -66,7 +66,7 @@ $panel
## Changing the font
By default, we use the [Be Vietnam Pro](https://fonts.google.com/specimen/Be+Vietnam+Pro) font. You can change this using the `font()` method in the [configuration](configuration) file:
By default, we use the [Inter](https://fonts.google.com/specimen/Inter) font. You can change this using the `font()` method in the [configuration](configuration) file:
```php
use Filament\Panel;
@@ -75,7 +75,7 @@ public function panel(Panel $panel): Panel
{
return $panel
// ...
->font('Inter');
->font('Poppins');
}
```
@@ -56,11 +56,6 @@
<style>
:root {
--font-family: {!! filament()->getFontFamily() !!};
@foreach (filament()->getFontWeights() as $fontWeightKey => $fontWeightValue)
--font-weight-{{ $fontWeightKey }}: {{ $fontWeightValue }};
@endforeach
--sidebar-width: {{ filament()->getSidebarWidth() }};
--collapsed-sidebar-width: {{ filament()->getCollapsedSidebarWidth() }};
}
-1
View File
@@ -40,7 +40,6 @@ use Illuminate\Support\Facades\Facade;
* @method static Htmlable getFontHtml()
* @method static string getFontProvider()
* @method static string | null getFontUrl()
* @method static array<string, int> getFontWeights()
* @method static array<string> getGlobalSearchKeyBindings()
* @method static GlobalSearchProvider | null getGlobalSearchProvider()
* @method static string | null getHomeUrl()
-8
View File
@@ -154,14 +154,6 @@ class FilamentManager
return $this->getCurrentPanel()->getFontUrl();
}
/**
* @return array<string, int>
*/
public function getFontWeights(): array
{
return $this->getCurrentPanel()->getFontWeights();
}
/**
* @return array<string>
*/
@@ -8,11 +8,10 @@ use Illuminate\Support\Str;
class BunnyFontProvider implements Contracts\FontProvider
{
public function getHtml(string $family, array $weights, ?string $url = null): Htmlable
public function getHtml(string $family, ?string $url = null): Htmlable
{
$family = Str::kebab($family);
$weights = implode(',', array_values($weights));
$url ??= "https://fonts.bunny.net/css?family={$family}:{$weights}&display=swap";
$url ??= "https://fonts.bunny.net/css?family={$family}:400,500,600,700&display=swap";
return new HtmlString("
<link rel=\"preconnect\" href=\"https://fonts.bunny.net\">
@@ -6,8 +6,5 @@ use Illuminate\Contracts\Support\Htmlable;
interface FontProvider
{
/**
* @param array<string, int> $weights
*/
public function getHtml(string $family, array $weights, ?string $url = null): Htmlable;
public function getHtml(string $family, ?string $url = null): Htmlable;
}
@@ -7,11 +7,10 @@ use Illuminate\Support\HtmlString;
class GoogleFontProvider implements Contracts\FontProvider
{
public function getHtml(string $family, array $weights, ?string $url = null): Htmlable
public function getHtml(string $family, ?string $url = null): Htmlable
{
$family = urlencode($family);
$weights = implode(';', array_values($weights));
$url ??= "https://fonts.googleapis.com/css2?family={$family}:wght@{$weights}&display=swap";
$url ??= "https://fonts.googleapis.com/css2?family={$family}:wght@400;500;600;700&display=swap";
return new HtmlString("
<link rel=\"preconnect\" href=\"https://fonts.googleapis.com\">
@@ -8,7 +8,7 @@ use InvalidArgumentException;
class LocalFontProvider implements Contracts\FontProvider
{
public function getHtml(string $family, array $weights, ?string $url = null): Htmlable
public function getHtml(string $family, ?string $url = null): Htmlable
{
if (blank($url)) {
throw new InvalidArgumentException('The local font\'s CSS URL must be specified.');
+2 -34
View File
@@ -13,18 +13,9 @@ trait HasFont
protected ?string $fontUrl = null;
/**
* @var array<string, int> | null
*/
protected ?array $fontWeights = null;
/**
* @param array<string, int> | null $weights
*/
public function font(string $family, ?array $weights = null, ?string $url = null, ?string $provider = null): static
public function font(string $family, ?string $url = null, ?string $provider = null): static
{
$this->fontFamily = $family;
$this->fontWeights = $weights;
$this->fontUrl = $url;
if (filled($provider)) {
@@ -36,14 +27,13 @@ trait HasFont
public function getFontFamily(): string
{
return $this->fontFamily ?? 'Be Vietnam Pro';
return $this->fontFamily ?? 'Inter';
}
public function getFontHtml(): Htmlable
{
return app($this->getFontProvider())->getHtml(
$this->getFontFamily(),
$this->getFontWeights(),
$this->getFontUrl(),
);
}
@@ -57,26 +47,4 @@ trait HasFont
{
return $this->fontUrl;
}
/**
* @return array<string, int>
*/
public function getFontWeights(): array
{
return $this->fontWeights ?? (
$this->fontFamily
? [
'normal' => 400,
'medium' => 500,
'semibold' => 600,
'bold' => 700,
]
: [
'normal' => 300,
'medium' => 400,
'semibold' => 500,
'bold' => 600,
]
);
}
}
@@ -5,11 +5,4 @@ defaultPreset.theme.extend.fontFamily = {
sans: ['var(--font-family)', ...defaultTheme.fontFamily.sans],
}
defaultPreset.theme.extend.fontWeight = {
normal: 'var(--font-weight-normal)',
medium: 'var(--font-weight-medium)',
semibold: 'var(--font-weight-semibold)',
bold: 'var(--font-weight-bold)',
}
export default defaultPreset
@@ -8,7 +8,7 @@ use Illuminate\Support\HtmlString;
class SpatieGoogleFontProvider implements Contracts\FontProvider
{
public function getHtml(string $family, array $weights, ?string $url = null): Htmlable
public function getHtml(string $family, ?string $url = null): Htmlable
{
return new HtmlString(Blade::render('@googlefonts'));
}