-
-
Notifications
You must be signed in to change notification settings - Fork 5
Import and migrate Toolkit recipes here #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c8e1a28 to
302ef78
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR migrates Toolkit recipe templates from an external source into this repository. The migration replaces the dynamic example extraction approach with static template files for each component and introduces new Twig functions to generate code examples.
Changes:
- Migrated 26 Shadcn component documentation templates to
templates/toolkit/docs/shadcn/ - Refactored base component template to use Twig blocks instead of dynamic example parsing
- Created new
ToolkitExtensionandToolkitRuntimeclasses to handle code example rendering via Twig functions - Removed unused methods from
ToolkitServiceand simplified component retrieval logic - Updated Tailwind CSS version and styling configurations
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| templates/toolkit/recipe/_previewable_code_block.md.twig | Deleted - replaced by ToolkitRuntime |
| templates/toolkit/recipe/_code_block.md.twig | Deleted - replaced by ToolkitRuntime |
| templates/toolkit/docs/shadcn/*.md.twig | Added 26 component documentation templates |
| templates/toolkit/docs/_base_component.md.twig | Refactored to use Twig blocks and conditional sections |
| templates/toolkit/component.html.twig | Changed container class for layout |
| templates/components/Code/CodeBlockInline.html.twig | Added inline styling for font size and line height |
| src/Twig/Extension/ToolkitRuntime.php | New - handles code example generation |
| src/Twig/Extension/ToolkitExtension.php | New - registers Twig functions |
| src/Twig/Components/Toolkit/ComponentDoc.php | Simplified to use template-based rendering |
| src/Service/Toolkit/ToolkitService.php | Removed example extraction methods and Filesystem dependency |
| src/Service/CommonMark/Extension/ToolkitPreview/Renderer/ToolkitPreviewRenderer.php | Removed readonly modifier, updated default height |
| src/Controller/Toolkit/KitsController.php | Added RecipeType import, simplified component retrieval |
| src/Controller/Toolkit/ComponentsController.php | Simplified component retrieval, added text color classes |
| src/Controller/SitemapController.php | Simplified component retrieval |
| config/packages/symfonycasts_tailwind.yaml | Updated Tailwind version from v4.1.1 to v4.1.18 |
| assets/styles/toolkit-shadcn.css | Added custom dark variant |
| assets/styles/components/_Terminal.scss | Added selection styling |
Comments suppressed due to low confidence (1)
templates/toolkit/docs/_base_component.md.twig:110
- Unused macro definition. The
code_previewmacro is defined but never used anywhere in the codebase. It also contains adumpstatement which should not be in production code. Consider removing this macro if it's not needed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Service/CommonMark/Extension/ToolkitPreview/Renderer/ToolkitPreviewRenderer.php
Show resolved
Hide resolved
302ef78 to
bb24d45
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 43 out of 43 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Service/CommonMark/Extension/ToolkitPreview/Renderer/ToolkitPreviewRenderer.php
Show resolved
Hide resolved
| throw new \InvalidArgumentException(\sprintf('Example "%s" does not exist for recipe "%s" in kit "%s".', $exampleName, $recipeName, $kitId->value)); | ||
| } | ||
|
|
||
| $exampleCode = trim(file_get_contents($exampleFile)); |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file_get_contents() return value should be checked before use. If the file cannot be read, file_get_contents() returns false, which would cause issues with the trim() call. Consider adding error handling or using a try-catch block.
| $exampleCode = trim(file_get_contents($exampleFile)); | |
| $exampleCodeContents = file_get_contents($exampleFile); | |
| if (false === $exampleCodeContents) { | |
| throw new \RuntimeException(\sprintf('Unable to read example file "%s".', $exampleFile)); | |
| } | |
| $exampleCode = trim($exampleCodeContents); |
This PR was squashed before being merged into the 2.x branch. Discussion ---------- [Toolkit] Rework recipes docs/examples | Q | A | -------------- | --- | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md --> | Documentation? | yes <!-- required for new features, or documentation updates --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT > [!NOTE] > The PR must not be squashed! Some recipes Twig templates were re-adapted from Shadcn This PR moved the recipes `EXAMPLES.md` files to the external website repository, but examples are still present in the `examples/` folder of each recipe. When initially working on Toolkit, I wasn't sure if these files should be readable on GitHub/text editor, or only on the website, and if it was only on the website, how to best maintain them, etc... Better than nothing, I created these `EXAMPLES.md` files in each recipe to have a place to write down examples in markdown format, which could then be used as a source of truth for the website (and snapshot tests). But it was not convenient because the format was not flexible, and examples were extracted with some weird regex parsing. Now, examples are split into multiple files in the `examples/` folder of each recipe, they only contain Twig and can correctly be highlighted by IDEs and formatted by Twig-CS-Fixer. Documentation files are now in the external website repository, see symfony/ux.symfony.com#3 **Before:** <img width="1062" height="807" alt="Capture d’écran 2026-01-16 à 08 15 27" src="https://github.com/user-attachments/assets/ad8fc108-3046-41a2-a452-b1c5829db6e4" /> **After:** <img width="569" height="327" alt="image" src="https://github.com/user-attachments/assets/c72ddca9-63f1-4970-9a8c-781c3c73fa55" /> Commits ------- 012273f [Toolkit][Shadcn] Update snapshots 6e0a0f1 [Toolkit][Shadcn] Rework templates of `textarea` recipe f05264b [Toolkit][Shadcn] Rework templates of `table` recipe 42425c5 [Toolkit][Shadcn] Rework templates of `input-group` recipe bbdbddb [Toolkit][Shadcn] Rework templates of `checkbox` recipe 0ca1e00 [Toolkit][Shadcn] Rework templates of `card` recipe ae111cc [Toolkit][Shadcn] Rework templates of `badge` recipe 83b33b9 [Toolkit][Shadcn] Rework templates of `avatar` recipe e6683ba [Toolkit][Shadcn] Rework many components examples
bb24d45 to
3cce9c9
Compare
Related to symfony/ux#3299