fix(mobile): apply useModalStyle to 7 more modal dialogs
ScheduleMessageModal, PollCreator, JoinAddressPrompt, JumpToTime, EditHistoryModal, ForwardMessageDialog, RemindMeDialog — all now render fullscreen on mobile (≤750px) and as a capped-width box on desktop, consistent with the existing useModalStyle pattern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
|||||||
} from 'folds';
|
} from 'folds';
|
||||||
import { stopPropagation } from '../../utils/keyboard';
|
import { stopPropagation } from '../../utils/keyboard';
|
||||||
import { isRoomAlias, isRoomId } from '../../utils/matrix';
|
import { isRoomAlias, isRoomId } from '../../utils/matrix';
|
||||||
|
import { useModalStyle } from '../../hooks/useModalStyle';
|
||||||
import { parseMatrixToRoom, parseMatrixToRoomEvent, testMatrixTo } from '../../plugins/matrix-to';
|
import { parseMatrixToRoom, parseMatrixToRoomEvent, testMatrixTo } from '../../plugins/matrix-to';
|
||||||
import { tryDecodeURIComponent } from '../../utils/dom';
|
import { tryDecodeURIComponent } from '../../utils/dom';
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ type JoinAddressProps = {
|
|||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
};
|
};
|
||||||
export function JoinAddressPrompt({ onOpen, onCancel }: JoinAddressProps) {
|
export function JoinAddressPrompt({ onOpen, onCancel }: JoinAddressProps) {
|
||||||
|
const modalStyle = useModalStyle(480);
|
||||||
const [invalid, setInvalid] = useState(false);
|
const [invalid, setInvalid] = useState(false);
|
||||||
|
|
||||||
const handleSubmit: FormEventHandler<HTMLFormElement> = (evt) => {
|
const handleSubmit: FormEventHandler<HTMLFormElement> = (evt) => {
|
||||||
@@ -71,7 +73,7 @@ export function JoinAddressPrompt({ onOpen, onCancel }: JoinAddressProps) {
|
|||||||
escapeDeactivates: stopPropagation,
|
escapeDeactivates: stopPropagation,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Dialog variant="Surface">
|
<Dialog variant="Surface" style={modalStyle}>
|
||||||
<Header
|
<Header
|
||||||
style={{
|
style={{
|
||||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import {
|
|||||||
import { Room } from 'matrix-js-sdk';
|
import { Room } from 'matrix-js-sdk';
|
||||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
import { stopPropagation } from '../../utils/keyboard';
|
import { stopPropagation } from '../../utils/keyboard';
|
||||||
|
import { useModalStyle } from '../../hooks/useModalStyle';
|
||||||
|
|
||||||
interface PollCreatorProps {
|
interface PollCreatorProps {
|
||||||
roomId: string;
|
roomId: string;
|
||||||
@@ -28,6 +29,7 @@ interface PollCreatorProps {
|
|||||||
|
|
||||||
export function PollCreator({ roomId, onClose }: PollCreatorProps) {
|
export function PollCreator({ roomId, onClose }: PollCreatorProps) {
|
||||||
const mx = useMatrixClient();
|
const mx = useMatrixClient();
|
||||||
|
const modalStyle = useModalStyle(440);
|
||||||
const [question, setQuestion] = useState('');
|
const [question, setQuestion] = useState('');
|
||||||
const [options, setOptions] = useState<string[]>(['', '']);
|
const [options, setOptions] = useState<string[]>(['', '']);
|
||||||
const [isMultiple, setIsMultiple] = useState(false);
|
const [isMultiple, setIsMultiple] = useState(false);
|
||||||
@@ -109,9 +111,7 @@ export function PollCreator({ roomId, onClose }: PollCreatorProps) {
|
|||||||
background: color.Surface.Container,
|
background: color.Surface.Container,
|
||||||
borderRadius: config.radii.R400,
|
borderRadius: config.radii.R400,
|
||||||
boxShadow: color.Other.Shadow,
|
boxShadow: color.Other.Shadow,
|
||||||
width: '100vw',
|
...modalStyle,
|
||||||
maxWidth: 440,
|
|
||||||
overflow: 'hidden',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { IContent } from 'matrix-js-sdk';
|
|||||||
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../hooks/useMatrixClient';
|
||||||
import { stopPropagation } from '../../utils/keyboard';
|
import { stopPropagation } from '../../utils/keyboard';
|
||||||
import { scheduleMessage } from '../../utils/scheduledMessages';
|
import { scheduleMessage } from '../../utils/scheduledMessages';
|
||||||
|
import { useModalStyle } from '../../hooks/useModalStyle';
|
||||||
|
|
||||||
interface ScheduleMessageModalProps {
|
interface ScheduleMessageModalProps {
|
||||||
roomId: string;
|
roomId: string;
|
||||||
@@ -89,6 +90,7 @@ export function ScheduleMessageModal({
|
|||||||
onScheduled,
|
onScheduled,
|
||||||
onClose,
|
onClose,
|
||||||
}: ScheduleMessageModalProps) {
|
}: ScheduleMessageModalProps) {
|
||||||
|
const modalStyle = useModalStyle(400);
|
||||||
const mx = useMatrixClient();
|
const mx = useMatrixClient();
|
||||||
const [messageText, setMessageText] = useState(initialBody ?? '');
|
const [messageText, setMessageText] = useState(initialBody ?? '');
|
||||||
const [submitting, setSubmitting] = useState(false);
|
const [submitting, setSubmitting] = useState(false);
|
||||||
@@ -186,9 +188,7 @@ export function ScheduleMessageModal({
|
|||||||
background: color.Surface.Container,
|
background: color.Surface.Container,
|
||||||
borderRadius: config.radii.R400,
|
borderRadius: config.radii.R400,
|
||||||
boxShadow: color.Other.Shadow,
|
boxShadow: color.Other.Shadow,
|
||||||
width: '100vw',
|
...modalStyle,
|
||||||
maxWidth: 400,
|
|
||||||
overflow: 'hidden',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import { getToday, getYesterday, timeDayMonthYear, timeHourMinute } from '../../
|
|||||||
import { DatePicker, TimePicker } from '../../../components/time-date';
|
import { DatePicker, TimePicker } from '../../../components/time-date';
|
||||||
import { useSetting } from '../../../state/hooks/settings';
|
import { useSetting } from '../../../state/hooks/settings';
|
||||||
import { settingsAtom } from '../../../state/settings';
|
import { settingsAtom } from '../../../state/settings';
|
||||||
|
import { useModalStyle } from '../../../hooks/useModalStyle';
|
||||||
|
|
||||||
type JumpToTimeProps = {
|
type JumpToTimeProps = {
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
@@ -38,6 +39,7 @@ type JumpToTimeProps = {
|
|||||||
};
|
};
|
||||||
export function JumpToTime({ onCancel, onSubmit }: JumpToTimeProps) {
|
export function JumpToTime({ onCancel, onSubmit }: JumpToTimeProps) {
|
||||||
const mx = useMatrixClient();
|
const mx = useMatrixClient();
|
||||||
|
const modalStyle = useModalStyle(480);
|
||||||
const room = useRoom();
|
const room = useRoom();
|
||||||
const alive = useAlive();
|
const alive = useAlive();
|
||||||
const createStateEvent = useStateEvent(room, StateEvent.RoomCreate);
|
const createStateEvent = useStateEvent(room, StateEvent.RoomCreate);
|
||||||
@@ -96,7 +98,7 @@ export function JumpToTime({ onCancel, onSubmit }: JumpToTimeProps) {
|
|||||||
escapeDeactivates: stopPropagation,
|
escapeDeactivates: stopPropagation,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Dialog variant="Surface">
|
<Dialog variant="Surface" style={modalStyle}>
|
||||||
<Header
|
<Header
|
||||||
style={{
|
style={{
|
||||||
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
padding: `0 ${config.space.S200} 0 ${config.space.S400}`,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {
|
|||||||
import { MatrixEvent, Room } from 'matrix-js-sdk';
|
import { MatrixEvent, Room } from 'matrix-js-sdk';
|
||||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||||
import { stopPropagation } from '../../../utils/keyboard';
|
import { stopPropagation } from '../../../utils/keyboard';
|
||||||
|
import { useModalStyle } from '../../../hooks/useModalStyle';
|
||||||
import { sanitizeCustomHtml } from '../../../utils/sanitize';
|
import { sanitizeCustomHtml } from '../../../utils/sanitize';
|
||||||
import { LINKIFY_OPTS } from '../../../plugins/react-custom-html-parser';
|
import { LINKIFY_OPTS } from '../../../plugins/react-custom-html-parser';
|
||||||
import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
|
import { AsyncStatus, useAsyncCallback } from '../../../hooks/useAsyncCallback';
|
||||||
@@ -92,6 +93,7 @@ function getVersionContent(evt: MatrixEvent): ReactNode {
|
|||||||
|
|
||||||
export function EditHistoryModal({ room, mEvent, onClose }: EditHistoryModalProps) {
|
export function EditHistoryModal({ room, mEvent, onClose }: EditHistoryModalProps) {
|
||||||
const mx = useMatrixClient();
|
const mx = useMatrixClient();
|
||||||
|
const modalStyle = useModalStyle(560);
|
||||||
const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock');
|
const [hour24Clock] = useSetting(settingsAtom, 'hour24Clock');
|
||||||
const [dateFormatString] = useSetting(settingsAtom, 'dateFormatString');
|
const [dateFormatString] = useSetting(settingsAtom, 'dateFormatString');
|
||||||
|
|
||||||
@@ -167,6 +169,7 @@ export function EditHistoryModal({ room, mEvent, onClose }: EditHistoryModalProp
|
|||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
aria-labelledby="edit-history-title"
|
aria-labelledby="edit-history-title"
|
||||||
|
style={modalStyle}
|
||||||
>
|
>
|
||||||
<Header
|
<Header
|
||||||
variant="Surface"
|
variant="Surface"
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { MatrixEvent, Room } from 'matrix-js-sdk';
|
|||||||
import { useAtomValue } from 'jotai';
|
import { useAtomValue } from 'jotai';
|
||||||
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
import { useMatrixClient } from '../../../hooks/useMatrixClient';
|
||||||
import { stopPropagation } from '../../../utils/keyboard';
|
import { stopPropagation } from '../../../utils/keyboard';
|
||||||
|
import { useModalStyle } from '../../../hooks/useModalStyle';
|
||||||
import { mDirectAtom } from '../../../state/mDirectList';
|
import { mDirectAtom } from '../../../state/mDirectList';
|
||||||
import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
|
import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication';
|
||||||
import { mxcUrlToHttp } from '../../../utils/matrix';
|
import { mxcUrlToHttp } from '../../../utils/matrix';
|
||||||
@@ -78,6 +79,7 @@ type Props = {
|
|||||||
|
|
||||||
export function ForwardMessageDialog({ mEvent, onClose }: Props) {
|
export function ForwardMessageDialog({ mEvent, onClose }: Props) {
|
||||||
const mx = useMatrixClient();
|
const mx = useMatrixClient();
|
||||||
|
const modalStyle = useModalStyle(400);
|
||||||
const directs = useAtomValue(mDirectAtom);
|
const directs = useAtomValue(mDirectAtom);
|
||||||
const useAuthentication = useMediaAuthentication();
|
const useAuthentication = useMediaAuthentication();
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState('');
|
||||||
@@ -129,6 +131,7 @@ export function ForwardMessageDialog({ mEvent, onClose }: Props) {
|
|||||||
borderRadius: config.radii.R500,
|
borderRadius: config.radii.R500,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
|
...modalStyle,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
} from 'folds';
|
} from 'folds';
|
||||||
import { stopPropagation } from '../../../utils/keyboard';
|
import { stopPropagation } from '../../../utils/keyboard';
|
||||||
import { useReminders } from '../../../hooks/useReminders';
|
import { useReminders } from '../../../hooks/useReminders';
|
||||||
|
import { useModalStyle } from '../../../hooks/useModalStyle';
|
||||||
|
|
||||||
type RemindMeDialogProps = {
|
type RemindMeDialogProps = {
|
||||||
roomId: string;
|
roomId: string;
|
||||||
@@ -39,6 +40,7 @@ function getPresets(): Array<{ label: string; ms: number }> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function RemindMeDialog({ roomId, eventId, previewText, onClose }: RemindMeDialogProps) {
|
export function RemindMeDialog({ roomId, eventId, previewText, onClose }: RemindMeDialogProps) {
|
||||||
|
const modalStyle = useModalStyle(320);
|
||||||
const { addReminder } = useReminders();
|
const { addReminder } = useReminders();
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
const presets = useMemo(() => getPresets(), []);
|
const presets = useMemo(() => getPresets(), []);
|
||||||
@@ -73,8 +75,7 @@ export function RemindMeDialog({ roomId, eventId, previewText, onClose }: Remind
|
|||||||
background: color.Surface.Container,
|
background: color.Surface.Container,
|
||||||
borderRadius: config.radii.R400,
|
borderRadius: config.radii.R400,
|
||||||
boxShadow: color.Other.Shadow,
|
boxShadow: color.Other.Shadow,
|
||||||
width: '100vw',
|
...modalStyle,
|
||||||
maxWidth: 280,
|
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user