Pin phone sheets to the visible viewport, and let people correct login and organizer errors.
This commit is contained in:
1 parent
27d74e510c
commit
39807ef452
17 files changed
+236
-16
No files matched your search
@@ -48,7 +48,7 @@ const CreateContainer = memo<CreateProps>(
|
||||
}) => {
|
||||
const createRef = useRef<HTMLDivElement>(null);
|
||||
const overlayRef = useRef<HTMLDivElement>(null);
|
||||
const viewportHeight = useVisualViewportHeight(
|
||||
const viewport = useVisualViewportHeight(
|
||||
isOpen && presentation === "sheet",
|
||||
);
|
||||
|
||||
@@ -92,7 +92,8 @@ const CreateContainer = memo<CreateProps>(
|
||||
kebabMenuItems={kebabMenuItems}
|
||||
belowCard={belowCard}
|
||||
presentation={presentation}
|
||||
viewportHeight={viewportHeight}
|
||||
viewportHeight={viewport?.height}
|
||||
viewportOffsetTop={viewport?.offsetTop}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -95,4 +95,6 @@ export interface CreateViewProps {
|
||||
belowCard?: React.ReactNode;
|
||||
presentation: CreateModalPresentationValue;
|
||||
viewportHeight?: number;
|
||||
/** `visualViewport.offsetTop`, so a phone sheet tracks the visible region on iOS. */
|
||||
viewportOffsetTop?: number;
|
||||
}
|
||||
@@ -43,6 +43,7 @@ export function CreateView({
|
||||
belowCard,
|
||||
presentation,
|
||||
viewportHeight,
|
||||
viewportOffsetTop,
|
||||
}: CreateViewProps) {
|
||||
return (
|
||||
<CreateModalFrameView
|
||||
@@ -57,6 +58,7 @@ export function CreateView({
|
||||
belowCard={belowCard}
|
||||
presentation={presentation}
|
||||
viewportHeight={viewportHeight}
|
||||
viewportOffsetTop={viewportOffsetTop}
|
||||
>
|
||||
<ModalHeader
|
||||
onClose={onClose}
|
||||
|
||||
@@ -33,6 +33,8 @@ export type CreateModalFrameViewProps = {
|
||||
presentation?: CreateModalPresentationValue;
|
||||
/** Visible viewport height so a phone sheet footer rides above the keyboard. */
|
||||
viewportHeight?: number;
|
||||
/** `visualViewport.offsetTop`, so the sheet tracks the visible region on iOS. */
|
||||
viewportOffsetTop?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -51,6 +53,7 @@ export function CreateModalFrameView({
|
||||
belowCard,
|
||||
presentation = "dialog",
|
||||
viewportHeight,
|
||||
viewportOffsetTop,
|
||||
}: CreateModalFrameViewProps) {
|
||||
if (!isOpen) return null;
|
||||
|
||||
@@ -65,7 +68,12 @@ export function CreateModalFrameView({
|
||||
: "flex min-h-0 max-h-[90vh] w-full max-w-[560px] shrink-0 flex-col overflow-hidden rounded-[var(--radius-500)] bg-[var(--color-surface-default-primary)] shadow-[0px_0px_48px_0px_rgba(0,0,0,0.1)] z-[9999]";
|
||||
const overlayStyle =
|
||||
isSheet && viewportHeight != null
|
||||
? { height: viewportHeight, maxHeight: viewportHeight }
|
||||
? {
|
||||
top: viewportOffsetTop ?? 0,
|
||||
bottom: "auto" as const,
|
||||
height: viewportHeight,
|
||||
maxHeight: viewportHeight,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
const content = (
|
||||
|
||||
Reference in new issue
Block a user