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

Accessors #6

Closed
jamesfoster opened this issue Apr 9, 2010 · 6 comments
Closed

Accessors #6

jamesfoster opened this issue Apr 9, 2010 · 6 comments

Comments

@jamesfoster
Copy link
Contributor

From the original less.rb tests, this test doesn't pass.

.magic-box {
    color: red;
}
.class {
    color: .magic-box['color'];
}

it fails on the [

@cloudhead
Copy link
Member

I've decided to scrap accessors, at least for the first version. It turns out they aren't all that useful..

@alixaxel
Copy link

@cloudhead: That's a shame, I could really see potential for "OO" organization in them (Issue #564).

I assume we have to wait at least till version 2 now?

@mindfullsilence
Copy link

@cloudhead: I've been google searching for days too see if this was possible with LESS. Is there a chance of it in the future? On a complex site I could be looking at all kinds of variables and it'd be great to be able to organize them inside mixins and be able to access them from other sources.

vars.less:

    .colors() {
        @blue: #234;
        @red: #b3452;
        etc...
    }
    .grid() {
        @col-width: 5em;
        @col-gutter: 1em;
    }
main.less:

    @import "vars";
    .alert {
        width: .grid[@col-width] * 12;
        margin: 0 (.grid[@col-gutter]/2) 0 (.grid[@col-gutter]/2)
        color: .colors[@red];
        background: lighten(.colors[@red], 50%);
    }

This would be INSANELY helpful. Is there hope?

@alixaxel
Copy link

alixaxel commented Mar 7, 2012

@mindfullsilence: @col-gutter or .grid[@col-gutter]? I don't think there's hope for this tho...

@mindfullsilence
Copy link

Fixed, thanks for pointing it out. I guess it's not that big of a deal, I can always seperate variables in my stylesheet with comments. But I have a few frameworks I've built and I like to use pieces from each one on occassion. So I prepend each variable with the name of my framework. It'd save a lot of time building these frameworks out if I could do something like this:

fw-1.less:
    
    .fw-1_colors() {
        @red: #2345ba;
        @blue: #928342;
    }
fw-2.less:

    fw-2_colors() {
        @red: #239401;
        @blue: #293872;
    }

Without this option, I end up prefixing every variable I have:

    @fw-1-colors_red: #2345ba;
    @fw-2-colors_red: #239401;
    @fw-1-colors_blue: #928342;
    @fw-2-colors_blue: #293872;

Some of my frameworks do as much as the twitter bootstrap, and end up having a LOT of variables. Be a lot easier to write these frameworks if I could just set them inside of a wrapping mixin.

@lukeapage
Copy link
Member

have you tried

#namespace {
   @blue: blue;
}

.class {
   #namespace;
   color: @blue;
}

I'd like to hear from @cloudhead whether this is a feature or a bug though (it could cause collisions if your using functions written by someone else)

This issue was closed.
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

5 participants