mirror of https://github.com/kern/filepizza
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.2 KiB
JavaScript
64 lines
1.2 KiB
JavaScript
import React from 'react'
|
|
|
|
export default class Centered extends React.Component {
|
|
|
|
render() {
|
|
const h = this.props.hor
|
|
const v = this.props.ver
|
|
|
|
if (h && v) {
|
|
|
|
return <div style={{
|
|
display: 'table',
|
|
width: '100%',
|
|
height: '100%'}}>
|
|
<div style={{
|
|
display: 'table-cell',
|
|
verticalAlign: 'middle',
|
|
textAlign: 'center'}}>
|
|
<div style={{display: 'inline-block'}}>
|
|
{this.props.children}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
} else if (h && !v) {
|
|
|
|
return <div style={{textAlign: 'center'}}>
|
|
<div style={{display: 'inline-block'}}>
|
|
{this.props.children}
|
|
</div>
|
|
</div>
|
|
|
|
} else if (!h && v) {
|
|
|
|
return <div style={{
|
|
display: 'table',
|
|
width: '100%',
|
|
height: '100%'}}>
|
|
<div style={{
|
|
display: 'table-cell',
|
|
verticalAlign: 'middle'}}>
|
|
{this.props.children}
|
|
</div>
|
|
</div>
|
|
|
|
} else {
|
|
|
|
return this.props.children
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
Centered.propTypes = {
|
|
hor: React.PropTypes.bool,
|
|
ver: React.PropTypes.bool
|
|
}
|
|
|
|
Centered.defaultProps = {
|
|
hor: false,
|
|
ver: false
|
|
}
|