forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request mui#980 from dmtrKovalenko/feature/toolbar-keybrd-…
…accessibility Toolbar keyboard accessibility
- Loading branch information
Showing
10 changed files
with
144 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ShallowWrapper } from 'enzyme'; | ||
import * as React from 'react'; | ||
import ToolbarText, { ToolbarTextProps } from '../../_shared/ToolbarText'; | ||
import { shallow } from '../test-utils'; | ||
|
||
describe('Toolbar Text', () => { | ||
let component: ShallowWrapper<ToolbarTextProps>; | ||
|
||
beforeEach(() => { | ||
component = shallow(<ToolbarText selected={true} label="hello" />); | ||
}); | ||
|
||
it('Should render', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Theme } from '@material-ui/core'; | ||
import withStyles, { WithStyles } from '@material-ui/core/styles/withStyles'; | ||
import Typography, { TypographyProps } from '@material-ui/core/Typography'; | ||
import clsx from 'clsx'; | ||
import * as PropTypes from 'prop-types'; | ||
import * as React from 'react'; | ||
import { ExtendMui } from '../typings/extendMui'; | ||
|
||
export interface ToolbarTextProps extends ExtendMui<TypographyProps>, WithStyles<typeof styles> { | ||
selected: boolean; | ||
label: string; | ||
} | ||
|
||
// TODO make a styled(Typography) when updated to material-ui | ||
const ToolbarText: React.FunctionComponent<ToolbarTextProps> = ({ | ||
classes, | ||
selected, | ||
label, | ||
className = null, | ||
...other | ||
}) => ( | ||
<Typography | ||
className={clsx(classes.toolbarTxt, className, { | ||
[classes.toolbarBtnSelected]: selected, | ||
})} | ||
{...other} | ||
> | ||
{label} | ||
</Typography> | ||
); | ||
|
||
(ToolbarText as any).propTypes = { | ||
selected: PropTypes.bool.isRequired, | ||
label: PropTypes.string.isRequired, | ||
classes: PropTypes.any.isRequired, | ||
className: PropTypes.string, | ||
innerRef: PropTypes.any, | ||
}; | ||
|
||
ToolbarText.defaultProps = { | ||
className: '', | ||
}; | ||
|
||
export const styles = (theme: Theme) => ({ | ||
toolbarTxt: { | ||
color: 'rgba(255, 255, 255, 0.54)', | ||
}, | ||
toolbarBtnSelected: { | ||
color: theme.palette.common.white, | ||
}, | ||
}); | ||
|
||
export default withStyles(styles, { name: 'MuiPickersToolbarText' })(ToolbarText); |