1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-02-09 00:18:00 +01:00

fix: make dialog the right height and make it scroll if it's smaller (#7103)

I've marked the project creation dialog as "compact", so that it's only
as tall as it needs to be.

However, by default, compact forms don't scroll because they have
overflow set to hidden. This is a problem on very short windows. To get
around this, I've set overflow to unset on compact forms.

I've also removed `min-height: 0` which has some weird side effects on
the centered dialog. Instead, I'm setting `min-height` to `unset` if
it's compact.


![image](https://github.com/Unleash/unleash/assets/17786332/e7d5db52-32d3-47d9-b31f-c73a5bb8e00f)

This task also uncovered some inconsistencies and some borders that only
show up sometimes, so I've removed them too.
This commit is contained in:
Thomas Heartman 2024-05-22 13:24:42 +02:00 committed by GitHub
parent ad4f269d23
commit c47154b939
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 39 additions and 33 deletions

View File

@ -41,12 +41,12 @@ const StyledContainer = styled('section', {
shouldForwardProp: (prop) => shouldForwardProp: (prop) =>
!['modal', 'compact'].includes(prop.toString()), !['modal', 'compact'].includes(prop.toString()),
})<{ modal?: boolean; compact?: boolean }>(({ theme, modal, compact }) => ({ })<{ modal?: boolean; compact?: boolean }>(({ theme, modal, compact }) => ({
minHeight: modal ? '100vh' : compact ? 0 : '80vh', minHeight: modal ? '100vh' : compact ? 'unset' : '80vh',
borderRadius: modal ? 0 : theme.spacing(2), borderRadius: modal ? 0 : theme.spacing(2),
width: '100%', width: '100%',
display: 'flex', display: 'flex',
margin: '0 auto', margin: '0 auto',
overflow: modal ? 'unset' : 'hidden', overflow: modal || compact ? 'unset' : 'hidden',
[theme.breakpoints.down(1100)]: { [theme.breakpoints.down(1100)]: {
flexDirection: 'column', flexDirection: 'column',
minHeight: 0, minHeight: 0,

View File

@ -118,6 +118,7 @@ export const CreateProjectDialogue = ({
return ( return (
<StyledDialog open={open} onClose={onClose}> <StyledDialog open={open} onClose={onClose}>
<FormTemplate <FormTemplate
compact
disablePadding disablePadding
description={documentation} description={documentation}
documentationLink='https://docs.getunleash.io/reference/projects' documentationLink='https://docs.getunleash.io/reference/projects'

View File

@ -3,6 +3,12 @@ import FormTemplate from 'component/common/FormTemplate/FormTemplate';
import { useRequiredPathParam } from 'hooks/useRequiredPathParam'; import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi'; import useProjectApi from 'hooks/api/actions/useProjectApi/useProjectApi';
import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { styled } from '@mui/material';
const StyledContainer = styled('div')(({ theme }) => ({
borderRadius: theme.spacing(2),
overflow: 'hidden',
}));
interface IDeleteProjectForm { interface IDeleteProjectForm {
featureCount: number; featureCount: number;
@ -17,19 +23,21 @@ export const DeleteProjectForm = ({ featureCount }: IDeleteProjectForm) => {
}; };
return ( return (
<FormTemplate <StyledContainer>
loading={loading} <FormTemplate
title='Delete project' loading={loading}
description='' title='Delete project'
documentationLink='https://docs.getunleash.io/reference/projects' description=''
documentationLinkLabel='Projects documentation' documentationLink='https://docs.getunleash.io/reference/projects'
formatApiCode={formatProjectDeleteApiCode} documentationLinkLabel='Projects documentation'
compact formatApiCode={formatProjectDeleteApiCode}
compactPadding compact
showDescription={false} compactPadding
showLink={false} showDescription={false}
> showLink={false}
<DeleteProject projectId={id} featureCount={featureCount} /> >
</FormTemplate> <DeleteProject projectId={id} featureCount={featureCount} />
</FormTemplate>
</StyledContainer>
); );
}; };

View File

@ -17,7 +17,6 @@ import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectO
const StyledContainer = styled('div')(({ theme }) => ({ const StyledContainer = styled('div')(({ theme }) => ({
minHeight: 0, minHeight: 0,
borderRadius: theme.spacing(2), borderRadius: theme.spacing(2),
border: `1px solid ${theme.palette.divider}`,
width: '100%', width: '100%',
display: 'flex', display: 'flex',
margin: '0 auto', margin: '0 auto',
@ -151,6 +150,7 @@ export const UpdateEnterpriseSettings = ({
documentationLinkLabel='Projects documentation' documentationLinkLabel='Projects documentation'
formatApiCode={formatProjectSettingsApiCode} formatApiCode={formatProjectSettingsApiCode}
compactPadding compactPadding
compact
showDescription={false} showDescription={false}
showLink={false} showLink={false}
> >

View File

@ -19,21 +19,18 @@ import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
import { styled } from '@mui/material'; import { styled } from '@mui/material';
import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectOverview'; import useProjectOverview from 'hooks/api/getters/useProjectOverview/useProjectOverview';
const StyledContainer = styled('div')<{ isPro: boolean }>( const StyledContainer = styled('div')(({ theme }) => ({
({ theme, isPro }) => ({ minHeight: 0,
borderRadius: theme.spacing(2),
width: '100%',
display: 'flex',
margin: '0 auto',
overflow: 'hidden',
[theme.breakpoints.down(1100)]: {
flexDirection: 'column',
minHeight: 0, minHeight: 0,
borderRadius: theme.spacing(2), },
border: isPro ? '0' : `1px solid ${theme.palette.divider}`, }));
width: '100%',
display: 'flex',
margin: '0 auto',
overflow: 'hidden',
[theme.breakpoints.down(1100)]: {
flexDirection: 'column',
minHeight: 0,
},
}),
);
const StyledFormContainer = styled('div')(({ theme }) => ({ const StyledFormContainer = styled('div')(({ theme }) => ({
borderTop: `1px solid ${theme.palette.divider}`, borderTop: `1px solid ${theme.palette.divider}`,
@ -46,7 +43,7 @@ interface IUpdateProject {
const EDIT_PROJECT_BTN = 'EDIT_PROJECT_BTN'; const EDIT_PROJECT_BTN = 'EDIT_PROJECT_BTN';
export const UpdateProject = ({ project }: IUpdateProject) => { export const UpdateProject = ({ project }: IUpdateProject) => {
const id = useRequiredPathParam('projectId'); const id = useRequiredPathParam('projectId');
const { uiConfig, isPro } = useUiConfig(); const { uiConfig } = useUiConfig();
const { setToastData, setToastApiError } = useToast(); const { setToastData, setToastApiError } = useToast();
const { defaultStickiness } = useDefaultProjectSettings(id); const { defaultStickiness } = useDefaultProjectSettings(id);
const { trackEvent } = usePlausibleTracker(); const { trackEvent } = usePlausibleTracker();
@ -110,7 +107,7 @@ export const UpdateProject = ({ project }: IUpdateProject) => {
}; };
return ( return (
<StyledContainer isPro={isPro()}> <StyledContainer>
<FormTemplate <FormTemplate
loading={loading} loading={loading}
title='General settings' title='General settings'