Skip to content

Commit 0524f30

Browse files
committed
feat(CPopover, CTooltip): add the animation property to enable the control of the component's fade effect
1 parent 8b21e7f commit 0524f30

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/coreui-react/src/components/popover/CPopover.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import type { Triggers } from '../../types'
1111
import { isRTL } from '../../utils'
1212

1313
export interface CPopoverProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'content'> {
14+
/**
15+
* Apply a CSS fade transition to the popover.
16+
*
17+
* @since 4.9.0-beta.1
18+
*/
19+
animation?: boolean
1420
/**
1521
* A string of all className you want applied to the component.
1622
*/
@@ -67,6 +73,7 @@ const getPlacement = (placement: string, element: HTMLDivElement | null): Placem
6773

6874
export const CPopover: FC<CPopoverProps> = ({
6975
children,
76+
animation = true,
7077
className,
7178
content,
7279
offset = [0, 8],
@@ -144,8 +151,8 @@ export const CPopover: FC<CPopoverProps> = ({
144151
className={classNames(
145152
'popover',
146153
'bs-popover-auto',
147-
'fade',
148154
{
155+
fade: animation,
149156
show: state === 'entered',
150157
},
151158
className,
@@ -167,6 +174,7 @@ export const CPopover: FC<CPopoverProps> = ({
167174
}
168175

169176
CPopover.propTypes = {
177+
animation: PropTypes.bool,
170178
children: PropTypes.node,
171179
className: PropTypes.string,
172180
content: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),

packages/coreui-react/src/components/tooltip/CTooltip.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import type { Triggers } from '../../types'
1111
import { isRTL } from '../../utils'
1212

1313
export interface CTooltipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'content'> {
14+
/**
15+
* Apply a CSS fade transition to the tooltip.
16+
*
17+
* @since 4.9.0-beta.1
18+
*/
19+
animation?: boolean
1420
/**
1521
* A string of all className you want applied to the component.
1622
*/
@@ -63,6 +69,7 @@ const getPlacement = (placement: string, element: HTMLDivElement | null): Placem
6369

6470
export const CTooltip: FC<CTooltipProps> = ({
6571
children,
72+
animation = true,
6673
className,
6774
content,
6875
offset = [0, 6],
@@ -138,8 +145,8 @@ export const CTooltip: FC<CTooltipProps> = ({
138145
className={classNames(
139146
'tooltip',
140147
'bs-tooltip-auto',
141-
'fade',
142148
{
149+
fade: animation,
143150
show: state === 'entered',
144151
},
145152
className,
@@ -160,6 +167,7 @@ export const CTooltip: FC<CTooltipProps> = ({
160167
}
161168

162169
CTooltip.propTypes = {
170+
animation: PropTypes.bool,
163171
children: PropTypes.node,
164172
content: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
165173
offset: PropTypes.any, // TODO: find good proptype

0 commit comments

Comments
 (0)