Commit 441aede
committed
feature #3073 [Toolkit][Shadcn] Add AlertDialog recipe (Kocal)
This PR was merged into the 2.x branch.
Discussion
----------
[Toolkit][Shadcn] Add AlertDialog recipe
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes <!-- please update src/**/CHANGELOG.md files -->
| Docs? | yes <!-- required for new features -->
| 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).
-->
With this new AlertDialog recipe, the following code:
```twig
<twig:AlertDialog>
<twig:AlertDialog:Trigger>
<twig:Button {{ ...trigger_attrs }}>Open</twig:Button>
</twig:AlertDialog:Trigger>
<twig:AlertDialog:Content>
<twig:AlertDialog:Header>
<twig:AlertDialog:Title>Are you absolutely sure?</twig:AlertDialog:Title>
<twig:AlertDialog:Description>
This action cannot be undone. This will permanently delete your account
and remove your data from our servers.
</twig:AlertDialog:Description>
</twig:AlertDialog:Header>
<twig:AlertDialog:Footer>
<twig:AlertDialog:Cancel>Cancel</twig:AlertDialog:Cancel>
<twig:AlertDialog:Action>Continue</twig:AlertDialog:Action>
</twig:AlertDialog:Footer>
</twig:AlertDialog:Content>
</twig:AlertDialog>
```
renders:
https://github.com/user-attachments/assets/4c1c836f-9051-489a-a2ec-83e09a75853f
---
This pull request introduces the new `AlertDialog` component to the Shadcn UI kit in the Symfony UX Toolkit, including its templates, JavaScript controller, documentation, and manifest. It also updates the toolkit infrastructure to support the new component, refines asset mapping, and improves component context handling. Additionally, some minor documentation and test updates are included.
**New AlertDialog Component:**
- Added the complete `AlertDialog` component, including Twig templates for all subcomponents (`Content`, `Header`, `Footer`, `Title`, `Description`, `Trigger`, `Action`, `Cancel`), a Stimulus controller for open/close behavior with transitions, and detailed usage examples in `EXAMPLES.md`. [[1]](diffhunk://#diff-1e8ce2e329975545f086aa3b8750d3b44da63cdf032646af0d99e7b9b2de4c5cR1-R47) [[2]](diffhunk://#diff-f14c3832bf831f5267b41d784094cf24a84edc5f79abc0637b1dac6920e14df1R1-R27) [[3]](diffhunk://#diff-91557baac0c727764c3898ee86de6ec62deb6b33ce82bc86d621f2c3b9ba7233R1-R13) [[4]](diffhunk://#diff-a2c365dd11321098d3f26effc35341c9279cded71da56b1797f861e1cd0c723aR1-R37) [[5]](diffhunk://#diff-2b90716a494d08147e3707a62675fcaaf6befdc041085d7d44e06cb3af32b485R1-R6) [[6]](diffhunk://#diff-40dc30f4cd5b6a18cfd9da93bb067cf7854e200c2348431e045cdcbebed4eb96R1-R6) [[7]](diffhunk://#diff-206b916d71f01ccad6e8b3950731ec0f3cd8dab058b2e038804439ba9b2d9c44R1-R7) [[8]](diffhunk://#diff-0369bb96b47c3d4c0acfe5dfdea8642690e8f8f6681bc926fae0b6264ef34219R1-R7) [[9]](diffhunk://#diff-7eda7755d4c14d6ce00a3e8199913b3b9f7a0f1e1ced0deeb8fba9a0e3379e96R1-R7) [[10]](diffhunk://#diff-05905531ae89a23629be33318174aaead05963b525710179b98e8e248c0d6ea4R1-R4) [[11]](diffhunk://#diff-bb139b689add718b84387dddd493a83d71911eb6e6faed46e41d68461b78d9b4R1-R7)
- Added a manifest for the `AlertDialog` component specifying dependencies and recipe details.
**Toolkit Infrastructure and Asset Handling:**
- Refined the `KitContextRunner` to better separate Twig and component factory contextualization, improving reliability and maintainability when running code for specific kits. [[1]](diffhunk://#diff-cfffacbba1a1731189cefcdcfbf0096947ac2b4f2d41d83656b8814f072ce535R27-R31) [[2]](diffhunk://#diff-cfffacbba1a1731189cefcdcfbf0096947ac2b4f2d41d83656b8814f072ce535L42-R99)
- Updated asset mapping to expose kit assets under a namespaced path and to exclude kit templates, documentation, and manifests from asset mapping. [[1]](diffhunk://#diff-f414b69a2be9ec873133c4230f66df08251e9efc1885d4dc9246a7d28c428472L5-R6) [[2]](diffhunk://#diff-f414b69a2be9ec873133c4230f66df08251e9efc1885d4dc9246a7d28c428472R15-R17)
- Registered the `alert-dialog` Stimulus controller in the app's JavaScript entrypoint and importmap, and added the `el-transition` dependency. [[1]](diffhunk://#diff-778967d6b92db56e30a61c00288340db8cf087bbb76626da93bdd2abd8399a18R2-R6) [[2]](diffhunk://#diff-a2b46fc4576c4f4edafcd41c9d18f6288c855a95ac32139e6e721be80d2e2052R207-R212)
**Documentation and Test Updates:**
- Updated kit and component documentation to reference the new homepage URL and include `AlertDialog` in suggestions and tests. [[1]](diffhunk://#diff-aa11a152e722d16f5bd4601cdbaa7a977b62370267ca536c1dc6677cb5d48cd3L6-R6) [[2]](diffhunk://#diff-bd0225f055b73556a1d02abc993c0cc75d00ec79077eebb0746a831d749c680cL79-R79) [[3]](diffhunk://#diff-13a35e56dbb84c2b7166f8ba00ee56fbbd9f79719a2e04f93a1171691961b22fL31-R31)
- Minor fix to use `self::generateTabs` in the toolkit service for consistency.
Commits
-------
bc9accc [Toolkit][Shadcn] Add AlertDialog recipeFile tree
24 files changed
+354
-28
lines changed- .github/workflows
- src/Toolkit
- kits/shadcn
- AlertDialog
- assets/controllers
- templates/components
- AlertDialog
- src
- Command
- Kit
- tests
- Command
- Functional/__snapshots__
- ux.symfony.com
- assets
- config/packages
- src/Service/Toolkit
24 files changed
+354
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
0 commit comments