Skip to content

✨ new(react-tooltips): create new element #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/react-button-icon/lib/react-button-icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const ButtonIcon = ({

let content = (
<React.Fragment>
<span className={ `sui-icon-${icon}${iconSize ? ' sui-' + iconSize : '' }` } aria-hidden="true" />
<span className="sui-screen-reader-text">{label}</span>
<span className={ `${icon ? 'sui-icon-' + icon : ''}${iconSize ? ' sui-' + iconSize : '' }` } aria-hidden="true" />
{label ? <span className="sui-screen-reader-text">{label}</span> : ''}
</React.Fragment>
);

Expand Down
11 changes: 11 additions & 0 deletions packages/react-tooltips/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `@wpmudev/react-tooltips`

> TODO: description

## Usage

```
const reactTooltips = require('@wpmudev/react-tooltips');

// TODO: DEMONSTRATE API
```
7 changes: 7 additions & 0 deletions packages/react-tooltips/__tests__/react-tooltips.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const reactTooltips = require('..');

describe('@wpmudev/react-tooltips', () => {
it('needs tests');
});
142 changes: 142 additions & 0 deletions packages/react-tooltips/docs/react-tooltips-position.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import React from 'react';
import { Box, BoxBody } from '@wpmudev/react-box';
import ToolTips from '../lib/react-tooltips';

export default {
title: 'Components/Tooltips/Position',
component: ToolTips,
args: {
buttonText: 'Element content',
tooltipText: 'Example tooltip content goes here',
position: 'top',
id: 'tooltip-id',
customWidth: '',
customMobileWidth: '',
icon: false,
},
argTypes: {
buttonText: {
description: 'This will be the text of the button.',
control: {
type: 'text',
},
},
tooltipText: {
description: 'This will be the content of the tooltip',
control: {
type: 'text',
},
},
position: {
description: 'This will be the position of the tooltip',
control: {
type: 'select',
options: {
Top: 'top',
'Top Left': 'top-left',
'Top Right': 'top-right',
Bottom: 'bottom',
'Bottom Left': 'bottom-left',
'Bottom Right': 'bottom-right',
Left: 'left',
Right: 'right',
},
},
},
id: {
description: 'This will be id and aria describedby for tooltip',
control: {
type: 'text',
},
},
customWidth: {
description: 'This will be the width of the tooltip',
control: {
type: 'text',
},
},
customMobileWidth: {
description: 'This will be the width of the tooltip in mobile view.',
control: {
type: 'text',
},
},
icon: {
description: 'This will be the icon of the tooltip',
},
iconName: {
description: 'This will be the icon name of the tooltip',
control: {
type: 'text',
},
},
iconLabel: {
description: 'This will be the icon label of the tooltip',
control: {
type: 'text',
},
},
},
};

const Template = (args) => {
return (
<Box>
<BoxBody>
<ToolTips {...args} />
</BoxBody>
</Box>
);
};

export const primary = Template.bind({});
primary.storyName = 'Top';

// top left position
export const topLeft = Template.bind({});
topLeft.storyName = 'Top Left';
topLeft.args = {
position: 'top-left',
};

// top right position
export const topRight = Template.bind({});
topRight.storyName = 'Top Right';
topRight.args = {
position: 'top-right',
};

// bottom position
export const bottom = Template.bind({});
bottom.storyName = 'Bottom';
bottom.args = {
position: 'bottom',
};

// bottom left position
export const bottomLeft = Template.bind({});
bottomLeft.storyName = 'Bottom Left';
bottomLeft.args = {
position: 'bottom-left',
};

// bottom right position
export const bottomRight = Template.bind({});
bottomRight.storyName = 'Bottom Right';
bottomRight.args = {
position: 'bottom-right',
};

// left position
export const left = Template.bind({});
left.storyName = 'Left';
left.args = {
position: 'left',
};

// right position
export const right = Template.bind({});
right.storyName = 'Right';
right.args = {
position: 'right',
};
117 changes: 117 additions & 0 deletions packages/react-tooltips/docs/react-tooltips.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import React from 'react';
import { Box, BoxBody } from '@wpmudev/react-box';
import ToolTips from '../lib/react-tooltips';

export default {
title: 'Components/Tooltips/Variations',
component: ToolTips,
args: {
buttonText: 'Element content',
tooltipText: 'Example tooltip content goes here',
position: 'top',
id: 'tooltip-id',
customWidth: '',
customMobileWidth: '',
icon: false,
},
argTypes: {
buttonText: {
description: 'This will be the text of the button.',
control: {
type: 'text',
},
},
tooltipText: {
description: 'This will be the content of the tooltip',
control: {
type: 'text',
},
},
position: {
description: 'This will be the position of the tooltip',
control: {
type: 'select',
options: {
Top: 'top',
'Top Left': 'top-left',
'Top Right': 'top-right',
Bottom: 'bottom',
'Bottom Left': 'bottom-left',
'Bottom Right': 'bottom-right',
Left: 'left',
Right: 'right',
},
},
},
id: {
description: 'This will be id and aria describedby for tooltip',
control: {
type: 'text',
},
},
customWidth: {
description: 'This will be the width of the tooltip',
control: {
type: 'text',
},
},
customMobileWidth: {
description: 'This will be the width of the tooltip in mobile view.',
control: {
type: 'text',
},
},
icon: {
description: 'This will be the icon of the tooltip',
},
iconName: {
description: 'This will be the icon name of the tooltip',
control: {
type: 'text',
},
},
iconLabel: {
description: 'This will be the icon label of the tooltip',
control: {
type: 'text',
},
},
},
};

const Template = (args) => {
return (
<Box>
<BoxBody>
<ToolTips {...args} />
</BoxBody>
</Box>
);
};

// icon button
export const button = Template.bind({});
button.storyName = 'Button';

// icon button
export const icon = Template.bind({});
icon.storyName = 'Icon Button';
icon.args = {
icon: true,
iconLabel: 'Icon Label',
iconName: 'info',
};

// custom width
export const customWidth = Template.bind({});
customWidth.storyName = 'Custom Width';
customWidth.args = {
customWidth: '171',
};

// custom mobile width
export const customMobileWidth = Template.bind({});
customMobileWidth.storyName = 'Custom Mobile Width';
customMobileWidth.args = {
customMobileWidth: '200',
};
Loading