@kaizen/components 1.51.0 → 1.52.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Button/GenericButton/GenericButton.cjs +89 -82
- package/dist/cjs/Button/GenericButton/GenericButton.module.scss.cjs +2 -1
- package/dist/cjs/ButtonGroup/ButtonGroup.cjs +4 -4
- package/dist/cjs/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.cjs +2 -2
- package/dist/cjs/GuidanceBlock/GuidanceBlock.cjs +2 -2
- package/dist/cjs/KaizenProvider/KaizenProvider.cjs +1 -1
- package/dist/cjs/KaizenProvider/subcomponents/OptionalIntlProvider/OptionalIntlProvider.cjs +11 -2
- package/dist/cjs/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.cjs +1 -2
- package/dist/cjs/RichTextEditor/RichTextEditor/subcomponents/ToggleIconButton/ToggleIconButton.cjs +2 -2
- package/dist/cjs/Table/Table.cjs +2 -2
- package/dist/cjs/Tabs/subcomponents/Tab.cjs +20 -14
- package/dist/cjs/__overlays__/Focusable/v3/Focusable.cjs +33 -0
- package/dist/cjs/__overlays__/Focusable/v3/Focusable.module.scss.cjs +6 -0
- package/dist/cjs/__overlays__/Tooltip/v1/Tooltip.module.scss.cjs +21 -0
- package/dist/cjs/__overlays__/Tooltip/v1/index.cjs +8 -0
- package/dist/cjs/__overlays__/Tooltip/v3/OverlayArrow.cjs +32 -0
- package/dist/cjs/__overlays__/Tooltip/v3/OverlayArrow.module.scss.cjs +7 -0
- package/dist/cjs/__overlays__/Tooltip/v3/Tooltip.cjs +59 -0
- package/dist/cjs/__overlays__/Tooltip/v3/Tooltip.module.scss.cjs +8 -0
- package/dist/cjs/__overlays__/Tooltip/v3/TooltipTrigger.cjs +24 -0
- package/dist/cjs/__utilities__/ReversedColors/v3/ReversedColors.cjs +23 -0
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/overlaysV1.cjs +4 -0
- package/dist/cjs/overlaysV2.cjs +4 -0
- package/dist/cjs/overlaysV3.cjs +15 -0
- package/dist/cjs/reactAriaComponentsV3.cjs +11 -0
- package/dist/cjs/reactAriaV3.cjs +11 -0
- package/dist/cjs/utilitiesV3.cjs +5 -0
- package/dist/cjs/utils/mergeClassNames.cjs +33 -0
- package/dist/esm/Button/GenericButton/GenericButton.mjs +90 -82
- package/dist/esm/Button/GenericButton/GenericButton.module.scss.mjs +2 -1
- package/dist/esm/ButtonGroup/ButtonGroup.mjs +1 -1
- package/dist/esm/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.mjs +1 -1
- package/dist/esm/GuidanceBlock/GuidanceBlock.mjs +1 -1
- package/dist/esm/KaizenProvider/KaizenProvider.mjs +1 -1
- package/dist/esm/KaizenProvider/subcomponents/OptionalIntlProvider/OptionalIntlProvider.mjs +11 -2
- package/dist/esm/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.mjs +1 -2
- package/dist/esm/RichTextEditor/RichTextEditor/subcomponents/ToggleIconButton/ToggleIconButton.mjs +1 -1
- package/dist/esm/Table/Table.mjs +1 -1
- package/dist/esm/Tabs/subcomponents/Tab.mjs +21 -15
- package/dist/esm/__overlays__/Focusable/v3/Focusable.mjs +24 -0
- package/dist/esm/__overlays__/Focusable/v3/Focusable.module.scss.mjs +4 -0
- package/dist/esm/__overlays__/Tooltip/v1/Tooltip.module.scss.mjs +19 -0
- package/dist/esm/__overlays__/Tooltip/v1/index.mjs +6 -0
- package/dist/esm/__overlays__/Tooltip/v3/OverlayArrow.mjs +24 -0
- package/dist/esm/__overlays__/Tooltip/v3/OverlayArrow.module.scss.mjs +5 -0
- package/dist/esm/__overlays__/Tooltip/v3/Tooltip.mjs +46 -0
- package/dist/esm/__overlays__/Tooltip/v3/Tooltip.module.scss.mjs +6 -0
- package/dist/esm/__overlays__/Tooltip/v3/TooltipTrigger.mjs +16 -0
- package/dist/esm/__utilities__/ReversedColors/v3/ReversedColors.mjs +14 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/overlaysV1.mjs +1 -0
- package/dist/esm/overlaysV2.mjs +1 -0
- package/dist/esm/overlaysV3.mjs +4 -0
- package/dist/esm/reactAriaComponentsV3.mjs +1 -0
- package/dist/esm/reactAriaV3.mjs +1 -0
- package/dist/esm/utilitiesV3.mjs +1 -0
- package/dist/esm/utils/mergeClassNames.mjs +25 -0
- package/dist/styles.css +18 -15
- package/dist/types/Button/GenericButton/GenericButton.d.ts +2 -1
- package/dist/types/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/dist/types/Container/Container.d.ts +1 -1
- package/dist/types/Content/Content.d.ts +1 -1
- package/dist/types/DateInput/DateInput/DateInput.d.ts +1 -1
- package/dist/types/DatePicker/subcomponents/DateInputField/DateInputField.d.ts +1 -1
- package/dist/types/Filter/FilterButton/subcomponents/FilterButtonBase/FilterButtonBase.d.ts +1 -1
- package/dist/types/Filter/FilterDatePicker/subcomponents/DateInputField/DateInputField.d.ts +1 -1
- package/dist/types/GuidanceBlock/GuidanceBlock.d.ts +1 -1
- package/dist/types/KaizenProvider/subcomponents/OptionalIntlProvider/OptionalIntlProvider.d.ts +2 -2
- package/dist/types/Notification/subcomponents/GenericNotification/GenericNotification.d.ts +1 -1
- package/dist/types/Select/Select.d.ts +3 -3
- package/dist/types/__future__/Select/Select.d.ts +2 -2
- package/dist/types/__future__/Select/subcomponents/SelectToggle/SelectToggle.d.ts +2 -2
- package/dist/types/__overlays__/Focusable/v3/Focusable.d.ts +6 -0
- package/dist/types/__overlays__/Focusable/v3/index.d.ts +1 -0
- package/dist/types/__overlays__/Tooltip/v1/index.d.ts +8 -0
- package/dist/types/{Tooltip → __overlays__/Tooltip/v1}/utils/isSemanticElement.d.ts +2 -2
- package/dist/types/__overlays__/Tooltip/v2/index.d.ts +1 -0
- package/dist/types/__overlays__/Tooltip/v3/OverlayArrow.d.ts +7 -0
- package/dist/types/__overlays__/Tooltip/v3/Tooltip.d.ts +32 -0
- package/dist/types/__overlays__/Tooltip/v3/TooltipTrigger.d.ts +19 -0
- package/dist/types/__overlays__/Tooltip/v3/index.d.ts +2 -0
- package/dist/types/__overlays__/v1.d.ts +1 -0
- package/dist/types/__overlays__/v2.d.ts +1 -0
- package/dist/types/__overlays__/v3.d.ts +2 -0
- package/dist/types/__react-aria-components__/index.d.ts +1 -0
- package/dist/types/__react-aria__/index.d.ts +1 -0
- package/dist/types/__utilities__/ReversedColors/v3/ReversedColors.d.ts +7 -0
- package/dist/types/__utilities__/ReversedColors/v3/index.d.ts +1 -0
- package/dist/types/__utilities__/v3.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/getNodeText.d.ts +1 -2
- package/dist/types/utils/mergeClassNames.d.ts +8 -0
- package/package.json +8 -3
- package/src/Button/Button/Button.module.scss +33 -23
- package/src/Button/GenericButton/GenericButton.tsx +135 -91
- package/src/Button/utils/_mixins.scss +1 -1
- package/src/ButtonGroup/ButtonGroup.tsx +1 -1
- package/src/ButtonGroup/_docs/ButtonGroup.stickersheet.stories.tsx +1 -1
- package/src/Filter/FilterButton/FilterButtonRemovable/FilterButtonRemovable.tsx +1 -1
- package/src/GuidanceBlock/GuidanceBlock.tsx +1 -1
- package/src/KaizenProvider/KaizenProvider.tsx +5 -7
- package/src/KaizenProvider/subcomponents/OptionalIntlProvider/OptionalIntlProvider.tsx +14 -4
- package/src/MultiSelect/subcomponents/MultiSelectToggle/MultiSelectToggle.tsx +1 -1
- package/src/Notification/subcomponents/GenericNotification/GenericNotification.tsx +1 -1
- package/src/RichTextEditor/RichTextEditor/subcomponents/ToggleIconButton/ToggleIconButton.tsx +1 -1
- package/src/Table/Table.tsx +1 -1
- package/src/Tabs/_docs/Tabs.stories.tsx +1 -1
- package/src/Tabs/subcomponents/Tab.tsx +27 -21
- package/src/__overlays__/Focusable/v3/Focusable.module.scss +3 -0
- package/src/__overlays__/Focusable/v3/Focusable.tsx +37 -0
- package/src/__overlays__/Focusable/v3/_docs/ApiSpecification.mdx +38 -0
- package/src/__overlays__/Focusable/v3/_docs/Focusable.stories.tsx +24 -0
- package/src/__overlays__/Focusable/v3/index.ts +1 -0
- package/src/{Tooltip → __overlays__/Tooltip/v1}/Tooltip.module.scss +1 -1
- package/src/__overlays__/Tooltip/v1/_docs/Tooltip.mdx +139 -0
- package/src/{Tooltip → __overlays__/Tooltip/v1}/_docs/Tooltip.stickersheet.stories.tsx +1 -1
- package/src/{Tooltip → __overlays__/Tooltip/v1}/_docs/Tooltip.stories.tsx +2 -2
- package/src/__overlays__/Tooltip/v1/index.ts +7 -0
- package/src/{Tooltip → __overlays__/Tooltip/v2}/_docs/Tooltip.mdx +2 -4
- package/src/__overlays__/Tooltip/v2/_docs/Tooltip.stories.tsx +49 -0
- package/src/__overlays__/Tooltip/v2/index.ts +1 -0
- package/src/__overlays__/Tooltip/v3/OverlayArrow.module.scss +43 -0
- package/src/__overlays__/Tooltip/v3/OverlayArrow.tsx +34 -0
- package/src/__overlays__/Tooltip/v3/Tooltip.module.scss +67 -0
- package/src/__overlays__/Tooltip/v3/Tooltip.tsx +101 -0
- package/src/__overlays__/Tooltip/v3/TooltipTrigger.tsx +30 -0
- package/src/__overlays__/Tooltip/v3/_docs/ApiSpecification.mdx +163 -0
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.docs.stories.tsx +203 -0
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.mdx +182 -0
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.spec.stories.tsx +219 -0
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.stickersheet.stories.tsx +46 -0
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.stories.tsx +72 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_anatomy.png +0 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_placement.png +0 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_trigger_1.png +0 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_trigger_2.png +0 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_trigger_3.png +0 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_variant.png +0 -0
- package/src/__overlays__/Tooltip/v3/_docs/assets/tooltip_when_to_use.png +0 -0
- package/src/__overlays__/Tooltip/v3/index.ts +2 -0
- package/src/__overlays__/v1.ts +1 -0
- package/src/__overlays__/v2.ts +2 -0
- package/src/__overlays__/v3.ts +2 -0
- package/src/__react-aria-components__/index.ts +1 -0
- package/src/__react-aria__/index.ts +1 -0
- package/src/__utilities__/ReversedColors/v3/ReversedColors.tsx +20 -0
- package/src/__utilities__/ReversedColors/v3/index.ts +1 -0
- package/src/__utilities__/v3.ts +1 -0
- package/src/index.ts +1 -1
- package/src/types/cssVariables.d.ts +7 -0
- package/src/utils/mergeClassNames.ts +32 -0
- package/v1/overlays/package.json +5 -0
- package/v2/overlays/package.json +5 -0
- package/v3/overlays/package.json +5 -0
- package/v3/react-aria/package.json +5 -0
- package/v3/react-aria-components/package.json +5 -0
- package/dist/cjs/Tooltip/Tooltip.module.scss.cjs +0 -21
- package/dist/esm/Tooltip/Tooltip.module.scss.mjs +0 -19
- package/dist/types/AvatarGroup/_docs/example-data.d.ts +0 -8
- package/dist/types/BrandMoment/_docs/ExampleHeaders.d.ts +0 -3
- package/dist/types/Calendar/_docs/controls/defaultMonthControls.d.ts +0 -2
- package/dist/types/Calendar/_docs/controls/weekStartsOnControls.d.ts +0 -2
- package/dist/types/DatePicker/_docs/controls/datePickerLocaleControls.d.ts +0 -2
- package/dist/types/DatePicker/_docs/controls/disabledDayMatchersControls.d.ts +0 -2
- package/dist/types/Filter/FilterBar/context/types.d.ts +0 -28
- package/dist/types/Filter/FilterDatePicker/_docs/controls/disabledDaysControls.d.ts +0 -2
- package/dist/types/Filter/FilterDatePicker/_docs/controls/validationControls.d.ts +0 -2
- package/dist/types/Filter/FilterDateRangePicker/_docs/controls/disabledDaysControls.d.ts +0 -2
- package/dist/types/Filter/FilterDateRangePicker/_docs/controls/validationControls.d.ts +0 -2
- package/dist/types/Filter/FilterMultiSelect/_docs/MockData.d.ts +0 -10
- package/dist/types/Filter/FilterSelect/_docs/mockData.d.ts +0 -6
- package/dist/types/Filter/_docs/controls/renderTriggerControls.d.ts +0 -2
- package/dist/types/Menu/_docs/MenuContentExample.d.ts +0 -8
- package/dist/types/Menu/_docs/examples.d.ts +0 -11
- package/dist/types/Modal/_docs/controls.d.ts +0 -11
- package/dist/types/MultiSelect/MultiSelect.d.ts +0 -23
- package/dist/types/MultiSelect/subcomponents/MultiSelectOptions/MultiSelectOptions.d.ts +0 -13
- package/dist/types/Tooltip/index.d.ts +0 -1
- package/dist/types/Workflow/_docs/controls/controls.d.ts +0 -2
- package/dist/types/Workflow/_docs/controls/index.d.ts +0 -1
- package/dist/types/__future__/Select/_docs/mockData.d.ts +0 -6
- package/dist/types/__future__/Select/types.d.ts +0 -22
- package/dist/types/__future__/Workflow/_docs/controls/controls.d.ts +0 -2
- package/dist/types/__future__/Workflow/_docs/controls/index.d.ts +0 -1
- package/src/Tooltip/index.ts +0 -1
- /package/dist/cjs/{Tooltip → __overlays__/Tooltip/v1}/Tooltip.cjs +0 -0
- /package/dist/cjs/{Tooltip → __overlays__/Tooltip/v1}/subcomponents/AppearanceAnim.cjs +0 -0
- /package/dist/cjs/{Tooltip → __overlays__/Tooltip/v1}/utils/isSemanticElement.cjs +0 -0
- /package/dist/esm/{Tooltip → __overlays__/Tooltip/v1}/Tooltip.mjs +0 -0
- /package/dist/esm/{Tooltip → __overlays__/Tooltip/v1}/subcomponents/AppearanceAnim.mjs +0 -0
- /package/dist/esm/{Tooltip → __overlays__/Tooltip/v1}/utils/isSemanticElement.mjs +0 -0
- /package/dist/types/{Tooltip → __overlays__/Tooltip/v1}/Tooltip.d.ts +0 -0
- /package/dist/types/{Tooltip → __overlays__/Tooltip/v1}/subcomponents/AppearanceAnim.d.ts +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/Tooltip.spec.tsx +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/Tooltip.tsx +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/_variables.scss +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/subcomponents/AppearanceAnim.spec.tsx +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/subcomponents/AppearanceAnim.tsx +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/utils/isSemanticElement.spec.tsx +0 -0
- /package/src/{Tooltip → __overlays__/Tooltip/v1}/utils/isSemanticElement.tsx +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { forwardRef, useContext, useLayoutEffect, useState } from "react"
|
|
2
|
+
import { VisuallyHidden } from "react-aria"
|
|
3
|
+
import {
|
|
4
|
+
Tooltip as RACTooltip,
|
|
5
|
+
TooltipContext,
|
|
6
|
+
TooltipProps as RACTooltipProps,
|
|
7
|
+
TooltipTriggerStateContext,
|
|
8
|
+
useContextProps,
|
|
9
|
+
} from "react-aria-components"
|
|
10
|
+
import { useReversedColors } from "~components/__utilities__/v3"
|
|
11
|
+
import { mergeClassNames } from "~utils/mergeClassNames"
|
|
12
|
+
import { OverlayArrow } from "./OverlayArrow"
|
|
13
|
+
import styles from "./Tooltip.module.scss"
|
|
14
|
+
|
|
15
|
+
export { TooltipContext }
|
|
16
|
+
|
|
17
|
+
export type TooltipProps = Omit<RACTooltipProps, "offset"> & {
|
|
18
|
+
/**
|
|
19
|
+
* The additional offset applied along the main axis between the element and its
|
|
20
|
+
* anchor element.
|
|
21
|
+
* @default 8
|
|
22
|
+
*/
|
|
23
|
+
offset?: number
|
|
24
|
+
/**
|
|
25
|
+
* The placement of the tooltip relative to the trigger.
|
|
26
|
+
* + we're intentionally limiting the placement options to rtl friendly ones (start, end, top, bottom)
|
|
27
|
+
*/
|
|
28
|
+
placement?:
|
|
29
|
+
| "bottom"
|
|
30
|
+
| "bottom start"
|
|
31
|
+
| "bottom end"
|
|
32
|
+
| "top"
|
|
33
|
+
| "top start"
|
|
34
|
+
| "top end"
|
|
35
|
+
| "start"
|
|
36
|
+
| "start top"
|
|
37
|
+
| "start bottom"
|
|
38
|
+
| "end"
|
|
39
|
+
| "end top"
|
|
40
|
+
| "end bottom"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A tooltip displays a description of an element on hover or focus.
|
|
45
|
+
*/
|
|
46
|
+
export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
47
|
+
({ children, className, ...props }, ref): JSX.Element => {
|
|
48
|
+
const [{ triggerRef }] = useContextProps(
|
|
49
|
+
{ children, className, ...props },
|
|
50
|
+
ref,
|
|
51
|
+
TooltipContext
|
|
52
|
+
)
|
|
53
|
+
const contextState = useContext(TooltipTriggerStateContext)
|
|
54
|
+
const reverseColors = useReversedColors()
|
|
55
|
+
const [shouldInlineHiddenContent, setShouldInlineHiddenContent] =
|
|
56
|
+
useState(false)
|
|
57
|
+
|
|
58
|
+
useLayoutEffect(() => {
|
|
59
|
+
setShouldInlineHiddenContent(
|
|
60
|
+
!!triggerRef?.current?.getAttribute("data-inline-hidden-content")
|
|
61
|
+
)
|
|
62
|
+
}, [triggerRef])
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<>
|
|
66
|
+
<RACTooltip
|
|
67
|
+
ref={ref}
|
|
68
|
+
offset={8}
|
|
69
|
+
{...props}
|
|
70
|
+
className={mergeClassNames(
|
|
71
|
+
styles.tooltip,
|
|
72
|
+
className,
|
|
73
|
+
reverseColors && styles.reversed
|
|
74
|
+
)}
|
|
75
|
+
>
|
|
76
|
+
{renderProps => (
|
|
77
|
+
<>
|
|
78
|
+
<OverlayArrow />
|
|
79
|
+
{typeof children === "function"
|
|
80
|
+
? children(renderProps)
|
|
81
|
+
: children}
|
|
82
|
+
</>
|
|
83
|
+
)}
|
|
84
|
+
</RACTooltip>
|
|
85
|
+
{shouldInlineHiddenContent ? (
|
|
86
|
+
<VisuallyHidden>
|
|
87
|
+
{typeof children === "function"
|
|
88
|
+
? children({
|
|
89
|
+
placement: "center",
|
|
90
|
+
isEntering: false,
|
|
91
|
+
isExiting: false,
|
|
92
|
+
state: contextState,
|
|
93
|
+
defaultChildren: undefined,
|
|
94
|
+
})
|
|
95
|
+
: children}
|
|
96
|
+
</VisuallyHidden>
|
|
97
|
+
) : null}
|
|
98
|
+
</>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import {
|
|
3
|
+
TooltipTrigger as RACTooltipTrigger,
|
|
4
|
+
TooltipTriggerComponentProps,
|
|
5
|
+
} from "react-aria-components"
|
|
6
|
+
|
|
7
|
+
export type TooltipTriggerProps = Omit<
|
|
8
|
+
TooltipTriggerComponentProps,
|
|
9
|
+
"delay" | "closeDelay"
|
|
10
|
+
> & {
|
|
11
|
+
/**
|
|
12
|
+
* The delay time for the tooltip to show up. [See guidelines](https://spectrum.adobe.com/page/tooltip/#Immediate-or-delayed-appearance).
|
|
13
|
+
* @default 300
|
|
14
|
+
*/
|
|
15
|
+
delay?: number
|
|
16
|
+
/**
|
|
17
|
+
* The delay time for the tooltip to close. [See guidelines](https://spectrum.adobe.com/page/tooltip/#Warmup-and-cooldown).
|
|
18
|
+
* @default 300
|
|
19
|
+
*/
|
|
20
|
+
closeDelay?: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* TooltipTrigger wraps around a trigger element and a Tooltip. It handles opening and closing
|
|
25
|
+
* the Tooltip when the user hovers over or focuses the trigger, and positioning the Tooltip
|
|
26
|
+
* relative to the trigger.
|
|
27
|
+
*/
|
|
28
|
+
export const TooltipTrigger = (props: TooltipTriggerProps): JSX.Element => (
|
|
29
|
+
<RACTooltipTrigger delay={300} closeDelay={300} {...props} />
|
|
30
|
+
)
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { Canvas, Controls, Meta } from "@storybook/blocks"
|
|
2
|
+
import { KAIOInstallation, ResourceLinks, SbContent } from "~storybook/components"
|
|
3
|
+
import * as docsStories from "./Tooltip.docs.stories"
|
|
4
|
+
import * as exampleStories from "./Tooltip.stories"
|
|
5
|
+
|
|
6
|
+
<Meta title="Overlays/Tooltip/v3/API Specification"/>
|
|
7
|
+
|
|
8
|
+
<SbContent>
|
|
9
|
+
# Tooltip API Specification (v3)
|
|
10
|
+
|
|
11
|
+
Updated June 25, 2024
|
|
12
|
+
</SbContent>
|
|
13
|
+
|
|
14
|
+
<ResourceLinks
|
|
15
|
+
sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/Tooltip"
|
|
16
|
+
figma="https://www.figma.com/file/eZKEE5kXbEMY3lx84oz8iN/%F0%9F%92%9C-UI-Kit%3A-Heart?type=design&node-id=1929%3A32006&mode=design&t=LwTCBZ5E1uRvOA1l-1"
|
|
17
|
+
designGuidelines="/?path=/docs/overlays-tooltip-v3-usage-guidelines--docs"
|
|
18
|
+
ariaComponentPage="https://react-spectrum.adobe.com/react-aria/Tooltip.html"
|
|
19
|
+
className="mt-16 !mb-8"
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
<SbContent className="mb-24">
|
|
23
|
+
|
|
24
|
+
<KAIOInstallation exportNames={["Tooltip", "TooltipTrigger" ]} family="overlays" version="3" />
|
|
25
|
+
|
|
26
|
+
## Overview
|
|
27
|
+
|
|
28
|
+
Tooltips are brief floating labels used to add additional contextual information when users hover, click or focus on an interactive element.
|
|
29
|
+
</SbContent>
|
|
30
|
+
|
|
31
|
+
<Canvas
|
|
32
|
+
className="mb-64"
|
|
33
|
+
of={exampleStories.OnButton}
|
|
34
|
+
source={{code: `
|
|
35
|
+
<TooltipTrigger>
|
|
36
|
+
<Button label="Button" />
|
|
37
|
+
<Tooltip>Tooltip content</Tooltip>
|
|
38
|
+
</TooltipTrigger>
|
|
39
|
+
`}}
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
<SbContent className="mb-64">
|
|
43
|
+
### React Aria
|
|
44
|
+
|
|
45
|
+
This component is built using the `react-aria-components` library and extends the [Tooltip component](https://react-spectrum.adobe.com/react-aria/Tooltip.html).
|
|
46
|
+
|
|
47
|
+
As this shares the same core [anatomy](https://react-spectrum.adobe.com/react-aria/Tooltip.html#anatomy), [props types](https://react-spectrum.adobe.com/react-aria/Tooltip.html#tooltip-1) and [functionality](https://react-spectrum.adobe.com/react-aria/Tooltip.html#features), the guidance below is tailored to our implementation and should cover known use cases of the Tooltip.
|
|
48
|
+
|
|
49
|
+
More on the React Aria API and a deep dive into other examples can be found via the [React Aria docs page](https://react-spectrum.adobe.com/react-aria/Tooltip.html) if not present below.
|
|
50
|
+
</SbContent>
|
|
51
|
+
|
|
52
|
+
<SbContent className="mb-12">
|
|
53
|
+
## API
|
|
54
|
+
</SbContent>
|
|
55
|
+
|
|
56
|
+
<Controls of={exampleStories.OnButton} />
|
|
57
|
+
|
|
58
|
+
<SbContent className=" mt-64">
|
|
59
|
+
### Placement
|
|
60
|
+
|
|
61
|
+
Placement controls where the `Tooltip` will float, relative to its reference element defined by the `triggerRef`. By default, this will float to the `bottom`.
|
|
62
|
+
</SbContent>
|
|
63
|
+
|
|
64
|
+
<Canvas className="mb-24" of={exampleStories.Placement} />
|
|
65
|
+
|
|
66
|
+
<SbContent>
|
|
67
|
+
The option, `shouldFlip`, will control whether the `Tooltip` inverts its orientation when insufficient room is available in the viewport. You can see the below example with a constrained [viewport here](?path=/story/overlays-tooltip-v3--should-flip&globals=viewport:small).
|
|
68
|
+
</SbContent>
|
|
69
|
+
|
|
70
|
+
<Canvas className="mb-64" of={docsStories.ShouldFlip} />
|
|
71
|
+
|
|
72
|
+
<SbContent>
|
|
73
|
+
### Controlled state
|
|
74
|
+
|
|
75
|
+
By default, the `Tooltip` state is controlled, so all interactive states do not need to be defined. There may be instances where a users may want want to toggle a `Tooltip` on or off. In this case we have exposed the `isOpen` prop.
|
|
76
|
+
</SbContent>
|
|
77
|
+
|
|
78
|
+
<Canvas className="mb-24" of={docsStories.UncontrolledState} />
|
|
79
|
+
|
|
80
|
+
<SbContent className="mb-64">
|
|
81
|
+
`isOpen` prop will negate the default state and relinquish control of `Tooltip` open and close to the user.
|
|
82
|
+
</SbContent>
|
|
83
|
+
|
|
84
|
+
<SbContent>
|
|
85
|
+
### TooltipTrigger
|
|
86
|
+
|
|
87
|
+
The `TooltipTrigger` wraps both the `Tooltip` and its trigger element, controlling the open and close interactions.
|
|
88
|
+
</SbContent>
|
|
89
|
+
|
|
90
|
+
```JSX
|
|
91
|
+
|
|
92
|
+
<TooltipTrigger>
|
|
93
|
+
*/ In this case the trigger element is the Button /*
|
|
94
|
+
<Button label="Button" />
|
|
95
|
+
*/ The Tooltip and its content is a child of the trigger /*
|
|
96
|
+
<Tooltip>
|
|
97
|
+
Tooltip content
|
|
98
|
+
</Tooltip>
|
|
99
|
+
</TooltipTrigger>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
<SbContent className="mb-64">
|
|
103
|
+
Any compatible interactive element within the `TooltipTrigger` will enable the interaction state.
|
|
104
|
+
</SbContent>
|
|
105
|
+
|
|
106
|
+
<SbContent>
|
|
107
|
+
### Reversed
|
|
108
|
+
|
|
109
|
+
The `Tooltip` uses the `useReversedColors` hook and `ReversedColors` provider to control the dark and light theme.
|
|
110
|
+
</SbContent>
|
|
111
|
+
|
|
112
|
+
<Canvas className="bg-purple-600 mb-24" of={exampleStories.OnReversed} />
|
|
113
|
+
|
|
114
|
+
<SbContent>
|
|
115
|
+
To enable the reversed theme, you will need to the component or application in the `ReversedColors` provider.
|
|
116
|
+
</SbContent>
|
|
117
|
+
|
|
118
|
+
```JSX
|
|
119
|
+
<ReversedColors isReversed={true}>
|
|
120
|
+
<Component />
|
|
121
|
+
</ReversedColors>
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
<SbContent className="mb-64">
|
|
125
|
+
These utilities can be imported from `@kaizen/components/v3/utilities`. This is an emerging pattern so more documentation will come.
|
|
126
|
+
</SbContent>
|
|
127
|
+
|
|
128
|
+
<SbContent className="mb-32">
|
|
129
|
+
## Examples
|
|
130
|
+
|
|
131
|
+
Here are examples of how to use the `Tooltip` with compatible Kaizen components.
|
|
132
|
+
</SbContent>
|
|
133
|
+
|
|
134
|
+
<SbContent>
|
|
135
|
+
### On Button
|
|
136
|
+
</SbContent>
|
|
137
|
+
|
|
138
|
+
<Canvas of={exampleStories.OnButton} />
|
|
139
|
+
|
|
140
|
+
<SbContent>
|
|
141
|
+
### On Link
|
|
142
|
+
</SbContent>
|
|
143
|
+
|
|
144
|
+
<Canvas of={exampleStories.OnLink} />
|
|
145
|
+
|
|
146
|
+
<SbContent>
|
|
147
|
+
### On IconButton
|
|
148
|
+
</SbContent>
|
|
149
|
+
|
|
150
|
+
<Canvas of={exampleStories.OnIconButton} />
|
|
151
|
+
|
|
152
|
+
<SbContent>
|
|
153
|
+
### On Tabs
|
|
154
|
+
</SbContent>
|
|
155
|
+
|
|
156
|
+
<Canvas of={exampleStories.OnTabs} />
|
|
157
|
+
|
|
158
|
+
<SbContent>
|
|
159
|
+
### On Tag
|
|
160
|
+
</SbContent>
|
|
161
|
+
|
|
162
|
+
<Canvas of={exampleStories.OnCustomFocusableElement} />
|
|
163
|
+
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import isChromatic from "chromatic"
|
|
4
|
+
import { Button, IconButton } from "~components/Button"
|
|
5
|
+
import { FieldMessage } from "~components/FieldMessage"
|
|
6
|
+
import { AddIcon, QuestionIcon } from "~components/Icon"
|
|
7
|
+
import { Input } from "~components/Input"
|
|
8
|
+
import { Label } from "~components/Label"
|
|
9
|
+
import { Focusable } from "~components/__overlays__/v3"
|
|
10
|
+
import { Tooltip, TooltipTrigger } from "../index"
|
|
11
|
+
import * as TestStories from "./Tooltip.spec.stories"
|
|
12
|
+
|
|
13
|
+
const meta = {
|
|
14
|
+
title: "Overlays/Tooltip/v3/Docs Assets",
|
|
15
|
+
component: Tooltip,
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: "centered",
|
|
18
|
+
a11y: { disable: true },
|
|
19
|
+
},
|
|
20
|
+
args: {
|
|
21
|
+
defaultOpen: isChromatic(),
|
|
22
|
+
},
|
|
23
|
+
argTypes: {
|
|
24
|
+
// eslint-disable-next-line camelcase
|
|
25
|
+
UNSTABLE_portalContainer: {
|
|
26
|
+
control: false,
|
|
27
|
+
table: { disable: true },
|
|
28
|
+
},
|
|
29
|
+
triggerRef: { control: false },
|
|
30
|
+
},
|
|
31
|
+
} satisfies Meta<typeof Tooltip>
|
|
32
|
+
|
|
33
|
+
export default meta
|
|
34
|
+
|
|
35
|
+
type Story = StoryObj<typeof meta>
|
|
36
|
+
|
|
37
|
+
export const Playground: Story = {
|
|
38
|
+
render: ({ defaultOpen: _, isOpen, ...args }) => (
|
|
39
|
+
<TooltipTrigger defaultOpen={true} isOpen={isOpen}>
|
|
40
|
+
<Button label="Button" />
|
|
41
|
+
<Tooltip {...args}>Tooltip content</Tooltip>
|
|
42
|
+
</TooltipTrigger>
|
|
43
|
+
),
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const Primary: Story = {
|
|
47
|
+
render: () => (
|
|
48
|
+
<TooltipTrigger>
|
|
49
|
+
<IconButton
|
|
50
|
+
label="Add something"
|
|
51
|
+
icon={<AddIcon role="presentation" />}
|
|
52
|
+
primary
|
|
53
|
+
// Negate the aria description (added by RAC) as it should be the
|
|
54
|
+
// same as the accessible name, therefore no need to duplicate it
|
|
55
|
+
aria-describedby={null}
|
|
56
|
+
/>
|
|
57
|
+
<Tooltip>Add something</Tooltip>
|
|
58
|
+
</TooltipTrigger>
|
|
59
|
+
),
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const Placement: Story = {
|
|
63
|
+
...TestStories.Placement,
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const DoFieldTooltip: Story = {
|
|
67
|
+
render: () => (
|
|
68
|
+
<div>
|
|
69
|
+
<Label>Password</Label>
|
|
70
|
+
<Input type="text" />
|
|
71
|
+
<FieldMessage message="Password must be at least 8 characters." />
|
|
72
|
+
</div>
|
|
73
|
+
),
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const DontFieldTooltip: Story = {
|
|
77
|
+
parameters: {
|
|
78
|
+
docs: {
|
|
79
|
+
source: { type: "dynamic" },
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
render: () => (
|
|
83
|
+
<div>
|
|
84
|
+
<TooltipTrigger>
|
|
85
|
+
<Focusable>
|
|
86
|
+
<Label>
|
|
87
|
+
Password{" "}
|
|
88
|
+
<span className="inline-flex align-middle">
|
|
89
|
+
<QuestionIcon
|
|
90
|
+
classNameOverride="w-[15px] m-auto"
|
|
91
|
+
role="presentation"
|
|
92
|
+
/>
|
|
93
|
+
</span>
|
|
94
|
+
</Label>
|
|
95
|
+
</Focusable>
|
|
96
|
+
<Tooltip>Password must be at least 8 characters</Tooltip>
|
|
97
|
+
</TooltipTrigger>
|
|
98
|
+
<div className="flex gap-4">
|
|
99
|
+
<Input type="text" />
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
),
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const DoConcise: Story = {
|
|
106
|
+
parameters: {
|
|
107
|
+
docs: {
|
|
108
|
+
source: { type: "dynamic" },
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
render: () => (
|
|
112
|
+
<div>
|
|
113
|
+
<TooltipTrigger>
|
|
114
|
+
<IconButton
|
|
115
|
+
label="Add topic"
|
|
116
|
+
icon={<AddIcon role="presentation" />}
|
|
117
|
+
primary
|
|
118
|
+
// Negate the aria description (added by RAC) as it should be the
|
|
119
|
+
// same as the accessible name, therefore no need to duplicate it
|
|
120
|
+
aria-describedby={null}
|
|
121
|
+
/>
|
|
122
|
+
<Tooltip>Add topic to agenda</Tooltip>
|
|
123
|
+
</TooltipTrigger>
|
|
124
|
+
</div>
|
|
125
|
+
),
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const DontConcise: Story = {
|
|
129
|
+
parameters: {
|
|
130
|
+
docs: {
|
|
131
|
+
source: { type: "dynamic" },
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
render: () => (
|
|
135
|
+
<div>
|
|
136
|
+
<TooltipTrigger>
|
|
137
|
+
<IconButton
|
|
138
|
+
label="Add something"
|
|
139
|
+
icon={<AddIcon role="presentation" />}
|
|
140
|
+
primary
|
|
141
|
+
// Negate the aria description (added by RAC) as it should be the
|
|
142
|
+
// same as the accessible name, therefore no need to duplicate it
|
|
143
|
+
aria-describedby={null}
|
|
144
|
+
/>
|
|
145
|
+
<Tooltip>
|
|
146
|
+
Add Topic to agenda. This will create a new topic where you can
|
|
147
|
+
discuss recent work with your manager.{" "}
|
|
148
|
+
</Tooltip>
|
|
149
|
+
</TooltipTrigger>
|
|
150
|
+
</div>
|
|
151
|
+
),
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export const ShouldFlip: Story = {
|
|
155
|
+
play: undefined,
|
|
156
|
+
render: () => (
|
|
157
|
+
<div className="flex flex-col gap-8 pl-96 overflow-hidden max-w-[250px]">
|
|
158
|
+
<TooltipTrigger>
|
|
159
|
+
<Button label="Should flip" />
|
|
160
|
+
<Tooltip placement="end">Tooltip content</Tooltip>
|
|
161
|
+
</TooltipTrigger>
|
|
162
|
+
<TooltipTrigger>
|
|
163
|
+
<Button label="Won't flip" />
|
|
164
|
+
<Tooltip placement="end" shouldFlip={false}>
|
|
165
|
+
Tooltip content
|
|
166
|
+
</Tooltip>
|
|
167
|
+
</TooltipTrigger>
|
|
168
|
+
</div>
|
|
169
|
+
),
|
|
170
|
+
parameters: {
|
|
171
|
+
viewport: {
|
|
172
|
+
viewports: {
|
|
173
|
+
small: {
|
|
174
|
+
name: "small",
|
|
175
|
+
styles: {
|
|
176
|
+
width: "300px",
|
|
177
|
+
height: "300px",
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
defaultViewport: "small",
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export const UncontrolledState: Story = {
|
|
187
|
+
play: undefined,
|
|
188
|
+
args: { placement: "end", shouldFlip: false },
|
|
189
|
+
render: () => {
|
|
190
|
+
const [isOpen, setIsOpen] = React.useState<boolean>(false)
|
|
191
|
+
return (
|
|
192
|
+
<div className="flex gap-12">
|
|
193
|
+
<button type="button" onClick={() => setIsOpen(!isOpen)}>
|
|
194
|
+
Toggle open
|
|
195
|
+
</button>
|
|
196
|
+
<TooltipTrigger isOpen={isOpen}>
|
|
197
|
+
<Button label="Button" />
|
|
198
|
+
<Tooltip>Tooltip content</Tooltip>
|
|
199
|
+
</TooltipTrigger>
|
|
200
|
+
</div>
|
|
201
|
+
)
|
|
202
|
+
},
|
|
203
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Canvas, Meta, Controls } from "@storybook/blocks"
|
|
2
|
+
import { CheckIcon, ClearIcon } from "~components/Icon"
|
|
3
|
+
import { ResourceLinks, SbContent, Installation } from "~storybook/components"
|
|
4
|
+
import * as TooltipStories from "./Tooltip.docs.stories"
|
|
5
|
+
import AnatomyPng from "./assets/tooltip_anatomy.png"
|
|
6
|
+
import PlacementPng from "./assets/tooltip_placement.png"
|
|
7
|
+
import Trigger1Png from "./assets/tooltip_trigger_1.png"
|
|
8
|
+
import Trigger2Png from "./assets/tooltip_trigger_2.png"
|
|
9
|
+
import Trigger3Png from "./assets/tooltip_trigger_3.png"
|
|
10
|
+
import WhenToUsePng from "./assets/tooltip_variant.png"
|
|
11
|
+
|
|
12
|
+
<Meta title="Overlays/Tooltip/v3/Usage Guidelines" />
|
|
13
|
+
|
|
14
|
+
<SbContent>
|
|
15
|
+
# Tooltip (v3)
|
|
16
|
+
|
|
17
|
+
Updated June 25, 2024
|
|
18
|
+
</SbContent>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
<ResourceLinks
|
|
22
|
+
sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/Tooltip"
|
|
23
|
+
figma="https://www.figma.com/file/eZKEE5kXbEMY3lx84oz8iN/%F0%9F%92%9C-UI-Kit%3A-Heart?type=design&node-id=1929%3A32006&mode=design&t=LwTCBZ5E1uRvOA1l-1"
|
|
24
|
+
designGuidelines="/?path=/docs/overlays-tooltip-v3-usage-guidelines--docs"
|
|
25
|
+
ariaComponentPage="https://react-spectrum.adobe.com/react-aria/Tooltip.html"
|
|
26
|
+
apiSpecification="/?path=/docs/overlays-tooltip-v3-api-specifications--docs"
|
|
27
|
+
className="!mb-8"
|
|
28
|
+
/>
|
|
29
|
+
|
|
30
|
+
<SbContent>
|
|
31
|
+
<Installation
|
|
32
|
+
installCommand="pnpm add @kaizen/components"
|
|
33
|
+
importStatement='import { Tooltip, TooltipTrigger } from "@kaizen/components/v3/overlays"'
|
|
34
|
+
/>
|
|
35
|
+
|
|
36
|
+
## Overview
|
|
37
|
+
|
|
38
|
+
Tooltips are brief floating labels used to add additional contextual information when users hover, click or focus on an interactive element. These should offer concise explanations, elaborating on the element they are associated with.
|
|
39
|
+
</SbContent>
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
<Canvas
|
|
43
|
+
of={TooltipStories.Playground}
|
|
44
|
+
source={{code: `
|
|
45
|
+
<TooltipTrigger>
|
|
46
|
+
<Button label="Button" />
|
|
47
|
+
<Tooltip>Tooltip content</Tooltip>
|
|
48
|
+
</TooltipTrigger>
|
|
49
|
+
`}}
|
|
50
|
+
/>
|
|
51
|
+
<Controls of={TooltipStories.Playground} include={["placement", "isOpen"]} className="mb-64" />
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
<SbContent className="mb-64">
|
|
55
|
+
### Anatomy
|
|
56
|
+
|
|
57
|
+
- The anatomy of a tooltip is made up of a container, description and arrow.
|
|
58
|
+
- **They do not include a title or heading**. If you need to include a title, use a Popover
|
|
59
|
+
- A tooltip is connected to a trigger element, such as a button or icon, that shows the tooltip when the interactive trigger element is hovered or focused. (More details below.)
|
|
60
|
+
|
|
61
|
+
<img src={AnatomyPng} alt="Indicates the anatomy of the Tooltip component, the Container, Label, Arrow and Trigger" className="mt-24" />
|
|
62
|
+
</ SbContent>
|
|
63
|
+
|
|
64
|
+
<SbContent className="mb-64">
|
|
65
|
+
### When to use
|
|
66
|
+
|
|
67
|
+
- Tooltips are used to provide additional information when space is tight.
|
|
68
|
+
- Tooltips must be concise with one or more lines of text.
|
|
69
|
+
- Tooltips must be accessible via hover and focus only.
|
|
70
|
+
- Trigger tooltips from Interactive elements (Buttons, Links, Icon buttons) or Non-interactive elements (Icons, Abbreviations Truncated text)—be mindful of keyboard accessibility
|
|
71
|
+
- **Never include any kind of error messages** in a tooltip
|
|
72
|
+
|
|
73
|
+
<img src={WhenToUsePng} alt="Illustration of when to use the Tooltip component" className="mt-24"/>
|
|
74
|
+
</ SbContent>
|
|
75
|
+
|
|
76
|
+
<SbContent >
|
|
77
|
+
### Dos and don'ts
|
|
78
|
+
</SbContent >
|
|
79
|
+
|
|
80
|
+
<div className="flex flex-col mt-16 gap-40 mb-64">
|
|
81
|
+
<div className="flex flex-col m-0 gap-16">
|
|
82
|
+
<SbContent variant="heading-4">
|
|
83
|
+
#### Do use tooltips to describe icons
|
|
84
|
+
Icons are not always easy to identify on their own. When you use components that don't have labels — for example, icon-only action buttons and tabs — make sure to use tooltips to provide context for the icons.
|
|
85
|
+
</SbContent>
|
|
86
|
+
<div className="grid grid-cols-2 gap-16">
|
|
87
|
+
<div className="relative [&>*]:m-0">
|
|
88
|
+
<div className="bg-green-500 absolute top-6 left-6 z-10 py-4 px-6 font-bold text-white rounded flex gap-2 items-center justify-center">
|
|
89
|
+
<CheckIcon role="presentation" />
|
|
90
|
+
<SbContent ><span className="text-white"><strong>Do</strong></span></SbContent>
|
|
91
|
+
</div>
|
|
92
|
+
<Canvas of={TooltipStories.Primary} className="border-green-500 !rounded" />
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<div className="flex flex-col gap-16">
|
|
98
|
+
<SbContent variant="heading-4">
|
|
99
|
+
#### Don't use tooltips to communicate crucial information
|
|
100
|
+
|
|
101
|
+
Tooltips should never stop a user (or be a gate) from completing a task or performing an action. They disappear so they should never contain critical information that a user would absolutely need to proceed, or information without which a user may cause errors. If the information is crucial for a user to proceed, consider using a modal or inline notification instead.
|
|
102
|
+
</SbContent>
|
|
103
|
+
<div className="grid grid-cols-2 gap-16">
|
|
104
|
+
<div className="relative [&>*]:m-0">
|
|
105
|
+
<div className="bg-green-500 absolute top-6 left-6 z-10 py-4 px-6 font-bold text-white rounded flex gap-2 items-center justify-center">
|
|
106
|
+
<CheckIcon role="presentation" />
|
|
107
|
+
<SbContent ><span className="text-white"><strong>Do</strong></span></SbContent>
|
|
108
|
+
</div>
|
|
109
|
+
<Canvas of={TooltipStories.DoFieldTooltip} className="border-green-500 !rounded-[10px]" />
|
|
110
|
+
</div>
|
|
111
|
+
<div className="relative [&>*]:m-0">
|
|
112
|
+
<div className="bg-gray-500 absolute top-6 left-6 z-10 py-4 px-6 font-bold text-white rounded flex gap-2 items-center justify-center">
|
|
113
|
+
<ClearIcon role="presentation" />
|
|
114
|
+
<SbContent ><span className="text-white"><strong>Don't</strong></span></SbContent>
|
|
115
|
+
</div>
|
|
116
|
+
<Canvas of={TooltipStories.DontFieldTooltip} className="border-gray-500 !rounded-[10px]" />
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
<div className="flex flex-col m-0 gap-16">
|
|
122
|
+
<SbContent variant="heading-4">
|
|
123
|
+
#### Do be concise
|
|
124
|
+
|
|
125
|
+
Good tooltips contain concise and helpful information, keep it short. If you need more space, consider using a Popover. Don’t use it to duplicate information that already exists on the page. Instead, closely consider its placement and whether the disclosed copy will inform the action the user is about to perform.
|
|
126
|
+
</SbContent>
|
|
127
|
+
<div className="grid grid-cols-2 gap-16">
|
|
128
|
+
<div className="relative [&>*]:m-0">
|
|
129
|
+
<div className="bg-green-500 absolute top-6 left-6 z-10 py-4 px-6 font-bold text-white rounded flex gap-2 items-center justify-center">
|
|
130
|
+
<CheckIcon role="presentation" />
|
|
131
|
+
<SbContent ><span className="text-white"><strong>Do</strong></span></SbContent>
|
|
132
|
+
</div>
|
|
133
|
+
<Canvas of={TooltipStories.DoConcise} className="border-green-500 !rounded-[10px]" />
|
|
134
|
+
</div>
|
|
135
|
+
<div className="relative [&>*]:m-0">
|
|
136
|
+
<div className="bg-gray-500 absolute top-6 left-6 z-10 py-4 px-6 font-bold text-white rounded flex gap-2 items-center justify-center">
|
|
137
|
+
<ClearIcon role="presentation" />
|
|
138
|
+
<SbContent ><span className="text-white"><strong>Don't</strong></span></SbContent>
|
|
139
|
+
</div>
|
|
140
|
+
<Canvas of={TooltipStories.DontConcise} className="border-gray-500 !rounded-[10px]" />
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
|
|
146
|
+
<SbContent className="mb-64">
|
|
147
|
+
### Placements
|
|
148
|
+
|
|
149
|
+
<img src={PlacementPng} alt="" className="mb-24" />
|
|
150
|
+
|
|
151
|
+
- Type: Dropdown to choose from Default (dark tooltip) and Reverse (light tooltip)
|
|
152
|
+
- Direction: Dropdown to choose where the arrow points
|
|
153
|
+
- Tooltip label: Input field allows you to type in the label from the properties panel
|
|
154
|
+
- Use strong signifiers for trigger elements to ensure the tooltip is discoverable.
|
|
155
|
+
- The proximity of tooltips is always paired to the element with which they are associated.
|
|
156
|
+
</SbContent>
|
|
157
|
+
|
|
158
|
+
<SbContent className="mb-64">
|
|
159
|
+
### Trigger
|
|
160
|
+
|
|
161
|
+
- Should be shown on hover, click or on focus events
|
|
162
|
+
- Needs to be discoverable:
|
|
163
|
+
- E.g. something like an icon to suggest there’s a tooltip.
|
|
164
|
+
- Avoid triggering tooltips from text that excludes a visual indicator (e.g. underline)
|
|
165
|
+
|
|
166
|
+
<img src={Trigger1Png} alt="" className="my-24" />
|
|
167
|
+
|
|
168
|
+
- Only trigger tooltips from interactive elements, such as:
|
|
169
|
+
- Buttons
|
|
170
|
+
- Links
|
|
171
|
+
- Icon buttons
|
|
172
|
+
|
|
173
|
+
<img src={Trigger2Png} alt="" className="my-24" />
|
|
174
|
+
|
|
175
|
+
- Non-interactive elements (be mindful of keyboard accessibility):
|
|
176
|
+
- Icons
|
|
177
|
+
- Abbreviations (e.g. dashed underlined text for HRIS that shows a tooltip that says Human Resource Information System)
|
|
178
|
+
- Truncated text
|
|
179
|
+
- For interactive elements that trigger tooltips, only have optional information in the tooltip because it could be missed when the user clicks
|
|
180
|
+
|
|
181
|
+
<img src={Trigger3Png} alt="" className="my-24" />
|
|
182
|
+
</SbContent>
|