Skip to content

Commit c603f15

Browse files
committed
add an option to select box model
1 parent 4644cf7 commit c603f15

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

main.coffee

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class CSS
7979
prefixed = _.partial(_prefixed, $$)
8080
declaration = _.partial(_declaration, $$, @options.vendorPrefixes, prefixed)
8181
comment = _.partial(_comment, $, @options.showComments)
82+
boxModelDimension = _.partial(css.boxModelDimension, @options.boxSizing, if @borders then @borders[0].width else null)
8283

8384
rootValue = switch @options.unit
8485
when 'px' then 0
@@ -146,8 +147,11 @@ class CSS
146147
declaration('top', @bounds.top, unit)
147148

148149
if @bounds
149-
declaration('width', unit(@bounds.width))
150-
declaration('height', unit(@bounds.height))
150+
width = boxModelDimension(@bounds.width)
151+
height = boxModelDimension(@bounds.height)
152+
153+
declaration('width', unit(width))
154+
declaration('height', unit(height))
151155

152156
declaration('opacity', @opacity)
153157

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@
5555
"type": "boolean",
5656
"default": true
5757
},
58+
"boxSizing": {
59+
"type": "select",
60+
"options": [
61+
"border-box",
62+
"content-box"
63+
],
64+
"default": "border-box"
65+
},
5866
"unit": {
5967
"type": "select",
6068
"options": [

0 commit comments

Comments
 (0)