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

Import styles from a class into another class feature #2517

Closed
qpan opened this issue May 7, 2018 · 2 comments
Closed

Import styles from a class into another class feature #2517

qpan opened this issue May 7, 2018 · 2 comments

Comments

@qpan
Copy link

qpan commented May 7, 2018

I believe this would be a nice and perhaps much needed feature for several use cases, especially for those architecting component-style css as well as atomic css. This feature, I will say is a mix between mixins and extend functionality. For example, I would like to include a utility class style into my component class. Extends and mixin can definitely do the job, however, the output css is not what I want from either mechanism. What I would like to happen is the component class simply inherits the style rules from another class. For example:

.font-normal {
font-weight: 400
}

%c-orange {
color: orange;
}

.component {
@require .font-normal;
@require %c-orange;

display: block;
position: relative;
}

OUTPUTTED CSS for the component:

.component {
font-weight: 400;
color: orange;
display: block;
position: relative;
}

Now a major question would be what happens when importing in styles from a class that have nested classes? I would say to ignore the nested classes but that might be naive, but what do you think should happen?

@chriseppstein
Copy link

We considered this feature years ago. Less css has it, but we found it to be lacking for the following reasons:

A class or placeholder is not a singleton definition. It is a reference to an html concept. It doesn’t make sense to include it because it can exist in multiple locations. In different runtime scopes. The way to connect two selectors is with @extend. Mixins are singleton definitions so including them has well defined semantics.

@ArmorDarks
Copy link

Just for the information, this issue overlaps with my comment in #1599 (comment)

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

No branches or pull requests

3 participants