From 2fc8846ba381ad030e071953e6147a20946f2529 Mon Sep 17 00:00:00 2001
From: Josh Bruce <15252830+joshbruce@users.noreply.github.com>
Date: Tue, 13 Dec 2022 06:51:54 -0500
Subject: [PATCH 1/2] feature: Metro can accept string-based tile color
---
src/Components/Favicons.php | 14 +++++++++++---
tests/Components/FaviconsTest.php | 13 +++++++++++++
.../favicons-windows-metro-tile-color-white.xml | 1 +
3 files changed, 25 insertions(+), 3 deletions(-)
create mode 100644 tests/Components/favicons-windows-metro-tile-color-white.xml
diff --git a/src/Components/Favicons.php b/src/Components/Favicons.php
index 1ddefd6..095dce7 100644
--- a/src/Components/Favicons.php
+++ b/src/Components/Favicons.php
@@ -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';
@@ -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;
@@ -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;
@@ -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',
diff --git a/tests/Components/FaviconsTest.php b/tests/Components/FaviconsTest.php
index ed4358e..6a48ffb 100644
--- a/tests/Components/FaviconsTest.php
+++ b/tests/Components/FaviconsTest.php
@@ -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"
+ );
}
}
diff --git a/tests/Components/favicons-windows-metro-tile-color-white.xml b/tests/Components/favicons-windows-metro-tile-color-white.xml
new file mode 100644
index 0000000..97895d6
--- /dev/null
+++ b/tests/Components/favicons-windows-metro-tile-color-white.xml
@@ -0,0 +1 @@
+
From 94563ef9a18d4ce90e82629a56f3f20b4bfd6352 Mon Sep 17 00:00:00 2001
From: Josh Bruce <15252830+joshbruce@users.noreply.github.com>
Date: Tue, 13 Dec 2022 06:52:10 -0500
Subject: [PATCH 2/2] remove: @group focus
---
tests/Components/CopyrightTest.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/tests/Components/CopyrightTest.php b/tests/Components/CopyrightTest.php
index 4599684..9031728 100644
--- a/tests/Components/CopyrightTest.php
+++ b/tests/Components/CopyrightTest.php
@@ -68,8 +68,6 @@ public function can_have_year_range(): void
/**
* @test
- *
- * @group focus
*/
public function can_include_copyright(): void
{