Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issue Refine Settings Layout #3429

Merged
merged 6 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import styled from '@emotion/styled';

import { objectSettingsWidth } from '../data-model/constants/objectSettings';
import { objectSettingsWidth } from '@/settings/data-model/constants/objectSettings';

const StyledSettingsPageContainer = styled.div<{ width?: number }>`
display: flex;
flex-direction: column;
gap: ${({ theme }) => theme.spacing(8)};
overflow: auto;
padding: ${({ theme }) => theme.spacing(8)};
width: ${({ width }) => (width ? width + 'px' : objectSettingsWidth)};
width: ${({ width }) => (width ? width + 'px' : objectSettingsWidth + 'px')};
`;

export { StyledSettingsPageContainer as SettingsPageContainer };
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const objectSettingsWidth = '512px';
export const objectSettingsWidth = 512;
24 changes: 22 additions & 2 deletions packages/twenty-front/src/modules/ui/layout/page/DefaultLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ReactNode } from 'react';
import { css, Global, useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { motion } from 'framer-motion';
import { AnimatePresence, LayoutGroup } from 'framer-motion';

import { AuthModal } from '@/auth/components/Modal';
Expand All @@ -11,8 +12,12 @@ import { AppErrorBoundary } from '@/error-handler/components/AppErrorBoundary';
import { KeyboardShortcutMenu } from '@/keyboard-shortcut-menu/components/KeyboardShortcutMenu';
import { AppNavigationDrawer } from '@/navigation/components/AppNavigationDrawer';
import { MobileNavigationBar } from '@/navigation/components/MobileNavigationBar';
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
import { objectSettingsWidth } from '@/settings/data-model/constants/objectSettings';
import { SignInBackgroundMockPage } from '@/sign-in-background-mock/components/SignInBackgroundMockPage';
import { desktopNavDrawerWidths } from '@/ui/navigation/navigation-drawer/constants';
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { useScreenSize } from '@/ui/utilities/screen-size/hooks/useScreenSize';

const StyledLayout = styled.div`
background: ${({ theme }) => theme.background.noisy};
Expand All @@ -39,7 +44,7 @@ const StyledLayout = styled.div`
}
`;

const StyledPageContainer = styled.div`
const StyledPageContainer = styled(motion.div)`
display: flex;
flex: 1 1 auto;
flex-direction: row;
Expand All @@ -63,7 +68,9 @@ type DefaultLayoutProps = {
export const DefaultLayout = ({ children }: DefaultLayoutProps) => {
const onboardingStatus = useOnboardingStatus();
const isMobile = useIsMobile();
const isSettingsPage = useIsSettingsPage();
const theme = useTheme();
const widowsWidth = useScreenSize().width;
return (
<>
<Global
Expand All @@ -76,7 +83,20 @@ export const DefaultLayout = ({ children }: DefaultLayoutProps) => {
<StyledLayout>
<CommandMenu />
<KeyboardShortcutMenu />
<StyledPageContainer>

<StyledPageContainer
animate={{
marginLeft:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

applying the marginLeft here rather than on SettingsPage to allow animation between pages

isSettingsPage && !isMobile
? (widowsWidth -
(objectSettingsWidth + desktopNavDrawerWidths.menu + 64)) /
2
: 0,
}}
transition={{
duration: theme.animation.duration.normal,
}}
>
<StyledAppNavigationDrawer />
<StyledMainContainer>
{onboardingStatus &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const StyledMainContainer = styled.div`
gap: ${({ theme }) => theme.spacing(2)};
min-height: 0;
padding-bottom: ${({ theme }) => theme.spacing(3)};
padding-left: 0;
padding-right: ${({ theme }) => theme.spacing(3)};
padding-left: 0;
width: 100%;

