Skip to content
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

[Toolkit] Introduce the UX Toolkit ✨ #2539

Open
wants to merge 51 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
7d0a214
Initialized the Toolkit component
Halleck45 Jan 30, 2025
bd93798
fixed path
Halleck45 Jan 30, 2025
9557e28
[Toolkit] Init the component
Kocal Jan 30, 2025
0044e0d
[Toolkit] Prepare registry
Kocal Jan 30, 2025
d9db7d7
merged different versions of component
Halleck45 Jan 30, 2025
710985f
added tools for testing components
Halleck45 Jan 30, 2025
a07a607
isolated identifier / repository
Halleck45 Jan 31, 2025
263942c
tests for official repository
Halleck45 Jan 31, 2025
8d69112
Tests the remote github repository
Halleck45 Jan 31, 2025
4864f60
Use finder insteadof f* function
Halleck45 Jan 31, 2025
edeb70e
Re-organize templates, fix Badge props/cva
Kocal Jan 31, 2025
dd67fb8
Fixed typos
Halleck45 Jan 31, 2025
24c3ef3
use filesystem
Halleck45 Jan 31, 2025
6b33a58
way to have screenshots comparaisons
Halleck45 Jan 31, 2025
3e4a7ee
First iteration of Registry
Kocal Jan 31, 2025
9eec434
fixed tests with the new directory structure
Halleck45 Jan 31, 2025
b35b76e
Way to configure ux_toolkit
Halleck45 Jan 31, 2025
daf701d
isolated compiler
Halleck45 Jan 31, 2025
790ec26
Take care of prefix in component generation
Halleck45 Jan 31, 2025
672c5ed
fix linting of JSON file
Halleck45 Jan 31, 2025
ba179e1
fix registry save output format
Kocal Jan 31, 2025
f35483a
refactored project according our previous discussions
Halleck45 Feb 1, 2025
6a6cfa4
minor typos
Halleck45 Feb 2, 2025
46bb2ad
fixed linter
Halleck45 Feb 2, 2025
a32ce21
way to detecte circular deependencies between components
Halleck45 Feb 2, 2025
6b3b126
use Zenstruck for command tests
Halleck45 Feb 2, 2025
2c83380
Way to get the list of available components in current theme
Halleck45 Feb 2, 2025
c3f82c0
compatibility with phpunit 9.5
Halleck45 Feb 2, 2025
d404ff5
Commands install component and its dependencies
Halleck45 Feb 2, 2025
68f86ce
trying to fix depreciations
Halleck45 Feb 2, 2025
8ccb3fc
Command for generate registry
Halleck45 Feb 3, 2025
d42b322
fails installation when fingerprint is incorrect
Halleck45 Feb 3, 2025
aacf196
improved tests
Halleck45 Feb 3, 2025
7021e18
minor fixes in test suite
Halleck45 Feb 4, 2025
5057785
fixed relative path, and tested in a real project
Halleck45 Feb 4, 2025
812e062
used shadcdn theme for button
Halleck45 Feb 4, 2025
dd3bf14
Add options to overwrite file on demand
Halleck45 Feb 5, 2025
241dc50
fix cascade installation
Halleck45 Feb 5, 2025
c61a46d
Grid component
Halleck45 Feb 5, 2025
6803095
Basic grid component
Halleck45 Feb 5, 2025
22261c9
component Row
Halleck45 Feb 5, 2025
6f62a5e
component table
Halleck45 Feb 5, 2025
a2c6ce9
fix remote path when repository contains special chars
Halleck45 Feb 6, 2025
0bd841c
removed useless attributes from Grid
Halleck45 Feb 6, 2025
f7c4a85
make error more explicit when theme does not exist
Halleck45 Feb 6, 2025
46ef6c1
New component: Aspect Ratio
Halleck45 Feb 6, 2025
cd96990
New component: Avatar
Halleck45 Feb 6, 2025
53ed9ed
Add component: Breadcrumb
Halleck45 Feb 7, 2025
8f4c54e
First step for documentation
Halleck45 Feb 7, 2025
5dd8607
adds details about ux_toolkit configuration in documentation
Halleck45 Feb 7, 2025
34d1aaa
documentation; note about how to find templates
Halleck45 Feb 7, 2025
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
5 changes: 5 additions & 0 deletions src/Toolkit/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.git* export-ignore
/.symfony.bundle.yaml export-ignore
/phpunit.xml.dist export-ignore
/doc export-ignore
/tests export-ignore
8 changes: 8 additions & 0 deletions src/Toolkit/.github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Please do not submit any Pull Requests here. They will be closed.
---

