Skip to content
This repository was archived by the owner on Jul 13, 2023. It is now read-only.

Added optional component class prop #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default class RelativePortal extends React.Component {
children: PropTypes.any.isRequired, // portal content
onOutClick: PropTypes.func, // called when user click outside portal element
component: PropTypes.string.isRequired, // dom tagName
componentClass: PropTypes.string, // dom class for tagName
};

static defaultProps = {
Expand Down
4 changes: 3 additions & 1 deletion src/RelativePortal.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default class RelativePortal extends React.Component {
children: PropTypes.any,
onOutClick: PropTypes.func,
component: PropTypes.string.isRequired,
componentClass: PropTypes.string,
};

static defaultProps = {
Expand Down Expand Up @@ -98,7 +99,7 @@ export default class RelativePortal extends React.Component {
}

render() {
const { component: Comp, top, left, right, fullWidth, ...props } = this.props;
const { component: Comp, top, left, right, fullWidth, componentClass, ...props } = this.props;

const fromLeftOrRight = right !== undefined ?
{ right: this.state.right + right } :
Expand All @@ -109,6 +110,7 @@ export default class RelativePortal extends React.Component {

return (
<Comp
className={componentClass}
ref={element => {
this.element = element;
}}
Expand Down