Skip to content

Commit

Permalink
find a way to preserve px value in some case(especially :root)
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed May 10, 2017
1 parent 7346b8b commit 6ac812e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/stylus-px2rem/mixins.styl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ html-font-size ?= 16px;
style-names ?= "min-height" "max-height" "min-width" "max-width" "width" "height" "border" "margin" "margin-top" "margin-bottom" "margin-left" "margin-right" "padding" "padding-left" "padding-right" "padding-bottom" "padding-top" "line-height"
// value less then ignore_limit will be ignored and return the original value
px2rem_ignore_limit ?= 1
// if you want to preserve px value in some case(html element for example), use `fontsize '16px!'`, and also you can override preserve_px to '_px'(then `fontsize '16_px'`) or something else
preserve_px ?= 'px!'

px2rem(prop,values){
values-px = null;
Expand All @@ -26,9 +28,11 @@ px2rem(prop,values){
value-rem = unit(value ,'rem');
}
push(values-rem,value-rem)
} else {
} else if(match(preserve_px+'$',''+value)) {
push(values-rem,unquote(replace(preserve_px,px,value)))
} else {
push(values-rem,value)
}
}
{prop} : values-rem;
}
}

0 comments on commit 6ac812e

Please sign in to comment.