Skip to content

Method for "getting" a selector's style #385

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

Closed
ghost opened this issue Sep 8, 2011 · 4 comments
Closed

Method for "getting" a selector's style #385

ghost opened this issue Sep 8, 2011 · 4 comments

Comments

@ghost
Copy link

ghost commented Sep 8, 2011

I've found several use cases for the following feature: Say I want to use a selector's style as a variable to format another selector. Well the way to do this currently is:

@divOneHeight: 200px;
.divOne {
    height: @divOneHeight;
}

.diveTwo {
    height: @divOneHeight + 200;
}

It's doable but it seems unnecessary. If DivTwo depends entirely on DivOne, why not just skip the variable creation and do something like

.divOne {
    height: 200px;
}

.divTwo {
    height: .divOne(height) + 200
}

I think this is in the spirit of Less.js and would certainly help developers. Thoughts?

@ttfkam
Copy link
Contributor

ttfkam commented Sep 8, 2011

I think you meant

.divOne {
    height: 200px;
}

.divTwo {
    height: .divOne(height) + 200
}

@ghost
Copy link
Author

ghost commented Sep 8, 2011

Yes, thank you!

@paulyoung
Copy link

I haven't tested but according to this gist (see Namespaces and Accessors) it's already possible.

#bundle {
  color: red;
}

.foo {
  color: #bundle['color'];
}

So in your case:

.divOne {
    height: 200px;
}

.divTwo {
    height: .divOne['height'];
}

@lukeapage
Copy link
Member

duplicate of #76

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