Skip to content

Commit

Permalink
feat(Tooltip): adds triggerClass prop
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya-kumawat committed Jul 24, 2020
1 parent e396caa commit b5cfc67
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
25 changes: 7 additions & 18 deletions core/components/atoms/tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import { Omit } from 'utility-types';
import { PopperWrapper } from '@/utils';
import classNames from 'classnames';

export type PositionType =
'top'
Expand Down Expand Up @@ -33,14 +32,13 @@ export interface TooltipProps extends DivProps {
* @default true
*/
appendToBody?: boolean;
/**
* Classes to be added to PopperWrapper trigger
*/
triggerClass?: string;
}

interface IState {
position: {
top: number;
left: number;
};
style: React.CSSProperties;
open: boolean;
}

Expand All @@ -57,11 +55,6 @@ export class Tooltip extends React.Component<TooltipProps, IState> {
super(props);

this.state = {
position: {
top: 0,
left: 0,
},
style: {},
open: false
};
}
Expand All @@ -81,18 +74,14 @@ export class Tooltip extends React.Component<TooltipProps, IState> {
tooltip,
children,
className,
triggerClass,
...props
} = this.props;

const classes = classNames({
['Tooltip']: true
}, className);

const tooltipWrapper = (
<div
className={classes}
className="Tooltip"
{...props}
style={this.state.style}
>
{tooltip}
</div>
Expand All @@ -102,12 +91,12 @@ export class Tooltip extends React.Component<TooltipProps, IState> {
<PopperWrapper
trigger={children}
placement={this.props.position}
style={this.state.style}
appendToBody={appendToBody}
on={'hover'}
offset={'Medium'}
onToggle={this.onToggle}
open={this.state.open}
triggerClass={triggerClass}
>
{tooltipWrapper}
</PopperWrapper>
Expand Down
2 changes: 1 addition & 1 deletion core/components/molecules/popover/Popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export interface PopoverProps extends BaseProps {
*/
children: React.ReactNode;
/**
* Classes to be added to PopperWrapper trigger
* Class to be added to PopperWrapper trigger
*/
triggerClass?: string;
}
Expand Down
2 changes: 1 addition & 1 deletion core/utils/PopperWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface Props {
triggerClass?: string;
placement: PositionType;
children: React.ReactElement<any>;
style: React.CSSProperties;
style?: React.CSSProperties;
appendToBody: boolean;
on?: actionType;
offset: keyof typeof Offsets;
Expand Down
2 changes: 2 additions & 0 deletions css/src/components/tooltip.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
background: var(--inverse);
overflow: hidden;
box-sizing: border-box;
word-break: break-word;
hyphens: auto;
}

0 comments on commit b5cfc67

Please sign in to comment.