Skip to content

Conversation

@Kocal
Copy link
Member

@Kocal Kocal commented Jan 16, 2026

Q A
Bug fix? no
New feature? no
Issues Fix #...
License MIT

Related to symfony/ux#3299

@Kocal Kocal self-assigned this Jan 16, 2026
@Kocal Kocal force-pushed the toolkit-move-and-rework-docs branch 2 times, most recently from c8e1a28 to 302ef78 Compare January 17, 2026 10:43
@Kocal Kocal requested a review from Copilot January 17, 2026 10:44
Copy link

Copilot AI left a 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 ToolkitExtension and ToolkitRuntime classes to handle code example rendering via Twig functions
  • Removed unused methods from ToolkitService and 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_preview macro is defined but never used anywhere in the codebase. It also contains a dump statement 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.

@Kocal Kocal force-pushed the toolkit-move-and-rework-docs branch from 302ef78 to bb24d45 Compare January 17, 2026 10:56
@Kocal Kocal requested a review from Copilot January 17, 2026 10:59
Copy link

Copilot AI left a 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.

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));
Copy link

Copilot AI Jan 17, 2026

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.

Suggested change
$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);

Copilot uses AI. Check for mistakes.
Kocal added a commit to symfony/ux that referenced this pull request Jan 17, 2026
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
@Kocal Kocal force-pushed the toolkit-move-and-rework-docs branch from bb24d45 to 3cce9c9 Compare January 17, 2026 11:08
@Kocal Kocal merged commit 2d16256 into symfony:main Jan 17, 2026
1 check failed
@Kocal Kocal deleted the toolkit-move-and-rework-docs branch January 17, 2026 11:11
@Kocal Kocal changed the title Import and migrate Toolkit recipces here Import and migrate Toolkit recipes here Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant