Skip to content

Commit

Permalink
Added sass file to config and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
backflip committed Jan 3, 2019
1 parent 46ddc99 commit 693f927
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The name of the generated font family (required). **Important**: Has to be ident
#### options.path
Type: `String`

The template path (optional, defaults to `css` template provided with plugin).If set to `'scss'` or `'less'`, the corresponding default template will be used. See [templates](templates)
The template path (optional, defaults to `css` template provided with plugin).If set to `'scss'`, `'sass'` or `'less'`, the corresponding default template will be used. See [templates](templates)

#### options.targetPath
Type: `String`
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function iconfontCSS(config) {
if(!config.path) {
config.path = 'scss';
}
if(/^(scss|less|css)$/i.test(config.path)) {
if(/^(scss|sass|less|css)$/i.test(config.path)) {
config.path = __dirname + '/templates/_icons.' + config.path;
}

Expand Down
50 changes: 50 additions & 0 deletions test/expected/type/css/_icons.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@font-face
font-family: "Icons"
src: url('../fonts/Icons.eot')
src: url('../fonts/Icons.eot?#iefix') format('eot'), url('../fonts/Icons.woff') format('woff'), url('../fonts/Icons.ttf') format('truetype'), url('../fonts/Icons.svg#Icons') format('svg')

@mixin custom-icon-styles
font-family: "Icons"
-webkit-font-smoothing: antialiased
-moz-osx-font-smoothing: grayscale
font-style: normal
font-variant: normal
font-weight: normal
// speak: none; // only necessary if not using the private unicode range (firstGlyph option)
text-decoration: none
text-transform: none


%custom-icon
+custom-icon-styles

@function custom-icon-char($filename)
$char: ""

@if $filename == github
$char: "\E001"

@if $filename == git
$char: "\E001"

@if $filename == twitter
$char: "\E002"

@return $char


@mixin custom-icon($filename, $insert: before, $extend: true)
&:#{$insert}
@if $extend
@extend %custom-icon
@else
+custom-icon-styles

content: custom-icon-char($filename)

.custom-icon-github
+custom-icon(github)
.custom-icon-git
+custom-icon(git)
.custom-icon-twitter
+custom-icon(twitter)
1 change: 1 addition & 0 deletions test/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ function testCacheBuster() {

describe('gulp-iconfont-css', function() {
testType('scss', 'SCSS');
testType('sass', 'Sass');
testType('less', 'Less');
testType('css', 'CSS');

Expand Down

0 comments on commit 693f927

Please sign in to comment.