diff --git a/lib/BorderShadow.js b/lib/BorderShadow.js index fe9baf8..ccf0d60 100644 --- a/lib/BorderShadow.js +++ b/lib/BorderShadow.js @@ -5,7 +5,11 @@ import Svg,{ Rect,Defs,LinearGradient,Stop,RadialGradient,Path } from 'react-nat export default class BorderShadow extends Component { render = () => { - const { setting:{side="bottom",width=0,color="#000",border=0,opacity=1,inset=false,style={}}, children } = this.props + const { setting:{side="bottom",width=0,color="#000",border=0,inset=false,style={}}, children } = this.props + var {setting: {opacity}} = this.props; + if (typeof opacity !== 'number') { + opacity = 1; + } const linear = (key) => { return [ @@ -22,25 +26,27 @@ export default class BorderShadow extends Component { switch (side){ case "top": return [ + opacity !== 0 ? {linear('BorderTop')} {linear('BorderTopInset')} - , + : null, ...children ] case "bottom": return [ ...children, + opacity !== 0 ? {linear('BorderBottom')} {linear('BorderBottomInset')} - + : null ] default: throw new Error("Wrong Type of Side! We just support 'top' and 'bottom'") diff --git a/lib/BoxShadow.js b/lib/BoxShadow.js index bff3bfc..c9bfbc2 100644 --- a/lib/BoxShadow.js +++ b/lib/BoxShadow.js @@ -27,7 +27,11 @@ function colorRgb (color){ export default class BoxShadow extends Component { render = () => { //get the shadow settings and give them default values - const { setting:{width=0,height=0,color="#000",border=0,radius=0,opacity=1,x=0,y=0,style={}}, children } = this.props + const { setting:{width=0,height=0,color="#000",border=0,radius=0,x=0,y=0,style={}}, children } = this.props + var {setting: {opacity}} = this.props; + if (typeof opacity !== 'number') { + opacity = 1; + } //define the lengths const lineWidth = border, @@ -58,13 +62,14 @@ export default class BoxShadow extends Component { //return a view ,whose background is a svg picture return ( + {opacity !== 0 ? {linear('BoxTop')} {linear('BoxBottom')} {linear('BoxLeft')} {linear('BoxRight')} - + {radial('BoxLeftTop')} {radial('BoxLeftBottom')} {radial('BoxRightTop')} @@ -82,7 +87,7 @@ export default class BoxShadow extends Component { - + : null} {children} )