diff --git a/apps/web/app/globals.css b/apps/web/app/globals.css index bf9d3d5..d763014 100644 --- a/apps/web/app/globals.css +++ b/apps/web/app/globals.css @@ -144,7 +144,26 @@ * { @apply border-border outline-ring/50; } + html { + -webkit-text-size-adjust: 100%; + text-size-adjust: 100%; + /* A tap shows the control's own pressed state, not the browser's grey box. */ + -webkit-tap-highlight-color: transparent; + } body { @apply bg-background text-foreground font-sans; + /* The page stays put: no rubber-band of the whole app, no pull to refresh. */ + overscroll-behavior: none; + } + /* No double-tap zoom, so taps answer at once. */ + a, + button, + input, + label, + select, + textarea, + [role='button'], + [role='tab'] { + touch-action: manipulation; } } diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx index 6b52389..6d078fa 100644 --- a/apps/web/app/layout.tsx +++ b/apps/web/app/layout.tsx @@ -1,4 +1,4 @@ -import type { Metadata } from 'next' +import type { Metadata, Viewport } from 'next' import { SITE_NAME } from '@/lib/site' import { GeistSans } from 'geist/font/sans' import { GeistMono } from 'geist/font/mono' @@ -16,6 +16,22 @@ export const dynamic = 'force-dynamic' export const metadata: Metadata = { title: SITE_NAME, description: 'A v0.app clone built with AI Elements and Geist.', + // Added to a phone's home screen, it opens full screen, like an app. + appleWebApp: { capable: true, title: SITE_NAME, statusBarStyle: 'default' }, +} + +// A phone: the page runs edge to edge (the shell pads for the notch and the +// home bar), the keyboard shrinks the page rather than covering the composer, +// and the browser's bars take the page's colour. +export const viewport: Viewport = { + width: 'device-width', + initialScale: 1, + viewportFit: 'cover', + interactiveWidget: 'resizes-content', + themeColor: [ + { media: '(prefers-color-scheme: light)', color: '#ffffff' }, + { media: '(prefers-color-scheme: dark)', color: '#0f0f11' }, + ], } export default async function RootLayout({ diff --git a/apps/web/app/manifest.ts b/apps/web/app/manifest.ts new file mode 100644 index 0000000..9e9b029 --- /dev/null +++ b/apps/web/app/manifest.ts @@ -0,0 +1,16 @@ +import type { MetadataRoute } from 'next' +import { SITE_NAME } from '@/lib/site' + +// Installed on a phone, the app opens on its own, without the browser's bars. +export default function manifest(): MetadataRoute.Manifest { + return { + name: SITE_NAME, + short_name: SITE_NAME, + description: 'A v0.app clone built with AI Elements and Geist.', + start_url: '/', + display: 'standalone', + background_color: '#ffffff', + theme_color: '#ffffff', + icons: [{ src: '/icon.svg', sizes: 'any', type: 'image/svg+xml' }], + } +} diff --git a/apps/web/components/ai-elements/prompt-input.tsx b/apps/web/components/ai-elements/prompt-input.tsx index d4416a6..6dc9c75 100644 --- a/apps/web/components/ai-elements/prompt-input.tsx +++ b/apps/web/components/ai-elements/prompt-input.tsx @@ -775,6 +775,10 @@ export const PromptInputTextarea = ({ if (e.shiftKey) { return } + // A touch keyboard's return key starts a new line; the send button sends. + if (window.matchMedia('(pointer: coarse)').matches) { + return + } e.preventDefault() // Check if the submit button is disabled before submitting diff --git a/apps/web/components/chat/chat-conversation.tsx b/apps/web/components/chat/chat-conversation.tsx index 0d185fd..80fb2cd 100644 --- a/apps/web/components/chat/chat-conversation.tsx +++ b/apps/web/components/chat/chat-conversation.tsx @@ -249,7 +249,7 @@ export function ChatConversation({ taskDisabled={isSubmitting || restoringMessageId !== null} vercelProjectId={vercelProjectId} /> -
+
= [ + { pane: 'chat', label: 'Chat' }, + { pane: 'preview', label: 'Preview' }, + { pane: 'code', label: 'Code' }, +] + export function ChatHeader({ chatId, title, view, onViewChange, + mobilePane, + onMobilePaneChange, }: { chatId: string title: string view: ChatView onViewChange: (view: ChatView) => void + mobilePane: MobilePane + onMobilePaneChange: (pane: MobilePane) => void }) { const router = useRouter() const deployChat = useDeployChat(`/api/chats/${encodeURIComponent(chatId)}/deploy`) @@ -99,135 +113,249 @@ export function ChatHeader({ } return ( -
-
- - {title} -
- -
-
- - + <> + {/* A phone: menu, the chat's title, its actions and a new chat; then the + Chat | Preview | Code switch. */} +
+ {/* Two equal sides, so the title sits in the middle. */} +
+
+ +
+ + {title} + +
+ + + + + + {deploymentUrl ? ( + + + + View deployment + + + ) : ( + { + event.preventDefault() + void publish() + }} + title={error ?? undefined} + > + {isPublishing ? ( + + ) : ( + + )} + {isPublishing ? 'Publishing' : 'Publish'} + + )} + { + event.preventDefault() + void duplicate() + }} + > + {isDuplicating ? ( + + ) : ( + + )} + {isDuplicating ? 'Duplicating' : 'Duplicate'} + + { + event.preventDefault() + void download() + }} + > + {isDownloading ? ( + + ) : ( + + )} + {isDownloading ? 'Downloading' : 'Download'} + + + + +
+ {error || duplicateError ? ( +

+ {error ?? duplicateError} +

+ ) : null} +
+
+ {MOBILE_PANES.map(({ pane, label }) => ( + + ))} +
+
+
-
- - - / - - - - - - +
+
+ + + {title} +
-
- - - - - - { - event.preventDefault() - void duplicate() - }} - title={duplicateError ?? undefined} - > - {isDuplicating ? ( - - ) : ( - - )} - {isDuplicating ? 'Duplicating' : 'Duplicate'} - - { - event.preventDefault() - void download() - }} - title={duplicateError ?? undefined} - > - {isDownloading ? ( - - ) : ( - - )} - {isDownloading ? 'Downloading' : 'Download'} - - - - {deploymentUrl ? ( - - ) : ( +
+ +
+ + - )} + / + + + + + + +
+ +
+ + + + + + { + event.preventDefault() + void duplicate() + }} + title={duplicateError ?? undefined} + > + {isDuplicating ? ( + + ) : ( + + )} + {isDuplicating ? 'Duplicating' : 'Duplicate'} + + { + event.preventDefault() + void download() + }} + title={duplicateError ?? undefined} + > + {isDownloading ? ( + + ) : ( + + )} + {isDownloading ? 'Downloading' : 'Download'} + + + + {deploymentUrl ? ( + + ) : ( + + )} +
-
-
+ + ) } diff --git a/apps/web/components/chat/chat-workspace.tsx b/apps/web/components/chat/chat-workspace.tsx index 866a881..2ff9631 100644 --- a/apps/web/components/chat/chat-workspace.tsx +++ b/apps/web/components/chat/chat-workspace.tsx @@ -8,9 +8,10 @@ import { CodeEditorPane, type ChatFilesResult, } from '@/components/chat/code-editor' -import { ChatHeader, type ChatView } from '@/components/chat/chat-header' +import { ChatHeader, type ChatView, type MobilePane } from '@/components/chat/chat-header' import { ChatConversation } from '@/components/chat/chat-conversation' import { PreviewPane } from '@/components/preview/preview-pane' +import { cn } from '@/lib/utils' import { designModeMessageText, type DesignModeTurn } from '@/lib/design-mode-message' import type { DesignModeMessage } from 'v0/browser' @@ -25,6 +26,9 @@ export function ChatWorkspace({ }) { const router = useRouter() const [view, setView] = useState('preview') + // A phone shows one pane at a time, the chat first; a wide screen shows the + // chat beside the preview or the code. + const [mobilePane, setMobilePane] = useState('chat') const [contentRevision, setContentRevision] = useState(0) const [previewRevision, setPreviewRevision] = useState(0) const [isPreviewReady, setIsPreviewReady] = useState(false) @@ -69,16 +73,28 @@ export function ChatWorkspace({ router.refresh() }, [router]) + const handleMobilePaneChange = useCallback((pane: MobilePane) => { + setMobilePane(pane) + if (pane !== 'chat') setView(pane) + }, []) + return (
-
+
-
+
-