Skip to content

Bugs with selectors and multiple elements #72

Description

@wesbos

Great lib! A few issues and suggestions, all revolving around some valid CSS selectors.

First, I'd like to be able to specify something like this and have it available to all elements:

[data-card-variant="primary"] {
  background-color: green;
  color: white;
}

On it's own it generates nothing.

When there is a selector above it, it merges it:

button {
  border-radius: 1rem;
  &[data-variant="primary"] {
    color: white;
  }
}

[data-card-variant="primary"] {
  background-color: green;
  color: white;
}

Sticks them all on button:

interface Mist_button extends ReactHTMLProps<'button'> {
  'data-variant'?: 'primary'
  'data-card-variant'?: 'primary'
}

I tried a few different ways to select multiple elements.

Nothing is generated for for this:

[data-card-variant="primary"]:is(div, article, section) {
  color: white;
}

This one generates the interfaces for all elements, but only applies it to the last one:

*:is(div, article, section)[data-card-variant="primary"] {
  color: white;
}
interface Mist_div extends ReactHTMLProps<'div'> {
}

interface Mist_article extends ReactHTMLProps<'article'> {
}

interface Mist_section extends ReactHTMLProps<'section'> {
  'data-card-variant'?: 'primary'
}

As does this:

article,
div,
section {
  &[data-card-variant="primary"] {
    color: white;
  }
}

I did get this to work, but it's not very scalable:

div[data-card-variant="primary"],
article[data-card-variant="primary"],
section[data-card-variant="primary"] {
  color: white;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions