Accessors #6

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

Comments

Projects
None yet
5 participants
@jamesfoster
Contributor

jamesfoster commented Apr 9, 2010

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

This comment has been minimized.

Show comment Hide comment
@cloudhead

cloudhead Apr 9, 2010

Member

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

Member

cloudhead commented Apr 9, 2010

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

@alixaxel

This comment has been minimized.

Show comment Hide comment
@alixaxel

alixaxel Jan 11, 2012

@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?

@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

This comment has been minimized.

Show comment Hide comment
@mindfullsilence

mindfullsilence Mar 7, 2012

@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?

@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

This comment has been minimized.

Show comment Hide comment
@alixaxel

alixaxel Mar 7, 2012

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

alixaxel commented Mar 7, 2012

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

@mindfullsilence

This comment has been minimized.

Show comment Hide comment
@mindfullsilence

mindfullsilence Mar 7, 2012

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.

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

This comment has been minimized.

Show comment Hide comment
@lukeapage

lukeapage Mar 8, 2012

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)

Member

lukeapage commented Mar 8, 2012

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