mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
refactor: use css grid for flags and no content grid (#8347)
This PR uses the new CSS grid layout for the flag grid and the no content grid. In doing so, it also improves how you use the grid item (giving them a `gridArea` prop) and extracts the breakpoint handling so that all sections that use breakpoints use the same breakpoints. As with the previous PR, here's screenies of the same screen width, but with open and closed sidebar: Open: ![image](https://github.com/user-attachments/assets/2d41d412-5072-4c66-9a48-e7aa0d8cff45) Closed: ![image](https://github.com/user-attachments/assets/994e3f2c-6f4c-4db1-9f10-e1d1a4d96540)
This commit is contained in:
parent
401425e35c
commit
f5c78605ed
@ -1,18 +1,18 @@
|
|||||||
import { Grid, Typography, styled } from '@mui/material';
|
import { Typography, styled } from '@mui/material';
|
||||||
import { AvatarGroupFromOwners } from 'component/common/AvatarGroupFromOwners/AvatarGroupFromOwners';
|
import { AvatarGroupFromOwners } from 'component/common/AvatarGroupFromOwners/AvatarGroupFromOwners';
|
||||||
import { UserAvatar } from 'component/common/UserAvatar/UserAvatar';
|
import { UserAvatar } from 'component/common/UserAvatar/UserAvatar';
|
||||||
import type { PersonalDashboardSchemaAdminsItem } from 'openapi/models/personalDashboardSchemaAdminsItem';
|
import type { PersonalDashboardSchemaAdminsItem } from 'openapi/models/personalDashboardSchemaAdminsItem';
|
||||||
import type { PersonalDashboardSchemaProjectOwnersItem } from 'openapi/models/personalDashboardSchemaProjectOwnersItem';
|
import type { PersonalDashboardSchemaProjectOwnersItem } from 'openapi/models/personalDashboardSchemaProjectOwnersItem';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
import {
|
||||||
|
ContentGridContainer,
|
||||||
|
EmptyGridItem,
|
||||||
|
ProjectGrid,
|
||||||
|
SpacedGridItem,
|
||||||
|
} from './Grid';
|
||||||
|
|
||||||
const ContentGrid = styled(Grid)(({ theme }) => ({
|
const PaddedEmptyGridItem = styled(EmptyGridItem)(({ theme }) => ({
|
||||||
backgroundColor: theme.palette.background.paper,
|
|
||||||
borderRadius: `${theme.shape.borderRadiusLarge}px`,
|
|
||||||
}));
|
|
||||||
|
|
||||||
const SpacedGridItem = styled(Grid)(({ theme }) => ({
|
|
||||||
padding: theme.spacing(4),
|
padding: theme.spacing(4),
|
||||||
border: `0.5px solid ${theme.palette.divider}`,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const TitleContainer = styled('div')(({ theme }) => ({
|
const TitleContainer = styled('div')(({ theme }) => ({
|
||||||
@ -68,30 +68,31 @@ type Props = {
|
|||||||
|
|
||||||
export const ContentGridNoProjects: React.FC<Props> = ({ owners, admins }) => {
|
export const ContentGridNoProjects: React.FC<Props> = ({ owners, admins }) => {
|
||||||
return (
|
return (
|
||||||
<ContentGrid container columns={{ lg: 12, md: 1 }}>
|
<ContentGridContainer>
|
||||||
<SpacedGridItem item lg={4} md={1}>
|
<ProjectGrid>
|
||||||
|
<SpacedGridItem gridArea='title'>
|
||||||
<Typography variant='h3'>My projects</Typography>
|
<Typography variant='h3'>My projects</Typography>
|
||||||
</SpacedGridItem>
|
</SpacedGridItem>
|
||||||
<SpacedGridItem item lg={8} md={1}>
|
<SpacedGridItem gridArea='onboarding'>
|
||||||
<Typography>Potential next steps</Typography>
|
<Typography>Potential next steps</Typography>
|
||||||
</SpacedGridItem>
|
</SpacedGridItem>
|
||||||
<SpacedGridItem item lg={4} md={1}>
|
<SpacedGridItem gridArea='projects'>
|
||||||
<GridContent>
|
<GridContent>
|
||||||
<Typography>
|
<Typography>
|
||||||
You don't currently have access to any projects in the
|
You don't currently have access to any projects in
|
||||||
system.
|
the system.
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography>
|
<Typography>
|
||||||
To get started, you can{' '}
|
To get started, you can{' '}
|
||||||
<Link to='/projects?create=true'>
|
<Link to='/projects?create=true'>
|
||||||
create your own project
|
create your own project
|
||||||
</Link>
|
</Link>
|
||||||
. Alternatively, you can review the available projects
|
. Alternatively, you can review the available
|
||||||
in the system and ask the owner for access.
|
projects in the system and ask the owner for access.
|
||||||
</Typography>
|
</Typography>
|
||||||
</GridContent>
|
</GridContent>
|
||||||
</SpacedGridItem>
|
</SpacedGridItem>
|
||||||
<SpacedGridItem item lg={4} md={1}>
|
<SpacedGridItem gridArea='box1'>
|
||||||
<GridContent>
|
<GridContent>
|
||||||
<TitleContainer>
|
<TitleContainer>
|
||||||
<NeutralCircleContainer>1</NeutralCircleContainer>
|
<NeutralCircleContainer>1</NeutralCircleContainer>
|
||||||
@ -126,13 +127,14 @@ export const ContentGridNoProjects: React.FC<Props> = ({ owners, admins }) => {
|
|||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<p>
|
<p>
|
||||||
You have no Unleash administrators to contact.
|
You have no Unleash administrators to
|
||||||
|
contact.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</BoxMainContent>
|
</BoxMainContent>
|
||||||
</GridContent>
|
</GridContent>
|
||||||
</SpacedGridItem>
|
</SpacedGridItem>
|
||||||
<SpacedGridItem item lg={4} md={1}>
|
<SpacedGridItem gridArea='box2'>
|
||||||
<GridContent>
|
<GridContent>
|
||||||
<TitleContainer>
|
<TitleContainer>
|
||||||
<NeutralCircleContainer>2</NeutralCircleContainer>
|
<NeutralCircleContainer>2</NeutralCircleContainer>
|
||||||
@ -149,15 +151,16 @@ export const ContentGridNoProjects: React.FC<Props> = ({ owners, admins }) => {
|
|||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<p>
|
<p>
|
||||||
There are no project owners in Unleash to ask
|
There are no project owners in Unleash to
|
||||||
for access.
|
ask for access.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</BoxMainContent>
|
</BoxMainContent>
|
||||||
</GridContent>
|
</GridContent>
|
||||||
</SpacedGridItem>
|
</SpacedGridItem>
|
||||||
<SpacedGridItem item lg={4} md={1} />
|
<EmptyGridItem />
|
||||||
<SpacedGridItem item lg={8} md={1} />
|
<PaddedEmptyGridItem gridArea='owners' />
|
||||||
</ContentGrid>
|
</ProjectGrid>
|
||||||
|
</ContentGridContainer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import { Box, Grid, styled } from '@mui/material';
|
import { Box, styled } from '@mui/material';
|
||||||
import type { Theme } from '@mui/material/styles/createTheme';
|
import type { Theme } from '@mui/material/styles/createTheme';
|
||||||
|
|
||||||
export const ContentGridContainer = styled('div')({
|
export const ContentGridContainer = styled('div')({
|
||||||
containerType: 'inline-size',
|
containerType: 'inline-size',
|
||||||
});
|
});
|
||||||
|
|
||||||
const ContentGrid2 = styled('article')(({ theme }) => {
|
const ContentGrid = styled('article')(({ theme }) => {
|
||||||
return {
|
return {
|
||||||
backgroundColor: theme.palette.divider,
|
backgroundColor: theme.palette.divider,
|
||||||
borderRadius: `${theme.shape.borderRadiusLarge}px`,
|
borderRadius: `${theme.shape.borderRadiusLarge}px`,
|
||||||
@ -21,19 +21,23 @@ const ContentGrid2 = styled('article')(({ theme }) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export const ProjectGrid = styled(ContentGrid2)(({ theme }) => ({
|
const onWideContainer =
|
||||||
'@container (min-width: 1000px)': {
|
(css: object) =>
|
||||||
gridTemplateColumns: '1fr 1fr 1fr',
|
({ theme }: { theme: Theme }) => {
|
||||||
display: 'grid',
|
const containerBreakpoint = '1000px';
|
||||||
gridTemplateAreas: `
|
const screenBreakpoint = theme.breakpoints.up('lg');
|
||||||
"title onboarding onboarding"
|
|
||||||
"projects box1 box2"
|
return {
|
||||||
". owners owners"
|
[`@container (min-width: ${containerBreakpoint})`]: css,
|
||||||
`,
|
|
||||||
},
|
|
||||||
|
|
||||||
'@supports not (container-type: inline-size)': {
|
'@supports not (container-type: inline-size)': {
|
||||||
[theme.breakpoints.up('lg')]: {
|
[screenBreakpoint]: css,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ProjectGrid = styled(ContentGrid)(
|
||||||
|
onWideContainer({
|
||||||
gridTemplateColumns: '1fr 1fr 1fr',
|
gridTemplateColumns: '1fr 1fr 1fr',
|
||||||
display: 'grid',
|
display: 'grid',
|
||||||
gridTemplateAreas: `
|
gridTemplateAreas: `
|
||||||
@ -41,36 +45,36 @@ export const ProjectGrid = styled(ContentGrid2)(({ theme }) => ({
|
|||||||
"projects box1 box2"
|
"projects box1 box2"
|
||||||
". owners owners"
|
". owners owners"
|
||||||
`,
|
`,
|
||||||
},
|
}),
|
||||||
},
|
);
|
||||||
}));
|
|
||||||
|
|
||||||
export const SpacedGridItem2 = styled('div')(({ theme }) => ({
|
export const FlagGrid = styled(ContentGrid)(
|
||||||
|
onWideContainer({
|
||||||
|
gridTemplateColumns: '1fr 1fr 1fr',
|
||||||
|
display: 'grid',
|
||||||
|
gridTemplateAreas: `
|
||||||
|
"title lifecycle lifecycle"
|
||||||
|
"flags chart chart"
|
||||||
|
`,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
export const SpacedGridItem = styled('div', {
|
||||||
|
shouldForwardProp: (prop) => prop !== 'gridArea',
|
||||||
|
})<{ gridArea: string }>(({ theme, gridArea }) => ({
|
||||||
padding: theme.spacing(4),
|
padding: theme.spacing(4),
|
||||||
|
gridArea,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const EmptyGridItem = styled('div')(({ theme }) => ({
|
export const EmptyGridItem = styled('div', {
|
||||||
|
shouldForwardProp: (prop) => prop !== 'gridArea',
|
||||||
|
})<{ gridArea?: string }>(({ theme, gridArea }) => ({
|
||||||
display: 'none',
|
display: 'none',
|
||||||
|
gridArea,
|
||||||
|
|
||||||
'@container (min-width: 1000px)': {
|
...onWideContainer({
|
||||||
display: 'block',
|
display: 'block',
|
||||||
},
|
})({ theme }),
|
||||||
|
|
||||||
'@supports not (container-type: inline-size)': {
|
|
||||||
[theme.breakpoints.up('lg')]: {
|
|
||||||
display: 'block',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
export const ContentGrid = styled(Grid)(({ theme }) => ({
|
|
||||||
backgroundColor: theme.palette.background.paper,
|
|
||||||
borderRadius: `${theme.shape.borderRadiusLarge}px`,
|
|
||||||
}));
|
|
||||||
|
|
||||||
export const SpacedGridItem = styled(Grid)(({ theme }) => ({
|
|
||||||
padding: theme.spacing(4),
|
|
||||||
border: `0.5px solid ${theme.palette.divider}`,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const ListItemBox = styled(Box)(({ theme }) => ({
|
export const ListItemBox = styled(Box)(({ theme }) => ({
|
||||||
|
@ -26,7 +26,7 @@ import {
|
|||||||
ListItemBox,
|
ListItemBox,
|
||||||
listItemStyle,
|
listItemStyle,
|
||||||
ProjectGrid,
|
ProjectGrid,
|
||||||
SpacedGridItem2,
|
SpacedGridItem,
|
||||||
} from './Grid';
|
} from './Grid';
|
||||||
|
|
||||||
const ActiveProjectDetails: FC<{
|
const ActiveProjectDetails: FC<{
|
||||||
@ -82,29 +82,15 @@ export const MyProjects: FC<{
|
|||||||
return (
|
return (
|
||||||
<ContentGridContainer>
|
<ContentGridContainer>
|
||||||
<ProjectGrid>
|
<ProjectGrid>
|
||||||
<SpacedGridItem2
|
<SpacedGridItem gridArea='title'>
|
||||||
sx={{
|
|
||||||
gridArea: 'title',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Typography variant='h3'>My projects</Typography>
|
<Typography variant='h3'>My projects</Typography>
|
||||||
</SpacedGridItem2>
|
</SpacedGridItem>
|
||||||
<SpacedGridItem2
|
<SpacedGridItem gridArea='onboarding'>
|
||||||
sx={{
|
|
||||||
gridArea: 'onboarding',
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'flex-end',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{setupIncomplete ? (
|
{setupIncomplete ? (
|
||||||
<Badge color='warning'>Setup incomplete</Badge>
|
<Badge color='warning'>Setup incomplete</Badge>
|
||||||
) : null}
|
) : null}
|
||||||
</SpacedGridItem2>
|
</SpacedGridItem>
|
||||||
<SpacedGridItem2
|
<SpacedGridItem gridArea='projects'>
|
||||||
sx={{
|
|
||||||
gridArea: 'projects',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<List
|
<List
|
||||||
disablePadding={true}
|
disablePadding={true}
|
||||||
sx={{ maxHeight: '400px', overflow: 'auto' }}
|
sx={{ maxHeight: '400px', overflow: 'auto' }}
|
||||||
@ -149,12 +135,8 @@ export const MyProjects: FC<{
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</List>
|
</List>
|
||||||
</SpacedGridItem2>
|
</SpacedGridItem>
|
||||||
<SpacedGridItem2
|
<SpacedGridItem gridArea='box1'>
|
||||||
sx={{
|
|
||||||
gridArea: 'box1',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{activeProjectStage === 'onboarded' &&
|
{activeProjectStage === 'onboarded' &&
|
||||||
personalDashboardProjectDetails ? (
|
personalDashboardProjectDetails ? (
|
||||||
<ProjectSetupComplete
|
<ProjectSetupComplete
|
||||||
@ -169,12 +151,8 @@ export const MyProjects: FC<{
|
|||||||
{activeProjectStage === 'first-flag-created' ? (
|
{activeProjectStage === 'first-flag-created' ? (
|
||||||
<ExistingFlag project={activeProject} />
|
<ExistingFlag project={activeProject} />
|
||||||
) : null}
|
) : null}
|
||||||
</SpacedGridItem2>
|
</SpacedGridItem>
|
||||||
<SpacedGridItem2
|
<SpacedGridItem gridArea='box2'>
|
||||||
sx={{
|
|
||||||
gridArea: 'box2',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{activeProjectStage === 'onboarded' &&
|
{activeProjectStage === 'onboarded' &&
|
||||||
personalDashboardProjectDetails ? (
|
personalDashboardProjectDetails ? (
|
||||||
<LatestProjectEvents
|
<LatestProjectEvents
|
||||||
@ -186,13 +164,9 @@ export const MyProjects: FC<{
|
|||||||
{setupIncomplete || activeProjectStage === 'loading' ? (
|
{setupIncomplete || activeProjectStage === 'loading' ? (
|
||||||
<ConnectSDK project={activeProject} />
|
<ConnectSDK project={activeProject} />
|
||||||
) : null}
|
) : null}
|
||||||
</SpacedGridItem2>
|
</SpacedGridItem>
|
||||||
<EmptyGridItem />
|
<EmptyGridItem />
|
||||||
<SpacedGridItem2
|
<SpacedGridItem gridArea='owners'>
|
||||||
sx={{
|
|
||||||
gridArea: 'owners',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{personalDashboardProjectDetails ? (
|
{personalDashboardProjectDetails ? (
|
||||||
<RoleAndOwnerInfo
|
<RoleAndOwnerInfo
|
||||||
roles={personalDashboardProjectDetails.roles.map(
|
roles={personalDashboardProjectDetails.roles.map(
|
||||||
@ -201,7 +175,7 @@ export const MyProjects: FC<{
|
|||||||
owners={personalDashboardProjectDetails.owners}
|
owners={personalDashboardProjectDetails.owners}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</SpacedGridItem2>
|
</SpacedGridItem>
|
||||||
</ProjectGrid>
|
</ProjectGrid>
|
||||||
</ContentGridContainer>
|
</ContentGridContainer>
|
||||||
);
|
);
|
||||||
|
@ -24,7 +24,8 @@ import HelpOutline from '@mui/icons-material/HelpOutline';
|
|||||||
import useLoading from '../../hooks/useLoading';
|
import useLoading from '../../hooks/useLoading';
|
||||||
import { MyProjects } from './MyProjects';
|
import { MyProjects } from './MyProjects';
|
||||||
import {
|
import {
|
||||||
ContentGrid,
|
ContentGridContainer,
|
||||||
|
FlagGrid,
|
||||||
ListItemBox,
|
ListItemBox,
|
||||||
listItemStyle,
|
listItemStyle,
|
||||||
SpacedGridItem,
|
SpacedGridItem,
|
||||||
@ -180,14 +181,13 @@ export const PersonalDashboard = () => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<ContentGrid container columns={{ lg: 12, md: 1 }} sx={{ mt: 2 }}>
|
<ContentGridContainer>
|
||||||
<SpacedGridItem item lg={4} md={1}>
|
<FlagGrid sx={{ mt: 2 }}>
|
||||||
|
<SpacedGridItem gridArea='title'>
|
||||||
<Typography variant='h3'>My feature flags</Typography>
|
<Typography variant='h3'>My feature flags</Typography>
|
||||||
</SpacedGridItem>
|
</SpacedGridItem>
|
||||||
<SpacedGridItem
|
<SpacedGridItem
|
||||||
item
|
gridArea='lifecycle'
|
||||||
lg={8}
|
|
||||||
md={1}
|
|
||||||
sx={{ display: 'flex', justifyContent: 'flex-end' }}
|
sx={{ display: 'flex', justifyContent: 'flex-end' }}
|
||||||
>
|
>
|
||||||
{activeFlag ? (
|
{activeFlag ? (
|
||||||
@ -198,8 +198,9 @@ export const PersonalDashboard = () => {
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</SpacedGridItem>
|
</SpacedGridItem>
|
||||||
<SpacedGridItem item lg={4} md={1}>
|
<SpacedGridItem gridArea='flags'>
|
||||||
{personalDashboard && personalDashboard.flags.length > 0 ? (
|
{personalDashboard &&
|
||||||
|
personalDashboard.flags.length > 0 ? (
|
||||||
<List
|
<List
|
||||||
disablePadding={true}
|
disablePadding={true}
|
||||||
sx={{ maxHeight: '400px', overflow: 'auto' }}
|
sx={{ maxHeight: '400px', overflow: 'auto' }}
|
||||||
@ -208,27 +209,30 @@ export const PersonalDashboard = () => {
|
|||||||
<FlagListItem
|
<FlagListItem
|
||||||
key={flag.name}
|
key={flag.name}
|
||||||
flag={flag}
|
flag={flag}
|
||||||
selected={flag.name === activeFlag?.name}
|
selected={
|
||||||
|
flag.name === activeFlag?.name
|
||||||
|
}
|
||||||
onClick={() => setActiveFlag(flag)}
|
onClick={() => setActiveFlag(flag)}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
) : (
|
) : (
|
||||||
<Typography>
|
<Typography>
|
||||||
You have not created or favorited any feature flags.
|
You have not created or favorited any feature
|
||||||
Once you do, they will show up here.
|
flags. Once you do, they will show up here.
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
</SpacedGridItem>
|
</SpacedGridItem>
|
||||||
|
|
||||||
<SpacedGridItem item lg={8} md={1}>
|
<SpacedGridItem gridArea='chart'>
|
||||||
{activeFlag ? (
|
{activeFlag ? (
|
||||||
<FlagMetricsChart flag={activeFlag} />
|
<FlagMetricsChart flag={activeFlag} />
|
||||||
) : (
|
) : (
|
||||||
<PlaceholderFlagMetricsChart />
|
<PlaceholderFlagMetricsChart />
|
||||||
)}
|
)}
|
||||||
</SpacedGridItem>
|
</SpacedGridItem>
|
||||||
</ContentGrid>
|
</FlagGrid>
|
||||||
|
</ContentGridContainer>
|
||||||
<WelcomeDialog
|
<WelcomeDialog
|
||||||
open={welcomeDialog === 'open'}
|
open={welcomeDialog === 'open'}
|
||||||
onClose={() => setWelcomeDialog('closed')}
|
onClose={() => setWelcomeDialog('closed')}
|
||||||
|
Loading…
Reference in New Issue
Block a user