Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Kocal
Copy link
Member

@Kocal Kocal commented Dec 30, 2025

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

This PR aims to improve the UX and DX, on the recipe page and how it's generated.

Before, the page was generated by a Twig Component that rendered Markdown with some HTML inside. It was very hacky, because inserting raw HTML in a Markdown can be difficult and came with costs, you need to be super careful about newlines and cie.

Now, the page is still generated by a Twig Component, but it only render raw Markdown. The Markdown is then properly parsed and interpreted by the PHPLeague CommonMark system. With some custom extensions, it is now possible to easily render tabs and Toolkit example preview without any issue.

In a markdown, it is possible to render tabs with:

::: tabs 

:: Title 1

Hello world

:: Title 2

(...)

:::

The Toolkit_Tab* components have been renamed to `Wysiwyg_Tab* in order to make them generic.

In a markdown, it is possible to render a Toolkit exemple preview with:

[toolkit-preview {"kitId": "shadcn"}]
<twig:FooBar />
[/toolkit-preview]

I also added a new component CodeBlockInline, because the actual CodeBlock was hard to use to render inline code.

A super-minimal Bash language support has been added to Tempest, in order to add some colors to Bash code.


Before/after: the commands are highlighted, and copy/pastable too!

image image

Before/after: the commands about packages dependencies are moved above, the files are not rendered in <details> tags anymore because copy/pasting the filename was super-hard. Now, they are rendered in dedicated code-blocks, fully-expanded, with a filename and a copy button:
image
image

@Kocal Kocal self-assigned this Dec 30, 2025
@carsonbot carsonbot added Site ux.symfony.com Status: Needs Review Needs to be reviewed labels Dec 30, 2025
@Kocal Kocal force-pushed the site-toolkit-ui-improvments branch from 8cecca4 to b9a35bf Compare December 30, 2025 23:14
@Kocal Kocal requested a review from Copilot December 30, 2025 23:14
Comment on lines +97 to +109
// format: "package@version", "@scope/package", "@scope/package@version"
$name = $package;
$version = null;
$versionPos = strrpos($package, '@');
if (false !== $versionPos && 0 !== $versionPos) {
$name = substr($package, 0, $versionPos);
$version = substr($package, $versionPos + 1);
}

if (null !== $version) {
$dependencies[] = new NpmPackageDependency($name, new ConstraintVersion($version));
} else {
$dependencies[] = new NpmPackageDependency($package);
$dependencies[] = new NpmPackageDependency($name);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small bug, must have been cherry-picked 🙈

Comment on lines +238 to +239
'#64748b',
'linear-gradient(142deg, #334155 -15%, #64748b 95%)',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't fan anymore about this color and gradient, and we already have 5/6 blue-colored packages.

Changing it to grey make it more "generic", more "basic", like the base Toolkit provides to create a design system.

Before:
Image

After:
Image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I'm open to suggestions btw)

@Kocal Kocal force-pushed the site-toolkit-ui-improvments branch from b9a35bf to a95eee5 Compare December 30, 2025 23:20
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 refactors the Toolkit recipe rendering system by replacing hacky HTML-in-Markdown with proper CommonMark extensions. The changes improve developer experience by making Markdown templates cleaner and more maintainable, while adding support for tabs and toolkit preview rendering through custom CommonMark parsers.

Key changes:

  • Introduced CommonMark extensions for tabs and toolkit preview rendering with custom parsers, nodes, and renderers
  • Refactored ToolkitService to extract reusable methods and simplified the markdown generation logic
  • Added Shell/Bash syntax highlighting support with command, comment, and option patterns
  • Renamed Toolkit_Tab* components to Wysiwyg_Tab* for better semantic clarity

Reviewed changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
ux.symfony.com/templates/toolkit/recipe/_previewable_code_block.md.twig New template for rendering code blocks with preview tabs
ux.symfony.com/templates/toolkit/recipe/_code_block.md.twig New template for rendering simple code blocks
ux.symfony.com/templates/toolkit/_component.md.twig New unified markdown template for component documentation
ux.symfony.com/templates/components/Toolkit/Tabs.html.twig Renamed tab component with updated CSS classes
ux.symfony.com/templates/components/Toolkit/Tab/Panel.html.twig Tab panel component with Wysiwyg naming
ux.symfony.com/templates/components/Toolkit/Tab/Control.html.twig Tab control component with updated structure
ux.symfony.com/templates/components/Toolkit/ComponentDoc.html.twig Simplified to use markdownContent property
ux.symfony.com/templates/components/Code/CodeBlockInline.html.twig New inline code block component with copy functionality
ux.symfony.com/src/Util/SourceCleaner.php Removed obsolete cleanupTwigFile method
ux.symfony.com/src/Twig/Components/Toolkit/ComponentDoc.php Refactored to use Twig templates for markdown generation
ux.symfony.com/src/Twig/Components/Code/CodeBlockInline.php New component class for inline code blocks
ux.symfony.com/src/Twig/Components/Code/CodeBlock.php Removed Twig file cleanup logic
ux.symfony.com/src/Service/UxPackageRepository.php Updated Toolkit package colors
ux.symfony.com/src/Service/Toolkit/ToolkitService.php Refactored to extract recipe data methods and made class readonly
ux.symfony.com/src/Service/Tempest/Highlighter/HighlighterFactory.php Factory for creating Tempest highlighter with custom languages
ux.symfony.com/src/Service/Tempest/Highlighter/Languages/Shell/ShellLanguage.php Shell language support for syntax highlighting
ux.symfony.com/src/Service/Tempest/Highlighter/Languages/Shell/Patterns/*.php Shell patterns for commands, comments, and options
ux.symfony.com/src/Service/CommonMark/Extension/ToolkitPreview/*.php CommonMark extension for toolkit preview blocks
ux.symfony.com/src/Service/CommonMark/Extension/Tabs/*.php CommonMark extension for tabs rendering
ux.symfony.com/src/Service/CommonMark/Extension/FencedCode/FencedCodeRenderer.php New renderer using CodeBlockInline component
ux.symfony.com/src/Service/CommonMark/Extension/CodeBlockRenderer/CodeBlockRenderer.php Removed old code block renderer
ux.symfony.com/src/Service/CommonMark/ConverterFactory.php Updated to register new CommonMark extensions
ux.symfony.com/config/services.yaml Added factory for Tempest Highlighter
ux.symfony.com/assets/styles/components/_Wysiwyg_Tabs.scss New styles for Wysiwyg tabs
ux.symfony.com/assets/styles/components/_Toolkit.scss Extracted Toolkit-specific styles
ux.symfony.com/assets/styles/components/_Toolkit_Tabs.scss Removed old Toolkit tabs styles
ux.symfony.com/assets/styles/components/_Wysiwyg.scss Updated with Terminal margin and link selector
ux.symfony.com/assets/styles/app.scss Fixed typo and updated imports
src/Toolkit/src/Recipe/RecipeManifest.php Fixed npm dependency parsing for scoped packages without versions
src/Toolkit/tests/Recipe/RecipeManifestTest.php Added test case for scoped package without version

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Kocal Kocal force-pushed the site-toolkit-ui-improvments branch from a95eee5 to 513877a Compare December 31, 2025 07:08
Kocal added a commit that referenced this pull request Dec 31, 2025
…der (Kocal)

This PR was merged into the 2.x branch.

Discussion
----------

[*CS-Fixer] Ensure "apps/" exists before adding it in Finder

| Q              | A
| -------------- | ---
| Bug fix?       | no
| New feature?   | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations?  | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md -->
| Documentation? | no <!-- 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

<!--
Replace this notice by a description of your feature/bugfix.
This will help reviewers and should be a good start for the documentation.

Additionally (see https://symfony.com/releases):
 - Always add tests and ensure they pass.
 - For new features, provide some code snippets to help understand usage.
 - Features and deprecations must be submitted against branch main.
 - Update/add documentation as required (we can help!)
 - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry
 - Never break backward compatibility (see https://symfony.com/bc).
-->

Follow #3251, I noticed in #3256 that Fabbot is failing because the Finder used by PHP-CS-Fixer throw an error because the directory `apps/` does not exist (https://github.com/symfony/ux/actions/runs/20607943823/job/59187283446?pr=3256#step:4:25).

Indeed, I didn't modified any files from `apps/` folder in this PR, and it looks like `Finder::in()` throws an exception when the path does not exist.

Commits
-------

0e355fe [*CS-Fixer] Ensure "apps/" exists before adding it in Finder
@Kocal Kocal force-pushed the site-toolkit-ui-improvments branch from 513877a to b7587ef Compare December 31, 2025 07:35
@Kocal Kocal merged commit a073116 into symfony:2.x Jan 1, 2026
27 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Site ux.symfony.com Status: Needs Review Needs to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants