SAPikachu / icomoon-build

Build IcoMoon project in Node
MIT License
27 stars 9 forks source link

Add an option to generate a sass map #5

Closed alexvb closed 10 years ago

alexvb commented 10 years ago

It would be great if there was an option to generate a sass map instead of variables. For example:

  $icons: (
    'file': '\f016',
    'heart': '\f0f6',
    'star': '\f1c1'
  );

This would enable the possibility to iterate over all references for more advanced usage like different classes for different use cases.

SAPikachu commented 10 years ago

Good idea, implemented in 0.2.0. :)

yairEO commented 9 years ago

@SAPikachu - This is not well implemented.... you merely created a map which is not even used, yet still generate tons of variables... not DRY at all :/

Consider generating this (example):

$icons-map: (add-user: '\e63e', remove-user: '\e63f', user: '\e628', search: '\e62e');
// no need for mixin! just loop..
@each $key, $value in $icons-map {
  .icon-#{$key}:before { content: #{$value}; }
}

output CSS - http://sassmeister.com/gist/1cbf8139c4afb77094de

now instead of generating a huge file (when having lots of icons), you generate a much smaller file.. I realize you are already looping in the javascript when generating this whole SCSS file, but still it'll make more sense when looking at it.

SAPikachu commented 9 years ago

@yairEO

  1. The map feature is meant to be used by user instead of the generated code itself.
  2. The SCSS file is script-generated, so in my opinion DRY is not applicable here.
  3. Since variables won't generate output, I don't think file size really matters.
  4. One more thing is, older SCSS doesn't support map, so if we use map in rest of the generated file, we will have to write extra logic to build output for different SCSS version, without any real gain.
  5. Mixin is there for a reason, it allows us to include the file in different SCSS files without generating any output, so that we can use variables without overhead.