Skip to content
This repository has been archived by the owner on Nov 14, 2023. It is now read-only.

Commit

Permalink
fix: [XSOS-6398] fix tooltips center error
Browse files Browse the repository at this point in the history
Signed-off-by: csonchen <cson_chensheng@163.com>
  • Loading branch information
csonchen committed Aug 22, 2023
1 parent f95370c commit dfebfff
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/components/Tooltip/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Tooltip: React.FC<TooltipProps> = props => {
contrast,
className,
style,
arrowAlign,
children,
placement: defaultPlacement,
...extra
Expand Down Expand Up @@ -75,7 +76,7 @@ const Tooltip: React.FC<TooltipProps> = props => {
<BaseTooltip
id="tooltip"
style={Object.assign({}, { maxWidth: 280 }, style)}
className={`${cn({ contrast })} ${className}`}
className={`${cn({ contrast, 'tooltip-center': arrowAlign === 'center' })} ${className}`}
onMouseEnter={handleShow}
onMouseLeave={handleHide}
>
Expand Down Expand Up @@ -120,12 +121,17 @@ Tooltip.propTypes = {
* 样式
*/
style: PropTypes.object,
/**
* 箭头对齐方式
*/
arrowAlign: PropTypes.oneOf(['center', 'auto']),
};

Tooltip.defaultProps = {
icon: 'tip-line',
iconAlign: 'text-bottom',
contrast: false,
arrowAlign: 'center',
};

export default Tooltip;
12 changes: 7 additions & 5 deletions src/components/Tooltip/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
}
}
.tooltip {
&.bs-tooltip-top,
&.bs-tooltip-bottom {
.tooltip-arrow {
left: 50%!important;
transform: translate(-50%, 0)!important;
&.tooltip-center {
&.bs-tooltip-top,
&.bs-tooltip-bottom {
.tooltip-arrow {
left: 50%!important;
transform: translate(-50%, 0)!important;
}
}
}
.tooltip-inner {
Expand Down
2 changes: 2 additions & 0 deletions src/interface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export interface IconProps {
}

export interface TooltipProps {
/**箭头对齐方式*/
arrowAlign?: 'center' | 'auto';
/**给图标传入的其他 class; */
iconClass?: string;
/**icon的type,用于图标提示 */
Expand Down

0 comments on commit dfebfff

Please sign in to comment.