Please submit your PR here instead:
https://github.com/symfony/ux

This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
20 changes: 20 additions & 0 deletions src/Toolkit/.github/workflows/close-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Close Pull Request

on:
pull_request_target:
types: [opened]

jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Thanks for your Pull Request! We love contributions.

However, you should instead open your PR on the main repository:
https://github.com/symfony/ux

This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
6 changes: 6 additions & 0 deletions src/Toolkit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vendor
composer.lock
.phpunit.result.cache
var
tests/ui/output
tests/ui/screens
3 changes: 3 additions & 0 deletions src/Toolkit/.symfony.bundle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
branches: ["2.x"]
maintained_branches: ["2.x"]
doc_dir: "doc"
5 changes: 5 additions & 0 deletions src/Toolkit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CHANGELOG

## 2.23

- Component added
19 changes: 19 additions & 0 deletions src/Toolkit/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2025-present Fabien Potencier

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
16 changes: 16 additions & 0 deletions src/Toolkit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Symfony UX Toolkit

**EXPERIMENTAL** This component is currently experimental and is
likely to change, or even change drastically.

Symfony UX Toolkit provides a set of ready-to-use UI components for Symfony applications.

**This repository is a READ-ONLY sub-tree split**. See
https://github.com/symfony/ux to create issues or submit pull requests.

## Resources

- [Documentation](https://symfony.com/bundles/ux-toolkit/current/index.html)
- [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)
29 changes: 29 additions & 0 deletions src/Toolkit/bin/build-registry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env php
<?php

require_once __DIR__ . '/../vendor/autoload.php';

use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\UX\Toolkit\Registry\Registry;
use Symfony\UX\Toolkit\Registry\RegistryItem;

// --- Configuration
$templateDir = __DIR__ . '/../templates';
$registryDir = __DIR__ . '/../registry';
// --- End of Configuration

$registry = Registry::empty();
$filesystem = new Filesystem();

$finderTemplates = Finder::create()
->files()
->in($templateDir)
->name('*.html.twig')
->sortByName();

foreach ($finderTemplates as $file) {
$registry->add(RegistryItem::fromFile($file));
}

$registry->save($registryDir, $filesystem);
70 changes: 70 additions & 0 deletions src/Toolkit/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"name": "symfony/ux-toolkit",
"type": "symfony-bundle",
"description": "Twig Toolkit for Symfony",
"keywords": [
"symfony-ux",
"twig",
"components"
],
"homepage": "https://symfony.com",
"license": "MIT",
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Hugo Alliaume",
"email": "[email protected]"
},
{
"name": "Jean-François Lépine",
"email": "[email protected]"
},
{
"name": "Simon André",
"email": "[email protected]"
}
],
"require": {
"php": ">=8.3",
"twig/extra-bundle": "^3.19|^4.0",
"twig/html-extra": "^3.19",
"twig/twig": "^2.12|^3.0",
"symfony/console": "^7.2",
"symfony/framework-bundle": "^6.4|^7.0",
"symfony/phpunit-bridge": "^6.4|^7.0",
"symfony/twig-bundle": "^6.4|^7.0",
"symfony/ux-twig-component": "^2.22",
"symfony/filesystem": "^7.2"
},
"require-dev": {
"symfony/finder": "6.4|^7.0",
"tales-from-a-dev/twig-tailwind-extra": "^0.3.0"
},
"autoload": {
"psr-4": {
"Symfony\\UX\\Toolkit\\": "src"
},
"exclude-from-classmap": []
},
"autoload-dev": {
"psr-4": {
"Symfony\\UX\\Toolkit\\Tests\\": "tests/"
}
},
"conflict": {
"symfony/ux-twig-component": "<2.21"
},
"extra": {
"thanks": {
"name": "symfony/ux",
"url": "https://github.com/symfony/ux"
}
},
"require-dev": {
"symfony/http-client": "6.4|^7.0",
"tales-from-a-dev/twig-tailwind-extra": "^0.3.0"
}
}
28 changes: 28 additions & 0 deletions src/Toolkit/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Symfony UX Toolkit

