Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Toolkit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ https://github.com/symfony/ux to create issues or submit pull requests.

## Resources

- [Documentation](https://symfony.com/bundles/ux-toolkit/current/index.html)
- [Documentation](https://ux.symfony.com/bundles/toolkit)
- [Report issues](https://github.com/symfony/ux/issues) and
[send Pull Requests](https://github.com/symfony/ux/pulls)
in the [main Symfony UX repository](https://github.com/symfony/ux)
172 changes: 0 additions & 172 deletions src/Toolkit/doc/index.rst

This file was deleted.

2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/AlertDialog/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "../../../schema-kit-recipe-v1.json",
"type": "component",
"name": "AlertDialog",
"name": "Alert Dialog",
"description": "A modal dialog that interrupts the user with important content and expects a response.",
"copy-files": {
"assets/": "assets/",
Expand Down
2 changes: 1 addition & 1 deletion src/Toolkit/kits/shadcn/AspectRatio/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "../../../schema-kit-recipe-v1.json",
"type": "component",
"name": "AspectRatio",
"name": "Aspect Ratio",
"description": "A container that maintains a specific width-to-height ratio for its content.",
"copy-files": {
"templates/": "templates/"
Expand Down
2 changes: 0 additions & 2 deletions src/Toolkit/kits/shadcn/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,3 @@ In your `assets/styles/app.css`, after the TailwindCSS imports, add the followin
}
}
```

And voilà! You are now ready to use Shadcn components in your Symfony project.
13 changes: 7 additions & 6 deletions src/Toolkit/src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
// If more than one kit is available, we ask the user which one to use
if (($availableKitsCount = \count($availableKits)) > 1) {
$kitName = $io->choice(null === $recipeName ? 'Which kit do you want to use?' : \sprintf('The recipe "%s" exists in multiple kits. Which one do you want to use?', $recipeName), array_map(fn (Kit $kit) => $kit->manifest->name, $availableKits));
$kitName = $io->choice(null === $recipeName ? 'Which Kit do you want to use?' : \sprintf('The recipe "%s" exists in multiple Kits. Which one do you want to use?', $recipeName), array_map(fn (Kit $kit) => $kit->manifest->name, $availableKits));

foreach ($availableKits as $availableKit) {
if ($availableKit->manifest->name === $kitName) {
Expand All @@ -117,11 +117,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
} elseif (1 === $availableKitsCount) {
$kit = $availableKits[0];
} else {
$io->error(
null === $recipeName
? 'It seems that no local kits are available and it should not happens. Please open an issue on https://github.com/symfony/ux to report this.'
: \sprintf("The recipe \"%s\" does not exist in any official kits.\n\nYou can try to run one of the following commands to interactively install recipes:\n%s\n\nOr you can try one of the community kits https://github.com/search?q=topic:ux-toolkit&type=repositories", $recipeName, implode("\n", array_map(fn (string $availableKitName) => \sprintf('$ bin/console %s --kit %s', $this->getName(), $availableKitName), $availableKitNames)))
);
if (null === $recipeName) {
$io->error('It seems that no official kits are available and it should not happens. Please open an issue on https://github.com/symfony/ux to report this.');
} else {
$io->error(\sprintf('The recipe "%s" does not exist in any official kits.', $recipeName));
// $io->error(\sprintf("The recipe \"%s\" does not exist in any official kits.\n\nYou can try to run one of the following commands to interactively install recipes:\n%s\n\nOr you can try one of the community kits https://github.com/search?q=topic:ux-toolkit&type=repositories", $recipeName, implode("\n", array_map(fn (string $availableKitName) => \sprintf('$ bin/console %s --kit %s', $this->getName(), $availableKitName), $availableKitNames))));
}

return Command::FAILURE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Toolkit/tests/Command/InstallCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testShouldFailAndSuggestAlternativeRecipesWhenKitIsExplicit()
->execute()
->assertFaulty()
->assertOutputContains('[WARNING] The recipe "A" does not exist')
->assertOutputContains('Possible alternatives: "Alert", "AlertDialog", "AspectRatio"')
->assertOutputContains('Possible alternatives: "Alert", "Alert Dialog", "Aspect Ratio"')
;
}

Expand Down
24 changes: 16 additions & 8 deletions src/Toolkit/tests/Functional/ComponentsRenderingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,22 @@
use Spatie\Snapshots\Drivers\HtmlDriver;
use Spatie\Snapshots\MatchesSnapshots;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Path;
use Symfony\Component\Finder\Finder;
use Symfony\UX\Toolkit\Kit\Kit;
use Symfony\UX\Toolkit\Kit\KitContextRunner;
use Symfony\UX\Toolkit\Kit\KitFactory;
use Symfony\UX\Toolkit\Kit\KitSynchronizer;
use Symfony\UX\Toolkit\Recipe\Recipe;
use Symfony\UX\Toolkit\Recipe\RecipeSynchronizer;
use Symfony\UX\Toolkit\Recipe\RecipeType;
use Symfony\UX\Toolkit\Registry\LocalRegistry;
use Symfony\UX\Toolkit\Tests\TestHelperTrait;

class ComponentsRenderingTest extends WebTestCase
{
use MatchesSnapshots;
use TestHelperTrait;

private const KITS_DIR = __DIR__.'/../../kits';

Expand All @@ -33,20 +38,23 @@ class ComponentsRenderingTest extends WebTestCase
*/
public static function provideTestComponentRendering(): iterable
{
$filesystem = new Filesystem();
$kitSynchronizer = new KitSynchronizer($filesystem, new RecipeSynchronizer());

foreach (LocalRegistry::getAvailableKitsName() as $kitName) {
$kitDir = Path::join(__DIR__, '../../kits', $kitName);
$docsFinder = (new Finder())->files()->name('EXAMPLES.md')->in($kitDir)->depth(1);
$kit = self::createLocalKit($kitName);
$kitSynchronizer->synchronize($kit);

foreach ($docsFinder as $docFile) {
$componentName = $docFile->getRelativePath();
foreach ($kit->getRecipes(RecipeType::Component) as $recipe) {
$examplesFilePath = Path::join($recipe->absolutePath, 'EXAMPLES.md');

$codeBlockMatchesResult = preg_match_all('/```twig.*?\n(?P<code>.+?)```/s', $docFile->getContents(), $codeBlockMatches);
$codeBlockMatchesResult = preg_match_all('/```twig.*?\n(?P<code>.+?)```/s', file_get_contents($examplesFilePath), $codeBlockMatches);
if (false === $codeBlockMatchesResult || 0 === $codeBlockMatchesResult) {
throw new \RuntimeException(\sprintf('No Twig code blocks found in file "%s"', $docFile->getRelativePathname()));
throw new \RuntimeException(\sprintf('No Twig code blocks found in file "%s"', $examplesFilePath));
}

foreach ($codeBlockMatches['code'] as $i => $code) {
yield \sprintf('Kit %s, component %s, code #%d', $kitName, $componentName, $i + 1) => [$kitName, $componentName, $code];
yield \sprintf('Kit %s, component %s, code #%d', $kitName, $recipe->manifest->name, $i + 1) => [$kitName, $recipe->manifest->name, $code];
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
- Kit: Shadcn UI
- Component: AlertDialog
- Component: Alert Dialog
- Code:
```twig
<twig:AlertDialog id="delete_account">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
- Kit: Shadcn UI
- Component: AlertDialog
- Component: Alert Dialog
- Code:
```twig
<twig:AlertDialog id="delete_account" open>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
- Kit: Shadcn UI
- Component: AspectRatio
- Component: Aspect Ratio
- Code:
```twig
<twig:AspectRatio ratio="1 / 1" class="max-w-[300px]">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
- Kit: Shadcn UI
- Component: AspectRatio
- Component: Aspect Ratio
- Code:
```twig
<twig:AspectRatio ratio="1 / 1" class="max-w-[350px]">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
- Kit: Shadcn UI
- Component: AspectRatio
- Component: Aspect Ratio
- Code:
```twig
<twig:AspectRatio ratio="16 / 9" class="max-w-[350px]">
Expand Down

This file was deleted.

Loading
Loading