Room list: add fade effect to room list item being dragged (#33696)
* feat: tweak opacity of dragged room in room list * feat: put test as primary when room item is dragged * test: update screenshots
This commit is contained in:
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
+6
-1
@@ -72,7 +72,12 @@
|
|||||||
|
|
||||||
.dragging {
|
.dragging {
|
||||||
outline: 1px solid var(--cpd-color-border-interactive-hovered);
|
outline: 1px solid var(--cpd-color-border-interactive-hovered);
|
||||||
background-color: color-mix(in srgb, var(--cpd-color-bg-action-tertiary-hovered) 90%, transparent);
|
background-color: color-mix(in srgb, var(--cpd-color-bg-action-tertiary-hovered) 95%, transparent);
|
||||||
|
color: var(--cpd-color-text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dragSource .container {
|
||||||
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
|
|||||||
+4
@@ -150,6 +150,8 @@ export interface RoomListItemViewProps extends Omit<React.HTMLAttributes<HTMLBut
|
|||||||
isLastItem: boolean;
|
isLastItem: boolean;
|
||||||
/** Function to render the room avatar */
|
/** Function to render the room avatar */
|
||||||
renderAvatar: (room: Room) => ReactNode;
|
renderAvatar: (room: Room) => ReactNode;
|
||||||
|
/** Whether this item is the source of an active drag operation */
|
||||||
|
isDragSource?: boolean;
|
||||||
ref?: Ref<Element>;
|
ref?: Ref<Element>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,6 +167,7 @@ export const RoomListItemView = memo(function RoomListItemView({
|
|||||||
isFirstItem,
|
isFirstItem,
|
||||||
isLastItem,
|
isLastItem,
|
||||||
renderAvatar,
|
renderAvatar,
|
||||||
|
isDragSource = false,
|
||||||
ref,
|
ref,
|
||||||
...props
|
...props
|
||||||
}: RoomListItemViewProps): JSX.Element {
|
}: RoomListItemViewProps): JSX.Element {
|
||||||
@@ -191,6 +194,7 @@ export const RoomListItemView = memo(function RoomListItemView({
|
|||||||
[styles.bold]: item.isBold,
|
[styles.bold]: item.isBold,
|
||||||
[styles.firstItem]: isFirstItem,
|
[styles.firstItem]: isFirstItem,
|
||||||
[styles.lastItem]: isLastItem,
|
[styles.lastItem]: isLastItem,
|
||||||
|
[styles.dragSource]: isDragSource,
|
||||||
mx_RoomListItemView_selected: isSelected,
|
mx_RoomListItemView_selected: isSelected,
|
||||||
})}
|
})}
|
||||||
gap="var(--cpd-space-3x)"
|
gap="var(--cpd-space-3x)"
|
||||||
|
|||||||
+6
-2
@@ -55,12 +55,16 @@ export const RoomListItemWrapper = memo(function RoomListItemWrapper({
|
|||||||
*/
|
*/
|
||||||
function DraggableWrapper(props: RoomListItemViewProps): JSX.Element {
|
function DraggableWrapper(props: RoomListItemViewProps): JSX.Element {
|
||||||
const item = useViewModel(props.vm);
|
const item = useViewModel(props.vm);
|
||||||
const { ref: draggableRef, handleRef } = useDraggable({
|
const {
|
||||||
|
ref: draggableRef,
|
||||||
|
handleRef,
|
||||||
|
isDragSource,
|
||||||
|
} = useDraggable({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
// We clone the item in the dnd overlay to avoid putting a hole in the list
|
// We clone the item in the dnd overlay to avoid putting a hole in the list
|
||||||
plugins: [Feedback.configure({ feedback: "clone" })],
|
plugins: [Feedback.configure({ feedback: "clone" })],
|
||||||
modifiers: [RestrictToVerticalAxis],
|
modifiers: [RestrictToVerticalAxis],
|
||||||
});
|
});
|
||||||
const dndRef = useMergeRefs([draggableRef, handleRef]);
|
const dndRef = useMergeRefs([draggableRef, handleRef]);
|
||||||
return <RoomListItemView {...props} ref={dndRef} />;
|
return <RoomListItemView {...props} ref={dndRef} isDragSource={isDragSource} />;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user