Skip to content

Commit f8f72c4

Browse files
author
Kubit
committed
Add align prop to Tooltip arrow
1 parent 29a50b4 commit f8f72c4

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

src/components/tooltip/tooltip.styled.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import styled, { css } from 'styled-components';
33
import { focusVisibleAlt } from '@/styles/mixins';
44
import { getStyles } from '@/utils/getStyles/getStyles';
55

6-
import { TooltipVariantStylesProps } from './types';
6+
import { TooltipAlignType, TooltipVariantStylesProps } from './types';
77

88
type TooltipStylesPropsTypes = {
99
styles: TooltipVariantStylesProps;
1010
hasCloseIcon?: boolean;
1111
hasTitle?: boolean;
1212
hasBorder?: boolean;
13+
align?: TooltipAlignType;
1314
};
1415

1516
export const TooltipStyled = styled.div<{ tooltipAsModal?: boolean }>`
@@ -62,6 +63,8 @@ export const TooltipCloseIconStyled = styled.div<TooltipStylesPropsTypes>`
6263
export const TooltipArrowStyled = styled.div<TooltipStylesPropsTypes>`
6364
position: absolute;
6465
${({ styles }) => getStyles(styles.arrowContainer)}
66+
${({ styles, align = TooltipAlignType.TOP }) =>
67+
getStyles(styles.arrowContainer?.tooltipAlignStyles?.[align])}
6568
width: ${props => props.styles.arrowContainer?.arrow_size};
6669
height: ${props => props.styles.arrowContainer?.arrow_size};
6770
transform: rotate(45deg);

src/components/tooltip/tooltipStandAlone.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ const TooltipStandAlone = ({
142142
)}
143143
</TooltipInnerContentStyled>
144144
</TooltipInternalContainerStyled>
145-
<TooltipArrowStyled styles={props.styles}>
145+
<TooltipArrowStyled align={props.align} styles={props.styles}>
146146
<TooltipArrowContentStyled styles={props.styles} />
147147
</TooltipArrowStyled>
148148
</TooltipExternalContainerStyled>

src/components/tooltip/tooltipUnControlled.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const TooltipUnControlledComponent = React.forwardRef(
1919
{
2020
ctv,
2121
tooltipAsModal,
22-
align,
2322
onOpenClose,
2423
variant,
2524
tooltipAriaLabel,
@@ -49,7 +48,7 @@ const TooltipUnControlledComponent = React.forwardRef(
4948
tooltipRef,
5049
variant,
5150
onOpenClose,
52-
align,
51+
align: props.align,
5352
ctv,
5453
});
5554

src/components/tooltip/types/tooltip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type TooltipPopoverType = Omit<IPopoverControlled, 'children' | 'open'>;
3131
export interface ITooltipStandAlone {
3232
disabled?: boolean;
3333
mediaDevice: DeviceBreakpointsType;
34+
align?: TooltipAlignType;
3435
title?: TooltipTitleType;
3536
content?: TooltipContentType;
3637
onFocus?: React.FocusEventHandler<HTMLElement>;
@@ -94,5 +95,4 @@ type propsToOmitUnControlled =
9495
export interface ITooltipUnControlled<V = undefined extends string ? unknown : string>
9596
extends Omit<ITooltipControlled<V>, propsToOmitUnControlled> {
9697
onOpenClose?: (open: boolean) => void;
97-
align?: TooltipAlignType;
9898
}

src/components/tooltip/types/tooltipTheme.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { CommonStyleType, DeviceBreakpointsType, IconTypes, TypographyTypes } from '@/types';
22

3+
import { TooltipAlignType } from './tooltipAlign';
4+
35
export type TooltipVariantStylesProps = {
46
tooltipExternalContainer?: CommonStyleType;
57
tooltipInternalContainer?: CommonStyleType;
@@ -21,7 +23,13 @@ export type TooltipVariantStylesProps = {
2123
[DeviceBreakpointsType.TABLET]?: boolean;
2224
[DeviceBreakpointsType.MOBILE]?: boolean;
2325
};
24-
arrowContainer?: CommonStyleType & { arrow_size?: string; arrow_position?: string };
26+
arrowContainer?: CommonStyleType & {
27+
arrow_size?: string;
28+
arrow_position?: string;
29+
tooltipAlignStyles?: {
30+
[key in TooltipAlignType]?: CommonStyleType;
31+
};
32+
};
2533
arrow?: CommonStyleType;
2634
dragIconContainer?: CommonStyleType;
2735
dragIcon?: IconTypes;

0 commit comments

Comments
 (0)