@media (max-width: ${MOBILE_VIEWPORT}px) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const StyledContainer = styled.div<{ isSubMenu?: boolean }>`
flex-direction: column;
gap: ${({ theme }) => theme.spacing(8)};
height: 100%;
min-width: ${desktopNavDrawerWidths.menu};
min-width: ${desktopNavDrawerWidths.menu}px;
padding: ${({ theme }) => theme.spacing(3, 2, 4)};

${({ isSubMenu, theme }) =>
Expand Down Expand Up @@ -80,9 +80,7 @@ export const NavigationDrawer = ({

const desktopWidth = !isNavigationDrawerOpen
? 12
: isSubMenu
? desktopNavDrawerWidths.submenu
: desktopNavDrawerWidths.menu;
: desktopNavDrawerWidths.menu;

const mobileWidth = isNavigationDrawerOpen ? '100%' : 0;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export const desktopNavDrawerWidths = {
menu: '236px',
submenu: '536px',
menu: 236,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useEffect, useState } from 'react';

export const useScreenSize = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abdul-irfan-k introducing this hook as based on design, it does not seem to be possible to handle this by css only

const [screenSize, setScreenSize] = useState({
width: window.innerWidth,
height: window.innerHeight,
});

useEffect(() => {
const handleResize = () => {
setScreenSize({
width: window.innerWidth,
height: window.innerHeight,
});
};

window.addEventListener('resize', handleResize);

return () => {
window.removeEventListener('resize', handleResize);
};
}, []);

return screenSize;
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const StyledH1Title = styled(H1Title)`

export const SettingsProfile = () => (
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
<SettingsPageContainer width={350}>
<SettingsPageContainer>
<StyledH1Title title="Profile" />
<Section>
<H2Title title="Picture" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const StyledH1Title = styled(H1Title)`

export const SettingsWorkspace = () => (
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
<SettingsPageContainer width={350}>
<SettingsPageContainer>
<StyledH1Title title="General" />
<Section>
<H2Title title="Picture" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const SettingsWorkspaceMembers = () => {

return (
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
<SettingsPageContainer width={350}>
<SettingsPageContainer>
<StyledH1Title title="Members" />
{currentWorkspace?.inviteHash && (
<Section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from '@emotion/styled';

import { CoreObjectNameSingular } from '@/object-metadata/types/CoreObjectNameSingular';
import { useFindManyRecords } from '@/object-record/hooks/useFindManyRecords';
import { objectSettingsWidth } from '@/settings/data-model/constants/objectSettings';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { SettingsApiKeysFieldItemTableRow } from '@/settings/developers/components/SettingsApiKeysFieldItemTableRow';
import { ApiFieldItem } from '@/settings/developers/types/ApiFieldItem';
import { formatExpirations } from '@/settings/developers/utils/format-expiration';
Expand All @@ -19,8 +19,6 @@ import { TableRow } from '@/ui/layout/table/components/TableRow';

const StyledContainer = styled.div`
height: fit-content;
padding: ${({ theme }) => theme.spacing(8)};
width: ${objectSettingsWidth};
`;

const StyledTableRow = styled(TableRow)`
Expand Down Expand Up @@ -62,41 +60,43 @@ export const SettingsDevelopersApiKeys = () => {

return (
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
<StyledContainer>
<StyledHeader>
<StyledH1Title title="APIs" />
<Button
Icon={IconPlus}
title="Create Key"
accent="blue"
size="small"
onClick={() => {
navigate('/settings/developers/api-keys/new');
}}
/>
</StyledHeader>
<H2Title
title="Active Keys"
description="Active APIs keys created by you or your team"
/>
<Table>
<StyledTableRow>
<TableHeader>Name</TableHeader>
<TableHeader>Type</TableHeader>
<TableHeader>Expiration</TableHeader>
<TableHeader></TableHeader>
</StyledTableRow>
{apiKeys.map((fieldItem) => (
<SettingsApiKeysFieldItemTableRow
key={fieldItem.id}
fieldItem={fieldItem}
<SettingsPageContainer>
<StyledContainer>
<StyledHeader>
<StyledH1Title title="APIs" />
<Button
Icon={IconPlus}
title="Create Key"
accent="blue"
size="small"
onClick={() => {
navigate(`/settings/developers/api-keys/${fieldItem.id}`);
navigate('/settings/developers/api-keys/new');
}}
/>
))}
</Table>
</StyledContainer>
</StyledHeader>
<H2Title
title="Active Keys"
description="Active APIs keys created by you or your team"
/>
<Table>
<StyledTableRow>
<TableHeader>Name</TableHeader>
<TableHeader>Type</TableHeader>
<TableHeader>Expiration</TableHeader>
<TableHeader></TableHeader>
</StyledTableRow>
{apiKeys.map((fieldItem) => (
<SettingsApiKeysFieldItemTableRow
key={fieldItem.id}
fieldItem={fieldItem}
onClick={() => {
navigate(`/settings/developers/api-keys/${fieldItem.id}`);
}}
/>
))}
</Table>
</StyledContainer>
</SettingsPageContainer>
</SubMenuTopBarContainer>
);
};