Skip to content

Commit

Permalink
[Tooltip] Rework the implementation (#12085)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jul 8, 2018
1 parent 3adacc8 commit 2af3c82
Show file tree
Hide file tree
Showing 104 changed files with 1,933 additions and 885 deletions.
4 changes: 2 additions & 2 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ module.exports = [
name: 'The size of all the modules of material-ui.',
webpack: true,
path: 'packages/material-ui/build/index.js',
limit: '95.3 KB',
limit: '94.3 KB',
},
{
name: 'The main bundle of the docs',
webpack: false,
path: getMainFile().path,
limit: '177.1 KB',
limit: '175 KB',
},
{
name: 'The home page of the docs',
Expand Down
18 changes: 7 additions & 11 deletions docs/src/modules/components/AppFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class AppFrame extends React.Component {
<Toolbar>
<IconButton
color="inherit"
aria-label="open drawer"
aria-label="Open drawer"
onClick={this.handleDrawerOpen}
className={navIconClassName}
>
Expand All @@ -146,24 +146,20 @@ class AppFrame extends React.Component {
)}
<div className={classes.grow} />
<AppSearch />
<Tooltip id="appbar-theme" title="Toggle light/dark theme" enterDelay={300}>
<Tooltip title="Toggle light/dark theme" enterDelay={300}>
<IconButton
color="inherit"
onClick={this.handleTogglePaletteType}
aria-labelledby="appbar-theme"
aria-label="Toggle light/dark theme"
>
{uiTheme.paletteType === 'light' ? <LightbulbOutlineIcon /> : <LightbulbFullIcon />}
</IconButton>
</Tooltip>
<Tooltip
id="appbar-direction"
title="Toggle right-to-left/left-to-right"
enterDelay={300}
>
<Tooltip title="Toggle right-to-left/left-to-right" enterDelay={300}>
<IconButton
color="inherit"
onClick={this.handleToggleDirection}
aria-labelledby="appbar-direction"
aria-label="Toggle right-to-left/left-to-right"
>
{uiTheme.direction === 'rtl' ? (
<FormatTextdirectionLToR />
Expand All @@ -172,12 +168,12 @@ class AppFrame extends React.Component {
)}
</IconButton>
</Tooltip>
<Tooltip id="appbar-github" title="GitHub repository" enterDelay={300}>
<Tooltip title="GitHub repository" enterDelay={300}>
<IconButton
component="a"
color="inherit"
href="https://github.com/mui-org/material-ui"
aria-labelledby="appbar-github"
aria-label="GitHub repository"
>
<GithubIcon />
</IconButton>
Expand Down
28 changes: 6 additions & 22 deletions docs/src/modules/components/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ const styles = theme => ({
[theme.breakpoints.up('sm')]: {
display: 'flex',
flip: false,
zIndex: 10,
position: 'absolute',
top: 0,
right: theme.spacing.unit,
Expand Down Expand Up @@ -207,37 +206,22 @@ class Demo extends React.Component {
{demoOptions.hideHeader ? null : (
<div>
<div className={classes.header}>
<Tooltip id={`demo-github-${index}`} title="See the source on GitHub" placement="top">
<IconButton
href={githubLocation}
target="_blank"
aria-labelledby={`demo-github-${index}`}
>
<Tooltip title="See the source on GitHub" placement="top">
<IconButton href={githubLocation} target="_blank" aria-label="GitHub">
<Github />
</IconButton>
</Tooltip>
{demoOptions.hideEditButton ? null : (
<Tooltip
id={`demo-codesandbox-${index}`}
title="Edit in CodeSandbox"
placement="top"
>
<IconButton
onClick={this.handleClickCodeSandbox}
aria-labelledby={`demo-codesandbox-${index}`}
>
<Tooltip title="Edit in CodeSandbox" placement="top">
<IconButton onClick={this.handleClickCodeSandbox} aria-label="CodeSandbox">
<EditIcon />
</IconButton>
</Tooltip>
)}
<Tooltip
id={`demo-source-${index}`}
title={codeOpen ? 'Hide the source' : 'Show the source'}
placement="top"
>
<Tooltip title={codeOpen ? 'Hide the source' : 'Show the source'} placement="top">
<IconButton
onClick={this.handleClickCodeOpen}
aria-labelledby={`demo-source-${index}`}
aria-label={`Source of demo${index}`}
>
<CodeIcon />
</IconButton>
Expand Down
7 changes: 5 additions & 2 deletions docs/src/modules/components/withRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,13 @@ const pages = [
pathname: '/utils',
children: [
{
pathname: '/utils/modals',
pathname: '/utils/modal',
},
{
pathname: '/utils/popovers',
pathname: '/utils/popover',
},
{
pathname: '/utils/popper',
},
{
pathname: '/utils/portal',
Expand Down
33 changes: 33 additions & 0 deletions docs/src/pages/demos/autocomplete/IntegrationDownshift.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import keycode from 'keycode';
import Downshift from 'downshift';
import { withStyles } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';
import Popper from '@material-ui/core/Popper';
import Paper from '@material-ui/core/Paper';
import MenuItem from '@material-ui/core/MenuItem';
import Chip from '@material-ui/core/Chip';
Expand Down Expand Up @@ -226,6 +227,8 @@ const styles = theme => ({
},
});

let popperNode;

function IntegrationDownshift(props) {
const { classes } = props;

Expand Down Expand Up @@ -259,6 +262,36 @@ function IntegrationDownshift(props) {
)}
</Downshift>
<DownshiftMultiple classes={classes} />
<Downshift>
{({ getInputProps, getItemProps, isOpen, inputValue, selectedItem, highlightedIndex }) => (
<div className={classes.container}>
{renderInput({
fullWidth: true,
classes,
InputProps: getInputProps({
placeholder: 'With Popper',
id: 'integration-downshift-popper',
}),
ref: node => {
popperNode = node;
},
})}
<Popper open={isOpen} anchorEl={popperNode}>
<Paper square style={{ width: popperNode ? popperNode.clientWidth : null }}>
{getSuggestions(inputValue).map((suggestion, index) =>
renderSuggestion({
suggestion,
index,
itemProps: getItemProps({ item: suggestion.label }),
highlightedIndex,
selectedItem,
}),
)}
</Paper>
</Popper>
</div>
)}
</Downshift>
</div>
);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/autocomplete/autocomplete.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Autocomplete React component
components: TextField, Paper, MenuItem
components: TextField, Paper, MenuItem, Popper
---

# Autocomplete
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/demos/buttons/ButtonSizes.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ function ButtonSizes(props) {
</Button>
</div>
<div>
<Button variant="fab" mini color="secondary" aria-label="add" className={classes.button}>
<Button variant="fab" mini color="secondary" aria-label="Add" className={classes.button}>
<AddIcon />
</Button>
<Button variant="fab" color="secondary" aria-label="add" className={classes.button}>
<Button variant="fab" color="secondary" aria-label="Add" className={classes.button}>
<AddIcon />
</Button>
</div>
Expand Down
8 changes: 4 additions & 4 deletions docs/src/pages/demos/buttons/FloatingActionButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ function FloatingActionButtons(props) {
const { classes } = props;
return (
<div>
<Button variant="fab" color="primary" aria-label="add" className={classes.button}>
<Button variant="fab" color="primary" aria-label="Add" className={classes.button}>
<AddIcon />
</Button>
<Button variant="fab" color="secondary" aria-label="edit" className={classes.button}>
<Button variant="fab" color="secondary" aria-label="Edit" className={classes.button}>
<Icon>edit_icon</Icon>
</Button>
<Button variant="extendedFab" aria-label="delete" className={classes.button}>
<Button variant="extendedFab" aria-label="Delete" className={classes.button}>
<NavigationIcon className={classes.extendedIcon} />
Extended
</Button>
<Button variant="fab" disabled aria-label="delete" className={classes.button}>
<Button variant="fab" disabled aria-label="Delete" className={classes.button}>
<DeleteIcon />
</Button>
</div>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/dialogs/ConfirmationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ConfirmationDialogRaw extends React.Component {
ref={node => {
this.radioGroup = node;
}}
aria-label="ringtone"
aria-label="Ringtone"
name="ringtone"
value={this.state.value}
onChange={this.handleChange}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/drawers/MiniDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class MiniDrawer extends React.Component {
<Toolbar disableGutters={!this.state.open}>
<IconButton
color="inherit"
aria-label="open drawer"
aria-label="Open drawer"
onClick={this.handleDrawerOpen}
className={classNames(classes.menuButton, this.state.open && classes.hide)}
>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/drawers/PersistentDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class PersistentDrawer extends React.Component {
<Toolbar disableGutters={!open}>
<IconButton
color="inherit"
aria-label="open drawer"
aria-label="Open drawer"
onClick={this.handleDrawerOpen}
className={classNames(classes.menuButton, open && classes.hide)}
>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/drawers/ResponsiveDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ResponsiveDrawer extends React.Component {
<Toolbar>
<IconButton
color="inherit"
aria-label="open drawer"
aria-label="Open drawer"
onClick={this.handleDrawerToggle}
className={classes.navIconHide}
>
Expand Down
Loading

0 comments on commit 2af3c82

Please sign in to comment.