Skip to content

Commit

Permalink
Add inside and outside aliases for shadow type
Browse files Browse the repository at this point in the history
  • Loading branch information
nvh committed Sep 13, 2017
1 parent adda6dd commit 70e3606
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
15 changes: 11 additions & 4 deletions framer/LayerStyle.coffee
Expand Up @@ -45,13 +45,20 @@ getShadowStrings = (layer, types, createString) ->
result = []
if layer.shadows?
for shadow in layer.shadows
if shadow is null or not (shadow.type in types)
if shadow is null
continue
shadow = _.defaults _.clone(shadow), Framer.Defaults.Shadow
if shadow.x is 0 and shadow.y is 0 and shadow.blur is 0 and shadow.spread is 0
if shadow.type is "inside"
shadow.type = "inset"
else if shadow.type is "outside"
if layer.image? and layer.image isnt ""
shadow.type = "drop"
else
shadow.type = "box"
if not (shadow.type in types) or (shadow.x is 0 and shadow.y is 0 and shadow.blur is 0 and shadow.spread is 0)
continue
dropShadow = createString(shadow, layer.context.pixelMultiplier)
result.push(dropShadow)
shadowString = createString(shadow, layer.context.pixelMultiplier)
result.push(shadowString)
return result

exports.LayerStyle =
Expand Down
25 changes: 25 additions & 0 deletions test/tests/LayerTest.coffee
Expand Up @@ -932,6 +932,31 @@ describe "Layer", ->
l.style.textShadow.should.equal "rgba(123, 123, 123, 0.498039) 5px 0px 0px"
l.style.webkitFilter.should.equal "drop-shadow(rgba(123, 123, 123, 0.498039) 0px 15px 0px)"

it "should use outside as an alias for box shadow", ->
l = new Layer
l.shadow1 =
type: "outside"
x: 10
l.shadow1.type.should.equal "outside"
l.style.boxShadow.should.equal "rgba(123, 123, 123, 0.498039) 10px 0px 0px 0px"

it "should use outside as an alias for drop shadow when image is set", ->
l = new Layer
image: "static/test2.png"
l.shadow1 =
type: "outside"
x: 10
l.shadow1.type.should.equal "outside"
l.style.webkitFilter.should.equal "drop-shadow(rgba(123, 123, 123, 0.498039) 10px 0px 0px)"

it "should use inside as an alias for inset shadow", ->
l = new Layer
l.shadow1 =
type: "inside"
x: 10
l.shadow1.type.should.equal "inside"
l.style.boxShadow.should.equal "rgba(123, 123, 123, 0.498039) 10px 0px 0px 0px inset"

describe "Events", ->

it "should remove all events", ->
Expand Down

0 comments on commit 70e3606

Please sign in to comment.