Now opacity set by property

old
@soyjavi 2015-11-15 10:17:07 +07:00
parent 5fbe67b9ac
commit 6cd6fd7340
3 changed files with 15 additions and 8 deletions

View File

@ -1,2 +1 @@
$overlay-color: unquote("rgb(#{$color-black})") !default;
$overlay-opacity: 0.5 !default;

View File

@ -6,11 +6,12 @@ class Overlay extends React.Component {
static propTypes = {
active: React.PropTypes.bool,
className: React.PropTypes.string,
onClick: React.PropTypes.func
onClick: React.PropTypes.func,
opacity: React.PropTypes.number
};
static defaultProps = {
className: ''
opacity: 0.5
};
componentDidMount () {
@ -31,10 +32,20 @@ class Overlay extends React.Component {
handleRender () {
let className = style.root;
if (this.props.active) className += ` ${style.active}`;
let overlayStyle = {};
if (this.props.active) {
className += ` ${style.active}`;
if (this.props.opacity) overlayStyle.opacity = this.props.opacity;
}
if (this.props.className) className += ` ${className}`;
ReactDOM.render(
<div className={className}>
<div className={style.overlay} onClick={this.props.onClick}></div>
<div
className={style.overlay}
onClick={this.props.onClick}
style={overlayStyle}
/>
{this.props.children}
</div>
, this.node);

View File

@ -31,7 +31,4 @@
.active {
pointer-events: all;
> .overlay {
opacity: $overlay-opacity;
}
}