Skip to content
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

[theme] Use a single theme variable for the hover effects of Button, IconButton and ListItem #10952

Merged
merged 2 commits into from
Apr 15, 2018
Merged
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
6 changes: 3 additions & 3 deletions src/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const styles = theme => ({
}),
'&:hover': {
textDecoration: 'none',
backgroundColor: fade(theme.palette.text.primary, 0.12),
backgroundColor: fade(theme.palette.text.primary, theme.palette.action.hoverOpacity),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: 'transparent',
Expand All @@ -45,7 +45,7 @@ export const styles = theme => ({
flatPrimary: {
color: theme.palette.primary.main,
'&:hover': {
backgroundColor: fade(theme.palette.primary.main, 0.12),
backgroundColor: fade(theme.palette.primary.main, theme.palette.action.hoverOpacity),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: 'transparent',
Expand All @@ -55,7 +55,7 @@ export const styles = theme => ({
flatSecondary: {
color: theme.palette.secondary.main,
'&:hover': {
backgroundColor: fade(theme.palette.secondary.main, 0.12),
backgroundColor: fade(theme.palette.secondary.main, theme.palette.action.hoverOpacity),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: 'transparent',
Expand Down
3 changes: 1 addition & 2 deletions src/CssBaseline/CssBaseline.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export interface CssBaselineProps {

declare const CssBaseline: React.ComponentType<CssBaselineProps>;

export type CssBaselineClassKey =
| '@global';
export type CssBaselineClassKey = '@global';

export default CssBaseline;
6 changes: 3 additions & 3 deletions src/IconButton/IconButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const styles = theme => ({
duration: theme.transitions.duration.shortest,
}),
'&:hover': {
backgroundColor: fade(theme.palette.action.active, 0.04),
backgroundColor: fade(theme.palette.action.active, theme.palette.action.hoverOpacity),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: 'transparent',
Expand All @@ -41,7 +41,7 @@ export const styles = theme => ({
colorPrimary: {
color: theme.palette.primary.main,
'&:hover': {
backgroundColor: fade(theme.palette.primary.main, 0.04),
backgroundColor: fade(theme.palette.primary.main, theme.palette.action.hoverOpacity),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: 'transparent',
Expand All @@ -51,7 +51,7 @@ export const styles = theme => ({
colorSecondary: {
color: theme.palette.secondary.main,
'&:hover': {
backgroundColor: fade(theme.palette.secondary.main, 0.04),
backgroundColor: fade(theme.palette.secondary.main, theme.palette.action.hoverOpacity),
// Reset on touch devices, it doesn't add specificity
'@media (hover: none)': {
backgroundColor: 'transparent',
Expand Down
3 changes: 2 additions & 1 deletion src/Select/Select.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { InputProps } from '../Input';
import { MenuProps } from '../Menu';
import { SelectInputProps } from './SelectInput';

export interface SelectProps extends StandardProps<InputProps, SelectClassKey, 'value' | 'onChange'> {
export interface SelectProps
extends StandardProps<InputProps, SelectClassKey, 'value' | 'onChange'> {
autoWidth?: boolean;
displayEmpty?: boolean;
input?: React.ReactNode;
Expand Down
2 changes: 2 additions & 0 deletions src/styles/createPalette.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const light = {
active: 'rgba(0, 0, 0, 0.54)',
// The color of an hovered action.
hover: 'rgba(0, 0, 0, 0.08)',
hoverOpacity: 0.08,
// The color of a selected action.
selected: 'rgba(0, 0, 0, 0.14)',
// The color of a disabled action.
Expand All @@ -58,6 +59,7 @@ export const dark = {
action: {
active: common.white,
hover: 'rgba(255, 255, 255, 0.1)',
hoverOpacity: 0.1,
selected: 'rgba(255, 255, 255, 0.2)',
disabled: 'rgba(255, 255, 255, 0.3)',
disabledBackground: 'rgba(255, 255, 255, 0.12)',
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/styles.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,4 @@ withStyles<'listItem'>(theme => ({
visibility: 'inherit',
},
},
}))
}));