Skip to content

Commit

Permalink
Replace "font" enum with interface
Browse files Browse the repository at this point in the history
  • Loading branch information
svenluijten authored and Sven Luijten committed Jan 8, 2024
1 parent cd63876 commit bcd07fe
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 26 deletions.
16 changes: 0 additions & 16 deletions src/Font.php

This file was deleted.

13 changes: 13 additions & 0 deletions src/Fonts/Inter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace SimonHamp\TheOg\Fonts;

use SimonHamp\TheOg\Interfaces\Font;

class Inter implements Font
{
public function path(): string
{
return __DIR__ . '/../../resources/fonts/Inter/static/Inter-Regular.ttf';
}
}
13 changes: 13 additions & 0 deletions src/Fonts/InterBlack.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace SimonHamp\TheOg\Fonts;

use SimonHamp\TheOg\Interfaces\Font;

class InterBlack implements Font
{
public function path(): string
{
return __DIR__ . '/../../resources/fonts/Inter/static/Inter-Black.ttf';
}
}
13 changes: 13 additions & 0 deletions src/Fonts/InterBold.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace SimonHamp\TheOg\Fonts;

use SimonHamp\TheOg\Interfaces\Font;

class InterBold implements Font
{
public function path(): string
{
return __DIR__ . '/../../resources/fonts/Inter/static/Inter-Bold.ttf';
}
}
13 changes: 13 additions & 0 deletions src/Fonts/InterLight.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace SimonHamp\TheOg\Fonts;

use SimonHamp\TheOg\Interfaces\Font;

class InterLight implements Font
{
public function path(): string
{
return __DIR__ . '/../../resources/fonts/Inter/static/Inter-Light.ttf';
}
}
8 changes: 8 additions & 0 deletions src/Interfaces/Font.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace SimonHamp\TheOg\Interfaces;

interface Font
{
public function path(): string;
}
1 change: 0 additions & 1 deletion src/Interfaces/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace SimonHamp\TheOg\Interfaces;

use Intervention\Image\Colors\Rgb\Color;
use SimonHamp\TheOg\Font;

interface Theme
{
Expand Down
2 changes: 1 addition & 1 deletion src/Layout/TextBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Intervention\Image\Modifiers\TextModifier;
use Intervention\Image\Typography\FontFactory;
use Intervention\Image\Typography\TextBlock;
use SimonHamp\TheOg\Font;
use SimonHamp\TheOg\Interfaces\Font;
use SimonHamp\TheOg\Modifiers\TextModifier as CustomTextModifier;

readonly class TextBox extends Box
Expand Down
2 changes: 1 addition & 1 deletion src/Themes/AbstractTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace SimonHamp\TheOg\Themes;

use Intervention\Image\Colors\Rgb\Color;
use SimonHamp\TheOg\Font;
use SimonHamp\TheOg\Interfaces\Background;
use SimonHamp\TheOg\Interfaces\Font;
use SimonHamp\TheOg\Interfaces\Theme;

abstract class AbstractTheme implements Theme
Expand Down
14 changes: 7 additions & 7 deletions src/Themes/Themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace SimonHamp\TheOg\Themes;

use SimonHamp\TheOg\Font;
use SimonHamp\TheOg\Fonts\{InterBlack, InterBold, InterLight};
use SimonHamp\TheOg\Interfaces\Theme;

enum Themes: string
Expand All @@ -27,12 +27,12 @@ protected function lightTheme(): Theme
accentColor: '#247BA0',
backgroundColor: '#ECEBE4',
baseColor: '#153B50',
baseFont: Font::InterBold,
baseFont: new InterBold(),
callToActionBackgroundColor: '#153B50',
callToActionColor: '#ECEBE4',
descriptionColor: '#429EA6',
descriptionFont: Font::InterLight,
titleFont: Font::InterBlack,
descriptionFont: new InterLight(),
titleFont: new InterBlack(),
) extends AbstractTheme {};
}

Expand All @@ -45,10 +45,10 @@ protected function darkTheme(): Theme
accentColor: '#5D737E',
backgroundColor: '#02111B',
baseColor: '#FCFCFC',
baseFont: Font::InterBold,
baseFont: new InterBold(),
descriptionColor: '#3F4045',
descriptionFont: Font::InterLight,
titleFont: Font::InterBlack,
descriptionFont: new InterLight(),
titleFont: new InterBlack(),
urlColor: '#30292F',
) extends AbstractTheme {};
}
Expand Down

0 comments on commit bcd07fe

Please sign in to comment.