Skip to content

[Toolkit] Introduce the UX Toolkit ✨ #2539

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

Open
wants to merge 12 commits into
base: 2.x
Choose a base branch
from

Conversation

Halleck45
Copy link

@Halleck45 Halleck45 commented Jan 31, 2025

Q A
Bug fix? no
New feature? yes
Issues
License MIT

Following numerous discussions with various people, I'm opening this PR as a draft for a potential ux-toolkit component. This is the result of a joint reflection with @Kocal and @smnandre .

I’m not speaking on their behalf, but summarizing my interpretation of our discussions. Of course, @Kocal and @smnandre, feel free to correct, adjust, or add anything as needed.

Why?

Saving time

Creating Twig components like Badge or Button seems to be a very common step. The same work appears to be done over and over again, with minor differences from one company to another.

Providing a "packaged" toolkit would allow these companies and developers to save time by starting from ready-made templates.

Simplifying the process

Today, a beginner coming to Symfony has a lot to learn. Onboarding on a Symfony project can feel overwhelming, so it makes sense to offer them the most pleasant experience possible—including making it as easy as possible to create a clean and visually appealing web page.

Improving quality and accessibility

By providing a toolkit, we can leverage an entire community to gradually enhance the quality of components, including their digital accessibility. Accessibility is a major challenge, and we can aim to provide components that help companies and developers better support it.

How?

By providing:

  • Boilerplate for basic, accessible components (button, badge, etc.)
  • A symfony console ux:toolkit:install-component Button command that will generate the corresponding Twig component in the user's project. If necessary, this command will also install any required dependencies (if a component relies on another one).

Components will be unique.

It will be possible for the community to distribute unofficial components: for example, the command could accept symfony console ux:toolkit:install-component Button --registry github.com/MyRemote/UiKit

The website https://ux.symfony.com/ will include:

  • Presentations of each component, with a demo and the code needed to use it.
  • Options for automatic installation (via the command) or manual installation (by copying and pasting Twig code).
  • A few demos showcasing different variants.

Philosophy

Since the web is constantly evolving, it would be difficult to commit to maintaining components that require frequent updates.

An approach similar to shadcn seems more suitable: components are generated locally on demand by the developer, who will handle updates if necessary.

This approach likely offers the greatest flexibility: the developer can customize their component as they see fit, add their own variants, and adapt it to their specific needs.

The list of components could be based on the OpenUI initiative, which already provides a solid selection.

The symfony/ux-toolkit package will not be responsible for installing the CSS required for the components to function. It remains the developer's responsibility to manage their assets.

EDIT 14th April: Many many things were done in the PR and it can be hard to follow all the work here. Please see the following links (time asc) to see precisely what's been done:


127 0 0 1_8000_toolkit (1)

Enregistrement.de.l.ecran.2025-04-13.a.20.15.39.mov

@carsonbot carsonbot added Feature New Feature Status: Needs Review Needs to be reviewed labels Jan 31, 2025
@Kocal Kocal changed the title Initialized the Toolkit component [Toolkit] Introduce the UX Toolkit ✨ Jan 31, 2025
@smnandre
Copy link
Member

Let's get to work! 👏

Copy link
Member

@smnandre smnandre left a comment

Choose a reason for hiding this comment

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

First comments on "form" only, just to warn early about some details

@Kocal Kocal added Status: Needs Work Additional work is needed and removed Status: Needs Review Needs to be reviewed labels Jan 31, 2025
@carsonbot carsonbot added Status: Needs Review Needs to be reviewed and removed Status: Needs Work Additional work is needed labels Feb 1, 2025
@seb-jean
Copy link
Contributor

seb-jean commented Feb 2, 2025

Wow, that's a awesome PR! 👏
I like it!

@ker0x
Copy link
Contributor

ker0x commented Feb 5, 2025

I really like the component idea, but is there any particular reason to store components source code in a json file rather than going through stubs files?

I'm afraid it's going to be hard to maintain because you'll have to remember to explicitly include line breaks, indentation and proper escaping!

Wouldn't it be better to have the code directly in {Component].html.twig files, so as to benefit from the autocompletion features of the IDE/text editor and reference it in the json?

Unless json are automatically generated 🤔?

@Halleck45
Copy link
Author

Unless json are automatically generated 🤔?

@ker0x yes, all JSON files are automatically generated from the html.twig files :) .

Relying on JSON files may evolve, but for now, it is the simplest and most sustainable solution we've found. It allows for easy discoverability of components, and generating the files is very straightforward. That being said, if we find a way to eliminate the need for them entirely, this approach may change.

@ker0x
Copy link
Contributor

ker0x commented Feb 5, 2025

@Halleck45 Thanks for the clarification!

I hadn't seen the .html.twig files, so I thought that the code for each component had to be written manually in the json files, hence my concerns!

But if they're automatically generated, then I don't see any problem in using this format 👍

@nfacciolo
Copy link

Are you planning to make a component accessible like this: <twig:Action:Button></twig:Action:Button> ?

Do you need any help? I can offer some time to contribute to this awesome PR.

Thanks for your work!

@javiereguiluz
Copy link
Member

This looks very interesting. Thanks!

A quick question: how can third-party bundles (e.g. SonataAdmin or EasyAdmin) install and use these UI components to build their interfaces?

@Halleck45
Copy link
Author

