Commit cce400c0 authored by chenshouchao's avatar chenshouchao

ui: 新建项目ui优化

parent 2fa04910
...@@ -37,27 +37,36 @@ const MyInput = (props: MyInputProps) => { ...@@ -37,27 +37,36 @@ const MyInput = (props: MyInputProps) => {
fontSize: "14px", fontSize: "14px",
"&.MuiInputBase-sizeSmall": { "&.MuiInputBase-sizeSmall": {
height: "32px", height: "32px",
"& .MuiOutlinedInput-notchedOutline": {
height: "34px",
},
}, },
}, },
multiline: {
height: "auto",
textarea: {
padding: 0,
},
},
input: {},
}, },
}, },
MuiInputLabel: { MuiInputLabel: {
styleOverrides: { styleOverrides: {
root: { root: {
top: label ? "-5px" : "-10px", top: "-9px",
},
shrink: {
top: 0,
},
sizeSmall: {
top: "-5px",
}, },
}, },
}, },
MuiOutlinedInput: { MuiOutlinedInput: {
styleOverrides: { styleOverrides: {
root: { root: {
height: "36px", "&.Mui-focused .MuiOutlinedInput-notchedOutline": {
lineHeight: "36px", borderWidth: "1px",
paddingRight: "12px", },
":hover": { ":hover": {
"& .MuiOutlinedInput-notchedOutline": error "& .MuiOutlinedInput-notchedOutline": error
? {} ? {}
...@@ -70,9 +79,6 @@ const MyInput = (props: MyInputProps) => { ...@@ -70,9 +79,6 @@ const MyInput = (props: MyInputProps) => {
padding: "6.5px 12px", padding: "6.5px 12px",
verticalAlign: "middle", verticalAlign: "middle",
}, },
notchedOutline: {
height: "36px",
},
}, },
}, },
}, },
......
/*
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-07-05 14:00:37
* @LastEditors: 吴永生#A02208 yongsheng.wu@wholion.com
* @LastEditTime: 2022-07-21 17:33:59
* @FilePath: /bkunyun/src/components/mui/MyInput.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import TextField, { TextFieldProps } from "@mui/material/TextField";
import { ThemeProvider, createTheme } from "@mui/material/styles";
interface MyInputProps extends Omit<TextFieldProps, "value"> {
value?: string;
variant?: "standard" | "filled" | "outlined";
size?: "small" | "medium";
placeholder?: string;
fullWidth?: boolean; // 宽度是否和容器一致
error?: boolean;
}
const MyInput = (props: MyInputProps) => {
const {
size = "medium",
placeholder = "请输入",
fullWidth = true,
error = false,
label,
...other
} = props;
const theme = createTheme({
components: {
MuiInputBase: {
styleOverrides: {
root: {
height: "36px",
fontSize: "14px",
"&.MuiInputBase-sizeSmall": {
height: "32px",
},
},
},
},
MuiInputLabel: {
styleOverrides: {
root: {
top: "-9px",
},
shrink: {
top: 0,
},
sizeSmall: {
top: "-5px",
},
},
},
MuiOutlinedInput: {
styleOverrides: {
root: {
"&.Mui-focused .MuiOutlinedInput-notchedOutline": {
borderWidth: "1px",
},
":hover": {
"& .MuiOutlinedInput-notchedOutline": error
? {}
: {
borderColor: "#1370ff",
},
},
},
input: {
padding: "6.5px 12px",
verticalAlign: "middle",
},
},
},
},
});
return (
<ThemeProvider theme={theme}>
<TextField
error={error}
size={size}
placeholder={placeholder}
fullWidth={fullWidth}
label={label}
{...other}
/>
</ThemeProvider>
);
};
export default MyInput;
.formBox { .formBox {
height: 300px; padding: 8px 0;
width: 388px; width: 388px;
display: flex;
flex-direction: column;
padding: 10px 0;
justify-content: space-around;
} }
import style from "./index.module.css"; import style from "./index.module.css";
import { TextField, MenuItem } from "@mui/material"; import { MenuItem } from "@mui/material";
import MyInput from "@/components/mui/MyInput";
import MyDialog from "@/components/mui/MyDialog"; import MyDialog from "@/components/mui/MyDialog";
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import useMyRequest from "@/hooks/useMyRequest"; import useMyRequest from "@/hooks/useMyRequest";
...@@ -165,7 +166,7 @@ const AddProject = (props: IAddProjectProps) => { ...@@ -165,7 +166,7 @@ const AddProject = (props: IAddProjectProps) => {
title="新建项目" title="新建项目"
> >
<div className={style.formBox} onClick={handleFromBox}> <div className={style.formBox} onClick={handleFromBox}>
<TextField <MyInput
required required
error={nameCheck.error} error={nameCheck.error}
id="name" id="name"
...@@ -174,9 +175,9 @@ const AddProject = (props: IAddProjectProps) => { ...@@ -174,9 +175,9 @@ const AddProject = (props: IAddProjectProps) => {
value={name} value={name}
onChange={handleNameChange} onChange={handleNameChange}
helperText={nameCheck.help} helperText={nameCheck.help}
size="small" sx={{ marginBottom: "20px" }}
/> />
<TextField <MyInput
id="zoneId" id="zoneId"
select select
required required
...@@ -185,7 +186,7 @@ const AddProject = (props: IAddProjectProps) => { ...@@ -185,7 +186,7 @@ const AddProject = (props: IAddProjectProps) => {
onChange={handleZoneIdChange} onChange={handleZoneIdChange}
variant="outlined" variant="outlined"
onClick={handleFromBox} onClick={handleFromBox}
size="small" sx={{ marginBottom: "20px" }}
> >
{zoneIdOptions && {zoneIdOptions &&
zoneIdOptions.map((option) => ( zoneIdOptions.map((option) => (
...@@ -193,19 +194,30 @@ const AddProject = (props: IAddProjectProps) => { ...@@ -193,19 +194,30 @@ const AddProject = (props: IAddProjectProps) => {
{option.name} {option.name}
</MenuItem> </MenuItem>
))} ))}
</TextField> </MyInput>
<TextField <div style={{ position: "relative" }}>
value={desc} <MyInput
error={descCheck.error} value={desc}
id="desc" error={descCheck.error}
label="项目描述" id="desc"
multiline label="项目描述"
rows={4} multiline
placeholder="请输入项目描述" rows={4}
onChange={handleDescChange} placeholder="请输入项目描述"
helperText={descCheck.help} onChange={handleDescChange}
size="small" helperText={descCheck.help}
/> />
<span
style={{
position: "absolute",
bottom: "7px",
right: "12px",
color: "rgba(194, 198, 204, 1)",
}}
>
{desc.length}/100
</span>
</div>
</div> </div>
</MyDialog> </MyDialog>
); );
......
import { memo } from "react"; import { memo } from "react";
import { InputAdornment } from "@mui/material"; import { InputAdornment } from "@mui/material";
// import InputComponent from "@/components/mui/MyInput"; import InputComponent from "@/components/mui/MyInput";
import InputComponent from "@/components/mui/MyInputCopy";
const ProjectMembers = () => { const ProjectMembers = () => {
return ( return (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment