1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-10-04 11:17:02 +02:00
unleash.unleash/frontend/src/component/common/Input/Input.tsx
Nuno Góis cef35387c5
feat: new variants per env form (#3004)
https://linear.app/unleash/issue/2-647/adapt-current-variants-ui-to-better-align-with-cr

## About the changes
Big refactor to the variants per environment UI/UX logic, making the
variants management happen on a side modal. This makes it so variants
per environment play a lot nicer with change requests.


![image](https://user-images.githubusercontent.com/14320932/214972213-32b9aba9-1390-47b3-a00a-8c4ada359953.png)


<!-- (For internal contributors): Does it relate to an issue on public
roadmap? -->
Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item:
[#2254](https://github.com/Unleash/unleash/issues/2254)

### Important files
A big chunk of the changes is mostly moving things around or straight up
removing them.

- EnvironmentVariantModal - The modal itself that controls all of the
variants that you're editing;
 - VariantForm - The extracted form for editing each of the variants;
2023-01-27 13:56:13 +01:00

63 lines
1.5 KiB
TypeScript

import { INPUT_ERROR_TEXT } from 'utils/testIds';
import { TextField, OutlinedTextFieldProps, styled } from '@mui/material';
import { useStyles } from './Input.styles';
interface IInputProps extends Omit<OutlinedTextFieldProps, 'variant'> {
label: string;
error?: boolean;
errorText?: string;
style?: Object;
className?: string;
value: string;
onChange: (e: any) => any;
onFocus?: (e: any) => any;
onBlur?: (e: any) => any;
multiline?: boolean;
rows?: number;
}
const StyledDiv = styled('div')(({ theme }) => ({
width: '100%',
position: 'relative',
}));
const Input = ({
label,
placeholder,
error,
errorText,
style,
className,
value,
onChange,
...rest
}: IInputProps) => {
const { classes: styles } = useStyles();
return (
<StyledDiv data-loading>
<TextField
size="small"
variant="outlined"
label={label}
placeholder={placeholder}
error={error}
helperText={errorText}
style={style}
className={className ? className : ''}
value={value}
onChange={onChange}
FormHelperTextProps={{
['data-testid']: INPUT_ERROR_TEXT,
title: errorText,
classes: {
root: styles.helperText,
},
}}
{...rest}
/>
</StyledDiv>
);
};
export default Input;