FPSMS-frontend
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

473 行
11 KiB

  1. import { ThemeOptions, createTheme } from "@mui/material";
  2. import palette from "./palette";
  3. // Used only to create transitions
  4. const defaultFontSize = 18;
  5. const muiTheme = createTheme();
  6. const components: ThemeOptions["components"] = {
  7. MuiAppBar: {
  8. styleOverrides: {
  9. colorDefault: {
  10. backgroundColor: palette.background.paper,
  11. },
  12. },
  13. },
  14. MuiAvatar: {
  15. styleOverrides: {
  16. root: {
  17. fontSize: defaultFontSize,
  18. fontWeight: 600,
  19. letterSpacing: 0,
  20. },
  21. },
  22. },
  23. MuiButton: {
  24. styleOverrides: {
  25. root: {
  26. borderRadius: "12px",
  27. textTransform: "none",
  28. },
  29. sizeSmall: {
  30. padding: "6px 16px",
  31. },
  32. sizeMedium: {
  33. padding: "8px 20px",
  34. },
  35. sizeLarge: {
  36. padding: "11px 24px",
  37. },
  38. textSizeSmall: {
  39. padding: "7px 12px",
  40. },
  41. textSizeMedium: {
  42. padding: "9px 16px",
  43. },
  44. textSizeLarge: {
  45. padding: "12px 16px",
  46. },
  47. },
  48. },
  49. MuiAlert: {
  50. styleOverrides: {
  51. root: {
  52. borderRadius: 8,
  53. },
  54. },
  55. },
  56. MuiPaper: {
  57. styleOverrides: {
  58. rounded: {
  59. borderRadius: 20,
  60. [`&.MuiPaper-elevation1`]: {
  61. boxShadow:
  62. "0px 5px 22px rgba(0, 0, 0, 0.04), 0px 0px 0px 0.5px rgba(0, 0, 0, 0.03)",
  63. },
  64. },
  65. outlined: {
  66. borderStyle: "solid",
  67. borderWidth: 1,
  68. overflow: "hidden",
  69. borderColor: palette.neutral[200],
  70. "&.MuiPaper-rounded": {
  71. borderRadius: 8,
  72. },
  73. },
  74. },
  75. },
  76. MuiCard: {
  77. styleOverrides: {
  78. root: {
  79. borderRadius: 20,
  80. [`&.MuiPaper-elevation1`]: {
  81. boxShadow:
  82. "0px 5px 22px rgba(0, 0, 0, 0.04), 0px 0px 0px 0.5px rgba(0, 0, 0, 0.03)",
  83. },
  84. },
  85. },
  86. },
  87. MuiCardContent: {
  88. styleOverrides: {
  89. root: {
  90. padding: "32px 24px",
  91. "&:last-child": {
  92. paddingBottom: "32px",
  93. },
  94. },
  95. },
  96. },
  97. MuiCardHeader: {
  98. defaultProps: {
  99. titleTypographyProps: {
  100. variant: "h6",
  101. },
  102. subheaderTypographyProps: {
  103. variant: "body2",
  104. },
  105. },
  106. styleOverrides: {
  107. root: {
  108. padding: "32px 24px 16px",
  109. },
  110. },
  111. },
  112. MuiCssBaseline: {
  113. styleOverrides: {
  114. "*": {
  115. boxSizing: "border-box",
  116. },
  117. html: {
  118. MozOsxFontSmoothing: "grayscale",
  119. WebkitFontSmoothing: "antialiased",
  120. display: "flex",
  121. flexDirection: "column",
  122. minHeight: "100%",
  123. width: "100%",
  124. },
  125. body: {
  126. display: "flex",
  127. flex: "1 1 auto",
  128. flexDirection: "column",
  129. minHeight: "100%",
  130. width: "100%",
  131. },
  132. "#__next": {
  133. display: "flex",
  134. flex: "1 1 auto",
  135. flexDirection: "column",
  136. height: "100%",
  137. width: "100%",
  138. },
  139. "#nprogress": {
  140. pointerEvents: "none",
  141. },
  142. "#nprogress .bar": {
  143. backgroundColor: palette.primary.main,
  144. height: 3,
  145. left: 0,
  146. position: "fixed",
  147. top: 0,
  148. width: "100%",
  149. zIndex: 2000,
  150. },
  151. ".swal2-custom-zindex": {
  152. zIndex: 10000, // Set z-index for SweetAlert2 modals
  153. },
  154. },
  155. },
  156. MuiInputBase: {
  157. styleOverrides: {
  158. root: {
  159. "&:not(.Mui-disabled)": {
  160. backgroundColor: "rgba(200, 230, 255, 0.2)", // Slightly cyan-ish background
  161. "&:hover": {
  162. backgroundColor: "rgba(200, 230, 255, 0.25)", // Slightly darker on hover
  163. },
  164. "&.Mui-focused": {
  165. backgroundColor: "rgba(200, 230, 255, 0.3)", // More pronounced on focus
  166. },
  167. },
  168. "&.Mui-disabled": {
  169. backgroundColor: "#ffffff", // White background
  170. opacity: 1, // Remove MUI's default opacity reduction
  171. "& .MuiInputBase-input": {
  172. color: "#000", // Black text
  173. cursor: "default", // Default cursor
  174. WebkitTextFillColor: "#000", // Ensure text color isn't grayed out in WebKit browsers
  175. },
  176. "& fieldset": {
  177. backgroundColor: "transparent", // Ensure no extra background effects
  178. boxShadow: "none", // Remove any box-shadow
  179. },
  180. },
  181. },
  182. input: {
  183. "&::placeholder": {
  184. opacity: 1,
  185. },
  186. },
  187. },
  188. },
  189. MuiInput: {
  190. styleOverrides: {
  191. input: {
  192. fontSize: defaultFontSize,
  193. fontWeight: 500,
  194. lineHeight: "24px",
  195. "&::placeholder": {
  196. color: palette.text.secondary,
  197. },
  198. },
  199. },
  200. },
  201. MuiAutocomplete: {
  202. styleOverrides: {
  203. root: {
  204. "& .MuiFilledInput-root": {
  205. paddingTop: 16,
  206. paddingBottom: 8,
  207. },
  208. },
  209. },
  210. },
  211. MuiFilledInput: {
  212. styleOverrides: {
  213. root: {
  214. backgroundColor: "transparent",
  215. borderRadius: 8,
  216. borderStyle: "solid",
  217. borderWidth: 1,
  218. overflow: "hidden",
  219. borderColor: palette.neutral[200],
  220. transition: muiTheme.transitions.create(["border-color", "box-shadow"]),
  221. "&:hover": {
  222. backgroundColor: palette.action.hover,
  223. },
  224. "&:before": {
  225. display: "none",
  226. },
  227. "&:after": {
  228. display: "none",
  229. },
  230. [`&.Mui-disabled`]: {
  231. backgroundColor: "transparent",
  232. },
  233. [`&.Mui-focused`]: {
  234. backgroundColor: "transparent",
  235. borderColor: palette.primary.main,
  236. boxShadow: `${palette.primary.main} 0 0 0 2px`,
  237. },
  238. [`&.Mui-error`]: {
  239. borderColor: palette.error.main,
  240. boxShadow: `${palette.error.main} 0 0 0 2px`,
  241. },
  242. },
  243. input: {
  244. fontSize: defaultFontSize,
  245. fontWeight: 500,
  246. lineHeight: "24px",
  247. },
  248. },
  249. },
  250. MuiOutlinedInput: {
  251. styleOverrides: {
  252. root: {
  253. "&:hover": {
  254. backgroundColor: palette.action.hover,
  255. [`& .MuiOutlinedInput-notchedOutline`]: {
  256. borderColor: palette.neutral[200],
  257. },
  258. },
  259. [`&.Mui-focused`]: {
  260. backgroundColor: "transparent",
  261. [`& .MuiOutlinedInput-notchedOutline`]: {
  262. borderColor: palette.primary.main,
  263. boxShadow: `${palette.primary.main} 0 0 0 2px`,
  264. },
  265. },
  266. [`&.Mui-error`]: {
  267. [`& .MuiOutlinedInput-notchedOutline`]: {
  268. borderColor: palette.error.main,
  269. boxShadow: `${palette.error.main} 0 0 0 2px`,
  270. },
  271. },
  272. "&:not(.Mui-disabled)": {
  273. "&:hover .MuiOutlinedInput-notchedOutline": {
  274. borderColor: "rgba(0, 0, 0, 0.6)", // Darker border on hover
  275. },
  276. "&.Mui-focused .MuiOutlinedInput-notchedOutline": {
  277. borderColor: "rgba(0, 0, 0, 0.7)", // Darkest border when focused
  278. },
  279. },
  280. "&.Mui-disabled .MuiOutlinedInput-notchedOutline": {
  281. border: "1px solid #ccc", // Simple gray border for disabled
  282. },
  283. },
  284. input: {
  285. fontSize: defaultFontSize,
  286. fontWeight: 500,
  287. lineHeight: "24px",
  288. },
  289. notchedOutline: {
  290. borderColor: palette.neutral[200],
  291. transition: muiTheme.transitions.create(["border-color", "box-shadow"]),
  292. legend: { width: 0 },
  293. },
  294. },
  295. },
  296. MuiFormLabel: {
  297. styleOverrides: {
  298. root: {
  299. fontSize: defaultFontSize,
  300. fontWeight: 500,
  301. [`&.MuiInputLabel-filled`]: {
  302. transform: "translate(12px, 18px) scale(1)",
  303. },
  304. [`&.MuiInputLabel-shrink`]: {
  305. [`&.MuiInputLabel-standard`]: {
  306. transform: "translate(0, -1.5px) scale(0.85)",
  307. },
  308. [`&.MuiInputLabel-filled`]: {
  309. transform: "translate(12px, 6px) scale(0.85)",
  310. },
  311. [`&.MuiInputLabel-outlined`]: {
  312. transform: "translate(14px, -9px) scale(0.85)",
  313. padding: "0 0.25rem",
  314. background: palette.primary.contrastText,
  315. },
  316. },
  317. "&.Mui-disabled": {
  318. color: "rgba(0, 0, 0, 0.6)", // Black label
  319. transform: "translate(14px, 16px) scale(1)", // Position like placeholder
  320. "&.Mui-focused": {
  321. transform: "translate(14px, 16px) scale(1)", // Keep label in place when "focused"
  322. },
  323. },
  324. },
  325. },
  326. },
  327. MuiTab: {
  328. styleOverrides: {
  329. root: {
  330. fontSize: defaultFontSize,
  331. fontWeight: 500,
  332. lineHeight: 1.71,
  333. minWidth: "auto",
  334. minHeight: 48,
  335. paddingLeft: 0,
  336. paddingRight: 0,
  337. textTransform: "none",
  338. "& + &": {
  339. marginLeft: 24,
  340. },
  341. },
  342. },
  343. },
  344. MuiTableRow: {
  345. styleOverrides: {
  346. root: {
  347. // '&:nth-of-type(odd)': {
  348. // backgroundColor: 'rgba(0, 0, 0, 0.04)', // Example for odd rows
  349. // },
  350. '&:nth-of-type(even)': {
  351. backgroundColor: palette.neutral[50], // Example for even rows
  352. },
  353. },
  354. },
  355. },
  356. MuiTableCell: {
  357. styleOverrides: {
  358. root: {
  359. borderBottomColor: palette.divider,
  360. padding: "10px 6px",
  361. fontSize: defaultFontSize - 2,
  362. // padding: "15px 16px",
  363. // lineHeight: 1.5,
  364. },
  365. },
  366. },
  367. MuiTableHead: {
  368. styleOverrides: {
  369. root: {
  370. borderBottom: "none",
  371. [`& .MuiTableCell-root`]: {
  372. borderBottom: "none",
  373. backgroundColor: palette.neutral[50],
  374. color: palette.neutral[700],
  375. fontSize: defaultFontSize - 2,
  376. fontWeight: 600,
  377. lineHeight: 2,
  378. letterSpacing: 0.5,
  379. textTransform: "uppercase",
  380. },
  381. [`& .MuiTableCell-paddingCheckbox`]: {
  382. paddingTop: 4,
  383. paddingBottom: 4,
  384. },
  385. },
  386. },
  387. },
  388. // MuiTableFooter: {
  389. // styleOverrides: {
  390. // root: {
  391. // padding: "1px 6px",
  392. // },
  393. // },
  394. // },
  395. MuiTextField: {
  396. defaultProps: {
  397. variant: "filled",
  398. },
  399. },
  400. MuiMenu: {
  401. styleOverrides: {
  402. list: {
  403. padding: 0,
  404. },
  405. },
  406. },
  407. MuiMenuItem: {
  408. styleOverrides: {
  409. root: {
  410. margin: "0.5rem",
  411. borderRadius: 8,
  412. },
  413. },
  414. },
  415. MuiList: {
  416. styleOverrides: {
  417. padding: {
  418. paddingBlock: "1rem",
  419. paddingInline: "1rem",
  420. "&.MuiDataGrid-menuList": {
  421. paddingBlock: "0.25rem",
  422. paddingInline: "0.25rem",
  423. },
  424. },
  425. },
  426. },
  427. MuiListItem: {
  428. styleOverrides: {
  429. root: {
  430. ":hover": {
  431. backgroundColor: palette.neutral[100],
  432. },
  433. },
  434. },
  435. },
  436. MuiListItemButton: {
  437. styleOverrides: {
  438. root: {
  439. borderRadius: 8,
  440. marginBlockEnd: "0.5rem",
  441. },
  442. },
  443. },
  444. MuiListItemText: {
  445. styleOverrides: {
  446. root: {
  447. marginInlineEnd: "2rem",
  448. },
  449. primary: {
  450. fontWeight: 500,
  451. },
  452. },
  453. },
  454. MuiListItemIcon: {
  455. styleOverrides: {
  456. root: {
  457. color: "inherit",
  458. },
  459. },
  460. },
  461. MuiSelect: {
  462. styleOverrides: {
  463. select: {
  464. borderRadius: 8,
  465. },
  466. },
  467. },
  468. };
  469. export default components;