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

Arbitrary variants #8299

Merged
merged 18 commits into from
May 8, 2022
Merged

Arbitrary variants #8299

merged 18 commits into from
May 8, 2022

Commits on May 7, 2022

  1. register arbitrary variants

    With the new `addVariant` API, we have a beautiful way of creating new
    variants.
    
    You can use it as:
    ```js
    addVariant('children', '& > *')
    ```
    
    Now you can use the `children:` variant. The API uses a `&` as a
    reference for the candidate, which means that:
    ```html
    children:pl-4
    ```
    
    Will result in:
    ```css
    .children\:pl-4 > * { .. }
    ```
    
    Notice that the `&` was replaced by `.children\:pl-4`.
    
    We can leverage this API to implement arbitrary variants, this means
    that you can write those `&>*` (Notice that we don't have spaces) inside
    a variant directly. An example of this can be:
    ```html
    <ul class="[&>*]:underline">
      <li>A</li>
      <li>B</li>
      <li>C</li>
    </ul>
    ```
    Which generates the following css:
    ```css
    .\[\&\>\*\]\:underline > * {
      text-decoration-line: underline;
    }
    ```
    
    Now all the children of the `ul` will have an `underline`. The selector
    itself is a bit crazy since it contains the candidate which is the
    selector itself, it is just escaped.
    RobinMalfait committed May 7, 2022
    Configuration menu
    Copy the full SHA
    08b177f View commit details
    Browse the repository at this point in the history
  2. add tests for arbitrary variants

    This still requires some work to the `defaultExtractor` to make sure it
    all works with existing code.
    RobinMalfait committed May 7, 2022
    Configuration menu
    Copy the full SHA
    e070079 View commit details
    Browse the repository at this point in the history
  3. update changelog

    RobinMalfait committed May 7, 2022
    Configuration menu
    Copy the full SHA
    7d49e55 View commit details
    Browse the repository at this point in the history

Commits on May 8, 2022

  1. Configuration menu
    Copy the full SHA
    623718e View commit details
    Browse the repository at this point in the history
  2. Refactor

    thecrypticace committed May 8, 2022
    Configuration menu
    Copy the full SHA
    42296f2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    02404ac View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3e24b75 View commit details
    Browse the repository at this point in the history
  5. Fix test

    thecrypticace committed May 8, 2022
    Configuration menu
    Copy the full SHA
    2bd6fba View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    a96eb72 View commit details
    Browse the repository at this point in the history
  7. Split top-level comma parsing into a generalized splitting routine

    We can now split on any character at the top level with any nesting. We don’t balance brackets directly here but this is probably “enough”
    thecrypticace committed May 8, 2022
    Configuration menu
    Copy the full SHA
    8d2f6bd View commit details
    Browse the repository at this point in the history
  8. Split variants by separator at the top-level only

    This means that the separator has to be ouside of balanced brackets
    thecrypticace committed May 8, 2022
    Configuration menu
    Copy the full SHA
    52baafc View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    fa829f6 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    0e04444 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    3236eb9 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    00a79e6 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    a4cff3c View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    8da1948 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    5487b27 View commit details
    Browse the repository at this point in the history