Skip to content

Commit 47a59a8

Browse files
committed
add an option to select line height unit
1 parent e317ed4 commit 47a59a8

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

main.coffee

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,15 @@ class CSS
8686
when 'rem' then @options.remValue
8787
unit = _.partial(css.unit, @options.unit, rootValue)
8888

89+
lhRoot = switch @options.lineHeightUnit
90+
when 'px' then 0
91+
when 'em' then @options.emValue
92+
when 'rem' then @options.remValue
93+
lineHeightUnit = _.partial(css.lineHeightUnit, @options.lineHeightUnit, unit, lhRoot)
94+
isUnitlessLh = @options.lineHeightUnit.toLowerCase().indexOf('unitless') isnt -1
95+
8996
convertColor = _.partial(_convertColor, @options)
90-
fontStyles = _.partial(css.fontStyles, declaration, convertColor, unit, @options.quoteType)
97+
fontStyles = _.partial(css.fontStyles, declaration, convertColor, unit, lineHeightUnit, isUnitlessLh, @options.quoteType)
9198

9299
selectorOptions =
93100
separator: @options.selectorTextStyle

package.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,37 @@
6464
],
6565
"default": "px"
6666
},
67+
"lineHeightUnit": {
68+
"type": "select",
69+
"options": [
70+
"Use global unit",
71+
"Unitless (divided by font size)",
72+
"px",
73+
"em",
74+
"rem"
75+
],
76+
"default": "Use global unit"
77+
},
6778
"emValue": {
6879
"description": "1 em = x px — Ammount of pixels that correspond to one em. Em value is **not** relative to parent element.",
6980
"type": "text",
7081
"default": 16,
7182
"validate": "setNumberValue",
72-
"showFor": "unit",
83+
"showFor": [
84+
"unit",
85+
"lineHeightUnit"
86+
],
7387
"showWhen": "em"
7488
},
7589
"remValue": {
7690
"description": "1 rem = x px — Ammount of pixels that correspond to one rem",
7791
"type": "text",
7892
"default": 16,
7993
"validate": "setNumberValue",
80-
"showFor": "unit",
94+
"showFor": [
95+
"unit",
96+
"lineHeightUnit"
97+
],
8198
"showWhen": "rem"
8299
},
83100
"autoprefixer": {

0 commit comments

Comments
 (0)