Skip to content

Commit

Permalink
Merge pull request #1115 from mfts/fix/invite-group
Browse files Browse the repository at this point in the history
fix: improve document nav on mobile devices
  • Loading branch information
mfts authored Oct 18, 2024
2 parents e235e70 + c53e064 commit 10e2be7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 20 deletions.
45 changes: 34 additions & 11 deletions components/ui/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,42 @@ const TooltipTrigger = TooltipPrimitive.Trigger;

const TooltipPortal = TooltipPrimitive.Portal;

const TooltipArrow = TooltipPrimitive.Arrow;

const TooltipContent = React.forwardRef<
React.ElementRef<typeof TooltipPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
<TooltipPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> & {
arrow?: boolean;
arrowClassName?: string;
}
>(
(
{
className,
)}
{...props}
/>
));
sideOffset = 4,
children,
arrow = false,
arrowClassName,
...props
},
ref,
) => (
<TooltipPrimitive.Content
ref={ref}
sideOffset={sideOffset}
className={cn(
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className,
)}
{...props}
>
{children}
{arrow ? (
<TooltipArrow className={cn("fill-popover", arrowClassName)} />
) : null}
</TooltipPrimitive.Content>
),
);
TooltipContent.displayName = TooltipPrimitive.Content.displayName;

export const BadgeTooltip = ({
Expand Down Expand Up @@ -77,6 +99,7 @@ export {
Tooltip,
TooltipTrigger,
TooltipPortal,
TooltipArrow,
TooltipContent,
TooltipProvider,
};
14 changes: 7 additions & 7 deletions components/view/nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export default function Nav({
</Breadcrumb>
) : null}
</div>
<div className="absolute inset-y-0 right-0 flex items-center space-x-4 pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0">
<div className="absolute inset-y-0 right-0 flex items-center space-x-2 pr-2 sm:static sm:inset-auto sm:ml-6 sm:space-x-4 sm:pr-0">
{embeddedLinks && embeddedLinks.length > 0 ? (
<DropdownMenu>
<DropdownMenuTrigger>
Expand Down Expand Up @@ -241,15 +241,15 @@ export default function Nav({
{allowDownload ? (
<Button
onClick={downloadFile}
className="m-1 bg-gray-900 text-white hover:bg-gray-900/80"
className="size-8 bg-gray-900 text-white hover:bg-gray-900/80 sm:size-10"
size="icon"
title="Download document"
>
<Download className="h-5 w-5" />
<Download className="size-4 sm:size-5" />
</Button>
) : null}

{!(isVertical && isMobile) && documentRefs ? (
{!isMobile && documentRefs ? (
<div className="flex gap-1">
<Button
onClick={() => {
Expand Down Expand Up @@ -296,16 +296,16 @@ export default function Nav({
</div>
) : null}
{pageNumber && numPages ? (
<div className="flex h-10 items-center rounded-md bg-gray-900 px-4 py-2 text-sm font-medium text-white">
<div className="flex h-8 items-center space-x-1 rounded-md bg-gray-900 px-3 py-1.5 text-xs font-medium text-white sm:h-10 sm:px-4 sm:py-2 sm:text-sm">
<span style={{ fontVariantNumeric: "tabular-nums" }}>
{pageNumber}
</span>
<span className="text-gray-400">/</span>
<span
className="text-gray-400"
style={{ fontVariantNumeric: "tabular-nums" }}
>
{" "}
/ {numPages}
{numPages}
</span>
</div>
) : null}
Expand Down
4 changes: 2 additions & 2 deletions components/view/report-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ export default function ReportForm({
>
<PopoverTrigger asChild>
<Button
className="m-1 bg-gray-900 text-gray-300 hover:bg-gray-900/80 hover:text-gray-50"
className="h-8 w-8 bg-gray-900 text-xs text-gray-300 hover:bg-gray-900/80 hover:text-gray-50 sm:h-10 sm:w-10 sm:text-sm"
size="icon"
title="Report abuse"
>
<Flag className="h-4 w-4" />
<Flag className="size-3 sm:size-4" />
</Button>
</PopoverTrigger>
</ButtonTooltip>
Expand Down

0 comments on commit 10e2be7

Please sign in to comment.