diff --git a/packages/web-react/src/components/Tooltip/Tooltip.tsx b/packages/web-react/src/components/Tooltip/Tooltip.tsx index d71ae654e9..3f9ef40e35 100644 --- a/packages/web-react/src/components/Tooltip/Tooltip.tsx +++ b/packages/web-react/src/components/Tooltip/Tooltip.tsx @@ -1,11 +1,11 @@ -import React, { useMemo, forwardRef, LegacyRef } from 'react'; import classNames from 'classnames'; +import React, { LegacyRef, forwardRef, useMemo } from 'react'; import { useStyleProps } from '../../hooks'; import { SpiritTooltipProps } from '../../types'; import TooltipCloseButton from './TooltipCloseButton'; import { useTooltipStyleProps } from './useTooltipStyleProps'; -const Tooltip = forwardRef((props: SpiritTooltipProps, ref) => { +export const Tooltip = forwardRef((props: SpiritTooltipProps, ref) => { const { children, isDismissible, closeLabel = 'Close', open, onClose, ...restProps } = props; const { classProps, props: modifiedProps } = useTooltipStyleProps({ diff --git a/packages/web-react/src/components/Tooltip/TooltipCloseButton.tsx b/packages/web-react/src/components/Tooltip/TooltipCloseButton.tsx index 60f739ed59..66e4235e51 100644 --- a/packages/web-react/src/components/Tooltip/TooltipCloseButton.tsx +++ b/packages/web-react/src/components/Tooltip/TooltipCloseButton.tsx @@ -6,7 +6,7 @@ import { Icon } from '../Icon'; import { VisuallyHidden } from '../VisuallyHidden'; import { useTooltipStyleProps } from './useTooltipStyleProps'; -const TooltipCloseButton = ({ label = 'Close', onClick, ...restProps }: TooltipCloseButtonProps) => { +export const TooltipCloseButton = ({ label = 'Close', onClick, ...restProps }: TooltipCloseButtonProps) => { const { classProps, props: modifiedProps } = useTooltipStyleProps({ ...restProps }); const { styleProps } = useStyleProps({ ...modifiedProps }); diff --git a/packages/web-react/src/components/Tooltip/TooltipWrapper.tsx b/packages/web-react/src/components/Tooltip/TooltipWrapper.tsx index fcb5eaa91a..f7c4d31e96 100644 --- a/packages/web-react/src/components/Tooltip/TooltipWrapper.tsx +++ b/packages/web-react/src/components/Tooltip/TooltipWrapper.tsx @@ -1,10 +1,10 @@ -import React from 'react'; import classNames from 'classnames'; +import React from 'react'; import { useStyleProps } from '../../hooks'; import { TooltipWrapperProps } from '../../types'; import { useTooltipStyleProps } from './useTooltipStyleProps'; -const TooltipWrapper = ({ children, ...restProps }: TooltipWrapperProps) => { +export const TooltipWrapper = ({ children, ...restProps }: TooltipWrapperProps) => { const { classProps, props: modifiedProps } = useTooltipStyleProps({ ...restProps }); const { styleProps } = useStyleProps({ ...modifiedProps }); diff --git a/packages/web-react/src/components/Tooltip/UncontrolledTooltip.tsx b/packages/web-react/src/components/Tooltip/UncontrolledTooltip.tsx index a4072a16cf..4a54c7e0d3 100644 --- a/packages/web-react/src/components/Tooltip/UncontrolledTooltip.tsx +++ b/packages/web-react/src/components/Tooltip/UncontrolledTooltip.tsx @@ -3,7 +3,7 @@ import { UncontrolledTooltipProps } from '../../types'; import Tooltip from './Tooltip'; import { useTooltip } from './useTooltip'; -const UncontrolledTooltip = (props: UncontrolledTooltipProps) => { +export const UncontrolledTooltip = (props: UncontrolledTooltipProps) => { const { children, isDismissible, ...restProps } = props; const { open, onClose } = useTooltip({ isDismissible }); diff --git a/packages/web-react/src/components/Tooltip/demo/TooltipOnHover.tsx b/packages/web-react/src/components/Tooltip/demo/TooltipOnHover.tsx index 6bfe2ee0a9..11f2dd24c9 100644 --- a/packages/web-react/src/components/Tooltip/demo/TooltipOnHover.tsx +++ b/packages/web-react/src/components/Tooltip/demo/TooltipOnHover.tsx @@ -1,38 +1,35 @@ import React from 'react'; import { ButtonLink } from '../../Button'; -import TooltipWrapper from '../TooltipWrapper'; import Tooltip from '../Tooltip'; +import TooltipWrapper from '../TooltipWrapper'; const TooltipOnHover = () => ( - <> - +
+ Tooltip on top Hello there! - - - + {' '} + Tooltip on right Hello there! - - - + {' '} + Tooltip on bottom Hello there! - - - + {' '} + Tooltip on left @@ -40,7 +37,7 @@ const TooltipOnHover = () => ( Hello there! - +
); export default TooltipOnHover; diff --git a/packages/web-react/src/components/Tooltip/demo/TooltipPlacements.tsx b/packages/web-react/src/components/Tooltip/demo/TooltipPlacements.tsx index a2100d1eca..7d68a393c6 100644 --- a/packages/web-react/src/components/Tooltip/demo/TooltipPlacements.tsx +++ b/packages/web-react/src/components/Tooltip/demo/TooltipPlacements.tsx @@ -14,8 +14,12 @@ const TooltipPlacements = () => { }; return ( -
- + +
{ value="bottom-right" />
-
+
{ value="left-bottom" />
-
+
{ />
- - Click the dots! - Hello! + + + Click +
the dots! +
+ {placement}
diff --git a/packages/web-react/src/components/Tooltip/demo/index.tsx b/packages/web-react/src/components/Tooltip/demo/index.tsx index 02d97bf247..d783c25b65 100644 --- a/packages/web-react/src/components/Tooltip/demo/index.tsx +++ b/packages/web-react/src/components/Tooltip/demo/index.tsx @@ -7,24 +7,24 @@ import ReactDOM from 'react-dom/client'; import icons from '@lmc-eu/spirit-icons/dist/icons'; import DocsSection from '../../../../docs/DocsSections'; import { IconsProvider } from '../../../context'; -import TooltipPlacements from './TooltipPlacements'; -import TooltipDefault from './TooltipDefault'; -import TooltipOnHover from './TooltipOnHover'; import TooltipClickable from './TooltipClickable'; +import TooltipDefault from './TooltipDefault'; import TooltipDismissible from './TooltipDismissible'; -import TooltipFloatingUI from './TooltipFloatingUi'; import TooltipDismissibleViaJS from './TooltipDismissibleViaJS'; +import TooltipFloatingUI from './TooltipFloatingUi'; +import TooltipOnHover from './TooltipOnHover'; +import TooltipPlacements from './TooltipPlacements'; ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render( - + - + diff --git a/packages/web-react/src/components/Tooltip/index.ts b/packages/web-react/src/components/Tooltip/index.ts index a4cd67bb78..211af3a55e 100644 --- a/packages/web-react/src/components/Tooltip/index.ts +++ b/packages/web-react/src/components/Tooltip/index.ts @@ -1,9 +1,10 @@ export * from './Tooltip'; -export * from './TooltipWrapper'; +export { default as Tooltip } from './Tooltip'; export * from './TooltipCloseButton'; +export { default as TooltipCloseButton } from './TooltipCloseButton'; +export * from './TooltipWrapper'; +export { default as TooltipWrapper } from './TooltipWrapper'; export * from './UncontrolledTooltip'; +export { default as UncontrolledTooltip } from './UncontrolledTooltip'; export * from './useTooltip'; export * from './useTooltipStyleProps'; -export { default as Tooltip } from './Tooltip'; -export { default as TooltipWrapper } from './TooltipWrapper'; -export { default as UncontrolledTooltip } from './UncontrolledTooltip'; diff --git a/packages/web-twig/src/Resources/components/Tooltip/Tooltip.stories.twig b/packages/web-twig/src/Resources/components/Tooltip/Tooltip.stories.twig index 73b02a34b3..a7232959d6 100644 --- a/packages/web-twig/src/Resources/components/Tooltip/Tooltip.stories.twig +++ b/packages/web-twig/src/Resources/components/Tooltip/Tooltip.stories.twig @@ -2,7 +2,7 @@ {% block content %} - + {% include '@components/Tooltip/stories/TooltipPlacements.twig' %} @@ -10,7 +10,7 @@ {% include '@components/Tooltip/stories/TooltipStatic.twig' %} - + {% include '@components/Tooltip/stories/TooltipOnHover.twig' %} diff --git a/packages/web-twig/src/Resources/components/Tooltip/stories/TooltipOnHover.twig b/packages/web-twig/src/Resources/components/Tooltip/stories/TooltipOnHover.twig index 15e948d3af..188feaabb9 100644 --- a/packages/web-twig/src/Resources/components/Tooltip/stories/TooltipOnHover.twig +++ b/packages/web-twig/src/Resources/components/Tooltip/stories/TooltipOnHover.twig @@ -1,51 +1,37 @@ - - - Tooltip on top - - - Hello there! - - +
+ + + Tooltip on top + + + Hello there! + + - - - Tooltip on right - - - Hello there! - - + + + Tooltip on right + + + Hello there! + + - - - Tooltip on bottom - - - Hello there! - - + + + Tooltip on bottom + + + Hello there! + + - - - Tooltip on left - - - Hello there! - - + + + Tooltip on left + + + Hello there! + + +
diff --git a/packages/web-twig/src/Resources/components/Tooltip/stories/TooltipPlacements.twig b/packages/web-twig/src/Resources/components/Tooltip/stories/TooltipPlacements.twig index e4d1850c89..fd79af4ef2 100644 --- a/packages/web-twig/src/Resources/components/Tooltip/stories/TooltipPlacements.twig +++ b/packages/web-twig/src/Resources/components/Tooltip/stories/TooltipPlacements.twig @@ -1,44 +1,45 @@ - - + +
- - - + + +
- - - + + +
-
+
- - - + + +
-
+
- - - + + +
- - Click the dots! - Hello! + + Click
the dots!
+ + bottom +
- diff --git a/packages/web/src/scss/components/Tooltip/index.html b/packages/web/src/scss/components/Tooltip/index.html index fb9e41ed89..2d86b72d67 100644 --- a/packages/web/src/scss/components/Tooltip/index.html +++ b/packages/web/src/scss/components/Tooltip/index.html @@ -4,10 +4,10 @@

Placements

-
+
-
-
+ +
-
+
-
+
-
-
Click the dots!
+
+
+ Click
+ the dots! +
- Hello! + bottom
@@ -117,8 +120,10 @@

Placements

radio.addEventListener('change', () => { const placement = radio.value; const tooltip = document.getElementById('tooltip_placements_example'); + const tooltipText = document.getElementById('tooltip_placements_example_text'); tooltip.classList.replace(tooltip.classList[1], `Tooltip--${placement}`); + tooltipText.textContent = placement.split(/(?=[A-Z])/).join('-').toLowerCase(); }); }); @@ -163,42 +168,44 @@

Static Tooltip (No Interaction)

Tooltip on Hover (Pure CSS)

-
+
-
- -
- Hello there! - +
+
+ +
+ Hello there! + +
-
-
- -
- Hello there! - +
+ +
+ Hello there! + +
-
-
- -
- Hello there! - +
+ +
+ Hello there! + +
-
-
- -
- Hello there! - +
+ +
+ Hello there! + +