Skip to content

Import less code into wrapper #3232

@gibbsfromncis

Description

@gibbsfromncis

Hey all,

I'm working on themes support for my project and in general my idea was like this:

darkTheme.less

body.darkTheme {
  @import "~library/style.less";

  @primary-color: #000;
}

But it doesn't work on this case:

library/style.less

.libraryPrefix-collapse {
  background: blue;
  & > &-item {
    background: red;
  }
}

Because in result I see the following code:
output.css

body.dark .libraryPrefix-collapse {
  background: blue;
}
body.dark .libraryPrefix-collapse > body.dark .libraryPrefix-collapse-item {
  background: red;
}

Can you please advice something that may help on this case. I've read all LESS docs and issues like that but no luck. Maybe there may be used some trick or can you add some specific symbol that will help to use parent selector only for the first-level children like:

body.darkTheme % {
  @import "~library/style.less";

  @primary-color: #000;
}

I found some issues on stackoverflow & your repo like this which mention this case but no one provides solution. I wouldn't post issue there is I had this issue with my local project only. But I'm trying to work on theming for vendor library and unfortunately I cannot touch its LESS code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions