Skip to content

Add test for group-hover classes #22

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

Closed
wants to merge 1 commit into from

Conversation

andersklenke
Copy link

This adds a failing test for group hover classes as discussed in here #20

cc. @kaspth

@kaspth
Copy link
Contributor

kaspth commented Jan 20, 2021

So it feels like the focus/hover purging is normalizing the passed in CSS class such that .group-hover looks like it's being used even though it isn't

.remove(/:(focus|hover)(-within)?/)

@andersklenke
Copy link
Author

andersklenke commented Jan 21, 2021

I believe this happens due to the .group class in the parent element. The word group will match with every single class that contains "group" afterwards.

<div class="group border-indigo-500 hover:bg-white hover:shadow-lg hover:border-transparent">

@kaspth
Copy link
Contributor

kaspth commented Jan 21, 2021

Ah! So we may need to throw a \b or \s in the final regex, to check for a word boundary or whitespace, respectively. Wanna try fiddling with either of those?

@andersklenke
Copy link
Author

Sure! I will give it a try

@andersklenke
Copy link
Author

A lot happened for me lately, so I haven't had the time to look at this yet. If anyone want to pick it up, feel free 🙂

jonathanhefner added a commit to jonathanhefner/tailwindcss-rails that referenced this pull request Feb 19, 2021
This rewrite accomplishes a few things:

* Fixes rails#20.  Closes rails#22.

* Purges selectors that aren't on the same line as their block brace:

    *Before*

    ```css
    .sm\:aspect-w-1,
    /* ... */
    .sm\:aspect-w-15 > *,
    @media (prefers-color-scheme: dark) {
    }
    ```

* Purges empty "at rule" blocks (e.g. `@media` blocks).

* Purges comments, except within property values.

* Adds support for nested selector blocks, to prepare for the future.
  For example, Tailwind has many `.group:hover .group-hover\:X` rules
  that could be written as `.group:hover { .group-hover\:X { ... } }`.

* Improves performance:

    *Before*

    ```bash
    $ bin/test -n test_basic_purge

    Finished in 2.307380s, 0.4334 runs/s, 3.0337 assertions/s.
    1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
    ```

    *After*

    ```bash
    $ bin/test -n test_basic_purge

    Finished in 1.824162s, 0.5482 runs/s, 3.8374 assertions/s.
    1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
    ```
jonathanhefner added a commit to jonathanhefner/tailwindcss-rails that referenced this pull request Feb 19, 2021
This rewrite accomplishes a few things:

* Fixes rails#20.  Closes rails#22.

* Purges selectors that aren't on the same line as their block brace:

    **Before**

    ```css
    .sm\:aspect-w-1,
    /* ... */
    .sm\:aspect-w-15 > *,
    @media (prefers-color-scheme: dark) {
    }
    ```

* Purges empty "at rule" blocks (e.g. empty `@media` blocks).

* Purges comments, except within property values.

* Adds support for nested selector blocks, to prepare for the future.
  For example, Tailwind has many `.group:hover .group-hover\:X` rules
  that could be written as `.group:hover { .group-hover\:X { ... } }`.

* Improves performance:

    **Before**

    ```bash
    $ bin/test -n test_basic_purge

    Finished in 2.307380s, 0.4334 runs/s, 3.0337 assertions/s.
    1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
    ```

    **After**

    ```bash
    $ bin/test -n test_basic_purge

    Finished in 1.824162s, 0.5482 runs/s, 3.8374 assertions/s.
    1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
    ```
jonathanhefner added a commit to jonathanhefner/tailwindcss-rails that referenced this pull request Feb 19, 2021
This rewrite accomplishes a few things:

* Fixes rails#20.  Closes rails#22.

* Purges selectors that aren't on the same line as their block brace:

    **Before**

    ```css
    .sm\:aspect-w-1,
    /* ... */
    .sm\:aspect-w-15 > *,
    @media (prefers-color-scheme: dark) {
    }
    ```

* Purges empty "at rule" blocks (e.g. empty `@media` blocks).

* Purges comments, except within property values.

* Adds support for nested selector blocks, to prepare for the future.
  For example, Tailwind has many `.group:hover .group-hover\:X` rules
  that could be written as `.group:hover { .group-hover\:X { ... } }`.

* Improves performance:

    **Before**

    ```bash
    $ bin/test -n test_basic_purge

    Finished in 2.307380s, 0.4334 runs/s, 3.0337 assertions/s.
    1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
    ```

    **After**

    ```bash
    $ bin/test -n test_basic_purge

    Finished in 1.824162s, 0.5482 runs/s, 3.8374 assertions/s.
    1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
    ```
@jonathanhefner jonathanhefner mentioned this pull request Feb 19, 2021
jonathanhefner added a commit to jonathanhefner/tailwindcss-rails that referenced this pull request Feb 22, 2021
This rewrite accomplishes a few things:

* Fixes rails#20.  Closes rails#22.

* Purges selectors that aren't on the same line as their block brace:

    **Before**

    ```css
    .sm\:aspect-w-1,
    /* ... */
    .sm\:aspect-w-15 > *,
    @media (prefers-color-scheme: dark) {
    }
    ```

* Purges empty "at rule" blocks (e.g. empty `@media` blocks).

* Purges comments, except within property values.

* Adds support for nested selector blocks, to prepare for the future.
  For example, Tailwind has many `.group:hover .group-hover\:X` rules
  that could be written as `.group:hover { .group-hover\:X { ... } }`.

* Improves performance:

    **Before**

    ```bash
    $ bin/test -n test_basic_purge

    Finished in 2.307380s, 0.4334 runs/s, 3.0337 assertions/s.
    1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
    ```

    **After**

    ```bash
    $ bin/test -n test_basic_purge

    Finished in 1.824162s, 0.5482 runs/s, 3.8374 assertions/s.
    1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
    ```
jonathanhefner added a commit to jonathanhefner/tailwindcss-rails that referenced this pull request Feb 22, 2021
This rewrite accomplishes a few things:

* Fixes rails#20.  Closes rails#22.

* Purges selectors that aren't on the same line as their block brace:

    **Before**

    ```css
    .sm\:aspect-w-1,
    /* ... */
    .sm\:aspect-w-15 > *,
    @media (prefers-color-scheme: dark) {
    }
    ```

* Purges empty "at rule" blocks (e.g. empty `@media` blocks).

* Purges comments, except within property values.

* Adds support for nested selector blocks, to prepare for the future.
  For example, Tailwind has many `.group:hover .group-hover\:X` rules
  that could be written as `.group:hover { .group-hover\:X { ... } }`.

* Improves performance:

    **Before**

    ```bash
    $ bin/test -n test_basic_purge

    Finished in 2.307380s, 0.4334 runs/s, 3.0337 assertions/s.
    1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
    ```

    **After**

    ```bash
    $ bin/test -n test_basic_purge

    Finished in 1.824162s, 0.5482 runs/s, 3.8374 assertions/s.
    1 runs, 7 assertions, 0 failures, 0 errors, 0 skips
    ```
@dhh dhh closed this in #46 Aug 18, 2021
@andersklenke andersklenke deleted the group-hover branch August 18, 2021 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants