|
@@ -1,13 +1,7 @@
|
|
import { useState, useCallback } from 'react';
|
|
import { useState, useCallback } from 'react';
|
|
-import * as React from 'react';
|
|
|
|
-import {
|
|
|
|
- // for strict mode
|
|
|
|
- unstable_createMuiStrictModeTheme as createMuiTheme,
|
|
|
|
- ThemeProvider,
|
|
|
|
- makeStyles,
|
|
|
|
-} from '@material-ui/core/styles';
|
|
|
|
-import { Backdrop, CircularProgress, SwipeableDrawer } from '@material-ui/core';
|
|
|
|
-
|
|
|
|
|
|
+import React from 'react';
|
|
|
|
+import { ThemeProvider, makeStyles } from '@material-ui/core/styles';
|
|
|
|
+import { SwipeableDrawer } from '@material-ui/core';
|
|
import {
|
|
import {
|
|
RootContextType,
|
|
RootContextType,
|
|
DialogType,
|
|
DialogType,
|
|
@@ -16,16 +10,7 @@ import {
|
|
} from './Types';
|
|
} from './Types';
|
|
import CustomSnackBar from '../components/customSnackBar/CustomSnackBar';
|
|
import CustomSnackBar from '../components/customSnackBar/CustomSnackBar';
|
|
import CustomDialog from '../components/customDialog/CustomDialog';
|
|
import CustomDialog from '../components/customDialog/CustomDialog';
|
|
-import lightBlue from '@material-ui/core/colors/lightBlue';
|
|
|
|
-
|
|
|
|
-declare module '@material-ui/core/styles/createPalette' {
|
|
|
|
- interface Palette {
|
|
|
|
- zilliz: Palette['primary'];
|
|
|
|
- }
|
|
|
|
- interface PaletteOptions {
|
|
|
|
- zilliz: PaletteOptions['primary'];
|
|
|
|
- }
|
|
|
|
-}
|
|
|
|
|
|
+import { theme } from '../styles/theme';
|
|
|
|
|
|
const DefaultDialogConfigs: DialogType = {
|
|
const DefaultDialogConfigs: DialogType = {
|
|
open: false,
|
|
open: false,
|
|
@@ -48,135 +33,9 @@ export const rootContext = React.createContext<RootContextType>({
|
|
dialog: DefaultDialogConfigs,
|
|
dialog: DefaultDialogConfigs,
|
|
setDialog: params => {},
|
|
setDialog: params => {},
|
|
handleCloseDialog: () => {},
|
|
handleCloseDialog: () => {},
|
|
- setGlobalLoading: () => {},
|
|
|
|
setDrawer: (params: any) => {},
|
|
setDrawer: (params: any) => {},
|
|
});
|
|
});
|
|
|
|
|
|
-const otherThemes = {
|
|
|
|
- spacing: (factor: any) => `${8 * factor}px`,
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-const theme = createMuiTheme({
|
|
|
|
- palette: {
|
|
|
|
- primary: {
|
|
|
|
- ...lightBlue,
|
|
|
|
- main: '#06AFF2',
|
|
|
|
- light: '#65DAF8',
|
|
|
|
- dark: '#009BC4',
|
|
|
|
- },
|
|
|
|
- secondary: {
|
|
|
|
- light: '#82D3BA',
|
|
|
|
- main: '#31B78D',
|
|
|
|
- dark: '#279371',
|
|
|
|
- },
|
|
|
|
- error: {
|
|
|
|
- main: '#FF4605',
|
|
|
|
- light: '#FF8F68',
|
|
|
|
- dark: '#CD3804',
|
|
|
|
- },
|
|
|
|
- zilliz: {
|
|
|
|
- ...lightBlue,
|
|
|
|
- light: lightBlue[50],
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- ...otherThemes,
|
|
|
|
- overrides: {
|
|
|
|
- MuiTypography: {
|
|
|
|
- button: {
|
|
|
|
- textTransform: 'initial',
|
|
|
|
- lineHeight: '16px',
|
|
|
|
- fontWeight: 'bold',
|
|
|
|
- },
|
|
|
|
- h1: {
|
|
|
|
- fontSize: '36px',
|
|
|
|
- lineHeight: '42px',
|
|
|
|
- letterSpacing: '-0.02em',
|
|
|
|
- },
|
|
|
|
- h2: {
|
|
|
|
- lineHeight: '24px',
|
|
|
|
- fontSize: '28px',
|
|
|
|
- },
|
|
|
|
- h3: {
|
|
|
|
- lineHeight: '20px',
|
|
|
|
- fontSize: '23px',
|
|
|
|
- fontWeight: 'bold',
|
|
|
|
- },
|
|
|
|
- h4: {
|
|
|
|
- fontWeight: 500,
|
|
|
|
- lineHeight: '23px',
|
|
|
|
- fontSize: '20px',
|
|
|
|
- letterSpacing: '-0.02em',
|
|
|
|
- },
|
|
|
|
- h5: {
|
|
|
|
- fontWeight: 'bold',
|
|
|
|
- fontSize: '16px',
|
|
|
|
- lineHeight: '24px',
|
|
|
|
- },
|
|
|
|
- h6: {
|
|
|
|
- fontWeight: 'normal',
|
|
|
|
- fontSize: '16px',
|
|
|
|
- lineHeight: '24px',
|
|
|
|
- letterSpacing: '-0.01em',
|
|
|
|
- },
|
|
|
|
- body1: {
|
|
|
|
- fontSize: '14px',
|
|
|
|
- lineHeight: '20px',
|
|
|
|
- },
|
|
|
|
- body2: {
|
|
|
|
- fontSize: '12px',
|
|
|
|
- lineHeight: '16px',
|
|
|
|
- },
|
|
|
|
- caption: {
|
|
|
|
- fontSize: '10px',
|
|
|
|
- lineHeight: '12px',
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- MuiButton: {
|
|
|
|
- root: {
|
|
|
|
- textTransform: 'initial',
|
|
|
|
- fontWeight: 'bold',
|
|
|
|
- },
|
|
|
|
- text: {
|
|
|
|
- '&:hover': {
|
|
|
|
- backgroundColor: lightBlue[50],
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- MuiDialogActions: {
|
|
|
|
- spacing: {
|
|
|
|
- padding: otherThemes.spacing(4),
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- MuiDialogContent: {
|
|
|
|
- root: {
|
|
|
|
- padding: `${otherThemes.spacing(1)} ${otherThemes.spacing(4)}`,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- MuiDialogTitle: {
|
|
|
|
- root: {
|
|
|
|
- padding: otherThemes.spacing(4),
|
|
|
|
- paddingBottom: otherThemes.spacing(1),
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- MuiStepIcon: {
|
|
|
|
- root: {
|
|
|
|
- color: '#c4c4c4',
|
|
|
|
- '&$active': {
|
|
|
|
- color: '#12C3F4',
|
|
|
|
- },
|
|
|
|
- '&$completed': {
|
|
|
|
- color: '#12C3F4',
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- MuiFormHelperText: {
|
|
|
|
- contained: {
|
|
|
|
- marginLeft: 0,
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
-});
|
|
|
|
-
|
|
|
|
const { Provider } = rootContext;
|
|
const { Provider } = rootContext;
|
|
// Dialog has two type : normal | custom;
|
|
// Dialog has two type : normal | custom;
|
|
// notice type mean it's a notice dialog you need to set props like title, content, actions
|
|
// notice type mean it's a notice dialog you need to set props like title, content, actions
|
|
@@ -200,7 +59,6 @@ export const RootProvider = (props: { children: React.ReactNode }) => {
|
|
autoHideDuration: 3000,
|
|
autoHideDuration: 3000,
|
|
});
|
|
});
|
|
const [dialog, setDialog] = useState<DialogType>(DefaultDialogConfigs);
|
|
const [dialog, setDialog] = useState<DialogType>(DefaultDialogConfigs);
|
|
- const [globalLoading, setGlobalLoading] = useState<boolean>(false);
|
|
|
|
const [drawer, setDrawer]: any = useState({
|
|
const [drawer, setDrawer]: any = useState({
|
|
anchor: 'right',
|
|
anchor: 'right',
|
|
open: false,
|
|
open: false,
|
|
@@ -255,7 +113,6 @@ export const RootProvider = (props: { children: React.ReactNode }) => {
|
|
dialog,
|
|
dialog,
|
|
setDialog,
|
|
setDialog,
|
|
handleCloseDialog,
|
|
handleCloseDialog,
|
|
- setGlobalLoading,
|
|
|
|
setDrawer,
|
|
setDrawer,
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
@@ -263,9 +120,6 @@ export const RootProvider = (props: { children: React.ReactNode }) => {
|
|
<CustomSnackBar {...snackBar} onClose={handleSnackBarClose} />
|
|
<CustomSnackBar {...snackBar} onClose={handleSnackBarClose} />
|
|
{props.children}
|
|
{props.children}
|
|
<CustomDialog {...dialog} onClose={handleCloseDialog} />
|
|
<CustomDialog {...dialog} onClose={handleCloseDialog} />
|
|
- <Backdrop open={globalLoading} style={{ zIndex: 2000 }}>
|
|
|
|
- <CircularProgress color="inherit" />
|
|
|
|
- </Backdrop>
|
|
|
|
|
|
|
|
<SwipeableDrawer
|
|
<SwipeableDrawer
|
|
anchor={drawer.anchor}
|
|
anchor={drawer.anchor}
|