Skip to content

Commit

Permalink
feat: pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kostasdano committed Oct 11, 2023
1 parent 1d1e757 commit 0b9e221
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 14 deletions.
30 changes: 19 additions & 11 deletions src/components/Tooltip/Tooltip.stories.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Meta, Story, Preview, Props } from '@storybook/addon-docs';
import { text, number, select, boolean, withKnobs } from '@storybook/addon-knobs';
import Tooltip from './Tooltip';
import { hoverOnTooltips } from './utils';
import Stack from '../storyUtils/Stack';
import TooltipShowcase from '../storyUtils/TooltipShowcase';
import { FIGMA_URL, Function } from '../../utils/common';
Expand Down Expand Up @@ -55,7 +56,7 @@ Tooltips provide brief, helpful information when a user hovers or focuses on the
Text Tooltip takes a string as a content prop. There are 2 variations of Text Tooltips, default and inverted.

<Preview>
<Story name="Text Tooltip">
<Story name="Text Tooltip" play={hoverOnTooltips} autoPlay>
<Stack>
<Function>
{() => {
Expand Down Expand Up @@ -90,7 +91,7 @@ Text Tooltip takes a string as a content prop. There are 2 variations of Text To
Interactive Tooltip takes a React Component as a content prop. There are 2 variations of Text Tooltips, default and inverted.

<Preview>
<Story name="Interactive Tooltip">
<Story name="Interactive Tooltip" play={hoverOnTooltips} autoPlay>
<Stack>
<TooltipShowcase />
</Stack>
Expand All @@ -105,26 +106,33 @@ Interactive Tooltip takes a React Component as a content prop. There are 2 varia
Tooltip can be placed to the top, bottom, left or right of the element.

<Preview>
<Story name="Tooltip Placement" parameters={{ decorators: [withKnobs] }}>
<Story name="Tooltip Placement" play={hoverOnTooltips} autoPlay>
<Stack>
<Function>
{() => {
return (
<div
style={{
padding: '16px',
width: '300px',
padding: '48px 72px',
width: '600px',
gap: '32px',
height: '100px',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Tooltip
content={'This is a Tooltip'}
placement={select('placement', ['top', 'right', 'bottom', 'left'], 'right')}
>
<Button>Hover here</Button>
<Tooltip content={'This is a Tooltip'} placement={'left'}>
<Button>Left Tooltip</Button>
</Tooltip>
<Tooltip content={'This is a Tooltip'} placement={'top'}>
<Button>Top Tooltip</Button>
</Tooltip>
<Tooltip content={'This is a Tooltip'} placement={'bottom'}>
<Button>Bottom Tooltip</Button>
</Tooltip>
<Tooltip content={'This is a Tooltip'} placement={'right'}>
<Button>Right Tooltip</Button>
</Tooltip>
</div>
);
Expand All @@ -137,7 +145,7 @@ Tooltip can be placed to the top, bottom, left or right of the element.
### Playground

<Preview>
<Story name="Playground" parameters={{ decorators: [withKnobs] }}>
<Story name="Playground" parameters={{ decorators: [withKnobs] }} play={hoverOnTooltips} autoPlay>
<Stack>
<Function>
{() => {
Expand Down
112 changes: 109 additions & 3 deletions src/components/Tooltip/__snapshots__/Tooltip.stories.storyshot
Original file line number Diff line number Diff line change
Expand Up @@ -1114,13 +1114,119 @@ exports[`Storyshots Design System/Tooltip Tooltip Placement 1`] = `
Object {
"alignItems": "center",
"display": "flex",
"gap": "32px",
"height": "100px",
"justifyContent": "center",
"padding": "16px",
"width": "300px",
"padding": "48px 72px",
"width": "600px",
}
}
>
<div
arrow={true}
className="emotion-3"
delay={
Array [
500,
500,
]
}
interactive={false}
placement="left"
>
<div
className="emotion-4"
>
<button
className="emotion-5"
data-testid="button"
disabled={false}
onClick={[Function]}
type="button"
>
<span
className="emotion-6"
>
<span>
Left Tooltip
</span>
</span>
</button>
</div>
</div>
<div>
This is a Tooltip
</div>
<div
arrow={true}
className="emotion-3"
delay={
Array [
500,
500,
]
}
interactive={false}
placement="top"
>
<div
className="emotion-4"
>
<button
className="emotion-5"
data-testid="button"
disabled={false}
onClick={[Function]}
type="button"
>
<span
className="emotion-6"
>
<span>
Top Tooltip
</span>
</span>
</button>
</div>
</div>
<div>
This is a Tooltip
</div>
<div
arrow={true}
className="emotion-3"
delay={
Array [
500,
500,
]
}
interactive={false}
placement="bottom"
>
<div
className="emotion-4"
>
<button
className="emotion-5"
data-testid="button"
disabled={false}
onClick={[Function]}
type="button"
>
<span
className="emotion-6"
>
<span>
Bottom Tooltip
</span>
</span>
</button>
</div>
</div>
<div>
This is a Tooltip
</div>
<div
arrow={true}
className="emotion-3"
Expand All @@ -1147,7 +1253,7 @@ exports[`Storyshots Design System/Tooltip Tooltip Placement 1`] = `
className="emotion-6"
>
<span>
Hover here
Right Tooltip
</span>
</span>
</button>
Expand Down
9 changes: 9 additions & 0 deletions src/components/Tooltip/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { fireEvent, screen } from '@testing-library/react';

export const hoverOnTooltips = async () => {
const buttons = screen.getAllByTestId('button');

buttons.forEach((button) => {
fireEvent.focus(button);
});
};

0 comments on commit 0b9e221

Please sign in to comment.