[5d6f37a] | 1 | import { alpha, Theme } from '@mui/material/styles';
|
---|
| 2 | import { inputBaseClasses } from '@mui/material/InputBase';
|
---|
| 3 | import { inputLabelClasses } from '@mui/material/InputLabel';
|
---|
| 4 | import { filledInputClasses } from '@mui/material/FilledInput';
|
---|
| 5 | import { outlinedInputClasses } from '@mui/material/OutlinedInput';
|
---|
| 6 |
|
---|
| 7 | // ----------------------------------------------------------------------
|
---|
| 8 |
|
---|
| 9 | export function textField(theme: Theme) {
|
---|
| 10 | const color = {
|
---|
| 11 | focused: theme.palette.text.primary,
|
---|
| 12 | active: theme.palette.text.secondary,
|
---|
| 13 | placeholder: theme.palette.text.disabled,
|
---|
| 14 | };
|
---|
| 15 |
|
---|
| 16 | const font = {
|
---|
| 17 | label: theme.typography.body1,
|
---|
| 18 | value: theme.typography.body2,
|
---|
| 19 | };
|
---|
| 20 |
|
---|
| 21 | return {
|
---|
| 22 | // HELPER
|
---|
| 23 | MuiFormHelperText: {
|
---|
| 24 | styleOverrides: {
|
---|
| 25 | root: {
|
---|
| 26 | marginTop: theme.spacing(1),
|
---|
| 27 | },
|
---|
| 28 | },
|
---|
| 29 | },
|
---|
| 30 |
|
---|
| 31 | // LABEL
|
---|
| 32 | MuiFormLabel: {
|
---|
| 33 | styleOverrides: {
|
---|
| 34 | root: {
|
---|
| 35 | ...font.value,
|
---|
| 36 | color: color.placeholder,
|
---|
| 37 | [`&.${inputLabelClasses.shrink}`]: {
|
---|
| 38 | ...font.label,
|
---|
| 39 | fontWeight: 600,
|
---|
| 40 | color: color.active,
|
---|
| 41 | [`&.${inputLabelClasses.focused}`]: {
|
---|
| 42 | color: color.focused,
|
---|
| 43 | },
|
---|
| 44 | [`&.${inputLabelClasses.error}`]: {
|
---|
| 45 | color: theme.palette.error.main,
|
---|
| 46 | },
|
---|
| 47 | [`&.${inputLabelClasses.disabled}`]: {
|
---|
| 48 | color: theme.palette.text.disabled,
|
---|
| 49 | },
|
---|
| 50 | [`&.${inputLabelClasses.filled}`]: {
|
---|
| 51 | transform: 'translate(12px, 6px) scale(0.75)',
|
---|
| 52 | },
|
---|
| 53 | },
|
---|
| 54 | },
|
---|
| 55 | },
|
---|
| 56 | },
|
---|
| 57 |
|
---|
| 58 | // BASE
|
---|
| 59 | MuiInputBase: {
|
---|
| 60 | styleOverrides: {
|
---|
| 61 | root: {
|
---|
| 62 | [`&.${inputBaseClasses.disabled}`]: {
|
---|
| 63 | '& svg': {
|
---|
| 64 | color: theme.palette.text.disabled,
|
---|
| 65 | },
|
---|
| 66 | },
|
---|
| 67 | },
|
---|
| 68 | input: {
|
---|
| 69 | ...font.value,
|
---|
| 70 | '&::placeholder': {
|
---|
| 71 | opacity: 1,
|
---|
| 72 | color: color.placeholder,
|
---|
| 73 | },
|
---|
| 74 | },
|
---|
| 75 | },
|
---|
| 76 | },
|
---|
| 77 |
|
---|
| 78 | // STANDARD
|
---|
| 79 | MuiInput: {
|
---|
| 80 | styleOverrides: {
|
---|
| 81 | underline: {
|
---|
| 82 | '&:before': {
|
---|
| 83 | borderBottomColor: alpha(theme.palette.grey[500], 0.32),
|
---|
| 84 | },
|
---|
| 85 | '&:after': {
|
---|
| 86 | borderBottomColor: color.focused,
|
---|
| 87 | },
|
---|
| 88 | },
|
---|
| 89 | },
|
---|
| 90 | },
|
---|
| 91 |
|
---|
| 92 | // OUTLINED
|
---|
| 93 | MuiOutlinedInput: {
|
---|
| 94 | styleOverrides: {
|
---|
| 95 | root: {
|
---|
| 96 | [`&.${outlinedInputClasses.focused}`]: {
|
---|
| 97 | [`& .${outlinedInputClasses.notchedOutline}`]: {
|
---|
| 98 | borderColor: color.focused,
|
---|
| 99 | },
|
---|
| 100 | },
|
---|
| 101 | [`&.${outlinedInputClasses.error}`]: {
|
---|
| 102 | [`& .${outlinedInputClasses.notchedOutline}`]: {
|
---|
| 103 | borderColor: theme.palette.error.main,
|
---|
| 104 | },
|
---|
| 105 | },
|
---|
| 106 | [`&.${outlinedInputClasses.disabled}`]: {
|
---|
| 107 | [`& .${outlinedInputClasses.notchedOutline}`]: {
|
---|
| 108 | borderColor: theme.palette.action.disabledBackground,
|
---|
| 109 | },
|
---|
| 110 | },
|
---|
| 111 | },
|
---|
| 112 | notchedOutline: {
|
---|
| 113 | borderColor: alpha(theme.palette.grey[500], 0.2),
|
---|
| 114 | transition: theme.transitions.create(['border-color'], {
|
---|
| 115 | duration: theme.transitions.duration.shortest,
|
---|
| 116 | }),
|
---|
| 117 | },
|
---|
| 118 | },
|
---|
| 119 | },
|
---|
| 120 |
|
---|
| 121 | // FILLED
|
---|
| 122 | MuiFilledInput: {
|
---|
| 123 | styleOverrides: {
|
---|
| 124 | root: {
|
---|
| 125 | borderRadius: theme.shape.borderRadius,
|
---|
| 126 | backgroundColor: alpha(theme.palette.grey[500], 0.08),
|
---|
| 127 | '&:hover': {
|
---|
| 128 | backgroundColor: alpha(theme.palette.grey[500], 0.16),
|
---|
| 129 | },
|
---|
| 130 | [`&.${filledInputClasses.focused}`]: {
|
---|
| 131 | backgroundColor: alpha(theme.palette.grey[500], 0.16),
|
---|
| 132 | },
|
---|
| 133 | [`&.${filledInputClasses.error}`]: {
|
---|
| 134 | backgroundColor: alpha(theme.palette.error.main, 0.08),
|
---|
| 135 | [`&.${filledInputClasses.focused}`]: {
|
---|
| 136 | backgroundColor: alpha(theme.palette.error.main, 0.16),
|
---|
| 137 | },
|
---|
| 138 | },
|
---|
| 139 | [`&.${filledInputClasses.disabled}`]: {
|
---|
| 140 | backgroundColor: theme.palette.action.disabledBackground,
|
---|
| 141 | },
|
---|
| 142 | },
|
---|
| 143 | },
|
---|
| 144 | },
|
---|
| 145 | };
|
---|
| 146 | }
|
---|