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

Allow multiple selectors #24

Closed
stuartcusackie opened this issue Feb 9, 2022 · 6 comments
Closed

Allow multiple selectors #24

stuartcusackie opened this issue Feb 9, 2022 · 6 comments
Labels
enhancement New feature or request

Comments

@stuartcusackie
Copy link

I was trying to target multiple elements like so:
'p, ul, ol, table' => 'mb-4 last:mb-0 empty:h-8',

But it produces the error:
Expected selector, but <delimiter ">" at 10> found

Nice package by the way. Would you believe I made something very similar: https://github.com/stuartcusackie/cdom

My package uses the PHP Simple HTML Dom package, which allows all kinds of CSS targeting:
https://simplehtmldom.sourceforge.io/docs/1.9/index.html#select-elements-using-css-selectors

It would be great if your package could handle any kind of CSS selectors.

@flemming-pr
Copy link
Contributor

Do I get it right, you want to add there props (mb-4 last:mb-0 empty:h-8) to each element?
Or should this (p, ul, ol, table) already be a chained selector?

@stuartcusackie
Copy link
Author

stuartcusackie commented Feb 9, 2022

Yes it would be to each element. If you wrote:

p, ul, ol, table { 
  margin-bottom: 1px; 
} 

then it would apply to each element separately. So I think the behaviour should be the same.

@flemming-pr
Copy link
Contributor

You can that by simply writing the following:

    'default' => [
        'p' => 'mb-4 last:mb-0 empty:h-8',
        'ul' => 'mb-4 last:mb-0 empty:h-8',
        'ol' => 'mb-4 last:mb-0 empty:h-8',
        'table' => 'mb-4 last:mb-0 empty:h-8',
    ],

But I will agree by chaining them it would be cleaner.
On the other hand the following could be a bit messy

    'default' => [
        'p, ul, ol, table' => 'mb-4 last:mb-0 empty:h-8',
        'table' => 'text-blue-900',
    ],

What do you think?

@flemming-pr flemming-pr added the enhancement New feature or request label Feb 9, 2022
@stuartcusackie
Copy link
Author

I think that allowing every kind of CSS chaining is useful, and would make sense to anyone who works with CSS or JS. I would have thought that the symfony/css-selector package would have all of these selectors and chaining methods built in, but perhaps not.

On the other hand, it isn't much effort for me to declare a line for each element individually. It might get more difficult to manage if you are styling many elements, but it might be fine too.

@flemming-pr
Copy link
Contributor

As you mentioned it would be a nice feature. We will try to implement this in the following days/weeks.

simonerd added a commit that referenced this issue Apr 18, 2023
@simonerd
Copy link
Member

@stuartcusackie "Good things come to those who wait" ... or something – anyways, we've finally implemented selector chaining in 19b33f0 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants