From a99ee0afdfc8289ad785013203be046dc08ba88b Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Fri, 6 Dec 2024 15:23:02 +0100 Subject: [PATCH] Dynamically set Tailwind blockquote colors in Blade --- .../views/components/colored-blockquote.blade.php | 7 ++++++- .../tests/Feature/IncludesFacadeTest.php | 2 +- .../Services/Markdown/ShortcodeProcessorTest.php | 4 ++-- .../Unit/ColoredBlockquoteShortcodesTest.php | 12 ++++++------ .../framework/tests/Unit/MarkdownHelpersTest.php | 2 +- packages/hydefront/components/blockquotes.css | 15 --------------- resources/assets/app.css | 1 - 7 files changed, 16 insertions(+), 27 deletions(-) delete mode 100644 packages/hydefront/components/blockquotes.css diff --git a/packages/framework/resources/views/components/colored-blockquote.blade.php b/packages/framework/resources/views/components/colored-blockquote.blade.php index 51e5df9f9e8..f43c8405964 100644 --- a/packages/framework/resources/views/components/colored-blockquote.blade.php +++ b/packages/framework/resources/views/components/colored-blockquote.blade.php @@ -1,3 +1,8 @@ -
+
$class === 'info', + 'border-green-500' => $class === 'success', + 'border-amber-500' => $class === 'warning', + 'border-red-600' => $class === 'danger', + ])> {!! $contents !!}
\ No newline at end of file diff --git a/packages/framework/tests/Feature/IncludesFacadeTest.php b/packages/framework/tests/Feature/IncludesFacadeTest.php index 08f4694ccde..3ee7b835836 100644 --- a/packages/framework/tests/Feature/IncludesFacadeTest.php +++ b/packages/framework/tests/Feature/IncludesFacadeTest.php @@ -163,7 +163,7 @@ public function testAdvancedMarkdownDocumentIsCompiledToHtml() $expected = <<<'HTML'

Heading

This is a paragraph. It has some bold and italic text.

-
+

Info Blockquote

echo 'Hello, World!';
diff --git a/packages/framework/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php b/packages/framework/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php
index 0d56ac0ef81..b7ff55d50eb 100644
--- a/packages/framework/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php
+++ b/packages/framework/tests/Feature/Services/Markdown/ShortcodeProcessorTest.php
@@ -38,7 +38,7 @@ public function testDiscoveredShortcodesAreUsedToProcessInput()
         $processor = new ShortcodeProcessor('>info foo');
 
         $this->assertSame(<<<'HTML'
-        
+

foo

HTML, $processor->run()); @@ -55,7 +55,7 @@ public function testProcessStaticShorthand() { $this->assertSame( <<<'HTML' -
+

foo

HTML, ShortcodeProcessor::preprocess('>info foo') diff --git a/packages/framework/tests/Unit/ColoredBlockquoteShortcodesTest.php b/packages/framework/tests/Unit/ColoredBlockquoteShortcodesTest.php index a86b11db4b4..efe45d0794e 100644 --- a/packages/framework/tests/Unit/ColoredBlockquoteShortcodesTest.php +++ b/packages/framework/tests/Unit/ColoredBlockquoteShortcodesTest.php @@ -40,7 +40,7 @@ public function testSignatures() public function testResolveMethod() { $this->assertSame(<<<'HTML' -
+

foo

HTML, ColoredBlockquotes::resolve('>info foo') @@ -51,7 +51,7 @@ public function testCanUseMarkdownWithinBlockquote() { $this->assertSame( <<<'HTML' -
+

foo bar

HTML, ColoredBlockquotes::resolve('>info foo **bar**') @@ -80,7 +80,7 @@ public static function blockquoteProvider(): array [ '>danger This is a danger blockquote', <<<'HTML' -
+

This is a danger blockquote

HTML, @@ -88,7 +88,7 @@ public static function blockquoteProvider(): array [ '>info This is an info blockquote', <<<'HTML' -
+

This is an info blockquote

HTML, @@ -96,7 +96,7 @@ public static function blockquoteProvider(): array [ '>success This is a success blockquote', <<<'HTML' -
+

This is a success blockquote

HTML, @@ -104,7 +104,7 @@ public static function blockquoteProvider(): array [ '>warning This is a warning blockquote', <<<'HTML' -
+

This is a warning blockquote

HTML, diff --git a/packages/framework/tests/Unit/MarkdownHelpersTest.php b/packages/framework/tests/Unit/MarkdownHelpersTest.php index 2c87440dd62..e0784327102 100644 --- a/packages/framework/tests/Unit/MarkdownHelpersTest.php +++ b/packages/framework/tests/Unit/MarkdownHelpersTest.php @@ -129,7 +129,7 @@ public function testRenderWithCustomHydeMarkdownFeatures() $this->assertSame(<<<'HTML'

Hello World

-
+

Colored blockquote

Home

diff --git a/packages/hydefront/components/blockquotes.css b/packages/hydefront/components/blockquotes.css deleted file mode 100644 index 133ef9dfc5d..00000000000 --- a/packages/hydefront/components/blockquotes.css +++ /dev/null @@ -1,15 +0,0 @@ -.prose blockquote.info { - @apply border-blue-500; -} - -.prose blockquote.success { - @apply border-green-500; -} - -.prose blockquote.warning { - @apply border-amber-500; -} - -.prose blockquote.danger { - @apply border-red-600; -} diff --git a/resources/assets/app.css b/resources/assets/app.css index 0b95f5d9fe4..42de1227e3f 100644 --- a/resources/assets/app.css +++ b/resources/assets/app.css @@ -12,7 +12,6 @@ */ @import 'hydefront/components/torchlight.css'; -@import 'hydefront/components/blockquotes.css'; @tailwind base; @tailwind components;