mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-09 00:18:00 +01:00
Refactor App.styles (#2822)
Signed-off-by: andreas-unleash <andreas@getunleash.ai> Refactor App.styles.ts to styled components <!-- Thanks for creating a PR! To make it easier for reviewers and everyone else to understand what your changes relate to, please add some relevant content to the headings below. Feel free to ignore or delete sections that you don't think are relevant. Thank you! ❤️ --> ## About the changes <!-- Describe the changes introduced. What are they and why are they being introduced? Feel free to also add screenshots or steps to view the changes if they're visual. --> <!-- Does it close an issue? Multiple? --> Closes # <!-- (For internal contributors): Does it relate to an issue on public roadmap? --> <!-- Relates to [roadmap](https://github.com/orgs/Unleash/projects/10) item: # --> ### Important files <!-- PRs can contain a lot of changes, but not all changes are equally important. Where should a reviewer start looking to get an overview of the changes? Are any files particularly important? --> ## Discussion points <!-- Anything about the PR you'd like to discuss before it gets merged? Got any questions or doubts? --> Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
parent
186accdef7
commit
cf3987ed2d
@ -1,82 +0,0 @@
|
|||||||
import { makeStyles } from 'tss-react/mui';
|
|
||||||
|
|
||||||
export const useStyles = makeStyles()(theme => ({
|
|
||||||
container: {
|
|
||||||
'& ul': {
|
|
||||||
margin: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
primaryBreadcrumb: {
|
|
||||||
color: 'white',
|
|
||||||
},
|
|
||||||
headerTitleLink: {
|
|
||||||
color: 'white',
|
|
||||||
textDecoration: 'none',
|
|
||||||
},
|
|
||||||
contentWrapper: {
|
|
||||||
margin: '0 auto',
|
|
||||||
flex: 1,
|
|
||||||
width: '100%',
|
|
||||||
backgroundColor: theme.palette.contentWrapper,
|
|
||||||
position: 'relative',
|
|
||||||
},
|
|
||||||
content: {
|
|
||||||
width: '1250px',
|
|
||||||
marginLeft: 'auto',
|
|
||||||
marginRight: 'auto',
|
|
||||||
[theme.breakpoints.down('lg')]: {
|
|
||||||
width: '1024px',
|
|
||||||
},
|
|
||||||
[theme.breakpoints.down(1024)]: {
|
|
||||||
width: '100%',
|
|
||||||
marginLeft: 0,
|
|
||||||
marginRight: 0,
|
|
||||||
},
|
|
||||||
[theme.breakpoints.down('sm')]: {
|
|
||||||
minWidth: '100%',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
contentContainer: {
|
|
||||||
padding: '2rem 0',
|
|
||||||
height: '100%',
|
|
||||||
},
|
|
||||||
drawerTitle: {
|
|
||||||
lineHeight: '1 !important',
|
|
||||||
paddingTop: '16px',
|
|
||||||
paddingBottom: '16px',
|
|
||||||
paddingLeft: '24px !important',
|
|
||||||
[theme.breakpoints.down(1024)]: {
|
|
||||||
paddingTop: '12px',
|
|
||||||
paddingBottom: '12px',
|
|
||||||
paddingLeft: '16px !important',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
drawerTitleLogo: {
|
|
||||||
paddingRight: '16px',
|
|
||||||
},
|
|
||||||
drawerTitleText: {
|
|
||||||
display: 'inline-block',
|
|
||||||
verticalAlign: 'middle',
|
|
||||||
fontSize: theme.fontSizes.smallerBody,
|
|
||||||
},
|
|
||||||
navigation: {
|
|
||||||
padding: '8px 5px 8px 0 !important',
|
|
||||||
},
|
|
||||||
navigationLink: {
|
|
||||||
padding: '12px 20px !important',
|
|
||||||
borderRadius: '0 50px 50px 0',
|
|
||||||
textDecoration: 'none',
|
|
||||||
[theme.breakpoints.down(1024)]: {
|
|
||||||
padding: '12px 16px !important',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
navigationIcon: {
|
|
||||||
marginRight: '16px',
|
|
||||||
},
|
|
||||||
iconGitHub: {
|
|
||||||
width: '24px',
|
|
||||||
height: '24px',
|
|
||||||
background:
|
|
||||||
'url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHN0eWxlPSJ3aWR0aDoyNHB4O2hlaWdodDoyNHB4IiB2aWV3Qm94PSIwIDAgMjQgMjQiPgogICAgPHBhdGggZmlsbD0iIzc1NzU3NSIgZD0iTTEyLDJ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es';
|
|||||||
import { useAuthDetails } from 'hooks/api/getters/useAuth/useAuthDetails';
|
import { useAuthDetails } from 'hooks/api/getters/useAuth/useAuthDetails';
|
||||||
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
|
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
|
||||||
import { SplashPageRedirect } from 'component/splash/SplashPageRedirect/SplashPageRedirect';
|
import { SplashPageRedirect } from 'component/splash/SplashPageRedirect/SplashPageRedirect';
|
||||||
import { useStyles } from './App.styles';
|
|
||||||
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
||||||
import useProjects from '../hooks/api/getters/useProjects/useProjects';
|
import useProjects from '../hooks/api/getters/useProjects/useProjects';
|
||||||
import { useLastViewedProject } from '../hooks/useLastViewedProject';
|
import { useLastViewedProject } from '../hooks/useLastViewedProject';
|
||||||
import MaintenanceBanner from './maintenance/MaintenanceBanner';
|
import MaintenanceBanner from './maintenance/MaintenanceBanner';
|
||||||
|
import { styled } from '@mui/material';
|
||||||
|
|
||||||
const InitialRedirect = () => {
|
const InitialRedirect = () => {
|
||||||
const { lastViewed } = useLastViewedProject();
|
const { lastViewed } = useLastViewedProject();
|
||||||
@ -52,12 +52,17 @@ const InitialRedirect = () => {
|
|||||||
return <Navigate to={redirectTo} />;
|
return <Navigate to={redirectTo} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const StyledContainer = styled('div')(() => ({
|
||||||
|
'& ul': {
|
||||||
|
margin: 0,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
export const App = () => {
|
export const App = () => {
|
||||||
const { authDetails } = useAuthDetails();
|
const { authDetails } = useAuthDetails();
|
||||||
const { user } = useAuthUser();
|
const { user } = useAuthUser();
|
||||||
const hasFetchedAuth = Boolean(authDetails || user);
|
const hasFetchedAuth = Boolean(authDetails || user);
|
||||||
|
|
||||||
const { classes: styles } = useStyles();
|
|
||||||
const { isOss, uiConfig } = useUiConfig();
|
const { isOss, uiConfig } = useUiConfig();
|
||||||
|
|
||||||
const availableRoutes = isOss()
|
const availableRoutes = isOss()
|
||||||
@ -83,7 +88,7 @@ export const App = () => {
|
|||||||
}
|
}
|
||||||
show={<MaintenanceBanner />}
|
show={<MaintenanceBanner />}
|
||||||
/>
|
/>
|
||||||
<div className={styles.container}>
|
<StyledContainer>
|
||||||
<ToastRenderer />
|
<ToastRenderer />
|
||||||
<Routes>
|
<Routes>
|
||||||
{availableRoutes.map(route => (
|
{availableRoutes.map(route => (
|
||||||
@ -115,7 +120,7 @@ export const App = () => {
|
|||||||
</Routes>
|
</Routes>
|
||||||
<FeedbackNPS openUrl="http://feedback.unleash.run" />
|
<FeedbackNPS openUrl="http://feedback.unleash.run" />
|
||||||
<SplashPageRedirect />
|
<SplashPageRedirect />
|
||||||
</div>
|
</StyledContainer>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { FC, useState, VFC } from 'react';
|
import { FC, useState, VFC } from 'react';
|
||||||
import { Box, Button, styled, Typography } from '@mui/material';
|
import { Box, Button, styled, Typography } from '@mui/material';
|
||||||
import { useStyles as useAppStyles } from 'component/App.styles';
|
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
import { ChangeRequestSidebar } from 'component/changeRequest/ChangeRequestSidebar/ChangeRequestSidebar';
|
import { ChangeRequestSidebar } from 'component/changeRequest/ChangeRequestSidebar/ChangeRequestSidebar';
|
||||||
import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests';
|
import { usePendingChangeRequests } from 'hooks/api/getters/usePendingChangeRequests/usePendingChangeRequests';
|
||||||
@ -21,14 +20,29 @@ const DraftBannerContentWrapper = styled(Box)(({ theme }) => ({
|
|||||||
color: theme.palette.warning.main,
|
color: theme.palette.warning.main,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const StyledBox = styled(Box)(({ theme }) => ({
|
||||||
|
width: '1250px',
|
||||||
|
marginLeft: 'auto',
|
||||||
|
marginRight: 'auto',
|
||||||
|
[theme.breakpoints.down('lg')]: {
|
||||||
|
width: '1024px',
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down(1024)]: {
|
||||||
|
width: '100%',
|
||||||
|
marginLeft: 0,
|
||||||
|
marginRight: 0,
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down('sm')]: {
|
||||||
|
minWidth: '100%',
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
const DraftBannerContent: FC<{
|
const DraftBannerContent: FC<{
|
||||||
changeRequest: IChangeRequest;
|
changeRequest: IChangeRequest;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
}> = ({ changeRequest, onClick }) => {
|
}> = ({ changeRequest, onClick }) => {
|
||||||
const { classes } = useAppStyles();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box className={classes.content}>
|
<StyledBox>
|
||||||
<DraftBannerContentWrapper>
|
<DraftBannerContentWrapper>
|
||||||
<Typography variant="body2" sx={{ mr: 4 }}>
|
<Typography variant="body2" sx={{ mr: 4 }}>
|
||||||
<strong>Change request mode</strong> – You have changes{' '}
|
<strong>Change request mode</strong> – You have changes{' '}
|
||||||
@ -63,7 +77,7 @@ const DraftBannerContent: FC<{
|
|||||||
View changes ({changesCount(changeRequest)})
|
View changes ({changesCount(changeRequest)})
|
||||||
</Button>
|
</Button>
|
||||||
</DraftBannerContentWrapper>
|
</DraftBannerContentWrapper>
|
||||||
</Box>
|
</StyledBox>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
import React, { forwardRef, ReactNode } from 'react';
|
import React, { forwardRef, ReactNode } from 'react';
|
||||||
import classnames from 'classnames';
|
import { Grid, styled } from '@mui/material';
|
||||||
import { makeStyles } from 'tss-react/mui';
|
|
||||||
import { Grid } from '@mui/material';
|
|
||||||
import { useStyles as useAppStyles } from 'component/App.styles';
|
|
||||||
import Header from 'component/menu/Header/Header';
|
import Header from 'component/menu/Header/Header';
|
||||||
import Footer from 'component/menu/Footer/Footer';
|
import Footer from 'component/menu/Footer/Footer';
|
||||||
import Proclamation from 'component/common/Proclamation/Proclamation';
|
import Proclamation from 'component/common/Proclamation/Proclamation';
|
||||||
@ -17,29 +14,63 @@ import { ConditionallyRender } from 'component/common/ConditionallyRender/Condit
|
|||||||
import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
|
import { useChangeRequestsEnabled } from 'hooks/useChangeRequestsEnabled';
|
||||||
import { DraftBanner } from './DraftBanner/DraftBanner';
|
import { DraftBanner } from './DraftBanner/DraftBanner';
|
||||||
|
|
||||||
const useStyles = makeStyles()(theme => ({
|
|
||||||
container: {
|
|
||||||
height: '100%',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
},
|
|
||||||
contentContainer: {
|
|
||||||
height: '100%',
|
|
||||||
padding: '3.25rem 0',
|
|
||||||
position: 'relative',
|
|
||||||
[theme.breakpoints.down('md')]: {
|
|
||||||
padding: '3.25rem 0.75rem',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
interface IMainLayoutProps {
|
interface IMainLayoutProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MainLayoutContainer = styled(Grid)(() => ({
|
||||||
|
height: '100%',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
}));
|
||||||
|
|
||||||
|
const MainLayoutContentWrapper = styled('main')(({ theme }) => ({
|
||||||
|
margin: theme.spacing(0, 'auto'),
|
||||||
|
flex: 1,
|
||||||
|
width: '100%',
|
||||||
|
backgroundColor: theme.palette.contentWrapper,
|
||||||
|
position: 'relative',
|
||||||
|
}));
|
||||||
|
|
||||||
|
const MainLayoutContent = styled(Grid)(({ theme }) => ({
|
||||||
|
width: '1250px',
|
||||||
|
marginLeft: 'auto',
|
||||||
|
marginRight: 'auto',
|
||||||
|
[theme.breakpoints.down('lg')]: {
|
||||||
|
width: '1024px',
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down(1024)]: {
|
||||||
|
width: '100%',
|
||||||
|
marginLeft: 0,
|
||||||
|
marginRight: 0,
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down('sm')]: {
|
||||||
|
minWidth: '100%',
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const StyledImg = styled('img')(() => ({
|
||||||
|
display: 'block',
|
||||||
|
position: 'fixed',
|
||||||
|
zIndex: 0,
|
||||||
|
bottom: 0,
|
||||||
|
right: 0,
|
||||||
|
width: 400,
|
||||||
|
pointerEvents: 'none',
|
||||||
|
userSelect: 'none',
|
||||||
|
}));
|
||||||
|
|
||||||
|
const MainLayoutContentContainer = styled('div')(({ theme }) => ({
|
||||||
|
height: '100%',
|
||||||
|
padding: theme.spacing(6.5, 0),
|
||||||
|
position: 'relative',
|
||||||
|
[theme.breakpoints.down('md')]: {
|
||||||
|
padding: theme.spacing(6.5, 1.5),
|
||||||
|
},
|
||||||
|
zIndex: 200,
|
||||||
|
}));
|
||||||
|
|
||||||
export const MainLayout = forwardRef<HTMLDivElement, IMainLayoutProps>(
|
export const MainLayout = forwardRef<HTMLDivElement, IMainLayoutProps>(
|
||||||
({ children }, ref) => {
|
({ children }, ref) => {
|
||||||
const { classes } = useStyles();
|
|
||||||
const { classes: styles } = useAppStyles();
|
|
||||||
const { uiConfig } = useUiConfig();
|
const { uiConfig } = useUiConfig();
|
||||||
const projectId = useOptionalPathParam('projectId');
|
const projectId = useOptionalPathParam('projectId');
|
||||||
const { isChangeRequestConfiguredInAnyEnv } = useChangeRequestsEnabled(
|
const { isChangeRequestConfiguredInAnyEnv } = useChangeRequestsEnabled(
|
||||||
@ -51,48 +82,25 @@ export const MainLayout = forwardRef<HTMLDivElement, IMainLayoutProps>(
|
|||||||
<SkipNavLink />
|
<SkipNavLink />
|
||||||
<Header />
|
<Header />
|
||||||
<SkipNavTarget />
|
<SkipNavTarget />
|
||||||
<Grid container className={classes.container}>
|
<MainLayoutContainer>
|
||||||
<main className={classnames(styles.contentWrapper)}>
|
<MainLayoutContentWrapper>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={Boolean(
|
condition={Boolean(
|
||||||
projectId && isChangeRequestConfiguredInAnyEnv()
|
projectId && isChangeRequestConfiguredInAnyEnv()
|
||||||
)}
|
)}
|
||||||
show={<DraftBanner project={projectId || ''} />}
|
show={<DraftBanner project={projectId || ''} />}
|
||||||
/>
|
/>
|
||||||
<Grid
|
<MainLayoutContent item xs={12} sm={12} my={2}>
|
||||||
item
|
<MainLayoutContentContainer ref={ref}>
|
||||||
className={styles.content}
|
|
||||||
xs={12}
|
|
||||||
sm={12}
|
|
||||||
my={2}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
className={classes.contentContainer}
|
|
||||||
style={{ zIndex: 200 }}
|
|
||||||
ref={ref}
|
|
||||||
>
|
|
||||||
<BreadcrumbNav />
|
<BreadcrumbNav />
|
||||||
<Proclamation toast={uiConfig.toast} />
|
<Proclamation toast={uiConfig.toast} />
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</MainLayoutContentContainer>
|
||||||
</Grid>
|
</MainLayoutContent>
|
||||||
<img
|
<StyledImg src={formatAssetPath(textureImage)} alt="" />
|
||||||
src={formatAssetPath(textureImage)}
|
</MainLayoutContentWrapper>
|
||||||
alt=""
|
|
||||||
style={{
|
|
||||||
display: 'block',
|
|
||||||
position: 'fixed',
|
|
||||||
zIndex: 0,
|
|
||||||
bottom: 0,
|
|
||||||
right: 0,
|
|
||||||
width: 400,
|
|
||||||
pointerEvents: 'none',
|
|
||||||
userSelect: 'none',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</main>
|
|
||||||
<Footer />
|
<Footer />
|
||||||
</Grid>
|
</MainLayoutContainer>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user