diff --git a/AGENTS.md b/AGENTS.md index 16bed86..7377980 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -18,7 +18,3 @@ The rest of this document is meant to help you navigate the codebase and make ch - Inferred types over annotations. `any` is the enemy. - Comments describe how a thing is used, and move when the code moves. To be used mostly to describe functions, not to annotate every line of behavior. - If a rule here fights the task in front of you, say so loudly and get a human sign-off before breaking it. - -## Additional tips - -- Don't verify with browsers or computer use unless the user explicitly agrees or requests it. diff --git a/src/components/AppNavbar.tsx b/src/components/AppNavbar.tsx index 8af4a7e..5417877 100644 --- a/src/components/AppNavbar.tsx +++ b/src/components/AppNavbar.tsx @@ -1,4 +1,4 @@ -import { createHotkey, formatForDisplay, type HotkeySequence } from "@tanstack/solid-hotkeys"; +import { createHotkey, type HotkeySequence } from "@tanstack/solid-hotkeys"; import { useNavigate } from "@tanstack/solid-router"; import { useServerFn } from "@tanstack/solid-start"; @@ -6,6 +6,7 @@ import { signOutFn } from "@/modules/auth/serverFunctions"; import { Button } from "./ui/Button"; import { ButtonLink } from "./ui/ButtonLink"; +import { HotkeyHint } from "./ui/HotkeyHint"; export function AppNavbar() { const signOut = useServerFn(signOutFn); @@ -32,18 +33,22 @@ export function AppNavbar() { >
- bg · {formatForDisplay(organizationsHotkeySequence).toLocaleLowerCase()} + bg + - - organizations · {formatForDisplay(organizationsHotkeySequence).toLocaleLowerCase()} + + organizations + - settings · {formatForDisplay(settingsHotkeySequence).toLocaleLowerCase()} + settings +
diff --git a/src/components/ui/HotkeyHint.tsx b/src/components/ui/HotkeyHint.tsx new file mode 100644 index 0000000..a7e2a56 --- /dev/null +++ b/src/components/ui/HotkeyHint.tsx @@ -0,0 +1,12 @@ +import { createFormatForDisplay, type DisplayHotkey } from "@tanstack/solid-hotkeys"; + +/** Renders ` · g h` after a label: `<>settings`. Hidden on touch screens. */ +export function HotkeyHint(props: { hotkey: DisplayHotkey }) { + const formatForDisplay = createFormatForDisplay(); + return ( + + {" "} + · {formatForDisplay(props.hotkey).toLocaleLowerCase()} + + ); +} diff --git a/src/modules/auth/components/SignInForm.test.tsx b/src/modules/auth/components/SignInForm.test.tsx index 5bf0c8d..e6e313b 100644 --- a/src/modules/auth/components/SignInForm.test.tsx +++ b/src/modules/auth/components/SignInForm.test.tsx @@ -17,7 +17,7 @@ const mocks = vi.hoisted(() => ({ vi.mock("@tanstack/solid-hotkeys", () => ({ createHotkey: (hotkey: { key: string } | string[], callback: () => unknown) => mocks.shortcuts.set(Array.isArray(hotkey) ? hotkey.join(",") : hotkey.key, callback), - formatForDisplay: () => "shortcut", + createFormatForDisplay: () => () => "shortcut", })); vi.mock("@tanstack/solid-router", () => ({ diff --git a/src/modules/auth/components/SignInForm.tsx b/src/modules/auth/components/SignInForm.tsx index c32a0d8..9608641 100644 --- a/src/modules/auth/components/SignInForm.tsx +++ b/src/modules/auth/components/SignInForm.tsx @@ -1,7 +1,6 @@ import { FieldApi, FormApi } from "@tanstack/form-core"; import { createHotkey, - formatForDisplay, type HotkeySequence, type RegisterableHotkey, } from "@tanstack/solid-hotkeys"; @@ -17,6 +16,7 @@ import { SUBMIT_HOTKEY, } from "@/components/forms/FormControls"; import { Button, buttonVariants } from "@/components/ui/Button"; +import { HotkeyHint } from "@/components/ui/HotkeyHint"; import { Separator } from "@/components/ui/Separator"; import { useField, useForm } from "@/lib/form"; import { destinationAfterAuth, inviteTokenFromHash } from "@/modules/organizations/inviteToken"; @@ -123,7 +123,8 @@ export function SignInForm() { field={password()} /> - sign in · {formatForDisplay(SUBMIT_HOTKEY).toLocaleLowerCase()} + sign in + @@ -135,15 +136,17 @@ export function SignInForm() { disabled={isPasskeyPending()} onClick={signInWithPasskey} > - {isPasskeyPending() - ? "..." - : `use passkey · ${formatForDisplay(passkeyHotkey).toLocaleLowerCase()}`} + + use passkey + +

don't have an account?{" "} - sign up · {formatForDisplay(signUpHotkeySequence).toLocaleLowerCase()} + sign up +

diff --git a/src/modules/auth/components/SignUpForm.tsx b/src/modules/auth/components/SignUpForm.tsx index 22dbbd3..5deb8d6 100644 --- a/src/modules/auth/components/SignUpForm.tsx +++ b/src/modules/auth/components/SignUpForm.tsx @@ -1,5 +1,5 @@ import { FieldApi, FormApi, revalidateLogic } from "@tanstack/form-core"; -import { createHotkey, formatForDisplay, type HotkeySequence } from "@tanstack/solid-hotkeys"; +import { createHotkey, type HotkeySequence } from "@tanstack/solid-hotkeys"; import { Link, useLocation, useNavigate, useRouter } from "@tanstack/solid-router"; import { useServerFn } from "@tanstack/solid-start"; import { createSignal, Show } from "solid-js"; @@ -11,6 +11,7 @@ import { SUBMIT_HOTKEY, } from "@/components/forms/FormControls"; import { buttonVariants } from "@/components/ui/Button"; +import { HotkeyHint } from "@/components/ui/HotkeyHint"; import { useField, useForm } from "@/lib/form"; import { destinationAfterAuth, inviteTokenFromHash } from "@/modules/organizations/inviteToken"; @@ -117,7 +118,8 @@ export function SignupForm() { - sign up · {formatForDisplay(SUBMIT_HOTKEY).toLocaleLowerCase()} + sign up + } @@ -128,7 +130,8 @@ export function SignupForm() {

already have an account?{" "} - sign in · {formatForDisplay(signInHotkeySequence).toLocaleLowerCase()} + sign in +

diff --git a/src/modules/backgroundRemoval/components/BackgroundRemovalGrid.tsx b/src/modules/backgroundRemoval/components/BackgroundRemovalGrid.tsx index cb31e5c..a22229d 100644 --- a/src/modules/backgroundRemoval/components/BackgroundRemovalGrid.tsx +++ b/src/modules/backgroundRemoval/components/BackgroundRemovalGrid.tsx @@ -53,7 +53,7 @@ export function BackgroundRemovalGrid(props: { return (
-
+

your images

diff --git a/src/modules/backgroundRemoval/components/BackgroundRemovalUploader.tsx b/src/modules/backgroundRemoval/components/BackgroundRemovalUploader.tsx index b7da28b..0d93b74 100644 --- a/src/modules/backgroundRemoval/components/BackgroundRemovalUploader.tsx +++ b/src/modules/backgroundRemoval/components/BackgroundRemovalUploader.tsx @@ -1,9 +1,10 @@ import { Dialog } from "@kobalte/core/dialog"; import { CloudUpload, X } from "@lucide/solid"; -import { createHotkey, formatForDisplay, type RegisterableHotkey } from "@tanstack/solid-hotkeys"; +import { createHotkey, type RegisterableHotkey } from "@tanstack/solid-hotkeys"; import { createMemo, createSignal, For, onSettled, Show } from "solid-js"; import { Button } from "@/components/ui/Button"; +import { HotkeyHint } from "@/components/ui/HotkeyHint"; import type { ReadyFile } from "@/modules/files/files"; import { SUPPORTED_IMAGE_MEDIA_TYPES } from "@/modules/files/images"; import { formatBytes } from "@/modules/files/imageUpload"; @@ -297,7 +298,8 @@ export function BackgroundRemovalUploader(props: {
} diff --git a/src/modules/organizations/components/CreateOrganizationForm.tsx b/src/modules/organizations/components/CreateOrganizationForm.tsx index 96e2d7d..4b43c8a 100644 --- a/src/modules/organizations/components/CreateOrganizationForm.tsx +++ b/src/modules/organizations/components/CreateOrganizationForm.tsx @@ -1,5 +1,4 @@ import { FieldApi, FormApi } from "@tanstack/form-core"; -import { formatForDisplay } from "@tanstack/solid-hotkeys"; import { useNavigate } from "@tanstack/solid-router"; import { useServerFn } from "@tanstack/solid-start"; import * as v from "valibot"; @@ -10,6 +9,7 @@ import { createFormSubmission, SUBMIT_HOTKEY, } from "@/components/forms/FormControls"; +import { HotkeyHint } from "@/components/ui/HotkeyHint"; import { useField, useForm } from "@/lib/form"; import { createAndJoinOrganizationFn } from "../serverFunctions"; @@ -88,7 +88,8 @@ export function CreateOrganizationForm() { /> - create · {formatForDisplay(SUBMIT_HOTKEY).toLocaleLowerCase()} + create +
diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx index 5ffe384..a0f5d6c 100644 --- a/src/routes/__root.tsx +++ b/src/routes/__root.tsx @@ -1,20 +1,35 @@ import { HydrationScript } from "@solidjs/web"; import { TanStackDevtools } from "@tanstack/solid-devtools"; +import { detectPlatform, HotkeysProvider } from "@tanstack/solid-hotkeys"; import { hotkeysDevtoolsPlugin } from "@tanstack/solid-hotkeys-devtools"; import { HeadContent, Outlet, Scripts, createRootRouteWithContext } from "@tanstack/solid-router"; import { TanStackRouterDevtools } from "@tanstack/solid-router-devtools"; +import { createIsomorphicFn } from "@tanstack/solid-start"; +import { getRequestHeader } from "@tanstack/solid-start/server"; import { Loading } from "solid-js"; import styleCss from "../styles.css?url"; +// The server reads the request's user agent so hotkey labels hydrate without changing. +const getHotkeyPlatform = createIsomorphicFn() + .server(() => detectPlatform(getRequestHeader("User-Agent") ?? "")) + .client(() => detectPlatform()); + export const Route = createRootRouteWithContext()({ head: () => ({ + meta: [ + { charSet: "utf-8" }, + { name: "viewport", content: "width=device-width, initial-scale=1" }, + ], links: [{ rel: "stylesheet", href: styleCss }], }), + loader: () => ({ hotkeyPlatform: getHotkeyPlatform() }), + staleTime: Infinity, shellComponent: RootComponent, }); function RootComponent() { + const data = Route.useLoaderData(); return ( @@ -22,11 +37,13 @@ function RootComponent() { - - - - - + + + + + + + diff --git a/src/routes/_app.tsx b/src/routes/_app.tsx index 04cfb0d..de08f69 100644 --- a/src/routes/_app.tsx +++ b/src/routes/_app.tsx @@ -24,7 +24,7 @@ function RouteComponent() { return (
diff --git a/src/routes/_app/$orgSlug.tsx b/src/routes/_app/$orgSlug.tsx index b08a37b..51543d7 100644 --- a/src/routes/_app/$orgSlug.tsx +++ b/src/routes/_app/$orgSlug.tsx @@ -1,7 +1,8 @@ -import { createHotkey, formatForDisplay, type HotkeySequence } from "@tanstack/solid-hotkeys"; +import { createHotkey, type HotkeySequence } from "@tanstack/solid-hotkeys"; import { createFileRoute, Outlet, redirect } from "@tanstack/solid-router"; import { ButtonLink } from "@/components/ui/ButtonLink"; +import { HotkeyHint } from "@/components/ui/HotkeyHint"; import { createElementHeight } from "@/lib/createElementHeight"; import { getOrganizationFn } from "@/modules/organizations/serverFunctions"; @@ -42,13 +43,13 @@ function RouteComponent() { return (
diff --git a/src/routes/_app/_user/create-organization.tsx b/src/routes/_app/_user/create-organization.tsx index 272eca3..08357c6 100644 --- a/src/routes/_app/_user/create-organization.tsx +++ b/src/routes/_app/_user/create-organization.tsx @@ -8,7 +8,7 @@ export const Route = createFileRoute("/_app/_user/create-organization")({ function RouteComponent() { return ( -
+
); diff --git a/src/routes/_app/_user/index.tsx b/src/routes/_app/_user/index.tsx index 005da9f..3e3efcd 100644 --- a/src/routes/_app/_user/index.tsx +++ b/src/routes/_app/_user/index.tsx @@ -1,13 +1,13 @@ import { createHotkeys, DEFAULT_SEQUENCE_TIMEOUT, - formatForDisplay, type HotkeySequence, } from "@tanstack/solid-hotkeys"; import { createFileRoute } from "@tanstack/solid-router"; import { createMemo, For, onCleanup, Show } from "solid-js"; import { ButtonLink } from "@/components/ui/ButtonLink"; +import { HotkeyHint } from "@/components/ui/HotkeyHint"; import { listOrganizationsFn } from "@/modules/organizations/serverFunctions"; export const Route = createFileRoute("/_app/_user/")({ @@ -54,7 +54,8 @@ function RouteComponent() {

Choose where you want to work.

- create organization · o c + create organization +
@@ -69,7 +70,8 @@ function RouteComponent() {

- create organization · o c + create organization +
} @@ -83,7 +85,8 @@ function RouteComponent() {
/{organization.slug}
- open · {formatForDisplay(sequence).toLocaleLowerCase()} + open + )} diff --git a/src/routes/_auth/invite/accept.tsx b/src/routes/_auth/invite/accept.tsx index f321c10..1c01241 100644 --- a/src/routes/_auth/invite/accept.tsx +++ b/src/routes/_auth/invite/accept.tsx @@ -12,7 +12,7 @@ export const Route = createFileRoute("/_auth/invite/accept")({ component: Invite function InvitePage() { return ( -
+
( <> diff --git a/src/routes/_auth/sign-in.tsx b/src/routes/_auth/sign-in.tsx index 0183569..1139abd 100644 --- a/src/routes/_auth/sign-in.tsx +++ b/src/routes/_auth/sign-in.tsx @@ -8,7 +8,7 @@ export const Route = createFileRoute("/_auth/sign-in")({ function RouteComponent() { return ( -
+
diff --git a/src/routes/_auth/sign-up.tsx b/src/routes/_auth/sign-up.tsx index aacec11..da29504 100644 --- a/src/routes/_auth/sign-up.tsx +++ b/src/routes/_auth/sign-up.tsx @@ -8,7 +8,7 @@ export const Route = createFileRoute("/_auth/sign-up")({ function RouteComponent() { return ( -
+
diff --git a/src/styles.css b/src/styles.css index 51ce4ad..1ce2470 100644 --- a/src/styles.css +++ b/src/styles.css @@ -17,6 +17,15 @@ body { margin: 0; } +/* iOS zooms into fields under 16px on focus. Unlayered so it beats `text-sm`. */ +@media (pointer: coarse) { + input, + select, + textarea { + font-size: 1rem; + } +} + @custom-variant dark (&:is(.dark *)); @theme inline {