docusaurus/lib/core/Container.js

49 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-07-07 13:28:29 -04:00
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
2017-07-07 13:28:29 -04:00
*/
2017-07-10 19:38:35 -04:00
const React = require("react");
const classNames = require("classnames");
2017-07-07 13:28:29 -04:00
class Container extends React.Component {
render() {
2017-07-10 19:38:35 -04:00
const containerClasses = classNames("container", this.props.className, {
darkBackground: this.props.background === "dark",
highlightBackground: this.props.background === "highlight",
lightBackground: this.props.background === "light",
paddingAll: this.props.padding.indexOf("all") >= 0,
paddingBottom: this.props.padding.indexOf("bottom") >= 0,
paddingLeft: this.props.padding.indexOf("left") >= 0,
paddingRight: this.props.padding.indexOf("right") >= 0,
paddingTop: this.props.padding.indexOf("top") >= 0
2017-07-07 13:28:29 -04:00
});
let wrappedChildren;
if (this.props.wrapper) {
2017-07-10 19:38:35 -04:00
wrappedChildren = (
<div className="wrapper">
{this.props.children}
</div>
);
2017-07-07 13:28:29 -04:00
} else {
wrappedChildren = this.props.children;
}
return (
<div className={containerClasses} id={this.props.id}>
{wrappedChildren}
</div>
);
}
}
Container.defaultProps = {
2017-07-10 19:38:35 -04:00
background: "transparent",
2017-07-07 13:28:29 -04:00
padding: [],
2017-07-10 19:38:35 -04:00
wrapper: true
2017-07-07 13:28:29 -04:00
};
module.exports = Container;