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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,20 @@ jobs:
dependency-version: 'highest'
- php-version: '8.4'
dependency-version: 'highest'
- php-version: '8.2'
minimum-stability: stable
component: Toolkit
- php-version: '8.2'
minimum-stability: dev
component: Toolkit
component: ${{ fromJson(needs.tests-php-components.outputs.components )}}
exclude:
- php-version: '8.1'
minimum-stability: 'dev'
- php-version: '8.3'
minimum-stability: 'dev'
- component: Toolkit # does not support PHP 8.1
php-version: '8.1'
- component: Swup # has no tests
- component: Turbo # has its own workflow (test-turbo.yml)
- component: Typed # has no tests
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/toolkit-kits-cs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Toolkit Kits

on:
push:
paths:
- 'src/Toolkit/kits/**'
pull_request:
paths:
- 'src/Toolkit/kits/**'

jobs:
kits-cs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: shivammathur/setup-php@v2
with:
php-version: 8.3

- name: Install composer packages
uses: ramsey/composer-install@v3
with:
working-directory: src/Toolkit

- name: Check kits code style
run: php vendor/bin/twig-cs-fixer check kits
working-directory: src/Toolkit
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!
7 changes: 7 additions & 0 deletions src/Toolkit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vendor
composer.lock
.phpunit.result.cache
var
.twig-cs-fixer.cache
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.25

- Package 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)
45 changes: 45 additions & 0 deletions src/Toolkit/bin/ux-toolkit-kit-create
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env php
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}

use Symfony\Component\Console\Application;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\UX\Toolkit\Command\CreateKitCommand;

function includeIfExists(string $file): bool
{
return file_exists($file) && include $file;
}

if (
!includeIfExists(__DIR__ . '/../../../autoload.php') &&
!includeIfExists(__DIR__ . '/../vendor/autoload.php')
) {
fwrite(STDERR, 'Install dependencies using Composer.'.PHP_EOL);
exit(1);
}

if (!class_exists(Application::class)) {
fwrite(STDERR, 'You need the "symfony/console" component in order to run the UX Toolkit kit linter.'.PHP_EOL);
exit(1);
}

$filesystem = new Filesystem();

(new Application())->add($command = new CreateKitCommand($filesystem))
->getApplication()
->setDefaultCommand($command->getName(), true)
->run()
;
61 changes: 61 additions & 0 deletions src/Toolkit/bin/ux-toolkit-kit-debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env php
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}

use Symfony\Component\Console\Application;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\Service\ServiceLocatorTrait;
use Symfony\Contracts\Service\ServiceProviderInterface;
use Symfony\UX\Toolkit\Command\DebugKitCommand;
use Symfony\UX\Toolkit\Dependency\DependenciesResolver;
use Symfony\UX\Toolkit\Kit\KitFactory;
use Symfony\UX\Toolkit\Registry\GitHubRegistry;
use Symfony\UX\Toolkit\Registry\LocalRegistry;
use Symfony\UX\Toolkit\Registry\RegistryFactory;
use Symfony\UX\Toolkit\Registry\Type;

function includeIfExists(string $file): bool
{
return file_exists($file) && include $file;
}

if (
!includeIfExists(__DIR__ . '/../../../autoload.php') &&
!includeIfExists(__DIR__ . '/../vendor/autoload.php')
) {
fwrite(STDERR, 'Install dependencies using Composer.'.PHP_EOL);
exit(1);
}

if (!class_exists(Application::class)) {
fwrite(STDERR, 'You need the "symfony/console" component in order to run the UX Toolkit kit linter.'.PHP_EOL);
exit(1);
}

$filesystem = new Filesystem();
$kitFactory = new KitFactory($filesystem, new DependenciesResolver($filesystem));
$registryFactory = new RegistryFactory(new class([
Type::Local->value => fn () => new LocalRegistry($kitFactory, $filesystem, getcwd() ?? throw new \RuntimeException('The current working directory could not be determined.')),
Type::GitHub->value => fn () => new GitHubRegistry($kitFactory, $filesystem, class_exists(HttpClient::class) ? HttpClient::create() : null),
]) implements ServiceProviderInterface {
use ServiceLocatorTrait;
});

(new Application())->add($command = new DebugKitCommand($registryFactory))
->getApplication()
->setDefaultCommand($command->getName(), true)
->run()
;
61 changes: 61 additions & 0 deletions src/Toolkit/bin/ux-toolkit-kit-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env php
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

if ('cli' !== \PHP_SAPI) {
throw new Exception('This script must be run from the command line.');
}

use Symfony\Component\Console\Application;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Contracts\Service\ServiceLocatorTrait;
use Symfony\Contracts\Service\ServiceProviderInterface;
use Symfony\UX\Toolkit\Command\LintKitCommand;
use Symfony\UX\Toolkit\Dependency\DependenciesResolver;
use Symfony\UX\Toolkit\Kit\KitFactory;
use Symfony\UX\Toolkit\Registry\GitHubRegistry;
use Symfony\UX\Toolkit\Registry\LocalRegistry;
use Symfony\UX\Toolkit\Registry\RegistryFactory;
use Symfony\UX\Toolkit\Registry\Type;

function includeIfExists(string $file): bool
{
return file_exists($file) && include $file;
}

if (
!includeIfExists(__DIR__ . '/../../../autoload.php') &&
!includeIfExists(__DIR__ . '/../vendor/autoload.php')
) {
fwrite(STDERR, 'Install dependencies using Composer.'.PHP_EOL);
exit(1);
}

if (!class_exists(Application::class)) {
fwrite(STDERR, 'You need the "symfony/console" component in order to run the UX Toolkit kit linter.'.PHP_EOL);
exit(1);
}

$filesystem = new Filesystem();
$kitFactory = new KitFactory($filesystem, new DependenciesResolver($filesystem));
$registryFactory = new RegistryFactory(new class([
Type::Local->value => fn () => new LocalRegistry($kitFactory, $filesystem, getcwd() ?? throw new \RuntimeException('The current working directory could not be determined.')),
Type::GitHub->value => fn () => new GitHubRegistry($kitFactory, $filesystem, class_exists(HttpClient::class) ? HttpClient::create() : null),
]) implements ServiceProviderInterface {
use ServiceLocatorTrait;
});

(new Application())->add($command = new LintKitCommand($registryFactory))
->getApplication()
->setDefaultCommand($command->getName(), true)
->run()
;
75 changes: 75 additions & 0 deletions src/Toolkit/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "symfony/ux-toolkit",
"type": "symfony-bundle",
"description": "A tool to easily create a design system in your Symfony app with customizable, well-crafted Twig components",
"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.1",
"twig/twig": "^3.0",
"symfony/console": "^6.4|^7.0",
"symfony/filesystem": "^6.4|^7.0",
"symfony/framework-bundle": "^6.4|^7.0",
"symfony/twig-bundle": "^6.4|^7.0",
"symfony/ux-twig-component": "^2.23",
"symfony/yaml": "^6.4|^7.0"
},
"require-dev": {
"symfony/finder": "6.4|^7.0",
"twig/extra-bundle": "^3.19|^4.0",
"twig/html-extra": "^3.19",
"zenstruck/console-test": "^1.7",
"symfony/http-client": "6.4|^7.0",
"symfony/stopwatch": "^6.4|^7.0",
"symfony/phpunit-bridge": "^6.4|^7.0",
"vincentlanglet/twig-cs-fixer": "^3.5"
},
"bin": [
"bin/ux-toolkit-kit-create",
"bin/ux-toolkit-kit-lint",
"bin/ux-toolkit-kit-debug"
],
"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"
}
}
}
Loading
Loading