minor fix - collapse button hover and dropdown button width (#7748)
follow up - #7414
This commit is contained in:
@ -1,21 +1,21 @@
|
|||||||
import { useTheme } from '@emotion/react';
|
|
||||||
import styled from '@emotion/styled';
|
|
||||||
import { useState } from 'react';
|
|
||||||
import { useRecoilValue } from 'recoil';
|
|
||||||
import { IconChevronDown } from 'twenty-ui';
|
|
||||||
|
|
||||||
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
|
||||||
import { Workspaces } from '@/auth/states/workspaces';
|
import { Workspaces } from '@/auth/states/workspaces';
|
||||||
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
|
||||||
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
||||||
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
|
||||||
import { MenuItemSelectAvatar } from '@/ui/navigation/menu-item/components/MenuItemSelectAvatar';
|
import { MenuItemSelectAvatar } from '@/ui/navigation/menu-item/components/MenuItemSelectAvatar';
|
||||||
|
import { NavigationDrawerAnimatedCollapseWrapper } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper';
|
||||||
import { DEFAULT_WORKSPACE_LOGO } from '@/ui/navigation/navigation-drawer/constants/DefaultWorkspaceLogo';
|
import { DEFAULT_WORKSPACE_LOGO } from '@/ui/navigation/navigation-drawer/constants/DefaultWorkspaceLogo';
|
||||||
import { MULTI_WORKSPACE_DROPDOWN_ID } from '@/ui/navigation/navigation-drawer/constants/MulitWorkspaceDropdownId';
|
import { MULTI_WORKSPACE_DROPDOWN_ID } from '@/ui/navigation/navigation-drawer/constants/MulitWorkspaceDropdownId';
|
||||||
import { useWorkspaceSwitching } from '@/ui/navigation/navigation-drawer/hooks/useWorkspaceSwitching';
|
import { useWorkspaceSwitching } from '@/ui/navigation/navigation-drawer/hooks/useWorkspaceSwitching';
|
||||||
import { NavigationDrawerHotKeyScope } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerHotKeyScope';
|
import { NavigationDrawerHotKeyScope } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerHotKeyScope';
|
||||||
|
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
|
||||||
|
import { useTheme } from '@emotion/react';
|
||||||
|
import styled from '@emotion/styled';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { useRecoilState, useRecoilValue } from 'recoil';
|
||||||
|
import { IconChevronDown } from 'twenty-ui';
|
||||||
import { getImageAbsoluteURI } from '~/utils/image/getImageAbsoluteURI';
|
import { getImageAbsoluteURI } from '~/utils/image/getImageAbsoluteURI';
|
||||||
import { NavigationDrawerAnimatedCollapseWrapper } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper';
|
|
||||||
|
|
||||||
const StyledLogo = styled.div<{ logo: string }>`
|
const StyledLogo = styled.div<{ logo: string }>`
|
||||||
background: url(${({ logo }) => logo});
|
background: url(${({ logo }) => logo});
|
||||||
@ -26,7 +26,7 @@ const StyledLogo = styled.div<{ logo: string }>`
|
|||||||
width: 16px;
|
width: 16px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledContainer = styled.div`
|
const StyledContainer = styled.div<{ isNavigationDrawerExpanded: boolean }>`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
color: ${({ theme }) => theme.font.color.primary};
|
color: ${({ theme }) => theme.font.color.primary};
|
||||||
@ -34,10 +34,13 @@ const StyledContainer = styled.div`
|
|||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
height: ${({ theme }) => theme.spacing(5)};
|
height: ${({ theme, isNavigationDrawerExpanded }) =>
|
||||||
|
isNavigationDrawerExpanded ? theme.spacing(5) : theme.spacing(4)};
|
||||||
padding: calc(${({ theme }) => theme.spacing(1)} - 1px);
|
padding: calc(${({ theme }) => theme.spacing(1)} - 1px);
|
||||||
width: 100%;
|
width: ${({ isNavigationDrawerExpanded }) =>
|
||||||
|
isNavigationDrawerExpanded ? '100%' : 'auto'};
|
||||||
|
gap: ${({ theme, isNavigationDrawerExpanded }) =>
|
||||||
|
isNavigationDrawerExpanded ? theme.spacing(1) : '0'};
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: ${({ theme }) => theme.background.transparent.lighter};
|
background-color: ${({ theme }) => theme.background.transparent.lighter};
|
||||||
border: 1px solid ${({ theme }) => theme.border.color.medium};
|
border: 1px solid ${({ theme }) => theme.border.color.medium};
|
||||||
@ -47,12 +50,13 @@ const StyledContainer = styled.div`
|
|||||||
const StyledLabel = styled.div`
|
const StyledLabel = styled.div`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
display: flex;
|
display: flex;
|
||||||
margin: 0 ${({ theme }) => theme.spacing(1)};
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledIconChevronDown = styled(IconChevronDown)<{ disabled?: boolean }>`
|
const StyledIconChevronDown = styled(IconChevronDown)<{ disabled?: boolean }>`
|
||||||
|
align-items: center;
|
||||||
color: ${({ disabled, theme }) =>
|
color: ${({ disabled, theme }) =>
|
||||||
disabled ? theme.font.color.extraLight : theme.font.color.tertiary};
|
disabled ? theme.font.color.extraLight : theme.font.color.tertiary};
|
||||||
|
display: flex;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
type MultiWorkspaceDropdownButtonProps = {
|
type MultiWorkspaceDropdownButtonProps = {
|
||||||
@ -77,6 +81,9 @@ export const MultiWorkspaceDropdownButton = ({
|
|||||||
closeDropdown();
|
closeDropdown();
|
||||||
await switchWorkspace(workspaceId);
|
await switchWorkspace(workspaceId);
|
||||||
};
|
};
|
||||||
|
const [isNavigationDrawerExpanded] = useRecoilState(
|
||||||
|
isNavigationDrawerExpandedState,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dropdown
|
<Dropdown
|
||||||
@ -85,7 +92,10 @@ export const MultiWorkspaceDropdownButton = ({
|
|||||||
scope: NavigationDrawerHotKeyScope.MultiWorkspaceDropdownButton,
|
scope: NavigationDrawerHotKeyScope.MultiWorkspaceDropdownButton,
|
||||||
}}
|
}}
|
||||||
clickableComponent={
|
clickableComponent={
|
||||||
<StyledContainer data-testid="workspace-dropdown">
|
<StyledContainer
|
||||||
|
data-testid="workspace-dropdown"
|
||||||
|
isNavigationDrawerExpanded={isNavigationDrawerExpanded}
|
||||||
|
>
|
||||||
<StyledLogo
|
<StyledLogo
|
||||||
logo={
|
logo={
|
||||||
getImageAbsoluteURI(
|
getImageAbsoluteURI(
|
||||||
|
|||||||
@ -13,14 +13,10 @@ const StyledCollapseButton = styled.div`
|
|||||||
color: ${({ theme }) => theme.font.color.light};
|
color: ${({ theme }) => theme.font.color.light};
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
height: ${({ theme }) => theme.spacing(5)};
|
height: ${({ theme }) => theme.spacing(4)};
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
width: ${({ theme }) => theme.spacing(6)};
|
width: ${({ theme }) => theme.spacing(4)};
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: ${({ theme }) => theme.background.quaternary};
|
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
type NavigationDrawerCollapseButtonProps = {
|
type NavigationDrawerCollapseButtonProps = {
|
||||||
|
|||||||
Reference in New Issue
Block a user