diff --git a/components/__tests__/__snapshots__/story-snapshots.test.jsx.snap b/components/__tests__/__snapshots__/story-snapshots.test.jsx.snap index d7ef38db1..02dc3308c 100644 --- a/components/__tests__/__snapshots__/story-snapshots.test.jsx.snap +++ b/components/__tests__/__snapshots__/story-snapshots.test.jsx.snap @@ -10495,6 +10495,33 @@ exports[`Story HTML snapshots > Tooltip > ErrorTheme 1`] = ` " `; +exports[`Story HTML snapshots > Tooltip > IconVariants 1`] = ` +"
+
+
+
bare +
+
+
warning +
+
+
error +
+
+
inverse +
+
+
" +`; + exports[`Story HTML snapshots > Tooltip > InButtonGroup 1`] = ` "
diff --git a/components/tooltip/__docs__/Tooltip.stories.jsx b/components/tooltip/__docs__/Tooltip.stories.jsx index 343839e44..9a80ef7a5 100644 --- a/components/tooltip/__docs__/Tooltip.stories.jsx +++ b/components/tooltip/__docs__/Tooltip.stories.jsx @@ -59,6 +59,11 @@ export default { options: ['info', 'error'], description: 'Theme of tooltip: info (blue) or error (red)', }, + iconVariant: { + control: 'select', + options: ['bare', 'error', 'inverse', 'warning'], + description: 'Styles the default info icon trigger (no children)', + }, variant: { control: 'select', options: ['base', 'learnMore', 'list-item'], @@ -172,7 +177,8 @@ export const LearnMore = { parameters: { docs: { description: { - story: 'The Learn More variant displays an info icon as the trigger. When no children are provided and `onClickTrigger` is set, it renders as a clickable link.', + story: + 'The Learn More variant displays an info icon as the trigger. When no children are provided and `onClickTrigger` is set, it renders as a clickable link.', }, }, }, @@ -197,7 +203,14 @@ export const AllAlignments = { ]; return ( -
+
{alignments.map((alignment) => (
( - + Hover over this text @@ -274,7 +291,8 @@ export const WithDelay = { parameters: { docs: { description: { - story: 'You can configure open and close delays. This example has a 500ms open delay and 300ms close delay.', + story: + 'You can configure open and close delays. This example has a 500ms open delay and 300ms close delay.', }, }, }, @@ -297,7 +315,8 @@ export const AnchoredNubbin = { parameters: { docs: { description: { - story: 'The anchored nubbin variant attaches the arrow directly to the trigger element. Use `hasStaticAlignment: true` with this feature.', + story: + 'The anchored nubbin variant attaches the arrow directly to the trigger element. Use `hasStaticAlignment: true` with this feature.', }, }, }, @@ -339,7 +358,8 @@ export const InButtonGroup = { parameters: { docs: { description: { - story: 'Tooltips work well with icon buttons in a button group to provide context about each action.', + story: + 'Tooltips work well with icon buttons in a button group to provide context about each action.', }, }, }, @@ -358,11 +378,7 @@ export const Controlled = { onClick={() => setIsOpen(!isOpen)} />
- +
@@ -371,7 +387,8 @@ export const Controlled = { parameters: { docs: { description: { - story: 'Use the `isOpen` prop to control tooltip visibility programmatically. When set, hover/focus behavior is disabled.', + story: + 'Use the `isOpen` prop to control tooltip visibility programmatically. When set, hover/focus behavior is disabled.', }, }, }, @@ -387,7 +404,44 @@ export const DefaultTrigger = { parameters: { docs: { description: { - story: 'When no children are provided, Tooltip renders a default info icon button as the trigger.', + story: + 'When no children are provided, Tooltip renders a default info icon button as the trigger.', + }, + }, + }, +}; + +// Icon variants on the default trigger (matches lightning-helptext icon-variant) +export const IconVariants = { + render: () => ( +
+ {['bare', 'warning', 'error'].map((iconVariant) => ( +
+ {' '} + {iconVariant} +
+ ))} +
+ {' '} + inverse +
+
+ ), + parameters: { + docs: { + description: { + story: + 'The `iconVariant` prop styles the default info icon trigger, like `icon-variant` on `lightning-helptext`. Use `inverse` on dark backgrounds, and `warning` or `error` to draw attention to the help text.', }, }, }, diff --git a/components/tooltip/__tests__/tooltip.test.jsx b/components/tooltip/__tests__/tooltip.test.jsx index aae9dae22..30263ac9c 100644 --- a/components/tooltip/__tests__/tooltip.test.jsx +++ b/components/tooltip/__tests__/tooltip.test.jsx @@ -18,7 +18,10 @@ describe('SLDSTooltip', () => { id: 'myTooltip123', }; - const renderTooltip = (props = {}, children =