Skip to content

Commit

Permalink
Merge pull request #9 from 8fold/fix-metro-tile-color
Browse files Browse the repository at this point in the history
Fix metro tile color
  • Loading branch information
joshbruce authored Dec 13, 2022
2 parents 20b4579 + 94563ef commit f29fb84
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/Components/Favicons.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Favicons implements Stringable

private bool $metroUsesWhite;

private FaviconMetroColors $metroTileColor = FaviconMetroColors::DarkOrange;
private FaviconMetroColors|string $metroTileColor = FaviconMetroColors::DarkOrange;

private string $safariThemeColor = '#5bbad5';

Expand Down Expand Up @@ -70,7 +70,7 @@ private function hasAppName(): bool
}

public function withMetro(
FaviconMetroColors $tileColor = FaviconMetroColors::DarkOrange,
FaviconMetroColors|string $tileColor = FaviconMetroColors::DarkOrange,
bool $useWhite = false
): self {
$this->metroTileColor = $tileColor;
Expand Down Expand Up @@ -98,6 +98,14 @@ private function metroUsesWhite(): bool
return $this->metroUsesWhite;
}

private function metroTileColor(): string
{
if (is_string($this->metroTileColor)) {
return $this->metroTileColor;
}
return $this->metroTileColor->value;
}

public function withSafariThemeColor(string $color): self
{
$this->safariThemeColor = $color;
Expand Down Expand Up @@ -135,7 +143,7 @@ public function __toString(): string
),
Element::meta()->omitEndTag()->props(
'name msapplication-TileColor',
'content ' . $this->metroTileColor->value
'content ' . $this->metroTileColor()
),
Element::meta()->omitEndTag()->props(
'name theme-color',
Expand Down
2 changes: 0 additions & 2 deletions tests/Components/CopyrightTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ public function can_have_year_range(): void

/**
* @test
*
* @group focus
*/
public function can_include_copyright(): void
{
Expand Down
13 changes: 13 additions & 0 deletions tests/Components/FaviconsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,18 @@ public function can_use_windows_metro_settings(): void
$expected,
$result . "\n"
);

$expected = file_get_contents(
__DIR__ . '/favicons-windows-metro-tile-color-white.xml'
);

$result = (string) Favicons::create()->withMetro(
'#ffffff'
);

$this->assertSame(
$expected,
$result . "\n"
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<link rel="apple-touch-icon" href="/apple-touch-icon.png" sizes="180x180"><link type="image/png" rel="icon" href="/favicon-32x32.png" sizes="32x32"><link type="image/png" rel="icon" href="/favicon-16x16.png" sizes="16x16"><link rel="manifest" href="/site.webmanifest"><meta name="msapplication-TileColor" content="#ffffff"><meta name="theme-color" content="#ffffff"><link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5">

0 comments on commit f29fb84

Please sign in to comment.