SassyFunctions

Install | Documentation | Website | Releases
πŸŽ‰ The little toolbox to use functions across all Sass versions


πŸ€” Why?

In order to improve modular namespacing, Sass 4 will only accept first-class functions as argument for call() so functions will be called in their own context. This allow developers to make their Sass packages more modular while still being able to call functions given by the user. As a first step, Sass 3.5 added get-function() to get a first-class function from its name and throw a warning if a function name string is passed to call().

We are now encouraged to use get-function(), but this would break our packages for older Sass versions. SassyFunctions is there to allow you to process first-hand functions and function name strings the same way and continue to support all Sass versions.

build status dev dependencies npm


πŸ‘· How to install

$ npm i -D sassy-functions

Then in Sass:

@import '/path/to/node_modules/sassy-functions/scss/sassy-functions';

Or with Eyeglass

@import 'sassy-functions';


πŸ‘©β€πŸ’» How to use

Package maintainers, safely use any function reference or name coming from anywhere!

// Let's say you provide a "map-on-my-list" function to iterate with given function on a list...
@function map-on-my-list($list, $func) {
  $newlist: ();

  @each $v in $list {
    $newlist: append($newlist, sf-call($func, $v));
  }
  
  @return $newlist;
}

Package users, safely pass your own function names to anywhere!

// Let's say you have a "to-upper-case" function and want to map a list on it...
$my-list: ('hello', 'world');
$uppercased-list: map-on-my-list($my-list, sf-get-function(to-upper-case));

✨ There is more! See the API to discover all the functions of the SassyFunctions toolbox.


πŸ“˜ API


πŸ‘©β€πŸ”¬ Testing

You can install SassyFunctions locally and test it with:

# Clone the repo
git clone git@github.com:ncoden/sassy-functions.git
cd sassy-functions

# Install dependencies
npm install

# Run tests
npm test




Made with ❀️  in Paris Copyright © 2018, Nicolas Coden. Released under the MIT license.