Check failure on line 1 in src/Toolkit/doc/index.rst

View workflow job for this annotation

GitHub Actions / DOCtor-RST

The following link definitions aren't used anymore and should be removed: "Twig Component"
==================

**EXPERIMENTAL** This component is currently experimental and is likely
to change, or even change drastically.

Symfony UX Toolkit provides a set of ready-to-use UI components for Symfony applications.
It is part of `the Symfony UX initiative`_.

Installation
------------

TODO

Configuration
-------------

TODO

Backward Compatibility promise
------------------------------

This bundle aims at following the same Backward Compatibility promise as
the Symfony framework:
https://symfony.com/doc/current/contributing/code/bc.html

.. _`the Symfony UX initiative`: https://ux.symfony.com/
.. _`Twig Component`: https://symfony.com/bundles/ux-twig-component/current/index.html
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Backward Compatibility promise
------------------------------
This bundle aims at following the same Backward Compatibility promise as
the Symfony framework:
https://symfony.com/doc/current/contributing/code/bc.html
.. _`the Symfony UX initiative`: https://ux.symfony.com/
.. _`Twig Component`: https://symfony.com/bundles/ux-twig-component/current/index.html
Backward Compatibility promise
------------------------------
This bundle aims at following the same Backward Compatibility promise as
the Symfony framework:
https://symfony.com/doc/current/contributing/code/bc.html
.. _`the Symfony UX initiative`: https://ux.symfony.com/
.. _`Twig Component`: https://symfony.com/bundles/ux-twig-component/current/index.html

Nonononono :)

This would only be legit after the experimental period. And we may have another strategy here, depending on how much the code is "maker" and how much is "runtime".

It's easier to add stuff than remove it (proof here) so even when you think "it will be needed later" let's keep it in mind/notes but wait it really is needed.
(jumping on the opportunity herer.. nothing special or important here about this file ;) )

Really something i learned (a bit -- still fighting my old habits) with @kbond :)

25 changes: 25 additions & 0 deletions src/Toolkit/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.readthedocs.io/en/latest/configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="vendor/autoload.php" failOnRisky="true" failOnWarning="true" cacheDirectory=".phpunit.cache">
<php>
Copy link
Member

Choose a reason for hiding this comment

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

For now we're not using 10.5.

But.

I think this is perfect occasion.

Should we create a new CI pipeline dedicated to this for now (and ux bundle and friends next) ? That would allow to focus on 8.4 / phpunit 11 on a small subset of new/modernised packages)

cc @Kocal ?

