Skip to content

Commit

Permalink
ui fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ketanMehtaa committed Oct 25, 2024
1 parent 4b0fbf6 commit 73db17e
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { NavigationDrawerHeader } from '@/ui/navigation/navigation-drawer/compon
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
import { useLocation } from 'react-router-dom';
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
import { getImageAbsoluteURI, IconSearch, IconSettings } from 'twenty-ui';
import {
getImageAbsoluteURI,
IconComponent,
IconList,
IconSearch,
IconSettings,
} from 'twenty-ui';
import { useIsSettingsPage } from '../hooks/useIsSettingsPage';
import { currentMobileNavigationDrawerState } from '../states/currentMobileNavigationDrawerState';

Expand All @@ -19,6 +25,8 @@ import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMe
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import styled from '@emotion/styled';
import { NavigationBar } from '@/ui/navigation/navigation-bar/components/NavigationBar';
import { NavigationBarItem } from '@/ui/navigation/navigation-bar/components/NavigationBarItem';

// type NavigationBarItemName = 'main' | 'search' | 'tasks' | 'settings';

Expand All @@ -29,7 +37,6 @@ const NavigationWrapper = styled.div`
width: 90%;
margin: auto;
overflow-x: auto;
overflow-y: hidden;
padding: ${({ theme }) => theme.spacing(3)};
z-index: 1001;
`;
Expand Down Expand Up @@ -59,7 +66,7 @@ export const MobileNavigationBar = () => {
? 'settings'
: 'main';

// const isMobile = useIsMobile();
const isMobile = useIsMobile();
// const { toggleCommandMenu } = useCommandMenu();
const location = useLocation();
const setNavigationMemorizedUrl = useSetRecoilState(
Expand Down Expand Up @@ -117,6 +124,7 @@ export const MobileNavigationBar = () => {
<NavigationWrapper>
<NavigationItem>
<NavigationDrawerHeader
visible={isMobile}
name={title}
logo={logo}
showCollapseButton={false}
Expand All @@ -126,7 +134,7 @@ export const MobileNavigationBar = () => {
<NavigationDrawerItem
label="Search"
Icon={IconSearch}
mobileNavigationDrawer = {true}
mobileNavigationDrawer={true}
onClick={() => {
if (!isCommandMenuOpened) {
openCommandMenu();
Expand All @@ -136,8 +144,25 @@ export const MobileNavigationBar = () => {
// keyboard={['⌘', 'K']}
/>
</NavigationItem>

<NavigationItem>
<NavigationBarItem
key={'settings'}
Icon={IconSettings}
isActive={activeItemName === 'settings'}
onClick={() => {
closeCommandMenu();
// setNavigationDrawerExpandedMemorized(isNavigationDrawerExpanded);
setIsNavigationDrawerExpanded(
(previousIsOpen) =>
activeItemName !== 'settings' || !previousIsOpen,
);
// setNavigationMemorizedUrl(location.pathname + location.search);
setCurrentMobileNavigationDrawer('settings');
}}
/>
</NavigationItem>

{/* <NavigationItem>
<NavigationDrawerItem
mobileNavigationDrawer={true}
label="Settings"
Expand All @@ -153,32 +178,33 @@ export const MobileNavigationBar = () => {
// setNavigationMemorizedUrl(location.pathname + location.search);
setCurrentMobileNavigationDrawer('settings');
}}

/>
</NavigationItem>
</NavigationItem> */}

{isWorkspaceFavoriteEnabled && (
<NavigationItem>
<NavigationDrawerOpenedSection mobileNavigationDrawer={true} />
<NavigationDrawerOpenedSection mobileNavigationDrawer={true} />
</NavigationItem>
)}

<NavigationItem>
<CurrentWorkspaceMemberFavorites mobileNavigationDrawer = {true}/>
<CurrentWorkspaceMemberFavorites mobileNavigationDrawer={true} />
</NavigationItem>

{isWorkspaceFavoriteEnabled ? (
<NavigationItem>
<WorkspaceFavorites mobileNavigationDrawer = {true}/>
<WorkspaceFavorites mobileNavigationDrawer={true} />
</NavigationItem>
) : (
<NavigationDrawerSectionForObjectMetadataItemsWrapper mobileNavigationDrawer={true}
<NavigationDrawerSectionForObjectMetadataItemsWrapper
mobileNavigationDrawer={true}
isRemote={false}
/>
)}

<NavigationItem>
<NavigationDrawerSectionForObjectMetadataItemsWrapper mobileNavigationDrawer={true}
<NavigationDrawerSectionForObjectMetadataItemsWrapper
mobileNavigationDrawer={true}
isRemote={true}
/>
</NavigationItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export const NavigationDrawerItemForObjectMetadataItem = ({
<SubItemsWrapper>
{sortedObjectMetadataViews.map((view, index) => (
<NavigationDrawerSubItem
mobileNavigationDrawer={mobileNavigationDrawer}
label={view.name}
to={`/objects/${objectMetadataItem.namePlural}?view=${view.id}`}
active={viewId === view.id}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
// import styled from '@emotion/styled';
// import { IconComponent } from 'twenty-ui';
import styled from '@emotion/styled';
import { IconComponent } from 'twenty-ui';

// import { NavigationBarItem } from './NavigationBarItem';
import { NavigationBarItem } from './NavigationBarItem';

// const StyledContainer = styled.div`
// display: flex;
// gap: ${({ theme }) => theme.spacing(4)};
// justify-content: center;
// padding: ${({ theme }) => theme.spacing(3)};
// z-index: 1001;
// `;
const StyledContainer = styled.div`
display: flex;
gap: ${({ theme }) => theme.spacing(4)};
justify-content: center;
padding: ${({ theme }) => theme.spacing(3)};
z-index: 1001;
`;

// type NavigationBarProps = {
// activeItemName: string;
// items: { name: string; Icon: IconComponent; onClick: () => void }[];
// };
type NavigationBarProps = {
activeItemName: string;
items: { name: string; Icon: IconComponent; onClick: () => void }[];
};

// export const NavigationBar = ({
// activeItemName,
// items,
// }: NavigationBarProps) => (
// <StyledContainer>
// {items.map(({ Icon, name, onClick }) => (
// <NavigationBarItem
// key={name}
// Icon={Icon}
// isActive={activeItemName === name}
// onClick={onClick}
// />
// ))}
// </StyledContainer>
// );
export const NavigationBar = ({
activeItemName,
items,
}: NavigationBarProps) => (
<StyledContainer>
{items.map(({ Icon, name, onClick }) => (
<NavigationBarItem
key={name}
Icon={Icon}
isActive={activeItemName === name}
onClick={onClick}
/>
))}
</StyledContainer>
);
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
// import { useTheme } from '@emotion/react';
// import styled from '@emotion/styled';
// import { IconComponent } from 'twenty-ui';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { IconComponent } from 'twenty-ui';

// const StyledIconButton = styled.div<{ isActive?: boolean }>`
// align-items: center;
// background-color: ${({ isActive, theme }) =>
// isActive ? theme.background.transparent.light : 'none'};
// border-radius: ${({ theme }) => theme.spacing(1)};
// cursor: pointer;
// display: flex;
// height: ${({ theme }) => theme.spacing(10)};
// justify-content: center;
// transition: background-color ${({ theme }) => theme.animation.duration.fast}s
// ease;
// width: ${({ theme }) => theme.spacing(10)};
const StyledIconButton = styled.div<{ isActive?: boolean }>`
align-items: center;
background-color: ${({ isActive, theme }) =>
isActive ? theme.background.transparent.light : 'none'};
border-radius: ${({ theme }) => theme.spacing(1)};
cursor: pointer;
display: flex;
height: ${({ theme }) => theme.spacing(8)};
justify-content: center;
transition: background-color ${({ theme }) => theme.animation.duration.fast}s
ease;
width: ${({ theme }) => theme.spacing(8)};
// &:hover {
// background-color: ${({ theme }) => theme.background.transparent.light};
// }
// `;
&:hover {
background-color: ${({ theme }) => theme.background.transparent.light};
}
`;

// type NavigationBarItemProps = {
// Icon: IconComponent;
// isActive: boolean;
// onClick: () => void;
// };
type NavigationBarItemProps = {
Icon: IconComponent;
isActive: boolean;
onClick: () => void;
};

// export const NavigationBarItem = ({
// Icon,
// isActive,
// onClick,
// }: NavigationBarItemProps) => {
// const theme = useTheme();
export const NavigationBarItem = ({
Icon,
isActive,
onClick,
}: NavigationBarItemProps) => {
const theme = useTheme();

// return (
// <StyledIconButton isActive={isActive} onClick={onClick}>
// <Icon color={theme.color.gray50} size={theme.icon.size.lg} />
// </StyledIconButton>
// );
// };
return (
<StyledIconButton isActive={isActive} onClick={onClick}>
<Icon color={theme.color.gray60} size={theme.icon.size.md} />
</StyledIconButton>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const StyledContainer = styled.div<{
isSettings
? isMobile
? theme.spacing(3, 8)
: theme.spacing(3, 8, 4, 0)
: theme.spacing(3, 8)
: theme.spacing(3, 2, 4)};
@media (max-width: ${MOBILE_VIEWPORT}px) {
Expand Down Expand Up @@ -113,6 +113,7 @@ export const NavigationDrawer = ({
!isMobile && <NavigationDrawerBackButton title={title} />
) : (
<NavigationDrawerHeader
visible={!isMobile}
name={title}
logo={logo}
showCollapseButton={isHovered}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useIsSettingsPage } from '@/navigation/hooks/useIsSettingsPage';
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
Expand All @@ -25,19 +24,26 @@ export const NavigationDrawerAnimatedCollapseWrapper = ({
// }

const animate: AnimationControls | TargetAndTransition =
isNavigationDrawerExpanded && !mobileNavigationDrawer
mobileNavigationDrawer
? {
opacity: 1,
width: 'auto',
height: 'auto',
pointerEvents: 'auto',
}
: {
opacity: 0,
width: 0,
height: 0,
pointerEvents: 'none',
};
width: 0,
height: 0,
pointerEvents: 'none',
}
: isNavigationDrawerExpanded
? {
opacity: 1,
width: 'auto',
height: 'auto',
pointerEvents: 'auto',
}
: {
opacity: 0,
width: 0,
height: 0,
pointerEvents: 'none',
};

return (
<StyledAnimatedContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,22 @@ type NavigationDrawerHeaderProps = {
name?: string;
logo?: string;
showCollapseButton: boolean;
visible: boolean;
};

export const NavigationDrawerHeader = ({
name = DEFAULT_WORKSPACE_NAME,
logo = DEFAULT_WORKSPACE_LOGO,
showCollapseButton,
visible,
}: NavigationDrawerHeaderProps) => {
const isMobile = useIsMobile();
const workspaces = useRecoilValue(workspacesState);
const isMultiWorkspace = workspaces !== null && workspaces.length > 1;
const isNavigationDrawerExpanded = useRecoilValue(
isNavigationDrawerExpandedState,
);

if (!visible) return <></>;
return (
<StyledContainer>
{isMultiWorkspace ? (
Expand Down
Loading

0 comments on commit 73db17e

Please sign in to comment.