Removed drag grip and accent is now tertiary in hidden fields (#6650)
Closes #6115 This change successfully addresses the issue as described. However, it also causes the primary non-draggable field, `Name`, to render without a draggable handle and with a secondary accent. Is this an acceptable outcome? https://github.com/user-attachments/assets/4bc15e00-6c73-41d4-8342-4e36487d0981 --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
This commit is contained in:
@ -182,6 +182,7 @@ export const RecordIndexOptionsDropdownContent = ({
|
|||||||
onDragEnd={handleReorderFields}
|
onDragEnd={handleReorderFields}
|
||||||
onVisibilityChange={handleChangeFieldVisibility}
|
onVisibilityChange={handleChangeFieldVisibility}
|
||||||
showSubheader={false}
|
showSubheader={false}
|
||||||
|
showDragGrip={true}
|
||||||
/>
|
/>
|
||||||
<DropdownMenuSeparator />
|
<DropdownMenuSeparator />
|
||||||
<DropdownMenuItemsContainer>
|
<DropdownMenuItemsContainer>
|
||||||
@ -209,6 +210,7 @@ export const RecordIndexOptionsDropdownContent = ({
|
|||||||
isDraggable={false}
|
isDraggable={false}
|
||||||
onVisibilityChange={handleChangeFieldVisibility}
|
onVisibilityChange={handleChangeFieldVisibility}
|
||||||
showSubheader={false}
|
showSubheader={false}
|
||||||
|
showDragGrip={false}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -3,10 +3,7 @@ import { IconComponent } from 'twenty-ui';
|
|||||||
import { LightIconButtonGroup } from '@/ui/input/button/components/LightIconButtonGroup';
|
import { LightIconButtonGroup } from '@/ui/input/button/components/LightIconButtonGroup';
|
||||||
|
|
||||||
import { MenuItemLeftContent } from '../internals/components/MenuItemLeftContent';
|
import { MenuItemLeftContent } from '../internals/components/MenuItemLeftContent';
|
||||||
import {
|
import { StyledHoverableMenuItemBase } from '../internals/components/StyledMenuItemBase';
|
||||||
StyledHoverableMenuItemBase,
|
|
||||||
StyledMenuItemBase,
|
|
||||||
} from '../internals/components/StyledMenuItemBase';
|
|
||||||
import { MenuItemAccent } from '../types/MenuItemAccent';
|
import { MenuItemAccent } from '../types/MenuItemAccent';
|
||||||
|
|
||||||
import { MenuItemIconButton } from './MenuItem';
|
import { MenuItemIconButton } from './MenuItem';
|
||||||
@ -24,6 +21,7 @@ export type MenuItemDraggableProps = {
|
|||||||
isDragDisabled?: boolean;
|
isDragDisabled?: boolean;
|
||||||
isHoverDisabled?: boolean;
|
isHoverDisabled?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MenuItemDraggable = ({
|
export const MenuItemDraggable = ({
|
||||||
LeftIcon,
|
LeftIcon,
|
||||||
accent = 'default',
|
accent = 'default',
|
||||||
@ -34,22 +32,14 @@ export const MenuItemDraggable = ({
|
|||||||
className,
|
className,
|
||||||
isIconDisplayedOnHoverOnly = true,
|
isIconDisplayedOnHoverOnly = true,
|
||||||
showGrip = false,
|
showGrip = false,
|
||||||
isHoverDisabled = false,
|
|
||||||
}: MenuItemDraggableProps) => {
|
}: MenuItemDraggableProps) => {
|
||||||
const showIconButtons = Array.isArray(iconButtons) && iconButtons.length > 0;
|
const showIconButtons = Array.isArray(iconButtons) && iconButtons.length > 0;
|
||||||
|
|
||||||
if (isHoverDisabled) {
|
const cursorType = showGrip
|
||||||
return (
|
? isDragDisabled
|
||||||
<StyledMenuItemBase accent={accent} isHoverBackgroundDisabled>
|
? 'not-allowed'
|
||||||
<MenuItemLeftContent
|
: 'drag'
|
||||||
LeftIcon={LeftIcon}
|
: 'default';
|
||||||
text={text}
|
|
||||||
isDisabled={isDragDisabled}
|
|
||||||
showGrip={showGrip}
|
|
||||||
/>
|
|
||||||
</StyledMenuItemBase>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledHoverableMenuItemBase
|
<StyledHoverableMenuItemBase
|
||||||
@ -57,6 +47,7 @@ export const MenuItemDraggable = ({
|
|||||||
accent={accent}
|
accent={accent}
|
||||||
className={className}
|
className={className}
|
||||||
isIconDisplayedOnHoverOnly={isIconDisplayedOnHoverOnly}
|
isIconDisplayedOnHoverOnly={isIconDisplayedOnHoverOnly}
|
||||||
|
cursor={cursorType}
|
||||||
>
|
>
|
||||||
<MenuItemLeftContent
|
<MenuItemLeftContent
|
||||||
LeftIcon={LeftIcon}
|
LeftIcon={LeftIcon}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { ReactNode } from 'react';
|
|
||||||
import { useTheme } from '@emotion/react';
|
import { useTheme } from '@emotion/react';
|
||||||
import { isString } from '@sniptt/guards';
|
import { isString } from '@sniptt/guards';
|
||||||
|
import { ReactNode } from 'react';
|
||||||
import {
|
import {
|
||||||
IconComponent,
|
IconComponent,
|
||||||
IconGripVertical,
|
IconGripVertical,
|
||||||
@ -34,13 +34,17 @@ export const MenuItemLeftContent = ({
|
|||||||
<StyledMenuItemLeftContent className={className}>
|
<StyledMenuItemLeftContent className={className}>
|
||||||
{showGrip &&
|
{showGrip &&
|
||||||
(isDisabled ? (
|
(isDisabled ? (
|
||||||
<IconGripVertical
|
<StyledDraggableItem>
|
||||||
size={theme.icon.size.md}
|
<IconGripVertical
|
||||||
stroke={theme.icon.stroke.sm}
|
size={theme.icon.size.md}
|
||||||
color={
|
stroke={theme.icon.stroke.sm}
|
||||||
isDisabled ? theme.font.color.extraLight : theme.font.color.light
|
color={
|
||||||
}
|
isDisabled
|
||||||
/>
|
? theme.font.color.extraLight
|
||||||
|
: theme.font.color.light
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</StyledDraggableItem>
|
||||||
) : (
|
) : (
|
||||||
<StyledDraggableItem>
|
<StyledDraggableItem>
|
||||||
<IconGripVertical
|
<IconGripVertical
|
||||||
|
|||||||
@ -106,10 +106,14 @@ export const StyledMenuItemRightContent = styled.div`
|
|||||||
|
|
||||||
export const StyledDraggableItem = styled.div`
|
export const StyledDraggableItem = styled.div`
|
||||||
cursor: grab;
|
cursor: grab;
|
||||||
|
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const StyledHoverableMenuItemBase = styled(StyledMenuItemBase)<{
|
export const StyledHoverableMenuItemBase = styled(StyledMenuItemBase)<{
|
||||||
isIconDisplayedOnHoverOnly?: boolean;
|
isIconDisplayedOnHoverOnly?: boolean;
|
||||||
|
cursor?: 'drag' | 'default' | 'not-allowed';
|
||||||
}>`
|
}>`
|
||||||
${({ isIconDisplayedOnHoverOnly, theme }) =>
|
${({ isIconDisplayedOnHoverOnly, theme }) =>
|
||||||
isIconDisplayedOnHoverOnly &&
|
isIconDisplayedOnHoverOnly &&
|
||||||
@ -131,4 +135,15 @@ export const StyledHoverableMenuItemBase = styled(StyledMenuItemBase)<{
|
|||||||
& .hoverable-buttons {
|
& .hoverable-buttons {
|
||||||
transition: opacity ${({ theme }) => theme.animation.duration.instant}s ease;
|
transition: opacity ${({ theme }) => theme.animation.duration.instant}s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cursor: ${({ cursor }) => {
|
||||||
|
switch (cursor) {
|
||||||
|
case 'drag':
|
||||||
|
return 'grab';
|
||||||
|
case 'not-allowed':
|
||||||
|
return 'not-allowed';
|
||||||
|
default:
|
||||||
|
return 'default';
|
||||||
|
}
|
||||||
|
}};
|
||||||
`;
|
`;
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
import { useRef, useState } from 'react';
|
|
||||||
import { createPortal } from 'react-dom';
|
|
||||||
import {
|
import {
|
||||||
DropResult,
|
DropResult,
|
||||||
OnDragEndResponder,
|
OnDragEndResponder,
|
||||||
ResponderProvided,
|
ResponderProvided,
|
||||||
} from '@hello-pangea/dnd';
|
} from '@hello-pangea/dnd';
|
||||||
|
import { useRef, useState } from 'react';
|
||||||
|
import { createPortal } from 'react-dom';
|
||||||
import {
|
import {
|
||||||
AppTooltip,
|
AppTooltip,
|
||||||
IconEye,
|
IconEye,
|
||||||
@ -33,6 +33,7 @@ type ViewFieldsVisibilityDropdownSectionProps = {
|
|||||||
) => void;
|
) => void;
|
||||||
title: string;
|
title: string;
|
||||||
showSubheader: boolean;
|
showSubheader: boolean;
|
||||||
|
showDragGrip: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ViewFieldsVisibilityDropdownSection = ({
|
export const ViewFieldsVisibilityDropdownSection = ({
|
||||||
@ -42,6 +43,7 @@ export const ViewFieldsVisibilityDropdownSection = ({
|
|||||||
onVisibilityChange,
|
onVisibilityChange,
|
||||||
title,
|
title,
|
||||||
showSubheader = true,
|
showSubheader = true,
|
||||||
|
showDragGrip,
|
||||||
}: ViewFieldsVisibilityDropdownSectionProps) => {
|
}: ViewFieldsVisibilityDropdownSectionProps) => {
|
||||||
const handleOnDrag = (result: DropResult, provided: ResponderProvided) => {
|
const handleOnDrag = (result: DropResult, provided: ResponderProvided) => {
|
||||||
onDragEnd?.(result, provided);
|
onDragEnd?.(result, provided);
|
||||||
@ -107,9 +109,8 @@ export const ViewFieldsVisibilityDropdownSection = ({
|
|||||||
isTooltipOpen={openToolTipIndex === fieldIndex}
|
isTooltipOpen={openToolTipIndex === fieldIndex}
|
||||||
text={field.label}
|
text={field.label}
|
||||||
className={`${title}-fixed-item-tooltip-anchor-${fieldIndex}`}
|
className={`${title}-fixed-item-tooltip-anchor-${fieldIndex}`}
|
||||||
accent={'placeholder'}
|
accent={showDragGrip ? 'placeholder' : 'default'}
|
||||||
isHoverDisabled={field.isVisible}
|
showGrip={showDragGrip}
|
||||||
showGrip
|
|
||||||
isDragDisabled
|
isDragDisabled
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Reference in New Issue
Block a user