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: complete builder photo entry and section defaults
Amruth Pillai409e8d14e1b3
diff --git a/apps/mobile/scripts/experience.test.mjs b/apps/mobile/scripts/experience.test.mjsindex 3c3b3f402..20614187c 100644--- a/apps/mobile/scripts/experience.test.mjs+++ b/apps/mobile/scripts/experience.test.mjs@@ -2295,6 +2295,17 @@ const { PictureScreen } = load("features/write/picture-screen.tsx", {"@/draft/native": { nativeEnvironment: {} },});const photoView = () => render(PictureScreen);+assert.equal(+ nodes(photoView()).some((node) => node.props?.label === "Rotation"),+ false,+ "unsupported rotation is not offered",+);+assert.equal(+ nodes(photoView()).some((node) => node.props?.label === "Size"),+ true,+ "existing photo offers appearance controls",+);+// Undo removal must retain the edit immediately before it.photoStore.getState().update((draft) => {draft.picture.size = 123;@@ -2304,6 +2315,12 @@ const photoConfirm = nodes(photoView()).find((node) => node.type === "ConfirmDiaif (photoConfirm) photoConfirm.props.onConfirm();assert.equal(photoStore.getState().data.picture.url, "");assert.equal(photoBytes.get(photoUrl), "photo bytes");+assert.equal(+ nodes(photoView()).some((node) => ["Fit", "Size", "Border color", "Shadow color"].includes(node.props?.label)),+ false,+ "empty photo offers upload before appearance controls",+);+assert.equal(nodes(photoView()).some((node) => node.type === "ConfirmDialog"),false,diff --git a/apps/mobile/src/features/write/picture-screen.tsx b/apps/mobile/src/features/write/picture-screen.tsxindex da7121d7c..a9d828854 100644--- a/apps/mobile/src/features/write/picture-screen.tsx+++ b/apps/mobile/src/features/write/picture-screen.tsx@@ -37,7 +37,7 @@ export function resolvePictureUrl(url: string, server: string): string {}}-/** Every photo option: upload with crop, address, show or hide, remove, fit, size, rotation, shape, border, shadow. */+/** Every photo option: upload with crop, address, show or hide, remove, fit, size, shape, border, shadow. */export function PictureScreen() {const { t } = useLingui();const { colors, radius, space } = useTheme();@@ -173,135 +173,128 @@ export function PictureScreen() {autoCorrect={false}onChangeText={(value) => set("url", value)}/>- <View style={{ flexDirection: "row", alignItems: "center", gap: space.s2 }}>- <Switch- label={t`Show photo`}- value={!picture.hidden}- disabled={locked}- onValueChange={(shown) => set("hidden", !shown, true)}- />- <Text>{t`Show photo`}</Text>- </View>+ {picture.url && (+ <>+ <View style={{ flexDirection: "row", alignItems: "center", gap: space.s2 }}>+ <Switch+ label={t`Show photo`}+ value={!picture.hidden}+ disabled={locked}+ onValueChange={(shown) => set("hidden", !shown, true)}+ />+ <Text>{t`Show photo`}</Text>+ </View>- <Segmented- label={t`Fit`}- value={picture.fit}- options={[- { value: "cover", label: t`Cover` },- { value: "contain", label: t`Contain` },- ]}- onChange={(fit) => !locked && set("fit", fit, true)}- />+ <Segmented+ label={t`Fit`}+ value={picture.fit}+ options={[+ { value: "cover", label: t`Cover` },+ { value: "contain", label: t`Contain` },+ ]}+ onChange={(fit) => !locked && set("fit", fit, true)}+ />- <NumberField- label={t`Size`}- unit="pt"- value={picture.size}- min={32}- max={512}- step={1}- disabled={locked}- onChange={(value) => set("size", value)}- />- <NumberField- label={t`Rotation`}- unit="°"- value={picture.rotation}- min={0}- max={360}- step={5}- disabled- helper={t`Rotation isn't supported by PDF rendering.`}- onChange={(value) => set("rotation", value)}- />- <NumberField- label={t`Aspect ratio`}- value={picture.aspectRatio}- min={0.5}- max={2.5}- step={0.1}- disabled={locked}- onChange={(value) => set("aspectRatio", value)}- />- <View style={{ flexDirection: "row", gap: space.s2 }}>- <Button- size="sm"- variant="secondary"- label={t`Square`}- disabled={locked}- onPress={() => set("aspectRatio", 1, true)}- />- <Button- size="sm"- variant="secondary"- label={t`Landscape`}- disabled={locked}- onPress={() => set("aspectRatio", 1.5, true)}- />- <Button- size="sm"- variant="secondary"- label={t`Portrait`}- disabled={locked}- onPress={() => set("aspectRatio", 0.5, true)}- />- </View>- <NumberField- label={t`Border radius`}- unit="pt"- value={picture.borderRadius}- min={0}- max={100}- step={1}- disabled={locked}- onChange={(value) => set("borderRadius", value)}- />+ <NumberField+ label={t`Size`}+ unit="pt"+ value={picture.size}+ min={32}+ max={512}+ step={1}+ disabled={locked}+ onChange={(value) => set("size", value)}+ />+ <NumberField+ label={t`Aspect ratio`}+ value={picture.aspectRatio}+ min={0.5}+ max={2.5}+ step={0.1}+ disabled={locked}+ onChange={(value) => set("aspectRatio", value)}+ />+ <View style={{ flexDirection: "row", gap: space.s2 }}>+ <Button+ size="sm"+ variant="secondary"+ label={t`Square`}+ disabled={locked}+ onPress={() => set("aspectRatio", 1, true)}+ />+ <Button+ size="sm"+ variant="secondary"+ label={t`Landscape`}+ disabled={locked}+ onPress={() => set("aspectRatio", 1.5, true)}+ />+ <Button+ size="sm"+ variant="secondary"+ label={t`Portrait`}+ disabled={locked}+ onPress={() => set("aspectRatio", 0.5, true)}+ />+ </View>+ <NumberField+ label={t`Border radius`}+ unit="pt"+ value={picture.borderRadius}+ min={0}+ max={100}+ step={1}+ disabled={locked}+ onChange={(value) => set("borderRadius", value)}+ />- <View>- <ColorRow- label={t`Border color`}- value={picture.borderColor}- disabled={locked}- onPress={() => setColorFor("borderColor")}- />- <NumberField- label={t`Border width`}- unit="pt"- value={picture.borderWidth}- min={0}- step={1}- disabled={locked}- onChange={(value) => set("borderWidth", value)}- />- </View>- <View>- <ColorRow- label={t`Shadow color`}- value={picture.shadowColor}- disabled={locked}- onPress={() => setColorFor("shadowColor")}- />- <NumberField- label={t`Shadow width`}- unit="pt"- value={picture.shadowWidth}- min={0}- step={0.5}- disabled={locked}- onChange={(value) => set("shadowWidth", value)}- />- </View>+ <View>+ <ColorRow+ label={t`Border color`}+ value={picture.borderColor}+ disabled={locked}+ onPress={() => setColorFor("borderColor")}+ />+ <NumberField+ label={t`Border width`}+ unit="pt"+ value={picture.borderWidth}+ min={0}+ step={1}+ disabled={locked}+ onChange={(value) => set("borderWidth", value)}+ />+ </View>+ <View>+ <ColorRow+ label={t`Shadow color`}+ value={picture.shadowColor}+ disabled={locked}+ onPress={() => setColorFor("shadowColor")}+ />+ <NumberField+ label={t`Shadow width`}+ unit="pt"+ value={picture.shadowWidth}+ min={0}+ step={0.5}+ disabled={locked}+ onChange={(value) => set("shadowWidth", value)}+ />+ </View>- <ColorPickerSheet- open={colorFor !== null}- title={colorFor === "shadowColor" ? t`Shadow color` : t`Border color`}- value={colorFor ? picture[colorFor] : ""}- onClose={() => setColorFor(null)}- onChange={(color) => {- if (colorFor) set(colorFor, color, true);- setColorFor(null);- }}- />+ <ColorPickerSheet+ open={colorFor !== null}+ title={colorFor === "shadowColor" ? t`Shadow color` : t`Border color`}+ value={colorFor ? picture[colorFor] : ""}+ onClose={() => setColorFor(null)}+ onChange={(color) => {+ if (colorFor) set(colorFor, color, true);+ setColorFor(null);+ }}+ />+ </>+ )}</EditorScreen>);}diff --git a/apps/web/src/features/resume/editor/write/basics-card.tsx b/apps/web/src/features/resume/editor/write/basics-card.tsxindex bb59eb425..399434ae9 100644--- a/apps/web/src/features/resume/editor/write/basics-card.tsx+++ b/apps/web/src/features/resume/editor/write/basics-card.tsx@@ -2,7 +2,6 @@ import type { Basics, CustomField } from "@reactive-resume/schema/resume/data";import { i18n } from "@lingui/core";import { t } from "@lingui/core/macro";import { Trans } from "@lingui/react/macro";-import { Button } from "@reactive-resume/ui/components/button";import { Collapsible, CollapsibleContent } from "@reactive-resume/ui/components/collapsible";import { Icon } from "@reactive-resume/ui/components/icon";import { IconButton } from "@reactive-resume/ui/components/icon-button";@@ -30,6 +29,7 @@ function useBasicsWriter() {*/export function BasicsCard({ locked }: { locked: boolean }) {const basics = useCurrentBuilderResumeSelector((resume) => resume.data.basics);+ const resumeId = useCurrentBuilderResumeSelector((resume) => resume.id);const open = useEditorStore((state) => state.basicsOpen);const selected = useEditorStore((state) => state.selection?.kind === "header");const write = useBasicsWriter();@@ -84,7 +84,7 @@ export function BasicsCard({ locked }: { locked: boolean }) {disabled={locked}className="m-0 grid min-w-0 grid-cols-2 items-start gap-x-3 gap-y-2.5 border-0 border-t border-line px-3 pt-3 pb-3.5">- <PhotoRow locked={locked} />+ <PictureSettings key={resumeId} locked={locked} /><TextFieldlabel={<Trans>Full name</Trans>}wide@@ -131,44 +131,6 @@ export function BasicsCard({ locked }: { locked: boolean }) {);}-function PhotoRow({ locked }: { locked: boolean }) {- const picture = useCurrentBuilderResumeSelector((resume) => resume.data.picture);- const hasPhoto = Boolean(picture.url);-- return (- <div id="sidebar-picture" className="col-span-full flex items-center gap-3 rounded-lg bg-bg p-2.5">- {hasPhoto ? (- <img src={picture.url} alt="" className="size-10 shrink-0 rounded-md object-cover" />- ) : (- <span className="grid size-10 shrink-0 place-items-center rounded-md bg-sunken text-ink-3">- <Icon name="camera-plus" />- </span>- )}- <p className="min-w-0 flex-1 text-xs leading-4 text-ink-2">- {!hasPhoto ? (- <Trans>No photo. Most ATS ignore photos; some regions expect one.</Trans>- ) : picture.hidden ? (- <Trans>Photo hidden from the page.</Trans>- ) : (- <Trans>Photo on the page.</Trans>- )}- </p>- <Popover>- <PopoverTrigger- render={- <Button variant="secondary" size="sm" disabled={locked}>- {hasPhoto ? <Trans>Edit</Trans> : <Trans>Add</Trans>}- </Button>- }- />- <PopoverContent align="end" className="max-h-[70svh] w-[360px] overflow-y-auto p-4">- <PictureSettings />- </PopoverContent>- </Popover>- </div>- );-}-/*** Extra contact details (icon, text and an optional link), as "Add field" under Website. `edit` changes the list where* it's kept: the resume's basics, or a letter's own sender details.diff --git a/apps/web/src/features/resume/editor/write/picture-settings.test.tsx b/apps/web/src/features/resume/editor/write/picture-settings.test.tsxindex ececa3873..5dea0962e 100644--- a/apps/web/src/features/resume/editor/write/picture-settings.test.tsx+++ b/apps/web/src/features/resume/editor/write/picture-settings.test.tsx@@ -8,9 +8,11 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";import { defaultResumeData } from "@reactive-resume/schema/resume/default";import { PictureSettings } from "./picture-settings";import { clearResumeDrafts, useResumeStore } from "@/features/resume/builder/draft";+import { invalidateAccountScope } from "@/libs/auth/account-scope";const mocks = vi.hoisted(() => ({removeFile: vi.fn(),+ uploadFile: vi.fn(),toast: vi.fn(),closeToast: vi.fn(),confirm: vi.fn(async () => true),@@ -21,7 +23,7 @@ vi.mock("@reactive-resume/ui/components/toast", () => ({ toast: { add: mocks.toavi.mock("@/libs/orpc/client", () => ({orpc: {storage: {- uploadFile: { mutationOptions: () => ({ mutationFn: vi.fn() }) },+ uploadFile: { mutationOptions: () => ({ mutationFn: mocks.uploadFile }) },deleteFile: { mutationOptions: () => ({ mutationFn: mocks.removeFile }) },},},@@ -33,15 +35,17 @@ afterEach(() => {localStorage.clear();vi.useRealTimers();vi.clearAllMocks();+ vi.unstubAllGlobals();});-function renderPhoto(url = "/api/uploads/owner/pictures/shared.jpeg") {+function renderPhoto(url = "/api/uploads/owner/pictures/shared.jpeg", fit: "cover" | "contain" = "cover") {vi.useFakeTimers();i18n.load("en", {});i18n.activate("en");mocks.toast.mockReturnValue("photo-toast");const data = structuredClone(defaultResumeData);data.picture.url = url;+ data.picture.fit = fit;const initial: Resume = {id: "original",name: "Original",@@ -57,10 +61,11 @@ function renderPhoto(url = "/api/uploads/owner/pictures/shared.jpeg") {render(<QueryClientProvider client={client}><I18nProvider i18n={i18n}>- <PictureSettings />+ <PictureSettings locked={false} /></I18nProvider></QueryClientProvider>,);+ if (url) fireEvent.click(screen.getByRole("button", { name: "Edit" }));return { initial, client };}@@ -81,7 +86,7 @@ it.each(["/api/uploads/owner/pictures/shared.jpeg", "https://photos.example.testexpect(sharedUpload.get(url)).toBe("photo bytes");expect(mocks.removeFile).not.toHaveBeenCalled();expect(mocks.confirm).not.toHaveBeenCalled();- expect(screen.getByRole("button", { name: "Upload photo" })).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Add" })).toBeInTheDocument();const action = mocks.toast.mock.lastCall?.[0].actionProps;expect(action?.children).toBe("Undo");act(() =>@@ -100,7 +105,7 @@ it.each(["/api/uploads/owner/pictures/shared.jpeg", "https://photos.example.test);act(() => action.onClick());expect(useResumeStore.getState().resume?.data.basics.name).toBe("After restoration");- expect(screen.getByRole("button", { name: "Remove photo" })).toBeInTheDocument();+ expect(screen.getByRole("button", { name: "Edit" })).toBeInTheDocument();client.clear();},);@@ -179,3 +184,67 @@ it("rejects unreadable photo bytes before opening the crop dialog", async () =>vi.unstubAllGlobals();client.clear();});++it("opens the file picker directly from Add before showing photo settings", () => {+ const { client } = renderPhoto("");+ const input = screen.getByLabelText("Upload photo");+ const choose = vi.spyOn(input, "click");+ fireEvent.click(screen.getByRole("button", { name: "Add" }));+ expect(choose).toHaveBeenCalledTimes(1);+ expect(screen.queryByRole("textbox", { name: "URL" })).toBeNull();+ client.clear();+});++it.each(["current", "resume", "locked", "account"])(+ "an upload only updates its current owner URL (%s)",+ async (scenario) => {+ let finish: (value: { url: string }) => void = () => {};+ mocks.uploadFile.mockImplementation(+ () =>+ new Promise((resolve) => {+ finish = resolve;+ }),+ );+ vi.stubGlobal(+ "Image",+ class {+ src = "";+ decode = async () => {};+ },+ );+ const { initial, client } = renderPhoto("/api/uploads/owner/pictures/shared.jpeg", "contain");+ const input = screen.getByLabelText("Upload photo");+ await act(async () => {+ fireEvent.change(input, { target: { files: [new File(["fictional"], "photo.png", { type: "image/png" })] } });+ });+ expect(mocks.uploadFile).toHaveBeenCalledTimes(1);+ act(() => {+ if (scenario === "resume") cleanup();+ if (scenario === "resume")+ useResumeStore.getState().initialize({ ...initial, id: "other", data: structuredClone(initial.data) });+ if (scenario === "locked")+ useResumeStore.getState().patchResume((resume) => {+ resume.isLocked = true;+ });+ if (scenario === "account") {+ invalidateAccountScope();+ useResumeStore.getState().initialize({ ...initial, data: structuredClone(initial.data) });+ }+ if (scenario === "current")+ useResumeStore.getState().updateResumeData((draft) => {+ draft.picture.size = 144;+ });+ });+ const before = useResumeStore.getState().resume;+ await act(async () => {+ finish({ url: "/api/uploads/owner/pictures/new.png" });+ });+ if (scenario === "current")+ expect(useResumeStore.getState().resume?.data.picture).toMatchObject({+ url: "/api/uploads/owner/pictures/new.png",+ size: 144,+ });+ else expect(useResumeStore.getState().resume).toBe(before);+ client.clear();+ },+);diff --git a/apps/web/src/features/resume/editor/write/picture-settings.tsx b/apps/web/src/features/resume/editor/write/picture-settings.tsxindex 81916b771..f0b8321b3 100644--- a/apps/web/src/features/resume/editor/write/picture-settings.tsx+++ b/apps/web/src/features/resume/editor/write/picture-settings.tsx@@ -21,6 +21,7 @@ import { FormControl, FormItem, FormLabel, FormMessage } from "@reactive-resume/import { Icon } from "@reactive-resume/ui/components/icon";import { Input } from "@reactive-resume/ui/components/input";import { InputGroup, InputGroupAddon, InputGroupText } from "@reactive-resume/ui/components/input-group";+import { Popover, PopoverContent, PopoverTrigger } from "@reactive-resume/ui/components/popover";import { Slider } from "@reactive-resume/ui/components/slider";import { toast } from "@reactive-resume/ui/components/toast";import "react-easy-crop/react-easy-crop.css";@@ -29,42 +30,30 @@ import { NumberInput } from "@/components/input/number-input";import { useCurrentBuilderResumeSelector, useResumeStore, useUpdateResumeData } from "@/features/resume/builder/draft";import { useClosingValue } from "@/hooks/use-closing-value";import { useSyncFormValues } from "@/hooks/use-sync-form-values";+import { getAccountGeneration } from "@/libs/auth/account-scope";import { getReadableErrorMessage } from "@/libs/error-message";import { orpc } from "@/libs/orpc/client";import { useAppForm } from "@/libs/tanstack-form";type PicturePreviewControlsProps = {- fileInputRef: React.RefObject<HTMLInputElement | null>;form: PictureSettingsForm;normalizedPictureUrl: string;picture: PictureValues;onAutoSave: () => void;onDeletePicture: () => void;onSelectPicture: () => void;- onUploadPicture: (event: React.ChangeEvent<HTMLInputElement>) => void;};function PicturePreviewControls({- fileInputRef,form,normalizedPictureUrl,picture,onAutoSave,onDeletePicture,onSelectPicture,- onUploadPicture,}: PicturePreviewControlsProps) {return (<div className="flex items-center gap-x-4">- <input- ref={fileInputRef}- type="file"- accept="image/*"- aria-label={t`Upload photo`}- className="hidden"- onChange={onUploadPicture}- />-<buttontype="button"onClick={picture.url ? onDeletePicture : onSelectPicture}@@ -648,7 +637,9 @@ function ColorWidthFields(props: ColorWidthFieldsProps) {}/** Every photo option: upload with crop, address, show or hide, delete, fit, size, shape, border and shadow. */-export function PictureSettings() {+type PictureSettingsProps = { locked: boolean };++export function PictureSettings({ locked }: PictureSettingsProps) {const fileInputRef = useRef<HTMLInputElement>(null);const appOrigin = window.location.origin;@@ -657,6 +648,11 @@ export function PictureSettings() {const resumeId = useCurrentBuilderResumeSelector((resume) => resume.id);const picture = useCurrentBuilderResumeSelector((resume) => resume.data.picture);const normalizedPictureUrl = normalizePictureUrl(picture.url, appOrigin);+ const generation = getAccountGeneration();+ const current = () => {+ const resume = useResumeStore.getState().resume;+ return generation === getAccountGeneration() && resume?.id === resumeId && !resume.isLocked;+ };const updateResumeData = useUpdateResumeData();const { mutate: uploadFile } = useMutation(orpc.storage.uploadFile.mutationOptions({ meta: { noInvalidate: true } }));@@ -711,6 +707,7 @@ export function PictureSettings() {};const uploadPictureFile = (file: File) => {+ if (!current()) return;if (file.size > 10 * 1024 * 1024) {toast.add({ type: "error", description: t`This photo is larger than 10 MB. Use Crop and upload to shrink it.` });return;@@ -719,11 +716,17 @@ export function PictureSettings() {uploadFile(file, {onSuccess: ({ url }) => {- form.setFieldValue("url", url);- handleAutoSave();toast.close(toastId);+ if (!current()) return;+ updateResumeData(+ (draft) => {+ draft.picture.url = url;+ },+ { newStep: true },+ );},onError: (error) => {+ if (!current()) return toast.close(toastId);toast.add({type: "error",description: getReadableErrorMessage(@@ -741,15 +744,20 @@ export function PictureSettings() {const onUploadPicture = async (e: React.ChangeEvent<HTMLInputElement>) => {const file = e.target.files?.[0];- if (!file) return;+ if (!file || !current()) return;const imageSrc = URL.createObjectURL(file);const image = new Image();image.src = imageSrc;try {await image.decode();+ if (!current()) {+ URL.revokeObjectURL(imageSrc);+ return;+ }} catch {URL.revokeObjectURL(imageSrc);e.target.value = "";+ if (!current()) return;toast.add({type: "error",description: t`This file isn't a readable image. Choose a PNG, JPEG, WebP or GIF photo.`,@@ -772,7 +780,31 @@ export function PictureSettings() {};return (- <>+ <div id="sidebar-picture" className="col-span-full flex items-center gap-3 rounded-lg bg-bg p-2.5">+ <input+ ref={fileInputRef}+ type="file"+ accept="image/*"+ aria-label={t`Upload photo`}+ className="hidden"+ onChange={onUploadPicture}+ />+ {picture.url ? (+ <img src={normalizedPictureUrl} alt="" className="size-10 shrink-0 rounded-md object-cover" />+ ) : (+ <span className="grid size-10 shrink-0 place-items-center rounded-md bg-sunken text-ink-3">+ <Icon name="camera-plus" />+ </span>+ )}+ <p className="min-w-0 flex-1 text-xs leading-4 text-ink-2">+ {!picture.url ? (+ <Trans>No photo. Most ATS ignore photos; some regions expect one.</Trans>+ ) : picture.hidden ? (+ <Trans>Photo hidden from the page.</Trans>+ ) : (+ <Trans>Photo on the page.</Trans>+ )}+ </p><PictureCropDialogcropState={cropState}aspect={Number(form.state.values.aspectRatio) || 1}@@ -780,59 +812,68 @@ export function PictureSettings() {onUpload={uploadPictureFile}/>- <form- className="space-y-4"- onSubmit={(event) => {- event.preventDefault();- event.stopPropagation();- void form.handleSubmit();- }}- >- <PicturePreviewControls- fileInputRef={fileInputRef}- form={form}- normalizedPictureUrl={normalizedPictureUrl}- picture={picture}- onAutoSave={handleAutoSave}- onDeletePicture={onDeletePicture}- onSelectPicture={onSelectPicture}- onUploadPicture={onUploadPicture}+ {!picture.url && (+ <Button variant="secondary" size="sm" disabled={locked} onClick={onSelectPicture}>+ <Trans>Add</Trans>+ </Button>+ )}+ <Popover>+ <PopoverTrigger+ render={+ <Button variant="secondary" size="sm" disabled={locked}>+ {picture.url ? <Trans>Edit</Trans> : <Trans>URL</Trans>}+ </Button>+ }/>+ <PopoverContent align="end" className="max-h-[70svh] w-[360px] overflow-y-auto p-4">+ <form+ className="space-y-4"+ onSubmit={(event) => {+ event.preventDefault();+ event.stopPropagation();+ void form.handleSubmit();+ }}+ >+ <PicturePreviewControls+ form={form}+ normalizedPictureUrl={normalizedPictureUrl}+ picture={picture}+ onAutoSave={handleAutoSave}+ onDeletePicture={onDeletePicture}+ onSelectPicture={onSelectPicture}+ />- {/* The look of a photo is set once there is one: before that, the choice is only which photo. */}- {picture.url ? (- <>- <PictureFitField form={form} onAutoSave={handleAutoSave} />-- <div className="grid grid-cols-1 gap-4 @md:grid-cols-2">- <PictureGeometryFields form={form} onAutoSave={handleAutoSave} />-- <ColorWidthFields- form={form}- colorName="borderColor"- widthName="borderWidth"- colorLabel={t`Border color`}- widthLabel={t`Border width`}- step={1}- onAutoSave={handleAutoSave}- />- <ColorWidthFields- form={form}- colorName="shadowColor"- widthName="shadowWidth"- colorLabel={t`Shadow color`}- widthLabel={t`Shadow width`}- step={0.5}- onAutoSave={handleAutoSave}- />- </div>- </>- ) : (- <p className="text-xs leading-4 text-ink-3">- <Trans>Choose a photo, or paste its address. Fit, shape, border and shadow appear once it's added.</Trans>- </p>- )}- </form>- </>+ {picture.url && (+ <>+ <PictureFitField form={form} onAutoSave={handleAutoSave} />++ <div className="grid grid-cols-1 gap-4 @md:grid-cols-2">+ <PictureGeometryFields form={form} onAutoSave={handleAutoSave} />++ <ColorWidthFields+ form={form}+ colorName="borderColor"+ widthName="borderWidth"+ colorLabel={t`Border color`}+ widthLabel={t`Border width`}+ step={1}+ onAutoSave={handleAutoSave}+ />+ <ColorWidthFields+ form={form}+ colorName="shadowColor"+ widthName="shadowWidth"+ colorLabel={t`Shadow color`}+ widthLabel={t`Shadow width`}+ step={0.5}+ onAutoSave={handleAutoSave}+ />+ </div>+ </>+ )}+ </form>+ </PopoverContent>+ </Popover>+ </div>);}diff --git a/docs/guides/creating-your-first-resume.mdx b/docs/guides/creating-your-first-resume.mdxindex fff373292..3cfd7b194 100644--- a/docs/guides/creating-your-first-resume.mdx+++ b/docs/guides/creating-your-first-resume.mdx@@ -71,7 +71,7 @@ The editor opens in **Write** mode. **Full name** starts with your account name;## Add your first section-Below your details, under **Sections · print order**, Reactive Resume suggests the sections most resumes have: Experience, Education, Projects, Skills and Summary. No work experience yet? Start with Education or Projects: when Experience and Education sit in the main column of the same page, they print in the order you start them. A blank resume also starts with your account's name and email filled in (a guest's has the name only).+Below your details, under **Sections · print order**, Reactive Resume suggests the sections most resumes have: Experience, Education, Projects, Skills and Summary. No work experience yet? Start with Education or Projects: when Experience and Education sit in the main column of the same page, they print in the order you start them. A blank resume also starts with your account's name and email filled in (a guest's has the name only). New resumes start with Summary, Experience, Education and Projects in that order; Profiles sits after the other main-column sections. Existing resumes and imported layouts keep their saved order.<Frame caption="Starter sections on a new resume"><imgdiff --git a/docs/guides/filling-in-your-details.mdx b/docs/guides/filling-in-your-details.mdxindex 741598102..dbeeac652 100644--- a/docs/guides/filling-in-your-details.mdx+++ b/docs/guides/filling-in-your-details.mdx@@ -82,23 +82,25 @@ Unreadable photo files are rejected before cropping. Photos larger than **10 MB*Whether to include a photo depends on where you're applying. Many applicant tracking systems ignore photos, while some countries expect one. The photo row at the top of the Basics card reminds you of this.<Steps>- <Step title="Open the photo settings">- In the photo row, select **Add** (or **Edit** if the resume already has a photo). The photo settings open.+ <Step title="Choose a photo">+ In the photo row, select **Add** to open your device's file picker directly. JPEG, PNG, WebP and GIF files work.+ Appearance controls become available after a photo is added.</Step>- <Step title="Upload a photo">- Select the empty square (**Upload photo**) and choose an image from your device. JPEG, PNG, WebP and GIF files up to 10 MB work.-- You can also paste the address of an image that's already online into the **URL** field.+ <Step title="Use an image address instead (optional)">+ Select **URL** beside **Add** to paste the address of an image that's already online. If a photo is already present,+ select **Edit** to change its **URL** or appearance.</Step><Step title="Crop it">- The **Crop photo** dialog opens. Drag the image to position it and use the **Zoom** slider to frame it, then select **Crop and upload**. Select **Skip and upload** to use the whole image, or **Cancel** to stop.+ After choosing a file, the **Crop photo** dialog opens. Drag the image to position it and use the **Zoom** slider to frame it, then select **Crop and upload**. Select **Skip and upload** to use the whole image, or **Cancel** to stop.- The crop frame follows the photo's **Aspect ratio** setting, so set that first if you want a non-square photo. When **Fit** is set to **Contain**, readable images within the size limit upload without the crop step. Larger images still open the crop editor.+ The crop frame follows the saved **Aspect ratio** setting. After adding a photo, select **Edit** to change its shape+ for later uploads. When **Fit** is set to **Contain**, readable images within the size limit upload without the crop+ step. Larger images still open the crop editor.</Step><Step title="Adjust how it looks">- Change the settings below and watch the page update. Your changes save as you make them.+ After the photo is added, select **Edit**, then change the settings below and watch the page update. Your changes save as you make them.</Step></Steps>@@ -114,7 +116,6 @@ Whether to include a photo depends on where you're applying. Many applicant trac| Eye icon next to **URL** | Hides the photo from the page without deleting it (**Hide photo** / **Show photo**). The photo row then says "Photo hidden from the page." || **Fit** | **Cover** fills the frame and trims the edges. **Contain** shows the whole image inside the frame. || **Size** | The photo's width on the page, from 32 to 512 pt. |-| **Rotation** | Disabled because the PDF engine does not support rotation. || **Aspect ratio** | Width divided by height, from 0.5 to 2.5. The three buttons set square (1), landscape (1.5) or portrait (0.5). || **Border radius** | Rounds the corners, from 0 to 100 pt. The buttons set square corners, slightly rounded, or a circle. || **Border width** and color | Draws a border around the photo. Select the color square to pick its color. |diff --git a/docs/images/guides/filling-in-your-details/crop-picture-dialog.webp b/docs/images/guides/filling-in-your-details/crop-picture-dialog.webpindex 8db541960..2f9a04282 100644Binary files a/docs/images/guides/filling-in-your-details/crop-picture-dialog.webp and b/docs/images/guides/filling-in-your-details/crop-picture-dialog.webp differdiff --git a/docs/images/guides/filling-in-your-details/photo-popover.webp b/docs/images/guides/filling-in-your-details/photo-popover.webpindex 31a710395..c6be9cdae 100644Binary files a/docs/images/guides/filling-in-your-details/photo-popover.webp and b/docs/images/guides/filling-in-your-details/photo-popover.webp differdiff --git a/packages/schema/src/resume/default-layout.test.ts b/packages/schema/src/resume/default-layout.test.tsnew file mode 100644index 000000000..bcba40e4f--- /dev/null+++ b/packages/schema/src/resume/default-layout.test.ts@@ -0,0 +1,20 @@+import { expect, it } from "vite-plus/test";+import { parseResumeData } from "./data";+import { defaultResumeData } from "./default";++it("starts a professional resume with its narrative and retains Profiles in the main column", () => {+ const [page] = defaultResumeData.metadata.layout.pages;+ expect(page?.main.slice(0, 4)).toEqual(["summary", "experience", "education", "projects"]);+ expect(page?.main.at(-1)).toBe("profiles");+ expect(page?.sidebar).not.toContain("profiles");+});++it("preserves an existing explicit section order when reading saved or structured imported data", () => {+ const source = structuredClone(defaultResumeData);+ const page = source.metadata.layout.pages[0];+ if (!page) throw new Error("Missing default page");+ page.main = ["profiles", "education", "experience", "summary", "projects", "volunteer", "references"];+ const before = structuredClone(source.metadata.layout);+ expect(parseResumeData(source).metadata.layout).toEqual(before);+ expect(source.metadata.layout).toEqual(before);+});diff --git a/packages/schema/src/resume/default.ts b/packages/schema/src/resume/default.tsindex c875c1d26..0a5c82b4a 100644--- a/packages/schema/src/resume/default.ts+++ b/packages/schema/src/resume/default.ts@@ -60,7 +60,7 @@ export const defaultResumeData: ResumeData = {{fullWidth: false,// Summary leads, with Profiles beside it near the contact details, then Experience before Education.- main: ["summary", "profiles", "experience", "education", "projects", "volunteer", "references"],+ main: ["summary", "experience", "education", "projects", "volunteer", "references", "profiles"],sidebar: ["skills", "certifications", "awards", "languages", "interests", "publications"],},],diff --git a/packages/ui/src/components/slider.test.tsx b/packages/ui/src/components/slider.test.tsxnew file mode 100644index 000000000..7e11a8820--- /dev/null+++ b/packages/ui/src/components/slider.test.tsx@@ -0,0 +1,23 @@+// @vitest-environment happy-dom+import { cleanup, render, screen } from "@testing-library/react";+import { afterEach, expect, it } from "vite-plus/test";+import { Slider } from "./slider";++afterEach(cleanup);++it("names the actual standalone range input and updates its label", () => {+ const view = render(<Slider value={[1]} min={1} max={3} aria-label="Zoom" />);+ // Happy DOM has no track geometry; browser coverage verifies the thumb's visibility.+ const input = view.container.querySelector('input[type="range"]');+ expect(input).toHaveAttribute("aria-label", "Zoom");+ view.rerender(<Slider value={[1]} min={1} max={3} aria-label="Vergrößern" />);+ expect(input).toHaveAttribute("aria-label", "Vergrößern");+});++it("keeps a range group's label without assigning it to both endpoints", () => {+ const view = render(<Slider defaultValue={[20, 80]} aria-label="Selected range" data-testid="range" />);+ expect(screen.getByTestId("range")).toHaveAccessibleName("Selected range");+ const inputs = view.container.querySelectorAll('input[type="range"]');+ expect(inputs).toHaveLength(2);+ for (const input of inputs) expect(input.getAttribute("aria-label")).toBeNull();+});diff --git a/packages/ui/src/components/slider.tsx b/packages/ui/src/components/slider.tsxindex 0edf5c795..02e5bbcfe 100644--- a/packages/ui/src/components/slider.tsx+++ b/packages/ui/src/components/slider.tsx@@ -15,6 +15,7 @@ function Slider({// would duplicate the id on the wrapper div. Standalone usage has no// FormControl context, so an explicit caller id must survive there.id: idProp,+ "aria-label": ariaLabel,"aria-labelledby": ariaLabelledBy,"aria-describedby": ariaDescribedBy,"aria-invalid": ariaInvalid,@@ -57,6 +58,7 @@ function Slider({max={max}thumbAlignment="edge"data-slot="slider"+ aria-label={ariaLabel}aria-labelledby={ariaLabelledBy ?? labelId}{...props}>@@ -74,6 +76,7 @@ function Slider({<SliderPrimitive.Thumbdata-slot="slider-thumb"key={thumb.key}+ aria-label={_values.length === 1 ? ariaLabel : undefined}aria-describedby={ariaDescribedBy}inputRef={syncThumbInput}className="relative block size-4 shrink-0 rounded-sm border-2 border-accent bg-white shadow-e1 transition-[box-shadow] duration-quick select-none after:absolute after:-inset-2 hover:shadow-[0_0_0_4px_var(--accent-soft)] active:shadow-[0_0_0_4px_var(--accent-soft)] disabled:pointer-events-none disabled:opacity-50 has-focus-visible:outline-2 has-focus-visible:outline-offset-2 has-focus-visible:outline-accent"diff --git a/tests/e2e/specs/builder-photo-defaults.spec.ts b/tests/e2e/specs/builder-photo-defaults.spec.tsnew file mode 100644index 000000000..230464138--- /dev/null+++ b/tests/e2e/specs/builder-photo-defaults.spec.ts@@ -0,0 +1,126 @@+import type { Page } from "@playwright/test";+import { execFileSync } from "node:child_process";+import { test, expect } from "../fixtures/test";+async function create(page: Page, name: string, sample = false) {+ const r = await page.request.post("/api/openapi/resumes", { data: { name, tags: [], withSampleData: sample } });+ expect(r.ok()).toBe(true);+ return r.json();+}+async function read(page: Page, id: string) {+ const r = await page.request.get(`/api/openapi/resumes/${id}`);+ expect(r.ok()).toBe(true);+ return r.json();+}+test("L3-15 new default PDF keeps career narrative first and all links, preserving explicit layouts", async ({+ authPage: page,+}) => {+ const id = await create(page, "Fictional professional order");+ const sample = await read(page, await create(page, "Fictional source", true));+ const saved = await read(page, id);+ const data = saved.data;+ expect(data.metadata.layout.pages[0].main.slice(0, 3)).toEqual(["summary", "experience", "education"]);+ expect(data.metadata.layout.pages[0].main.at(-1)).toBe("profiles");+ data.metadata.template = "onyx";+ data.basics.name = "Jordan Rivera";+ data.summary.content = "<p>Fictional professional summary.</p>";+ for (const [key, title] of [+ ["experience", "Fictional experience"],+ ["education", "Fictional education"],+ ["profiles", "Fictional links"],+ ]) {+ data.sections[key].title = title;+ data.sections[key].items = sample.data.sections[key].items.slice(0, 1);+ }+ const patch = await page.request.patch(`/api/openapi/resumes/${id}`, {+ data: {+ operations: ["basics", "metadata", "summary", "sections"].map((key) => ({+ op: "replace",+ path: "/" + key,+ value: data[key],+ })),+ },+ });+ expect(patch.ok()).toBe(true);+ await page.goto(`/builder/${id}`);+ const pending = page.waitForEvent("download");+ await page.getByRole("button", { name: "Download PDF", exact: true }).click();+ const file = await pending;+ expect(await file.failure()).toBeNull();+ const path = await file.path();+ if (!path) throw Error("missing PDF");+ const text = execFileSync("pdftotext", [path, "-"], { encoding: "utf8" }).toLowerCase();+ for (const title of [+ "Fictional professional summary.",+ "Fictional experience",+ "Fictional education",+ "Fictional links",+ ])+ expect(text).toContain(title.toLowerCase());+ expect(text.indexOf("fictional professional summary.")).toBeLessThan(text.indexOf("fictional experience"));+ expect(text.indexOf("fictional experience")).toBeLessThan(text.indexOf("fictional education"));+ expect(text.indexOf("fictional education")).toBeLessThan(text.indexOf("fictional links"));+ const explicit = ["profiles", "education", "experience", "summary", "projects", "volunteer", "references"];+ const changed = await page.request.patch(`/api/openapi/resumes/${id}`, {+ data: { operations: [{ op: "replace", path: "/metadata/layout/pages/0/main", value: explicit }] },+ });+ expect(changed.ok()).toBe(true);+ await page.reload();+ expect((await read(page, id)).data.metadata.layout.pages[0].main).toEqual(explicit);+});+test("L3-30 Add chooses file, crop cancel keeps document, upload enables appearance controls", async ({+ authPage: page,+}, info) => {+ await page.setViewportSize({ width: 1440, height: 1200 });+ const id = await create(page, "Fictional photo flow");+ await page.goto(`/builder/${id}`);+ const row = page.locator("#sidebar-picture");+ const pending = page.waitForEvent("filechooser");+ await row.getByRole("button", { name: "Add", exact: true }).click();+ const chooser = await pending;+ await chooser.setFiles("apps/web/public/photos/sample-picture.jpg");+ const crop = page.getByRole("dialog", { name: "Crop photo", exact: true });+ await expect(crop).toBeVisible();+ await expect(crop.getByRole("slider", { name: "Zoom", exact: true })).toBeVisible();+ await crop.screenshot({ path: info.outputPath("crop-picture-dialog.png"), animations: "disabled" });+ await crop.getByRole("button", { name: "Cancel", exact: true }).click();+ await expect(crop).toBeHidden();+ expect((await read(page, id)).data.picture.url).toBe("");+ const choose = page.waitForEvent("filechooser");+ await row.getByRole("button", { name: "Add", exact: true }).click();+ await (await choose).setFiles("apps/web/public/photos/sample-picture.jpg");+ await expect(crop.getByRole("button", { name: "Crop and upload", exact: true })).toBeEnabled();+ await crop.getByRole("button", { name: "Crop and upload", exact: true }).click();+ await expect(row.getByRole("button", { name: "Edit", exact: true })).toBeVisible();+ await page.getByRole("status").filter({ hasText: "Saved" }).waitFor();+ expect((await read(page, id)).data.picture.url).not.toBe("");+ await row.getByRole("button", { name: "Edit", exact: true }).click();+ await expect(page.getByText("Border color", { exact: true })).toBeVisible();+ await expect(page.getByText("Rotation", { exact: true })).toHaveCount(0);+ await page+ .locator('[data-slot="popover-content"]')+ .screenshot({ path: info.outputPath("photo-options.png"), animations: "disabled" });+ await page.reload();+ await expect(row.getByRole("button", { name: "Edit", exact: true })).toBeVisible();+});++for (const width of [1440, 390]) {+ test(`L3-30 image URL remains usable before upload at ${width}px`, async ({ authPage: page }) => {+ await page.setViewportSize({ width, height: 900 });+ const id = await create(page, "Fictional address photo");+ await page.goto(`/builder/${id}`);+ if (width === 390) await page.getByRole("button", { name: "Write", exact: true }).click();+ const row = page.locator("#sidebar-picture");+ await row.getByRole("button", { name: "URL", exact: true }).click();+ await expect(page.getByText("Border color", { exact: true })).toHaveCount(0);+ const url = new URL("/photos/sample-picture.jpg", page.url()).href;+ await page.getByRole("textbox", { name: "URL", exact: true }).fill(url);+ await page.getByRole("textbox", { name: "URL", exact: true }).blur();+ await page.getByRole("status").filter({ hasText: "Saved" }).waitFor();+ expect((await read(page, id)).data.picture.url).toBe(url);+ await page.reload();+ if (width === 390) await page.getByRole("button", { name: "Write", exact: true }).click();+ await expect(row.getByRole("button", { name: "Edit", exact: true })).toBeVisible();+ const overflow = await page.evaluate(() => document.documentElement.scrollWidth > innerWidth);+ expect(overflow).toBe(false);+ });+}