Fix input's hover effect when errored

This commit is contained in:
dominik-zeglen 2019-09-26 16:51:28 +02:00
parent 96b1a445f0
commit 1bc91e0cfc
2 changed files with 38 additions and 11 deletions

View file

@ -34,6 +34,7 @@ const dark: IThemeColors = {
disabled: "#393939", disabled: "#393939",
disabledBackground: "#292A2D", disabledBackground: "#292A2D",
disabledText: "#9D9D9D", disabledText: "#9D9D9D",
error: "#8C2054",
text: "#FCFCFC", text: "#FCFCFC",
textHover: "#616161" textHover: "#616161"
}, },
@ -69,6 +70,7 @@ const light: IThemeColors = {
disabled: "#EAEAEA", disabled: "#EAEAEA",
disabledBackground: "#F4F4F4", disabledBackground: "#F4F4F4",
disabledText: "#9D9D9D", disabledText: "#9D9D9D",
error: "#8C2054",
text: "#3D3D3D", text: "#3D3D3D",
textHover: "#616161" textHover: "#616161"
}, },

View file

@ -34,6 +34,7 @@ export type IThemeColors = Record<
| "disabled" | "disabled"
| "disabledBackground" | "disabledBackground"
| "disabledText" | "disabledText"
| "error"
| "text" | "text"
| "textHover", | "textHover",
string string
@ -110,7 +111,14 @@ export default (colors: IThemeColors): Theme =>
}, },
MuiFormLabel: { MuiFormLabel: {
filled: { filled: {
color: [[colors.primary], "!important"] as any "&&:not($error)": {
color: colors.primary
}
},
root: {
"&&$focused:not($error)": {
color: colors.font.gray
}
} }
}, },
MuiIconButton: { MuiIconButton: {
@ -171,8 +179,13 @@ export default (colors: IThemeColors): Theme =>
"&$disabled": { "&$disabled": {
color: `${fade(colors.primary, 0.4)} !important` as any color: `${fade(colors.primary, 0.4)} !important` as any
}, },
"&$focused": { "&&$focused": {
"&$error": {
color: colors.error
},
"&:not($error)": {
color: colors.primary color: colors.primary
}
}, },
color: colors.input.text color: colors.input.text
}, },
@ -266,9 +279,11 @@ export default (colors: IThemeColors): Theme =>
}, },
root: { root: {
"& fieldset": { "& fieldset": {
background: colors.background.paper, "&&:not($error)": {
borderColor: colors.input.border borderColor: colors.input.border
}, },
background: colors.background.paper
},
"& legend": { "& legend": {
display: "none" display: "none"
}, },
@ -283,24 +298,34 @@ export default (colors: IThemeColors): Theme =>
} }
}, },
"&$focused": { "&$focused": {
"& fieldset": {
borderColor: colors.primary
},
"& input": { "& input": {
"&::placeholder": { "&::placeholder": {
opacity: [[1], "!important"] as any opacity: [[1], "!important"] as any
}, },
color: colors.font.default, color: colors.font.default,
zIndex: 2 zIndex: 2
}
}, },
"&:hover": { "&&&": {
"& fieldset": { "& fieldset": {
borderColor: colors.primary borderColor: colors.primary
}, },
"&$error fieldset": {
borderColor: colors.error
}
}
},
"&:hover": {
"& input": { "& input": {
color: colors.font.default, color: colors.font.default,
zIndex: 2 zIndex: 2
},
"&&&": {
"& fieldset": {
borderColor: colors.primary
},
"&$error fieldset": {
borderColor: colors.input.error
}
} }
}, },
borderColor: colors.input.border borderColor: colors.input.border