<ini name="display_errors" value="1"/>
<ini name="error_reporting" value="-1"/>
<server name="APP_ENV" value="test" force="true"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="9.5"/>
<ini name="error_reporting" value="-1"/>
<server name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0&amp;max[direct]=0"/>
<server name="KERNEL_CLASS" value="Symfony\UX\Toolkit\Tests\Fixtures\Kernel"/>
</php>
<testsuites>
<testsuite name="UX Toolkit Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
9 changes: 9 additions & 0 deletions src/Toolkit/registry/default/components/Alert.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Alert",
"theme": "default",
"type": "component",
"code": "<div {{ attributes.without('class') }}\n class=\"{{ (' ' ~ attributes.render('class'))|tailwind_merge }}\"\n>\n <twig:Button>Dependency test<\/twig:Button>\n {% block content %}Alert{% endblock %}\n<\/div>\n",
"dependencies": [
"Button"
]
}
7 changes: 7 additions & 0 deletions src/Toolkit/registry/default/components/Badge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Badge",
"theme": "default",
"type": "component",
"code": "{%- props variant = 'default', outline = false -%}\n{%- set style = html_cva(\n base: 'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',\n variants: {\n variant: {\n default: \"border-transparent bg-primary text-primary-foreground hover:bg-primary\/80\",\n secondary: \"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary\/80\",\n destructive: \"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive\/80\",\n }\n outline: {\n true: \"text-foreground bg-white\",\n }\n },\n compoundVariants: [{\n variant: ['default'],\n outline: ['true'],\n class: 'border-primary',\n }, {\n variant: ['secondary'],\n outline: ['true'],\n class: 'border-secondary',\n }, {\n variant: ['destructive'],\n outline: ['true'],\n class: 'border-destructive',\n },]\n) -%}\n\n<div\n class=\"{{ style_alert.apply({variant, outline}, attributes.render('class'))|tailwind_merge }}\"\n {{ attributes.defaults({}).without('class') }}\n>\n {% block content %}{% endblock %}\n<\/div>\n",
"dependencies": []
}
7 changes: 7 additions & 0 deletions src/Toolkit/registry/default/components/Button.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Button",
"theme": "default",
"type": "component",
"code": "<button {{ attributes.without('class') }}\n class=\"{{ (' ' ~ attributes.render('class'))|tailwind_merge }}\"\n>\n {% block content %}Button{% endblock %}\n<\/button>\n",
"dependencies": []
}
7 changes: 7 additions & 0 deletions src/Toolkit/registry/default/components/Card.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Card",
"theme": "default",
"type": "component",
"code": "<div {{ attributes.without('class') }}\n class=\"{{ (' ' ~ attributes.render('class'))|tailwind_merge }}\"\n>\n {% block content %}{% endblock %}\n<\/div>\n",
"dependencies": []
}
7 changes: 7 additions & 0 deletions src/Toolkit/registry/default/components/Navbar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Navbar",
"theme": "default",
"type": "component",
"code": "<nav {{ attributes.without('class') }}\n class=\"{{ (' ' ~ attributes.render('class'))|tailwind_merge }}\"\n>\n {% block content %}{% endblock %}\n<\/nav>\n",
"dependencies": []
}
9 changes: 9 additions & 0 deletions src/Toolkit/registry/default/components/Table.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Table",
"theme": "default",
"type": "component",
"code": "{# ux:with{Row, Button} #}\n<table {{ attributes.without('class') }}\n class=\"{{ (' ' ~ attributes.render('class'))|tailwind_merge }}\"\n>\n {% block content %}{% endblock %}\n<\/table>\n",
"dependencies": [
"Row"
]
}
7 changes: 7 additions & 0 deletions src/Toolkit/registry/default/components/Table/Row.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Row",
"theme": "default",
"type": "component",
"code": "<tr {{ attributes.without('class') }}\n class=\"{{ (' ' ~ attributes.render('class'))|tailwind_merge }}\"\n>\n {% block content %}Row{% endblock %}\n<\/tr>\n",
"dependencies": []
}
7 changes: 7 additions & 0 deletions src/Toolkit/registry/default/examples/Badge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Badge",
"theme": "default",
"type": "example",
"code": "<twig:Badge>Badge<\/twig:Badge>\n",
"dependencies": []
}
7 changes: 7 additions & 0 deletions src/Toolkit/registry/default/examples/BadgeOutline.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "BadgeOutline",
"theme": "default",
"type": "example",
"code": "<twig:Badge outline>Badge<\/twig:Badge>\n<twig:Badge variant=\"primary\" outline>Badge<\/twig:Badge>\n<twig:Badge variant=\"secondary\" outline>Badge<\/twig:Badge>\n",
"dependencies": []
}
7 changes: 7 additions & 0 deletions src/Toolkit/registry/default/examples/Button.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "Button",
"theme": "default",
"type": "example",
"code": "<twig:Button>Click me<\/twig:Button>\n",
"dependencies": []
}
Loading
Loading