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

Powerful custom functions #111

Open
javiermarinros opened this issue Jun 9, 2011 · 6 comments
Open

Powerful custom functions #111

javiermarinros opened this issue Jun 9, 2011 · 6 comments

Comments

@javiermarinros
Copy link

An interesting feature for improve the custom functions may be allow to return multiple values for the same property. As example, I can do:

class myless extends lessc {
    function lib_gradient($arg) {
        list($type, $value) = $arg;

        return array($type, array(
'url(...)',//Path for a background image generated from PHP 'on-the-fly' for old browsers
'-moz-linear-gradient(top, '.$value[0].' 0%,  '.$value[1].'100%)',
'-webkit-gradient(linear, left top, left bottom, color-stop(0%, '.$value[0].'), color-stop(100%,  '.$value[0].'))'
));
    }
}

And for this input:

selector {
 background: gradient(#fff, #000);
}

Will generate:

selector {
 background: url(path/to/gradient/image);
 background: -moz-linear-gradient(top, #fff 0%, #000 100%);
 background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #fff), color-stop(100%,#000));
}

Thank you

@jamwaffles
Copy link

This is a very very good idea, especially the generated image for stuff like IE. If we could see this implemented, as well as other stuff like translucent backgrounds, for example, this would make life a lot easier. I'm assuming the generated image would be cached and stored in a directory so it doesn't have to be re-generated every page load. The only problem I can see here is where this directory could be, but I think the best idea would be a folder with a completely random name to stop overwrites in the same directory as less.php?

@javiermarinros
Copy link
Author

I use less with a css and js cache system (http://www.digitalestudio.es/proyectos/tinyfier/), then the generated image will be saved in the same folder that the css and js cache, usually this folder is in the same directory than the original css.
I'm working in adding support to css sprites in less too, with some function like:

selector {
 background: sprite('image.png', 'group-name')
}

@kepten
Copy link

kepten commented Dec 7, 2011

did you manage to integrate css sprite functionality somehow?

@javiermarinros
Copy link
Author

yes, and gd-generated gradients too, but it's still experimental, if you want to try and look the code you can download it from: http://dl.dropbox.com/u/2124047/tinyfier_beta.rar

@kepten
Copy link

kepten commented Dec 12, 2011

wow, it looks great! can you put it to github so I (and others) can fork it?

@javiermarinros
Copy link
Author

Sure, you have it in https://github.com/javiermarinros/Tinyfier

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