Commit Graph

140 Commits

Author SHA1 Message Date
nicolas-joubert f16382ba91 [Doc] Fix enum title
Copy/Paste fix from enum_case documentation page
2024-09-30 23:05:34 +02:00
Fabien Potencier 1d31ac4b77 Tweak previous merge 2024-09-28 09:57:08 +02:00
Fabien Potencier 8efdab4780 minor #3983 Added details in the doc of filters and functions of IntlExtension (FlorianChenot)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Added details in the doc of filters and functions of IntlExtension

Commits
-------

8716392603 Added details in the doc of filters and functions of IntlExtension
2024-09-28 09:46:54 +02:00
unknown 8716392603 Added details in the doc of filters and functions of IntlExtension 2024-09-28 09:46:50 +02:00
Nicolas Grekas cff6f1ca80 Implement the enum function 2024-09-27 08:23:21 +02:00
Fabien Potencier 048183eaa6 Add cross-link 2024-09-13 14:06:34 +02:00
Fabien Potencier 8d1af0fc03 Let's no deprecate the attribute function yet 2024-09-13 13:56:05 +02:00
Fabien Potencier 333638e8e6 Allow to use a dynamic attribute on the . operator via () 2024-09-12 21:44:45 +02:00
Fabien Potencier 08f28fd06c Remove most usage of foo/bar/baz in the docs 2024-09-12 21:40:08 +02:00
Fabien Potencier b1c35cd1fc Tweak docs 2024-09-12 19:19:56 +02:00
Fabien Potencier a39b6e164c minor #4241 Adjust cycle implementation (smnandre)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Adjust `cycle` implementation

