Skip to content

Commit

Permalink
fix: code optimization for custom styles
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlLiu2023 committed Apr 17, 2023
1 parent 57c64f7 commit 5e09689
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 72 deletions.
15 changes: 4 additions & 11 deletions apps/storefront/src/components/layout/B3Nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
ListItem,
ListItemButton,
ListItemText,
useTheme,
} from '@mui/material'

import {
Expand Down Expand Up @@ -43,10 +44,6 @@ import {
b3HexToRgb,
} from '../outSideComponents/utils/b3CustomStyles'

import {
CustomStyleContext,
} from '../../shared/customStyleButtton/context'

interface B3NavProps {
closeSidebar?: (x: boolean) => void;
}
Expand All @@ -66,13 +63,9 @@ export const B3Nav = ({
state: globalState,
} = useContext(GlobaledContext)

const {
state: {
portalStyle: {
primaryColor = '',
},
},
} = useContext(CustomStyleContext)
const theme = useTheme()

const primaryColor = theme.palette.primary.main

const jumpRegister = () => {
navigate('/registered')
Expand Down
17 changes: 5 additions & 12 deletions apps/storefront/src/components/spin/B3Sping.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {
ReactNode,
useContext,
} from 'react'

import {
CircularProgress,
useTheme,
} from '@mui/material'

import {
Expand All @@ -16,10 +17,6 @@ import {
SpinContext,
} from './styled'

import {
CustomStyleContext,
} from '@/shared/customStyleButtton'

interface B3SpingProps {
isSpinning: Boolean | undefined,
children: ReactNode,
Expand All @@ -45,13 +42,9 @@ export const B3Sping = (props: B3SpingProps) => {
isFlex,
} = props

const {
state: {
portalStyle: {
primaryColor = '',
},
},
} = useContext(CustomStyleContext)
const theme = useTheme()

const primaryColor = theme.palette.primary.main

const [isMobile] = useMobile()

Expand Down
15 changes: 4 additions & 11 deletions apps/storefront/src/components/upload/B3Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Box,
Link,
Alert,
useTheme,
} from '@mui/material'

import Grid from '@mui/material/Unstable_Grid2'
Expand Down Expand Up @@ -59,10 +60,6 @@ import {
ParseEmptyDataProps,
} from './utils'

import {
CustomStyleContext,
} from '@/shared/customStyleButtton'

interface B3UploadProps {
isOpen: boolean,
setIsOpen: Dispatch<SetStateAction<boolean>>,
Expand Down Expand Up @@ -115,13 +112,9 @@ export const B3Upload = (props: B3UploadProps) => {
},
} = useContext(GlobaledContext)

const {
state: {
portalStyle: {
primaryColor = '',
},
},
} = useContext(CustomStyleContext)
const theme = useTheme()

const primaryColor = theme.palette.primary.main

const [step, setStep] = useState<string>('init')
const [fileDatas, setFileDatas] = useState<CustomFieldItems>({})
Expand Down
16 changes: 4 additions & 12 deletions apps/storefront/src/pages/quote/components/FileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Box,
Tooltip,
Typography,
useTheme,
} from '@mui/material'

import AttachFileIcon from '@mui/icons-material/AttachFile'
Expand All @@ -15,7 +16,6 @@ import {
Ref,
forwardRef,
useImperativeHandle,
useContext,
} from 'react'

import {
Expand Down Expand Up @@ -46,10 +46,6 @@ import {
snackbar,
} from '@/utils'

import {
CustomStyleContext,
} from '@/shared/customStyleButtton'

const FileUploadContainer = styled(Box)(({
style,
}) => ({
Expand Down Expand Up @@ -150,13 +146,9 @@ const FileUpload = (props: FileUploadProps, ref: Ref<unknown>) => {
isEndLoadding = false,
} = props

const {
state: {
portalStyle: {
primaryColor = '',
},
},
} = useContext(CustomStyleContext)
const theme = useTheme()

const primaryColor = theme.palette.primary.main

const [loading, setLoading] = useState<boolean>(false)

Expand Down
19 changes: 4 additions & 15 deletions apps/storefront/src/pages/quote/components/QuoteDetailHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,13 @@ import {
Grid,
styled,
Typography,
useTheme,
} from '@mui/material'

import {
ArrowBackIosNew,
} from '@mui/icons-material'

import {
useContext,
} from 'react'

import {
QuoteStatus,
} from './QuoteStatus'
Expand All @@ -28,10 +25,6 @@ import {
useMobile,
} from '@/hooks'

import {
CustomStyleContext,
} from '@/shared/customStyleButtton'

import {
CustomButton,
} from '@/components'
Expand Down Expand Up @@ -69,13 +62,9 @@ const QuoteDetailHeader = (props: QuoteDetailHeaderProps) => {
salesRepInfo,
} = props

const {
state: {
portalStyle: {
primaryColor = '',
},
},
} = useContext(CustomStyleContext)
const theme = useTheme()

const primaryColor = theme.palette.primary.main

const navigate = useNavigate()
const gridOptions = (xs: number) => (isMobile ? {} : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
import {
Box,
Grid,
useTheme,
} from '@mui/material'

import {
Expand Down Expand Up @@ -73,10 +74,6 @@ import ShoppingDetailFooter from './components/ShoppingDetailFooter'
import ShoppingDetailTable from './components/ShoppingDetailTable'
import ShoppingDetailDeleteItems from './components/ShoppingDetailDeleteItems'

import {
CustomStyleContext,
} from '@/shared/customStyleButtton'

interface TableRefProps extends HTMLInputElement {
initSearch: () => void,
}
Expand Down Expand Up @@ -128,13 +125,9 @@ const ShoppingListDetails = ({
dispatch,
} = useContext(ShoppingListDetailsContext)

const {
state: {
portalStyle: {
primaryColor = '',
},
},
} = useContext(CustomStyleContext)
const theme = useTheme()

const primaryColor = theme.palette.primary.main

const tableRef = useRef<TableRefProps | null>(null)

Expand Down

0 comments on commit 5e09689

Please sign in to comment.