Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

Revert "💄 Mobile-friendly buttons and dialogs (#3546)"

Luke Vellaaebd898aa7ff
diff --git a/apps/web/src/features/poll/components/mobile-poll.tsx b/apps/web/src/features/poll/components/mobile-poll.tsx
index c89ef3055..84d459ad6 100644
--- a/apps/web/src/features/poll/components/mobile-poll.tsx
+++ b/apps/web/src/features/poll/components/mobile-poll.tsx
@@ -143,7 +143,7 @@ const MobilePoll: React.FunctionComponent = () => {
</SelectContent>
</Select>
) : (
- <div className="flex min-h-9 grow items-center px-1">
+ <div className="flex h-9 grow items-center px-1">
<Participant>
<YouAvatar />
<ParticipantName>
diff --git a/apps/web/src/features/poll/components/new-participant-modal.tsx b/apps/web/src/features/poll/components/new-participant-modal.tsx
index f842b6489..6b83e98b5 100644
--- a/apps/web/src/features/poll/components/new-participant-modal.tsx
+++ b/apps/web/src/features/poll/components/new-participant-modal.tsx
@@ -253,9 +253,7 @@ export const NewParticipantForm = (props: NewParticipantModalProps) => {
return (
<>
- {/* The vote that opened this dialog already says what it is for. The
- title stays in the DOM to name the dialog via aria-labelledby. */}
- <DialogHeader className="max-sm:hidden">
+ <DialogHeader>
<DialogTitle>
<Trans i18nKey="newParticipant" defaults="New participant" />
</DialogTitle>
@@ -434,12 +432,7 @@ export const NewParticipantForm = (props: NewParticipantModalProps) => {
</form>
</Form>
<DialogFooter>
- <Button
- type="button"
- variant="ghost"
- className="max-sm:hidden"
- onClick={props.onCancel}
- >
+ <Button type="button" variant="ghost" onClick={props.onCancel}>
{t("back")}
</Button>
<Button
diff --git a/apps/web/src/features/poll/components/voting-form.tsx b/apps/web/src/features/poll/components/voting-form.tsx
index 185a0cafc..198d024e9 100644
--- a/apps/web/src/features/poll/components/voting-form.tsx
+++ b/apps/web/src/features/poll/components/voting-form.tsx
@@ -154,7 +154,7 @@ export const VotingForm = ({ children }: React.PropsWithChildren) => {
open={isNewParticipantModalOpen}
onOpenChange={setIsNewParticipantModalOpen}
>
- <DialogContent size="sm" fullScreenOnMobile>
+ <DialogContent size="sm">
<NewParticipantForm
votes={normalizeVotes(optionIds, form.watch("votes"))}
onSubmit={(newParticipant) => {
diff --git a/apps/web/src/features/poll/vote/components/vote-form.tsx b/apps/web/src/features/poll/vote/components/vote-form.tsx
index 7aaa2bfdc..ccd35826c 100644
--- a/apps/web/src/features/poll/vote/components/vote-form.tsx
+++ b/apps/web/src/features/poll/vote/components/vote-form.tsx
@@ -286,7 +286,7 @@ export function VoteForm({
open={isNewParticipantOpen}
onOpenChange={setIsNewParticipantOpen}
>
- <DialogContent size="sm" fullScreenOnMobile>
+ <DialogContent size="sm">
<NewParticipantForm
pollId={pollId}
requireParticipantEmail={requireParticipantEmail}
diff --git a/packages/tailwind-config/shared-styles.css b/packages/tailwind-config/shared-styles.css
index 39045421d..6fa44daa4 100644
--- a/packages/tailwind-config/shared-styles.css
+++ b/packages/tailwind-config/shared-styles.css
@@ -2,8 +2,8 @@
@custom-variant dark (&:where(.dark, .dark *));
/* A dialog header or footer at the top level of the dialog's scroll area
- * (directly, or inside a top-level form or wizard step), where it spans the
- * dialog's edges. */
+ * (directly, or inside a top-level form or wizard step), where it pins to
+ * the edge. */
@custom-variant dialog-edge (:is(
[data-slot="dialog-scroller"],
[data-slot="dialog-scroller"] > form,
diff --git a/packages/ui/src/button-variants.ts b/packages/ui/src/button-variants.ts
index 7ce4433d1..ca472fe60 100644
--- a/packages/ui/src/button-variants.ts
+++ b/packages/ui/src/button-variants.ts
@@ -22,14 +22,13 @@ export const buttonVariants = cva(
link: "border-transparent text-primary underline-offset-4 hover:underline",
},
size: {
- // Below sm the default sizes grow to a 44px touch target.
default:
- "h-9 gap-1.5 px-4 text-sm has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 max-sm:h-11 max-sm:gap-2 max-sm:px-5 max-sm:text-base max-sm:has-data-[icon=inline-end]:pr-3.5 max-sm:has-data-[icon=inline-start]:pl-3.5",
+ "h-9 gap-1.5 px-4 text-sm has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5",
xs: "h-6 gap-1 px-2.5 text-xs has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
sm: "h-7 gap-1.5 px-3 text-sm has-data-[icon=inline-end]:pr-1.75 has-data-[icon=inline-start]:pl-1.75 [&_svg:not([class*='size-'])]:size-3.5",
lg: "h-10 gap-1.5 px-4.5 text-sm has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",
xl: "h-12 gap-2 px-5.5 text-base has-data-[icon=inline-end]:pr-3.75 has-data-[icon=inline-start]:pl-3.75 [&_svg:not([class*='size-'])]:size-4.5",
- icon: "size-9 max-sm:size-11",
+ icon: "size-9",
"icon-xs": "size-6 [&_svg:not([class*='size-'])]:size-3",
"icon-sm": "size-7",
"icon-lg": "size-10",
diff --git a/packages/ui/src/dialog.tsx b/packages/ui/src/dialog.tsx
index 86c8d251a..ca652d9ca 100644
--- a/packages/ui/src/dialog.tsx
+++ b/packages/ui/src/dialog.tsx
@@ -5,7 +5,6 @@ import type { VariantProps } from "class-variance-authority";
import { cva } from "class-variance-authority";
import { XIcon } from "lucide-react";
import React from "react";
-import { buttonVariants } from "./button-variants";
import { cn } from "./lib/utils";
function Dialog({ ...props }: DialogPrimitive.Root.Props) {
@@ -50,7 +49,7 @@ function DialogOverlay({
const dialogVariants = cva(
cn(
- "data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 relative my-auto flex w-full shrink-0 flex-col overflow-hidden rounded-2xl border border-popover-border bg-popover shadow-lg outline-none duration-200 data-closed:animate-out data-open:animate-in",
+ "data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 fixed top-[50%] left-[50%] z-50 flex max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] flex-col overflow-hidden rounded-2xl border border-popover-border bg-popover shadow-lg outline-none duration-200 data-closed:animate-out data-open:animate-in",
),
{
variants: {
@@ -75,64 +74,33 @@ function DialogContent({
children,
showCloseButton = true,
size = "md",
- fullScreenOnMobile = false,
...props
}: DialogPrimitive.Popup.Props &
VariantProps<typeof dialogVariants> & {
showCloseButton?: boolean;
- /**
- * Below the `sm` breakpoint the dialog fills the viewport and a short
- * dialog's footer sits on the bottom edge. Use for form dialogs, not
- * confirmations.
- */
- fullScreenOnMobile?: boolean;
}) {
return (
<DialogPortal data-slot="dialog-portal">
<DialogOverlay />
- {/* A dialog taller than the screen scrolls as one card inside the
- viewport rather than scrolling its own content. */}
- <DialogPrimitive.Viewport
- data-slot="dialog-viewport"
- className={cn(
- "fixed inset-0 z-50 flex flex-col items-center overflow-y-auto overscroll-contain p-4",
- fullScreenOnMobile && "max-sm:p-0",
- )}
+ <DialogPrimitive.Popup
+ data-slot="dialog-content"
+ className={cn(dialogVariants({ size }), className)}
+ data-close-button={showCloseButton ? "" : undefined}
+ {...props}
>
- <DialogPrimitive.Popup
- data-slot="dialog-content"
- className={cn(
- dialogVariants({ size }),
- fullScreenOnMobile &&
- "max-sm:my-0 max-sm:min-h-dvh max-sm:rounded-none max-sm:border-0",
- className,
- )}
- data-close-button={showCloseButton ? "" : undefined}
- {...props}
+ <div
+ data-slot="dialog-scroller"
+ className="grid min-h-0 grow gap-4 overflow-y-auto overscroll-contain p-4"
>
- <div
- data-slot="dialog-scroller"
- className={cn(
- "grid gap-4 p-4",
- fullScreenOnMobile &&
- "max-sm:flex max-sm:grow max-sm:flex-col max-sm:*:data-[slot=dialog-footer]:mt-auto! max-sm:*:data-[slot=dialog-footer]:pb-[max(0.75rem,env(safe-area-inset-bottom))]!",
- )}
- >
- {children}
- </div>
- {showCloseButton && (
- <DialogClose
- className={cn(
- buttonVariants({ variant: "ghost", size: "icon" }),
- "absolute top-2 right-2 z-20 max-sm:top-1 max-sm:right-1 max-sm:size-10",
- )}
- >
- <XIcon />
- <span className="sr-only">Close</span>
- </DialogClose>
- )}
- </DialogPrimitive.Popup>
- </DialogPrimitive.Viewport>
+ {children}
+ </div>
+ {showCloseButton && (
+ <DialogClose className="absolute top-4 right-4 z-20 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0">
+ <XIcon />
+ <span className="sr-only">Close</span>
+ </DialogClose>
+ )}
+ </DialogPrimitive.Popup>
</DialogPortal>
);
}
@@ -142,9 +110,9 @@ function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
<div
data-slot="dialog-header"
className={cn(
- "dialog-edge:pb-2",
+ "dialog-edge:sticky dialog-edge:-top-4 dialog-edge:z-10 dialog-edge:-mx-4 dialog-edge:-mt-4 dialog-edge:bg-popover dialog-edge:px-4 dialog-edge:pt-4 dialog-edge:pb-2",
// Only the first row sits beside the close button.
- "dialog-edge:in-data-close-button:*:first:pr-10",
+ "dialog-edge:in-data-close-button:*:first:pr-8",
className,
)}
{...props}
@@ -158,7 +126,7 @@ function DialogFooter({ className, ...props }: React.ComponentProps<"div">) {
data-slot="dialog-footer"
className={cn(
"flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
- "dialog-edge:-mx-4 dialog-edge:mt-2 dialog-edge:-mb-4 dialog-edge:border-popover-border dialog-edge:border-t dialog-edge:bg-card dialog-edge:px-4 dialog-edge:py-3",
+ "dialog-edge:sticky dialog-edge:-bottom-4 dialog-edge:z-10 dialog-edge:-mx-4 dialog-edge:mt-2 dialog-edge:-mb-4 dialog-edge:border-popover-border dialog-edge:border-t dialog-edge:bg-card dialog-edge:px-4 dialog-edge:py-3",
className,
)}
{...props}