feat: enhance image components with draggable attribute and context menu handling
This commit is contained in:
@@ -90,6 +90,7 @@ export const ImageViewer = as<'div', ImageViewerProps>(
|
|||||||
}}
|
}}
|
||||||
src={src}
|
src={src}
|
||||||
alt={alt}
|
alt={alt}
|
||||||
|
draggable={false}
|
||||||
onMouseDown={onMouseDown}
|
onMouseDown={onMouseDown}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -4,6 +4,12 @@ import * as css from './media.css';
|
|||||||
|
|
||||||
export const Image = forwardRef<HTMLImageElement, ImgHTMLAttributes<HTMLImageElement>>(
|
export const Image = forwardRef<HTMLImageElement, ImgHTMLAttributes<HTMLImageElement>>(
|
||||||
({ className, alt, ...props }, ref) => (
|
({ className, alt, ...props }, ref) => (
|
||||||
<img className={classNames(css.Image, className)} alt={alt} {...props} ref={ref} />
|
<img
|
||||||
|
className={classNames(css.Image, className)}
|
||||||
|
alt={alt}
|
||||||
|
draggable={false}
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
/>
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -164,7 +164,6 @@ export const ImageContent = as<'div', ImageContentProps>(
|
|||||||
<Modal
|
<Modal
|
||||||
className={ModalWide}
|
className={ModalWide}
|
||||||
size="500"
|
size="500"
|
||||||
onContextMenu={(evt: any) => evt.stopPropagation()}
|
|
||||||
>
|
>
|
||||||
{renderViewer({
|
{renderViewer({
|
||||||
src: srcState.data,
|
src: srcState.data,
|
||||||
|
|||||||
@@ -18,19 +18,19 @@ export function UnreadBadgeCenter({ children }: { children: ReactNode }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function UnreadBadge({ highlight, count }: UnreadBadgeProps) {
|
export function UnreadBadge({ highlight, count }: UnreadBadgeProps) {
|
||||||
|
if (count === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Badge
|
<Badge
|
||||||
variant={highlight ? 'Success' : 'Secondary'}
|
variant={highlight ? 'Success' : 'Secondary'}
|
||||||
size={count > 0 ? '400' : '200'}
|
size="400"
|
||||||
fill="Solid"
|
fill="Solid"
|
||||||
radii="Pill"
|
radii="Pill"
|
||||||
outlined={false}
|
outlined={false}
|
||||||
>
|
>
|
||||||
{count > 0 && (
|
|
||||||
<Text as="span" size="L400">
|
<Text as="span" size="L400">
|
||||||
{millify(count)}
|
{millify(count)}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
|
||||||
</Badge>
|
</Badge>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -919,7 +919,7 @@ export const Message = as<'div', MessageProps>(
|
|||||||
const handleContextMenu: MouseEventHandler<HTMLDivElement> = (evt) => {
|
const handleContextMenu: MouseEventHandler<HTMLDivElement> = (evt) => {
|
||||||
if (evt.altKey || !window.getSelection()?.isCollapsed || edit) return;
|
if (evt.altKey || !window.getSelection()?.isCollapsed || edit) return;
|
||||||
const tag = (evt.target as any).tagName;
|
const tag = (evt.target as any).tagName;
|
||||||
if (typeof tag === 'string' && tag.toLowerCase() === 'a') return;
|
if (typeof tag === 'string' && (tag.toLowerCase() === 'a' || tag.toLowerCase() === 'img')) return;
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
setMenuAnchor({
|
setMenuAnchor({
|
||||||
x: evt.clientX,
|
x: evt.clientX,
|
||||||
@@ -1297,7 +1297,7 @@ export const Event = as<'div', EventProps>(
|
|||||||
const handleContextMenu: MouseEventHandler<HTMLDivElement> = (evt) => {
|
const handleContextMenu: MouseEventHandler<HTMLDivElement> = (evt) => {
|
||||||
if (evt.altKey || !window.getSelection()?.isCollapsed) return;
|
if (evt.altKey || !window.getSelection()?.isCollapsed) return;
|
||||||
const tag = (evt.target as any).tagName;
|
const tag = (evt.target as any).tagName;
|
||||||
if (typeof tag === 'string' && tag.toLowerCase() === 'a') return;
|
if (typeof tag === 'string' && (tag.toLowerCase() === 'a' || tag.toLowerCase() === 'img')) return;
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
setMenuAnchor({
|
setMenuAnchor({
|
||||||
x: evt.clientX,
|
x: evt.clientX,
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ function MessageNotifications() {
|
|||||||
eventId: string;
|
eventId: string;
|
||||||
isDm: boolean;
|
isDm: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const notificationTitle = `${username} - Paarrot`;
|
const notificationTitle = username;
|
||||||
const notificationBody = messageBody || 'New message';
|
const notificationBody = messageBody || 'New message';
|
||||||
|
|
||||||
/** Replicates TitleBar click navigation logic */
|
/** Replicates TitleBar click navigation logic */
|
||||||
|
|||||||
@@ -119,10 +119,16 @@ export function DirectTab() {
|
|||||||
</SidebarAvatar>
|
</SidebarAvatar>
|
||||||
)}
|
)}
|
||||||
</SidebarItemTooltip>
|
</SidebarItemTooltip>
|
||||||
{directUnread && (
|
{directUnread && directUnread.total > 0 && (
|
||||||
<SidebarItemBadge hasCount={directUnread.total > 0}>
|
<div style={{
|
||||||
|
position: 'absolute',
|
||||||
|
bottom: '2px',
|
||||||
|
right: '2px',
|
||||||
|
pointerEvents: 'none',
|
||||||
|
zIndex: 2,
|
||||||
|
}}>
|
||||||
<UnreadBadge highlight={directUnread.highlight > 0} count={directUnread.total} />
|
<UnreadBadge highlight={directUnread.highlight > 0} count={directUnread.total} />
|
||||||
</SidebarItemBadge>
|
</div>
|
||||||
)}
|
)}
|
||||||
{menuAnchor && (
|
{menuAnchor && (
|
||||||
<PopOut
|
<PopOut
|
||||||
|
|||||||
Reference in New Issue
Block a user