Commit e73466a8 by Johannes Schill

panel-header: Make it possible to style the reference element and fix so panel…

panel-header: Make it possible to style the reference element and fix so panel description looks good
parent 0430bb47
...@@ -6,22 +6,24 @@ interface Props { ...@@ -6,22 +6,24 @@ interface Props {
show: boolean; show: boolean;
placement?: any; placement?: any;
content: string | ((props: any) => JSX.Element); content: string | ((props: any) => JSX.Element);
refClassName?: string;
} }
class Popper extends PureComponent<Props> { class Popper extends PureComponent<Props> {
render() { render() {
const { children, renderContent, show, placement } = this.props; const { children, renderContent, show, placement, refClassName } = this.props;
const { content } = this.props; const { content } = this.props;
const modifiers = {
flip: { enabled: false },
preventOverflow: { enabled: false },
hide: { enabled: false },
};
return ( return (
<Manager> <Manager>
<Reference>{({ ref }) => <div ref={ref}>{children}</div>}</Reference> <Reference>
{({ ref }) => (
<div className={`popper_ref ${refClassName || ''}`} ref={ref}>
{children}
</div>
)}
</Reference>
{show && ( {show && (
<ReactPopper placement={placement} modifiers={modifiers}> <ReactPopper placement={placement}>
{({ ref, style, placement, arrowProps }) => { {({ ref, style, placement, arrowProps }) => {
return ( return (
<div ref={ref} style={style} data-placement={placement} className="popper"> <div ref={ref} style={style} data-placement={placement} className="popper">
......
...@@ -8,11 +8,13 @@ export interface UsingPopperProps { ...@@ -8,11 +8,13 @@ export interface UsingPopperProps {
placement?: string; placement?: string;
content: string | ((props: any) => JSX.Element); content: string | ((props: any) => JSX.Element);
className?: string; className?: string;
refClassName?: string;
} }
interface Props { interface Props {
placement?: string; placement?: string;
className?: string; className?: string;
refClassName?: string;
content: string | ((props: any) => JSX.Element); content: string | ((props: any) => JSX.Element);
} }
......
...@@ -45,11 +45,13 @@ export class PanelHeader extends PureComponent<Props, State> { ...@@ -45,11 +45,13 @@ export class PanelHeader extends PureComponent<Props, State> {
return ( return (
<div className={panelHeaderClass}> <div className={panelHeaderClass}>
{panel.description && ( {panel.description && (
<Tooltip content={panel.description}> <Tooltip
<span className="panel-info-corner panel-info-corner--info"> content={panel.description}
<i className="fa" /> className="absolute"
<span className="panel-info-corner-inner" /> refClassName="panel-info-corner panel-info-corner--info"
</span> >
<i className="fa" />
<span className="panel-info-corner-inner" />
</Tooltip> </Tooltip>
)} )}
{isLoading && ( {isLoading && (
......
...@@ -78,3 +78,7 @@ button.close { ...@@ -78,3 +78,7 @@ button.close {
.d-inline-block { .d-inline-block {
display: inline-block; display: inline-block;
} }
.absolute {
position: absolute;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment