-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2056 from hydephp/blade-based-colored-markdown-bl…
…ockquotes [2.x] Blade-based colored Markdown blockquotes
- Loading branch information
Showing
16 changed files
with
198 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
packages/framework/resources/views/components/colored-blockquote.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<blockquote @class([ | ||
'border-blue-500' => $class === 'info', | ||
'border-green-500' => $class === 'success', | ||
'border-amber-500' => $class === 'warning', | ||
'border-red-600' => $class === 'danger', | ||
])> | ||
{!! $contents !!} | ||
</blockquote> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
packages/framework/tests/Feature/ColoredBlockquoteShortcodesTest.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
packages/framework/tests/Unit/ColoredBlockquoteShortcodesTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Hyde\Framework\Testing\Unit; | ||
|
||
use Hyde\Markdown\Processing\ColoredBlockquotes; | ||
use Hyde\Testing\UnitTestCase; | ||
use Hyde\Testing\UsesRealBladeInUnitTests; | ||
|
||
/** | ||
* @covers \Hyde\Markdown\Processing\ColoredBlockquotes | ||
*/ | ||
class ColoredBlockquoteShortcodesTest extends UnitTestCase | ||
{ | ||
use UsesRealBladeInUnitTests; | ||
|
||
protected static bool $needsKernel = true; | ||
protected static bool $needsConfig = true; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->mockRender(); | ||
$this->createRealBladeCompilerEnvironment(); | ||
} | ||
|
||
public function testSignature() | ||
{ | ||
$this->assertSame('>', ColoredBlockquotes::signature()); | ||
} | ||
|
||
public function testSignatures() | ||
{ | ||
$this->assertSame( | ||
['>danger', '>info', '>success', '>warning'], | ||
ColoredBlockquotes::getSignatures() | ||
); | ||
} | ||
|
||
public function testResolveMethod() | ||
{ | ||
$this->assertSame(<<<'HTML' | ||
<blockquote class="border-blue-500"> | ||
<p>foo</p> | ||
</blockquote> | ||
HTML, ColoredBlockquotes::resolve('>info foo') | ||
); | ||
} | ||
|
||
public function testCanUseMarkdownWithinBlockquote() | ||
{ | ||
$this->assertSame( | ||
<<<'HTML' | ||
<blockquote class="border-blue-500"> | ||
<p>foo <strong>bar</strong></p> | ||
</blockquote> | ||
HTML, ColoredBlockquotes::resolve('>info foo **bar**') | ||
); | ||
} | ||
|
||
public function testWithUnrelatedClass() | ||
{ | ||
$this->assertSame( | ||
'>foo foo', | ||
ColoredBlockquotes::resolve('>foo foo') | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider blockquoteProvider | ||
*/ | ||
public function testItResolvesAllShortcodes(string $input, string $expectedOutput) | ||
{ | ||
$this->assertSame($expectedOutput, ColoredBlockquotes::resolve($input)); | ||
} | ||
|
||
public static function blockquoteProvider(): array | ||
{ | ||
return [ | ||
[ | ||
'>danger This is a danger blockquote', | ||
<<<'HTML' | ||
<blockquote class="border-red-600"> | ||
<p>This is a danger blockquote</p> | ||
</blockquote> | ||
HTML, | ||
], | ||
[ | ||
'>info This is an info blockquote', | ||
<<<'HTML' | ||
<blockquote class="border-blue-500"> | ||
<p>This is an info blockquote</p> | ||
</blockquote> | ||
HTML, | ||
], | ||
[ | ||
'>success This is a success blockquote', | ||
<<<'HTML' | ||
<blockquote class="border-green-500"> | ||
<p>This is a success blockquote</p> | ||
</blockquote> | ||
HTML, | ||
], | ||
[ | ||
'>warning This is a warning blockquote', | ||
<<<'HTML' | ||
<blockquote class="border-amber-500"> | ||
<p>This is a warning blockquote</p> | ||
</blockquote> | ||
HTML, | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.