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 include tag names like H1, H2, ... as mixins #1011

Closed
al6x opened this issue Oct 30, 2012 · 7 comments
Closed

Allow include tag names like H1, H2, ... as mixins #1011

al6x opened this issue Oct 30, 2012 · 7 comments

Comments

@al6x
Copy link

al6x commented Oct 30, 2012

What do You think about allowing to use tag elements like H1, H2, .... as mixins?

Use Case

I'm using Twitter Bootstrap and create header for page. Currently, because I can't reuse styles from H1 element I has to put extra stuff into HTML and code looks like that:

<div class='header'>
  <h1>
    <a href='#'>Some text</a>
  </h1>
</div>
.header {
  h1 {
    float: left;
  }
}

But if it would be possible to reuse styles on H1 the HTML code could be more clean:

<div class='header'>
  <a href='#' class='header-title'>Some text</a>
</div>
.header {
}
.header-title {   
  float: left;
  // Including
  .h1()
}

At fist I though to post an issue to Twitter Bootstrap project and ask them to create alias for every tag name (like .h1 for H1), but then realized that it would be better if LESS allow to use tags as mixins.

What do You think?

@lukeapage
Copy link
Member

We already have a issue about whether we should continue to allow using
classes without () as mixins.. so I think its too far. The more we allow,
the more complex less can look.. I assume we would have to put h1() not
.h1()

I'm -1 I think.

@lukeapage
Copy link
Member

P.s. in your use case couldn't you just swap things round and put the rules
on the class?

@al6x
Copy link
Author

al6x commented Oct 30, 2012

... the more complex less can look ...

Actually it's more complex with special syntax for mixins. You has to remember special syntax and supply it vs. beeng just able to use anything as mixin instantly.

So, it's actually a simplification and making the syntax more consistent.

P.s. in your use case couldn't you just swap things round and put the rules on the class?

No, big part of rules defined in vendor css file (in Twitter Bootstrap CSS Framework) - so I has to change vendor css file or copy-paste it - it's not good. I just want to alter it a little - with mixins it's easy.

@adrianheine
Copy link
Contributor

@alexeyPetrushin Take a look at this SO answer, it might show you a way to solve your problem.

@gaurav21r
Copy link

+1

@gaurav21r
Copy link

Lets move the discussion to #1048

@lukeapage
Copy link
Member

moved to #1048

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

No branches or pull requests

4 participants