-
-
Notifications
You must be signed in to change notification settings - Fork 394
[Toolkit] Add CONTRIBUTING.md #3161
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,15 +5,15 @@ Thank you for considering contributing to Symfony UX! | |||||
| Symfony UX is an open source, community-driven project, and we are happy to receive contributions from the community! | ||||||
|
|
||||||
| > [!TIP] | ||||||
| > It's a good idea to read the [Symfony's Contribution Guide](https://symfony.com/doc/current/contributing/index.html) first, even if not all of it applies to Symfony UX and should be adapted to this project (e.g.: Symfony UX has only one base branch, `2.x`). | ||||||
| > It's a good idea to read the [Symfony's Contribution Guide](https://symfony.com/doc/current/contributing/index.html) first | ||||||
|
|
||||||
| ## Reporting an issue | ||||||
|
|
||||||
| If you either find a bug, have a feature request, or need help/have a question, please [open an issue](https://github.com/symfony/ux/issues/new/choose). | ||||||
| If you find a bug, have a feature request, or need help/have a question, please [open an issue](https://github.com/symfony/ux/issues/new/choose). | ||||||
|
|
||||||
| Please provide as much information as possible, | ||||||
| and remember to follow our [Code of Conduct](https://symfony.com/doc/current/contributing/code_of_conduct/index.html) | ||||||
| as well, to ensure a friendly environment for all contributors. | ||||||
| to ensure a friendly environment for all contributors. | ||||||
|
|
||||||
| ## Contributing to the code and documentation | ||||||
|
|
||||||
|
|
@@ -22,11 +22,15 @@ Thanks for your interest in contributing to Symfony UX! Here are some guidelines | |||||
| ### Forking the repository | ||||||
|
|
||||||
| To contribute to Symfony UX, you need to [fork the **symfony/ux** repository](https://github.com/symfony/ux/fork) on GitHub. | ||||||
| This will give you a copy of the code under your GitHub user account, read [the documentation "How to fork a repository"](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo). | ||||||
| This will give you a copy of the code under your GitHub user account. Read [the documentation "How to fork a repository"](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo). | ||||||
|
|
||||||
| After forking the repository, you can clone it to your local machine: | ||||||
|
|
||||||
| ```shell | ||||||
| # With GitHub CLI https://cli.github.com/ | ||||||
| $ gh repo clone <USERNAME>/symfony-ux symfony-ux | ||||||
|
|
||||||
| # Using SSH | ||||||
| $ git clone git@github.com:<USERNAME>/symfony-ux.git symfony-ux | ||||||
| $ cd symfony-ux | ||||||
| # Add the upstream repository, to keep your fork up-to-date | ||||||
|
|
@@ -37,16 +41,19 @@ $ git remote add upstream git@github.com:symfony/ux.git | |||||
|
|
||||||
| To set up the development environment, you need the following tools: | ||||||
|
|
||||||
| - [PHP](https://www.php.net/downloads.php) 8.1 or higher | ||||||
| - [Composer](https://getcomposer.org/download/) | ||||||
| - [Node.js](https://nodejs.org/en/download/package-manager) 22.18 or higher | ||||||
| - [Corepack](https://github.com/nodejs/corepack) | ||||||
| - [PNPM](https://pnpm.io/) 10.13 or higher | ||||||
| - **[PHP](https://www.php.net/downloads.php) 8.1 or higher** - Required for running Symfony components | ||||||
| - **[Composer](https://getcomposer.org/download/)** - PHP dependency manager | ||||||
| - **[Node.js](https://nodejs.org/en/download/package-manager) 22.18 or higher** - Required for asset compilation | ||||||
| - **[Corepack](https://github.com/nodejs/corepack)** - Package manager manager (comes with Node.js 16+) | ||||||
| - **[PNPM](https://pnpm.io/) 10.16.1 or higher** - JavaScript package manager (installed via Corepack) | ||||||
|
||||||
| - **[PNPM](https://pnpm.io/) 10.16.1 or higher** - JavaScript package manager (installed via Corepack) | |
| - **[PNPM](https://pnpm.io/) 10.13 or higher** - JavaScript package manager (installed via Corepack) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # Contributing | ||
|
|
||
| Due to its nature, the Symfony UX Toolkit requires a specific setup to develop and test it properly. Please follow the instructions below to set up your development environment. | ||
|
|
||
| ## Setting up the development environment | ||
|
|
||
| First, ensure you have followed the [Symfony UX's Contribution Guide](https://github.com/symfony/ux/blob/2.x/CONTRIBUTING.md) to set up your fork of the main repository, install dependencies, etc. | ||
|
|
||
| Then, install the UX Toolkit dependencies: | ||
| ```shell | ||
| # src/Toolkit | ||
| composer install | ||
| ``` | ||
|
|
||
| ## Previewing kits | ||
|
|
||
| Currently, kits can only be previewed through the Symfony UX Website. Installation instructions can be found in the [Symfony UX Website's `README.md`](https://github.com/symfony/ux/tree/2.x/ux.symfony.com). | ||
|
|
||
| Then, run the following commands from the `ux.symfony.com/` directory: | ||
| ```shell | ||
| # Link local UX packages | ||
| php ../link | ||
|
|
||
| # Run the local web server | ||
| symfony serve -d | ||
| ``` | ||
|
|
||
| When the server is running, you can access: | ||
| - The UX Toolkit homepage at https://127.0.0.1:9044/toolkit | ||
| - The list of available kits at https://127.0.0.1:9044/toolkit#kits | ||
| - A dedicated section for each kit, e.g., https://127.0.0.1:9044/toolkit/kits/shadcn for the Shadcn UI Kit | ||
|
|
||
| ## Kit structure | ||
|
|
||
| A kit is composed of several recipes, each providing Twig components, styles, and JavaScript. | ||
|
|
||
| 1. Each kit is located in the `src/Toolkit/kits/` directory | ||
| 2. Each kit has its own directory named after the kit, e.g., `shadcn/` for the Shadcn UI Kit | ||
| 3. Each kit directory contains: | ||
| - An `INSTALL.md` file with installation instructions (used by the UX Website) | ||
| - A `manifest.json` file containing metadata about the kit: its name, description, license, homepage, etc. | ||
| - A folder for each recipe provided by the kit, e.g., `button/` for the Button recipe | ||
| 4. Each recipe directory contains: | ||
| - A `manifest.json` file containing metadata about the recipe: its type, name, description, files to copy, dependencies, etc. | ||
| - An `EXAMPLES.md` file with usage examples (used by the UX Website) | ||
| - Based on the "files to copy" setting, the kit may contain subdirectories such as: | ||
| - `templates/components/` for Twig components | ||
| - `assets/controllers/` for Stimulus controllers | ||
| - The "files to copy" structure is flexible, but we recommend following the above conventions for consistency across kits and Symfony apps | ||
|
|
||
| ## Working with kits | ||
|
|
||
| After setting up your development environment and the UX Website locally, you can start modifying the kits and testing them. | ||
|
|
||
| Adding new recipes or modifying existing ones will be automatically reflected in the UX Website, thanks to the local linking done with the `php link` command. | ||
| You can then preview your changes by navigating to the relevant sections in the UX Website. | ||
|
|
||
| ### Running tests & snapshots | ||
|
|
||
| Tests use snapshots to ensure that the kits and their recipes work as expected and to prevent regressions. | ||
|
|
||
| Snapshots are created from all Twig code examples provided in each recipe's `EXAMPLES.md` file. The Twig code examples are rendered in an isolated environment. | ||
|
|
||
| The rendered output is then compared to stored snapshots to ensure that the kit's recipes work as expected. | ||
|
|
||
| To update the snapshots, run the following command from the `src/Toolkit/` directory: | ||
| ```shell | ||
| # Remove existing snapshots (may be useful if some Twig code examples were removed) | ||
| rm -fr tests/Functional/__snapshots__ | ||
|
|
||
| # Run tests and update snapshots | ||
| php vendor/bin/simple-phpunit -d --update-snapshots | ||
|
|
||
| # Add the updated snapshots to git | ||
| git add tests/Functional/__snapshots__ | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repository name should be 'ux' not 'symfony-ux'. The correct command should be
gh repo clone <USERNAME>/ux symfony-uxto clone the fork of the symfony/ux repository.