Update code following [#4158](https://github.com/twigphp/Twig/issues/4158)
* return mixed
* trigger when non countable
* type the position argument

Add doc precisions

Commits
-------

7c3c1615 Adjust `cycle` implementation
2024-08-30 20:43:09 +02:00
Simon André 7c3c16154e Adjust cycle implementation 2024-08-30 20:43:06 +02:00
Ruud Kamphuis 8c3df0c0bc Clarify block function
It actually renders the block again.
2024-08-28 08:20:39 +02:00
Fabien Potencier 1d5a8dc98b Fix html_cva docs 2024-08-18 09:38:48 +02:00
Fabien Potencier e85519fcd9 Fix html_cva docs 2024-08-18 09:38:02 +02:00
Fabien Potencier 0bfef5b300 feature #4006 Introduce CVA to html-extra (WebMamba)
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Introduce CVA to html-extra

Hey! This PR introduces CVA to Twig. All of this has already been merged into SymfonyUX (https://github.com/symfony/ux/pull/1416), but `@kbond` suggested that this repo can be a better place for this feature.

Here is a description from the PR merged in to SymfonyUX:

------------------------------

This PR introduces a new concept CVA (Class Variance Authority), by adding a1 twig function, to help you manage your class in your component.

Let's take an example an Alert component. In your app, an alert can have a lot of different styles one for success, one for alert, one for warning, and different sizes, with icons or not... You need something that lets you completely change the style of your component without creating a new component, and without creating too much complexity in your template.

Here is the reason came CVA.

Your Alert component can now look like this:

```twig
{% props color = 'blue', size = 'md' %}

{% set alert =  html_cva(
      'alert rounded-lg',
     {
        color: {
            blue: 'text-blue-800 bg-blue-50 dark:bg-gray-800 dark:text-blue-400',
            red: 'text-red-800 bg-red-50 dark:bg-gray-800 dark:text-red-400',
            green: 'text-green-800 bg-green-50 dark:bg-gray-800 dark:text-green-400',
            yellow: 'text-yellow-800 bg-yellow-50 dark:bg-gray-800 dark:text-yellow-400',
        },
        size: {
            sm: 'px-4 py-3 text-sm',
            md: 'px-6 py-4 text-base',
            lg: 'px-8 py-5 text-lg',
        }
    },
    [{
           color: ['red'],
           size: ['lg'],
          class: 'font-semibold'
    }],
   {
           rounded: 'md'
    }
}) %}

<div class="{{ cva.apply({color, size}, attribute.render('class'), 'flex p-4') }}">
    ...
</div>
```

So here you have a `cva` function that lets you define different variants of your component.

You can now use your component like this:
```twig
<twig:Alert color="red" size="md"/>

<twig:Alert color="green" size="sm"/>

<twig:Alert color="yellow" size="lg"/>

<twig:Alert color="red" size="md" class="dark:bg-gray-800"/>
```

And then you get the following result:

<img width="1269" alt="Capture d’écran 2024-01-24 à 00 52 33" src="https://github.com/symfony/ux/assets/32077734/6a5e25be-5b81-4ae7-8385-0fa5422d0396">

If you want to know more about the concept I implement here you can look at:
- CVA (js version): https://cva.style/docs
- tailwind merge: https://github.com/gehrisandro/tailwind-merge-php, https://github.com/dcastil/tailwind-merge
- this implementation by using tailwind-merge and cva is inspired a lot by: https://ui.shadcn.com/ (shadcn is the most starred library on github in 2023)
- a really good article that explains the philosophy behind https://manupa.dev/blog/anatomy-of-shadcn-ui
- this PR works great in a LASTstack: https://symfonycasts.com/screencast/last-stack/last-stack

Tell me what you think about it! Thanks for your time! Cheers 🧡

------------

Commits
-------

e3ac14e1 Introduce CVA to html-extra
2024-08-18 09:36:20 +02:00
Matheo Daninos e3ac14e1c8 Introduce CVA to html-extra 2024-08-18 09:36:16 +02:00
Fabien Potencier 0c30e78b1c Add support for named arguments on special functions 2024-08-16 08:37:24 +02:00
Christophe Coevoet ff4d01f940 Implement the enum_cases function
The implementation contains an optimized implementation of the function
for the common case of using a string literal as the argument. It will
validate the enum existence during compilation and compile the code to
use `MyEnum::cases()` directly.
2024-08-09 21:21:58 +02:00
Fabien Potencier c44be99a84 Rename array to sequence 2024-06-22 19:37:51 +02:00
Fabien Potencier 8f8d67b489 Add some missing functions in docs 2022-12-27 13:34:33 +01:00
seb-jean b376bdd0a9 Add function twig *_name for intl list 2022-12-27 12:49:56 +01:00
Fabien Potencier e5c87f8821 Merge branch '2.x' into 3.x
* 2.x:
  Add output
  Fix the drupal testing script
  Add missing argument for the cycle function
2022-12-15 11:46:42 +01:00
Katharina Luthe 1e3b126cf2 Add output 2022-12-15 11:46:17 +01:00
Christophe Coevoet 883fb333b3 Add missing argument for the cycle function 2022-12-15 11:26:46 +01:00
Fabien Potencier be33323ab1 Merge branch '2.x' into 3.x
* 2.x:
  Fix doc CS
  Adding installation instructions for Symfony
2022-09-28 08:41:08 +02:00
Fabien Potencier 9170edfa35 Fix doc CS 2022-09-28 08:40:57 +02:00
Thomas Landauer c034c1d248 Adding installation instructions for Symfony
Wording is taken from https://twig.symfony.com/doc/3.x/filters/format_datetime.html
2022-09-28 08:37:59 +02:00
Kévin Dunglas 0d6bd45844 add support for the class constant on objects 2022-03-25 09:58:48 +01:00
Fabien Potencier 4659a99cdf Merge branch '2.x' into 3.x
* 2.x:
  Fix URLs
  Replace secure.php.net with www.php.net
2021-05-19 09:38:07 +02:00
Fabien Potencier 398487c101 Merge branch '1.x' into 2.x
* 1.x:
  Replace secure.php.net with www.php.net
2021-05-19 09:14:37 +02:00
Maurício Meneghini Fauth 1783298bb8 Replace secure.php.net with www.php.net
See: https://news-web.php.net/php.internals/104533

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2021-05-18 16:07:51 -03:00
Fabien Potencier eda44caf9b Merge branch '2.x' into 3.x
* 2.x:
  Tweak wording on docs
  Adding link to RFC
2021-04-10 09:46:12 +02:00
Fabien Potencier 33729ab9a3 Tweak wording on docs 2021-04-10 09:41:46 +02:00
Fabien Potencier 22537dd1c4 Merge branch '2.x' into 3.x
* 2.x:
  Fix small typo
  Fix: Typo
  Enhancement: Use GithubActions instead of Travis for tests
  Fix: DOCtor-RST build
  Enhancement: Use no_explicit_use_of_code_block_php rule
  Fix: Highlighting
  Enhancement: Introduce DOCtor-RST config + Sphinx build + GithubActions
  Enhancement: Use GithubActions instead of Travis for tests
  Fix `odd` not working for negative numbers
  Bump version to 2.14.2-DEV
  Prepare the 2.14.1 release
  Update CHANGELOG
  Bump version to 1.44.2-DEV
  Prepare the 1.44.1 release
2020-11-05 18:38:00 +01:00
Fabien Potencier 4afea9870d Merge branch '1.x' into 2.x
* 1.x:
  Enhancement: Use no_explicit_use_of_code_block_php rule
2020-11-05 18:30:36 +01:00
Oskar Stark 5ceda707ed Fix: DOCtor-RST build 2020-11-05 13:57:55 +01:00
Oskar Stark 87eb1396ba Enhancement: Use no_explicit_use_of_code_block_php rule 2020-11-05 13:36:29 +01:00
Fabien Potencier c2a264a91d Merge branch '1.x' into 2.x
* 1.x:
  Enhancement: Introduce DOCtor-RST config + Sphinx build + GithubActions
  Enhancement: Use GithubActions instead of Travis for tests
  Fix `odd` not working for negative numbers
  Bump version to 1.44.2-DEV
  Prepare the 1.44.1 release
2020-11-05 13:31:01 +01:00
Oskar Stark c9328ad613 Enhancement: Introduce DOCtor-RST config + Sphinx build + GithubActions 2020-11-05 13:09:07 +01:00
Fabien Potencier df7471fed6 Merge branch '2.x' into 3.x
* 2.x:
  Fix PHP 8 support
2020-10-21 14:27:08 +02:00
Fabien Potencier 53650c55c1 Merge branch '1.x' into 2.x
* 1.x:
  Fix PHP 8 support
2020-10-21 14:27:01 +02:00
Fabien Potencier b1c9faa33e Fix PHP 8 support 2020-10-21 14:08:16 +02:00
Fabien Potencier 3c56677c85 Merge branch '2.x' into 3.x
* 2.x:
  Fix PHP 8 support
2020-10-21 13:43:41 +02:00
Fabien Potencier 2ffab581fe Merge branch '1.x' into 2.x
* 1.x:
  Fix PHP 8 support
2020-10-21 13:43:35 +02:00
Fabien Potencier d46aeb0724 Fix PHP 8 support 2020-10-21 13:43:26 +02:00
Fabien Potencier 050fdf54b8 Merge branch '2.x' into 3.x
* 2.x:
  Update api.rst
  Fix typo
  Fix typos
  Fix CI on PHP5
2020-04-24 08:31:57 +02:00
Pierre Grimaud 0273057622 Fix typos 2020-04-24 08:22:30 +02:00
fancyweb e6d3402c71 Remove versionadded in 2.x in 3.x doc 2020-01-11 12:38:48 +01:00
fancyweb 6b25dccf33 Fix versionadded in doc 2020-01-11 12:21:32 +01:00