feat(webui): refine mobile message actions and hover timestamps
This commit is contained in:
1 parent
4693bba81f
commit
7aac9355ec
10 files changed
+334
-73
No files matched your search
@@ -38,9 +38,10 @@ const DialogPositionedContent = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
|
||||
positionerStyle?: React.CSSProperties;
|
||||
placement?: "center" | "bottom";
|
||||
}
|
||||
>(({ positionerStyle, ...props }, ref) => (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center p-4" style={positionerStyle}>
|
||||
>(({ positionerStyle, placement, ...props }, ref) => (
|
||||
<div className={cn("fixed inset-0 z-50 flex justify-center", placement === "bottom" ? "items-end" : "items-center p-4")} style={positionerStyle}>
|
||||
<DialogPrimitive.Content ref={ref} {...props} />
|
||||
</div>
|
||||
));
|
||||
@@ -50,19 +51,20 @@ interface DialogContentProps
|
||||
extends React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> {
|
||||
showCloseButton?: boolean;
|
||||
overlayClassName?: string;
|
||||
placement?: "center" | "bottom";
|
||||
}
|
||||
|
||||
const DialogContent = React.forwardRef<
|
||||
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||
DialogContentProps
|
||||
>(({ className, children, showCloseButton = true, overlayClassName, onOpenAutoFocus, ...props }, ref) => {
|
||||
>(({ className, children, showCloseButton = true, overlayClassName, placement = "center", onOpenAutoFocus, ...props }, ref) => {
|
||||
const { t } = useTranslation();
|
||||
const [container, setContainer] = React.useState<HTMLDivElement | null>(null);
|
||||
const contentNode = React.useRef<HTMLDivElement | null>(null);
|
||||
const layoutAnchor = React.useContext(DialogLayoutContext);
|
||||
const [layout, setLayout] = React.useState<React.CSSProperties>();
|
||||
React.useLayoutEffect(() => {
|
||||
if (!layoutAnchor) {
|
||||
if (!layoutAnchor || placement === "bottom") {
|
||||
setLayout(undefined);
|
||||
return;
|
||||
}
|
||||
@@ -81,7 +83,7 @@ const DialogContent = React.forwardRef<
|
||||
observer?.disconnect();
|
||||
window.removeEventListener("resize", update);
|
||||
};
|
||||
}, [layoutAnchor]);
|
||||
}, [layoutAnchor, placement]);
|
||||
const contentRef = React.useCallback((node: HTMLDivElement | null) => {
|
||||
contentNode.current = node;
|
||||
setContainer(node);
|
||||
@@ -93,6 +95,7 @@ const DialogContent = React.forwardRef<
|
||||
<DialogOverlay className={overlayClassName} />
|
||||
<DialogPositionedContent
|
||||
positionerStyle={layout}
|
||||
placement={placement}
|
||||
ref={contentRef}
|
||||
onOpenAutoFocus={(event) => {
|
||||
if (onOpenAutoFocus) onOpenAutoFocus(event);
|
||||
@@ -103,7 +106,10 @@ const DialogContent = React.forwardRef<
|
||||
}}
|
||||
className={cn(
|
||||
modalSurfaceClassName,
|
||||
"relative grid w-full max-w-lg origin-center gap-4 rounded-modal p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 motion-reduce:animate-none",
|
||||
"relative grid w-full max-w-lg gap-4 p-6 duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 motion-reduce:animate-none",
|
||||
placement === "bottom"
|
||||
? "max-h-[85dvh] overflow-y-auto overscroll-contain rounded-t-modal pb-[max(1rem,env(safe-area-inset-bottom))] data-[state=open]:slide-in-from-bottom-4 data-[state=closed]:slide-out-to-bottom-4"
|
||||
: "origin-center rounded-modal data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
@@ -112,7 +118,7 @@ const DialogContent = React.forwardRef<
|
||||
{children}
|
||||
</FloatingPortalContext.Provider>
|
||||
{showCloseButton ? (
|
||||
<DialogPrimitive.Close className="absolute right-2.5 top-2.5 grid h-7 w-7 place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground active:bg-muted/80 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none">
|
||||
<DialogPrimitive.Close className={cn("absolute right-2.5 top-2.5 grid place-items-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground active:bg-muted/80 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none", placement === "bottom" ? "h-11 w-11" : "h-7 w-7")}>
|
||||
<X className="h-4 w-4" />
|
||||
<span className="sr-only">{t("common.close")}</span>
|
||||
</DialogPrimitive.Close>
|
||||
|
||||
Reference in new issue
Block a user