-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate tooltip to ts #4524
Migrate tooltip to ts #4524
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,31 @@ | ||||||
import React from 'react'; | ||||||
import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger'; | ||||||
import Tooltip from 'react-bootstrap/lib/Tooltip'; | ||||||
import { StyledTooltip } from './Tooltip'; | ||||||
|
||||||
export type ToolTypeGeneratorProps = { | ||||||
message: string; | ||||||
}; | ||||||
|
||||||
export const tooltipGenerator: React.FC<ToolTypeGeneratorProps> = ({ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
message, | ||||||
}) => { | ||||||
return <Tooltip id={message}>{message}</Tooltip>; | ||||||
}; | ||||||
|
||||||
export type ToolTipProps = { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use |
||||||
message: ToolTypeGeneratorProps; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to pass
Suggested change
|
||||||
placement: string; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we narrow this type?
Suggested change
|
||||||
children: any; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you're using
Suggested change
|
||||||
}; | ||||||
|
||||||
export const ToolTip: React.FC<ToolTipProps> = props => { | ||||||
const { message, placement, children } = props; | ||||||
return ( | ||||||
<OverlayTrigger placement={placement} overlay={tooltipGenerator(message)}> | ||||||
<StyledTooltip aria-hidden="true" {...props}> | ||||||
{children} | ||||||
</StyledTooltip> | ||||||
</OverlayTrigger> | ||||||
); | ||||||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should provide typings for
StyledTooltip
which are:styled-system
)