Are you planning to make a component accessible like this: <twig:Action:Button></twig:Action:Button> ?

Do you need any help? I can offer some time to contribute to this awesome PR.

Thanks for your work!

@nfacciolo For now, yes (or rather twig:Button simply). In the future, the syntax might eventually evolve to on its own, but that's something to discuss, think about, etc., in another PR.

Yes, help is very welcome, that would be great! We need to adjust quite a few things, but there are tons of components left to build and a lot of documentation to write. The easiest way is probably to connect on the Symfony Slack.

A quick question: how can third-party bundles (e.g. SonataAdmin or EasyAdmin) install and use these UI components to build their interfaces?

@javiereguiluz Hi! I'm not sure I fully understand the question. As it stands, the components will be freely available for everyone to use and will be 100% customizable. Any Symfony project will be able to integrate them.

Was that the intent of your question?

@javiereguiluz
Copy link
Member

@Halleck45 let me explain what I mean.

You said that using elements from this UI toolkit will be as easy as:

(1) Run this command symfony console ux:toolkit:install Button
(2) If needed, tweak, change the downloaded component to make it yours

OK. Now, I'm developing a third-party bundle (e.g. EasyAdmin) that has a lot of UI features and I want to use this button from UX toolkit.

So, I run the command symfony console ux:toolkit:install Button ... and I see an error, because I cannot run any commands because this is not a full Symfony application.


In those cases, can third-party bundles just copy+paste some files manually from the UX repository to use those components or does this need more configuration + wiring? Thanks

@Kocal
Copy link
Member

Kocal commented Feb 9, 2025

Hey @javiereguiluz, indeed the command symfony console ux:toolkit:install is reserved to Symfony applications.

But we will also provide a manual installation (copy/paste) for each components, that will be visible on ux.symfony.com.

@sblondeau
Copy link
Contributor

Hi @Halleck45
Great work ! This is very interesting :-) One question, it will be tightly coupled to Tailwind if I understand correctly?
How could we use another css library or our own CSS classes ? We should have to adapt all the CSS classes in the html_cva ?
Thanks for clarification :-)

@Kocal
Copy link
Member

Kocal commented Feb 14, 2025

Yes it wil be tightly coupled to Tailwind (since we re-use examples from Shadcn). Thanks to the "pull" system we are implementing (like Shadcn does), the code you download will be yours and so open to fully customization. If you want to drop Tailwind for something else, you can, and yes CVA will make things easier on this point.

Also, surely in the future, we may propose other "themes" that can be based on another CSS framework, like Bootstrap for example.

@tibobaldwin
Copy link

tibobaldwin commented Feb 16, 2025

I'm curious to see some components like dialog or dropdown 😊.

@daFish
Copy link
Contributor

daFish commented Mar 5, 2025

Thanks @Halleck45 for this change. I tested some of the components (simple copy & paste) and saw that there needs to be additional configuration for Tailwind. There are currently no defined theme variables for things like destructive. Do you plan to add documentation for this?

@Halleck45
Copy link
Author

Thanks @Halleck45 for this change. I tested some of the components (simple copy & paste) and saw that there needs to be additional configuration for Tailwind. There are currently no defined theme variables for things like destructive. Do you plan to add documentation for this?

Hi ! We are planning two things:

  • Documentation first (I pushed an update to the documentation with information on this).
  • Eventually, removing external packages so that everything is managed by UX.

@Kocal
Copy link
Member

Kocal commented Mar 13, 2025

Hey! I just started a code review, let's begin with "visual" review first:

  1. On Packages page, there is no icon for the Toolkit yet, I believe this is on purpose? :
    Capture d’écran 2025-03-13 à 09 28 26
  2. The "copy" button color is wrong
  3. Badge examples do not work
    Capture d’écran 2025-03-13 à 09 29 48

Let's see the code next

Copy link
Member

@Kocal Kocal left a comment

Choose a reason for hiding this comment

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

Thanks for your work, here are my final review comments. After, I believe we would be ready to merge the PR and continue to iterate on Toolkit.

Thanks!

@carsonbot carsonbot added Status: Needs Work Additional work is needed and removed Status: Needs Review Needs to be reviewed labels Mar 13, 2025
@smnandre
Copy link
Member

Amazing job guys! If i find time i'll review what I can without bothering you too much tomorrow or tuesday, but don"t wait for it, it may also never come :)

@Kocal Kocal force-pushed the ux_toolkit branch 2 times, most recently from 8895b81 to 6e56056 Compare April 14, 2025 07:08
Copy link
Member

@Kocal Kocal left a comment

Choose a reason for hiding this comment

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

That's perfect 😍

(😇)

@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Apr 14, 2025
@Kocal Kocal force-pushed the ux_toolkit branch 4 times, most recently from 2e799ac to 636acd5 Compare April 15, 2025 07:22
Copy link
Member

@kbond kbond left a comment

Choose a reason for hiding this comment

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

First round.

@Kocal
Copy link
Member

Kocal commented Apr 15, 2025

Following internal discussions, I've just removed tales-from-a-dev/twig-tailwind-extra dev-dependency (that we didn't really use in tests) in order to pin PHP minimal support to 8.1

@Kocal
Copy link
Member

Kocal commented Apr 16, 2025

Sorry for the rebase, but I had some conflicts after merging #2695

…ription/uxIcon/installation steps in `Kit` VO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Status: Reviewed Has been reviewed by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.