A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
fix(mobile): stabilize sheets and preview controls
Amruth Pillai5d75e81b33b0
diff --git a/apps/mobile/scripts/layout.test.mjs b/apps/mobile/scripts/layout.test.mjsindex 01e0032a3..02dae8bbc 100644--- a/apps/mobile/scripts/layout.test.mjs+++ b/apps/mobile/scripts/layout.test.mjs@@ -323,7 +323,7 @@ const componentFixtures = {"react-native-reanimated": animation,};const { CollectionHeader } = load("components/collection-header.tsx");-const { ListRow } = load("ui/layout.tsx", componentFixtures);+const { ListRow, EmptyState } = load("ui/layout.tsx", componentFixtures);const { Segmented } = load("ui/fields.tsx", {...componentFixtures,"./layout": { ListRow },@@ -490,3 +490,72 @@ assert.equal(scrolled.at(-1), 40, "Changing route must reveal the selected tab aconsole.log("PASS safe areas, measured Screen viewport, Duo rail navigation/targets, tablet sidebar, responsive editor modes, history split, measured PDF pages, large-text chrome/rows/navigation, workspace selection and overflow",);++// Long empty-state headings need bounded width before Android measures wrapped text.+for (const title of ["All your applications are closed", "Your job search starts here"]) {+ const empty = render(EmptyState, { title });+ const heading = nodes(empty).find((node) => node.props.accessibilityRole === "header");+ assert.equal(heading.props.children[0], title);+ assert.equal(heading.props.style.alignSelf, "stretch");+ assert.equal(heading.props.numberOfLines, undefined);+}++// Browse every printable glyph, search beyond the old 60-result cap, select and clear.+const iconPaths = JSON.parse(+ readFileSync(new URL("../../../packages/pdf/src/forme/phosphor-icons.json", import.meta.url)),+);+const resumeIcons = load("../../../packages/schema/src/icons.ts").icons;+const { IconPickerSheet } = load("features/write/pickers.tsx", {+ "react-native-svg": { SvgXml: "SvgXml" },+ "@reactive-resume/pdf/icons": { default: iconPaths, __esModule: true },+ "@reactive-resume/schema/icons": { icons: resumeIcons },+ "@/ui": { ...ui, Sheet: "Sheet", TextField: "TextField", ListRow: "ListRow" },+});+hooks.length = 0;+const selections = [];+const pickerProps = { open: true, value: "github-logo", onClose() {}, onChange: (name) => selections.push(name) };+const pickerList = (props = pickerProps) =>+ nodes(render(IconPickerSheet, props)).find((node) => node.type === "FlatList");+let picker = pickerList();+assert.deepEqual(new Set(picker.props.data), new Set(["", ...Object.keys(iconPaths)]));+assert.ok(picker.props.data.length > 1500);+for (const name of picker.props.data) {+ const cell = picker.props.renderItem({ item: name });+ assert.equal(cell.props.accessibilityLabel, name || "None");+ assert.equal(cell.props.accessibilityState.checked, name === pickerProps.value);+ assert.equal(+ nodes(cell).some((node) => node.type === "Text"),+ false,+ "Grid cells must show glyphs without names",+ );+ if (name)+ assert.ok(+ nodes(cell)+ .find((node) => node.type === "SvgXml")+ .props.xml.includes(iconPaths[name]),+ );+}+for (const width of [240, 480, 320]) {+ picker.props.onLayout({ nativeEvent: { layout: { width } } });+ picker = pickerList();+ const cellWidth = width / picker.props.numColumns;+ assert.ok(cellWidth >= theme.size.hit, "Grid preserves minimum touch target on narrow screens");+}+picker.props.renderItem({ item: "github-logo" }).props.onPress();+picker.props.renderItem({ item: "" }).props.onPress();+assert.deepEqual(selections, ["github-logo", ""]);+const search = (query) => {+ const tree = render(IconPickerSheet, pickerProps);+ nodes(tree)+ .find((node) => node.type === "TextField")+ .props.onChangeText(query);+ return pickerList();+};+picker = search(" Arrow ");+assert.ok(picker.props.data.length > 60, "Search must not truncate large result sets");+assert.ok(picker.props.data.every((name) => !name || name.includes("arrow")));+picker = search("no-such-icon");+assert.deepEqual(picker.props.data, [""]);+assert.ok(picker.props.ListFooterComponent);+assert.deepEqual(pickerList({ ...pickerProps, open: false }).props.data, []);+console.log("PASS wrapped empty-state titles and complete accessible searchable icon grid");diff --git a/apps/mobile/scripts/sheets.test.mjs b/apps/mobile/scripts/sheets.test.mjsindex 6b7b6ccd7..b37bcda24 100644--- a/apps/mobile/scripts/sheets.test.mjs+++ b/apps/mobile/scripts/sheets.test.mjs@@ -26,7 +26,7 @@ const theme = {colors: {},radius: {},size: { formSheet: 540 },- space: { s2: 8, s3: 12, s4: 16 },+ space: { s2: 8, s3: 12, s4: 16, s6: 24 },};const tag = (parts, ...values) => parts.reduce((text, part, index) => text + part + (values[index] ?? ""), "");const mocks = {@@ -116,6 +116,19 @@ tree = render(Sheet, { ...props, open: true });tree.props.onDidDismiss();assert.equal(closes, 1, "Interactive dismissal reaches the owning form once");+// Title-only sheets keep their accessible pane name without a heading under the grabber.+tree = render(Sheet, { ...props, title: "Document options" });+assert.equal(tree.props.header, undefined);+assert.equal(tree.props.accessibilityOptions.paneTitle, "Document options");+tree = render(Sheet, { ...props, title: "Edit", headerEnd: "Save" });+assert.ok(tree.props.header, "Sheets with header actions must preserve Save/Cancel controls");+assert.equal(tree.props.header.props.headerEnd, "Save");+const header = tree.props.header.type(tree.props.header.props);+assert.equal(header.props.style.paddingTop, theme.space.s6);+tree = render(Sheet, { ...props, scroll: false, children: "virtualized grid" });+assert.equal(tree.props.children[0].props.children[0], "virtualized grid");+assert.equal(tree.props.children[0].props.style.flex, 1);+hooks.length = 0;const editor = { dirty: true, pending: false, onClose: () => closes++, children: "unsaved form" };tree = render(EditorSheet, editor);diff --git a/apps/mobile/src/features/letters/page.tsx b/apps/mobile/src/features/letters/page.tsxindex aac70a5ef..e8242f4fb 100644--- a/apps/mobile/src/features/letters/page.tsx+++ b/apps/mobile/src/features/letters/page.tsx@@ -2,7 +2,7 @@ import type { ResumeData } from "@reactive-resume/schema/resume/data";import { plural } from "@lingui/core/macro";import { useLingui } from "@lingui/react/macro";import { useEffect, useMemo, useRef, useState } from "react";-import { ActivityIndicator, PixelRatio, View } from "react-native";+import { PixelRatio, View } from "react-native";import { coverLetterTextToHtml } from "@reactive-resume/resume/cover-letter";import { LETTER_RENDER_OPTIONS, letterPageData, useLetterWords } from "./compose";import { useLetterDrafting } from "./drafting";@@ -122,7 +122,6 @@ export function LetterPages({ data, zoomBar = true }: { data: ResumeData | null;<Text variant="caption" color="ink3">{plural(result?.pageCount ?? 1, { one: "# page", other: "# pages" })}</Text>- {preview.rendering && result ? <ActivityIndicator color={colors.accent} /> : null}</View>) : null}</View>diff --git a/apps/mobile/src/features/write/basics-screen.tsx b/apps/mobile/src/features/write/basics-screen.tsxindex eb22fef59..09f6bdeed 100644--- a/apps/mobile/src/features/write/basics-screen.tsx+++ b/apps/mobile/src/features/write/basics-screen.tsx@@ -201,7 +201,6 @@ function CustomFields({ fields, locked, focusField }: CustomFieldsProps) {<IconButtonicon={field.link ? "link-simple-horizontal" : "link-simple-horizontal-break"}label={field.link ? t`Edit link` : t`Add a link`}- selected={!!field.link}disabled={locked}onPress={() => setLinkFor(field.id)}/>diff --git a/apps/mobile/src/features/write/pickers.tsx b/apps/mobile/src/features/write/pickers.tsxindex bd29470ea..f6c19010d 100644--- a/apps/mobile/src/features/write/pickers.tsx+++ b/apps/mobile/src/features/write/pickers.tsx@@ -1,8 +1,9 @@-import type { IconName } from "@/ui";import type { KeyboardTypeOptions } from "react-native";import { useLingui } from "@lingui/react/macro";import { useState } from "react";-import { Pressable, View } from "react-native";+import { FlatList, Pressable, View } from "react-native";+import { SvgXml } from "react-native-svg";+import iconPaths from "@reactive-resume/pdf/icons";import { icons as resumeIcons } from "@reactive-resume/schema/icons";import { Button, Icon, ListRow, Sheet, Text, TextField, useTheme } from "@/ui";@@ -52,31 +53,6 @@ export function PromptSheet({ open, title, message, initialValue, keyboardType,);}-// The icons the mockup's grid leads with; search covers every icon the page can print.-const SUGGESTED_ICONS: readonly string[] = [- "briefcase",- "graduation-cap",- "graph",- "lightning",- "translate",- "bookmark-simple",- "check-circle",- "list-checks",- "file-text",- "user-circle",- "phone",- "link-simple-horizontal",- "code",- "star",- "globe",- "envelope-simple",- "map-pin",- "calendar-blank",- "trend-up",- "sparkle",- "palette",-] satisfies IconName[];-type IconPickerSheetProps = {open: boolean;value: string;@@ -84,45 +60,63 @@ type IconPickerSheetProps = {onChange: (icon: string) => void;};-/**- * Section, entry and custom-field icons: None, the common ones, and search over every icon the PDF can draw.- * ponytail: only the suggested icons (all in the app's icon map) preview a glyph; search results show names. Ship- * the PDF's Phosphor paths to the app if every glyph must preview.- */+/** Every printable Phosphor icon, virtualized so the full catalog stays cheap to browse. */export function IconPickerSheet({ open, value, onClose, onChange }: IconPickerSheetProps) {const { t } = useLingui();- const { space } = useTheme();+ const { colors, radius, size, space } = useTheme();const [query, setQuery] = useState("");+ const [columns, setColumns] = useState(1);const search = query.trim().toLowerCase();- const names = search- ? resumeIcons.filter((name) => name && name.includes(search)).slice(0, 60)- : SUGGESTED_ICONS.filter((name) => (resumeIcons as readonly string[]).includes(name));+ const names = resumeIcons.filter((name) => !name || (Object.hasOwn(iconPaths, name) && name.includes(search)));return (- <Sheet open={open} onClose={onClose} title={t`Icon`} detents={[0.6, 1]}>- <View style={{ paddingHorizontal: space.s4 }}>- <TextField- label={t`Search icons`}- placeholder={t`Search icons`}- value={query}- onChangeText={setQuery}- autoCapitalize="none"- autoCorrect={false}- />- </View>- <ListRow title={t`None`} selected={!value} onPress={() => onChange("")} />- {names.map((name) => (- <ListRow- key={name}- title={name}- leading={SUGGESTED_ICONS.includes(name) ? <Icon name={name as IconName} size={20} /> : undefined}- selected={value === name}- onPress={() => onChange(name)}- />- ))}- {search && names.length === 0 ? (- <Text color="ink3" style={{ paddingHorizontal: space.s4 }}>{t`No icons match.`}</Text>- ) : null}+ <Sheet open={open} onClose={onClose} title={t`Icon`} detents={[0.6, 1]} scroll={false}>+ <TextField+ label={t`Search icons`}+ placeholder={t`Search icons`}+ value={query}+ onChangeText={setQuery}+ autoCapitalize="none"+ autoCorrect={false}+ />+ <FlatList+ key={columns}+ style={{ flex: 1, marginTop: space.s3 }}+ onLayout={({ nativeEvent: { layout } }) => setColumns(Math.max(1, Math.floor(layout.width / size.hit)))}+ numColumns={columns}+ data={open ? names : []}+ extraData={value}+ keyExtractor={(name) => name}+ keyboardShouldPersistTaps="handled"+ nestedScrollEnabled+ renderItem={({ item: name }) => (+ <Pressable+ accessibilityRole="radio"+ accessibilityLabel={name || t`None`}+ accessibilityState={{ checked: value === name }}+ onPress={() => onChange(name)}+ style={({ pressed }) => ({+ width: `${100 / columns}%`,+ minHeight: size.hit,+ alignItems: "center",+ justifyContent: "center",+ borderRadius: radius.rMd,+ backgroundColor: value === name ? colors.selectedFill : pressed ? colors.press : "transparent",+ })}+ >+ {name ? (+ <SvgXml+ xml={`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="${colors.ink}">${(iconPaths as Record<string, string>)[name]}</svg>`}+ width={size.icon.toolbar}+ height={size.icon.toolbar}+ />+ ) : (+ <Icon name="x" />+ )}+ </Pressable>+ )}+ ListFooterComponent={search && names.length === 1 ? <Text color="ink3">{t`No icons match.`}</Text> : undefined}+ /></Sheet>);}diff --git a/apps/mobile/src/preview/page.tsx b/apps/mobile/src/preview/page.tsxindex 3021b8e8a..d00bb10c2 100644--- a/apps/mobile/src/preview/page.tsx+++ b/apps/mobile/src/preview/page.tsx@@ -281,7 +281,6 @@ export function ResumePage({ id, draft, focused, previewData }: ResumePageProps)color="ink3"accessibilityLiveRegion="polite">{t`Page ${currentPage} of ${result?.pageCount ?? 1}`}</Text>- {preview.rendering && result ? <ActivityIndicator color={colors.accent} /> : null}</View></View>);diff --git a/apps/mobile/src/ui/layout.tsx b/apps/mobile/src/ui/layout.tsxindex 5495ff6be..011e8bc2d 100644--- a/apps/mobile/src/ui/layout.tsx+++ b/apps/mobile/src/ui/layout.tsx@@ -304,7 +304,7 @@ export function EmptyState({ icon, title, message, action, secondaryAction }: Em<Icon name={icon} size={size.icon.bar + space.s2} color={colors.ink2} /></View>) : null}- <Text accessibilityRole="header" variant="heading" align="center">+ <Text accessibilityRole="header" variant="heading" align="center" style={{ alignSelf: "stretch" }}>{title}</Text>{message ? (diff --git a/apps/mobile/src/ui/overlays.tsx b/apps/mobile/src/ui/overlays.tsxindex d3f37f532..54b66f434 100644--- a/apps/mobile/src/ui/overlays.tsx+++ b/apps/mobile/src/ui/overlays.tsx@@ -42,19 +42,29 @@ export type SheetProps = {headerEnd?: ReactNode;/** Pads the content with `s4`. Defaults to true; full-width rows pass false. */padded?: boolean | undefined;+ /** Lists that own scrolling pass false to avoid nesting inside a ScrollView. */+ scroll?: boolean | undefined;};type SheetHeaderProps = Pick<SheetProps, "title" | "headerStart" | "headerEnd">;function SheetHeader({ title, headerStart, headerEnd }: SheetHeaderProps) {const { size, space } = useTheme();- if (!title && !headerStart && !headerEnd) return null;+ if (!headerStart && !headerEnd) return null;// Equal side slots keep the title centred.const slot = { flex: 1, flexDirection: "row", alignItems: "center" } as const;return (- <View style={{ flexDirection: "row", alignItems: "center", minHeight: size.topBar, paddingHorizontal: space.s2 }}>+ <View+ style={{+ flexDirection: "row",+ alignItems: "center",+ minHeight: size.topBar,+ paddingHorizontal: space.s2,+ paddingTop: space.s6,+ }}+ ><View style={slot}>{headerStart}</View>{title ? (<Text accessibilityRole="header" variant="title" align="center" style={{ flexShrink: 1, maxWidth: "60%" }}>@@ -77,6 +87,7 @@ export function Sheet({headerStart,headerEnd,padded = true,+ scroll = true,dismissible = true,}: SheetProps) {const { t } = useLingui();@@ -156,7 +167,9 @@ export function Sheet({accessibilityOptions={title ? { paneTitle: title } : {}}scrollableinsetAdjustment="never"- header={<SheetHeader title={title} headerStart={headerStart} headerEnd={headerEnd} />}+ {...(headerStart || headerEnd+ ? { header: <SheetHeader title={title} headerStart={headerStart} headerEnd={headerEnd} /> }+ : {})}{...(footer? {footer: (@@ -178,21 +191,36 @@ export function Sheet({: {})}footerOptions={{ keyboardOffset: -insets.bottom }}>- <ScrollView- nestedScrollEnabled- accessibilityViewIsModal- onAccessibilityEscape={dismissible ? onClose : undefined}- keyboardShouldPersistTaps="handled"- keyboardDismissMode="interactive"- contentContainerStyle={{- gap: space.s3,- paddingTop: space.s2,- paddingHorizontal: padded ? space.s4 : 0,- paddingBottom: footer ? footerHeight + space.s4 : insets.bottom + space.s4,- }}- >- {children}- </ScrollView>+ {scroll ? (+ <ScrollView+ nestedScrollEnabled+ accessibilityViewIsModal+ onAccessibilityEscape={dismissible ? onClose : undefined}+ keyboardShouldPersistTaps="handled"+ keyboardDismissMode="interactive"+ contentContainerStyle={{+ gap: space.s3,+ paddingTop: headerStart || headerEnd ? space.s2 : space.s6,+ paddingHorizontal: padded ? space.s4 : 0,+ paddingBottom: footer ? footerHeight + space.s4 : insets.bottom + space.s4,+ }}+ >+ {children}+ </ScrollView>+ ) : (+ <View+ accessibilityViewIsModal+ onAccessibilityEscape={dismissible ? onClose : undefined}+ style={{+ flex: 1,+ paddingTop: space.s6,+ paddingHorizontal: padded ? space.s4 : 0,+ paddingBottom: insets.bottom + space.s4,+ }}+ >+ {children}+ </View>+ )}</TrueSheet>);}diff --git a/packages/pdf/package.json b/packages/pdf/package.jsonindex 499de6541..23e24e720 100644--- a/packages/pdf/package.json+++ b/packages/pdf/package.json@@ -4,6 +4,7 @@"type": "module","private": true,"exports": {+ "./icons": "./src/forme/phosphor-icons.json","./browser": "./src/browser.tsx","./document": "./src/document.tsx","./native": "./src/native.tsx",