Skip to content

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!

feat: add cover letter builder rail shortcut

Amruth Pillaia3784558b7fb
diff --git a/apps/web/src/features/resume/builder/section-recovery.tsx b/apps/web/src/features/resume/builder/section-recovery.tsx
index 581261739..a25b9bb91 100644
--- a/apps/web/src/features/resume/builder/section-recovery.tsx
+++ b/apps/web/src/features/resume/builder/section-recovery.tsx
@@ -25,14 +25,14 @@ export function getVisibleLeftSidebarSections(data: ResumeData): LeftSidebarSect
);
}
-export function focusLeftSidebarSection(section: LeftSidebarSection): void {
- const editorTarget = document.getElementById(`sidebar-${section}`);
+function focusSidebarSection(sectionId: string): void {
+ const editorTarget = document.getElementById(`sidebar-${sectionId}`);
if (editorTarget) {
editorTarget.scrollIntoView({ block: "start", inline: "nearest", behavior: "smooth" });
return;
}
- const recoveryTargetId = `sidebar-hidden-${section}`;
+ const recoveryTargetId = `sidebar-hidden-${sectionId}`;
const focusRecoveryTarget = () => {
const recoveryTarget = document.getElementById(recoveryTargetId);
if (!recoveryTarget) return;
@@ -51,6 +51,14 @@ export function focusLeftSidebarSection(section: LeftSidebarSection): void {
focusRecoveryTarget();
}
+export function focusLeftSidebarSection(section: LeftSidebarSection): void {
+ focusSidebarSection(section);
+}
+
+export function focusCustomSidebarSection(sectionId: string): void {
+ focusSidebarSection(sectionId);
+}
+
type SectionEditorListProps = {
renderSection: (section: LeftSidebarSection) => ReactNode;
};
diff --git a/apps/web/src/routes/builder/$resumeId/-sidebar/left/index.tsx b/apps/web/src/routes/builder/$resumeId/-sidebar/left/index.tsx
index 4ce4b3305..5fc133f41 100644
--- a/apps/web/src/routes/builder/$resumeId/-sidebar/left/index.tsx
+++ b/apps/web/src/routes/builder/$resumeId/-sidebar/left/index.tsx
@@ -11,8 +11,17 @@ import { ScrollArea } from "@reactive-resume/ui/components/scroll-area";
import { toast } from "@reactive-resume/ui/components/toast";
import { Tooltip, TooltipContent, TooltipTrigger } from "@reactive-resume/ui/components/tooltip";
import { getInitials } from "@reactive-resume/utils/string";
-import { useCurrentResume, useIsResumeLocked, usePatchResume } from "@/features/resume/builder/draft";
-import { focusLeftSidebarSection, SectionEditorList } from "@/features/resume/builder/section-recovery";
+import {
+ useCurrentBuilderResumeSelector,
+ useCurrentResume,
+ useIsResumeLocked,
+ usePatchResume,
+} from "@/features/resume/builder/draft";
+import {
+ focusCustomSidebarSection,
+ focusLeftSidebarSection,
+ SectionEditorList,
+} from "@/features/resume/builder/section-recovery";
import { UserDropdownMenu } from "@/features/user/dropdown-menu";
import { getResumeErrorMessage } from "@/libs/error-message";
import { orpc } from "@/libs/orpc/client";
@@ -119,11 +128,25 @@ function LockBanner() {
function SidebarEdge() {
const { toggleSidebar } = useBuilderSidebar();
+ const coverLetterSectionId = useCurrentBuilderResumeSelector(
+ (resume) => resume.data.customSections.find((section) => section.type === "cover-letter")?.id ?? null,
+ );
+ type SidebarRailSection = LeftSidebarSection | "cover-letter";
+ type SidebarRailItem = { key: string; section: SidebarRailSection; target: string };
+ const railSections = leftSidebarSections.flatMap<SidebarRailItem>((section) => {
+ if (section !== "custom" || !coverLetterSectionId) return [{ key: section, section, target: section }];
+
+ return [
+ { key: "cover-letter", section: "cover-letter" as const, target: coverLetterSectionId },
+ { key: section, section, target: section },
+ ];
+ });
const scrollToSection = useCallback(
- (section: LeftSidebarSection) => {
+ (section: LeftSidebarSection | "cover-letter", target: LeftSidebarSection | string) => {
toggleSidebar("left", true);
- focusLeftSidebarSection(section);
+ if (section === "cover-letter") focusCustomSidebarSection(target);
+ else focusLeftSidebarSection(section);
},
[toggleSidebar],
);
@@ -133,15 +156,15 @@ function SidebarEdge() {
<div className="flex min-h-0 w-full flex-1 flex-col items-center gap-y-2 overflow-hidden">
<div className="no-scrollbar min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden">
<div className="flex min-h-full flex-col items-center justify-center gap-y-2">
- {leftSidebarSections.map((section) => (
- <Tooltip key={section}>
+ {railSections.map(({ key, section, target }) => (
+ <Tooltip key={key}>
<TooltipTrigger
render={
<Button
size="icon"
variant="ghost"
aria-label={getSectionTitle(section)}
- onClick={() => scrollToSection(section)}
+ onClick={() => scrollToSection(section, target)}
>
{getSectionIcon(section)}
</Button>
diff --git a/apps/web/src/routes/builder/$resumeId/-sidebar/left/sections/custom.tsx b/apps/web/src/routes/builder/$resumeId/-sidebar/left/sections/custom.tsx
index 455422e6c..bbe97ba17 100644
--- a/apps/web/src/routes/builder/$resumeId/-sidebar/left/sections/custom.tsx
+++ b/apps/web/src/routes/builder/$resumeId/-sidebar/left/sections/custom.tsx
@@ -164,7 +164,7 @@ function CustomSectionContainer({ section }: CustomSectionContainerProps) {
};
return (
- <div className="rounded-md border">
+ <div id={`sidebar-${section.id}`} className="rounded-md border">
{/* Section Header */}
<div className="group flex select-none">
<button
diff --git a/tests/e2e/specs/cover-letter-library.spec.ts b/tests/e2e/specs/cover-letter-library.spec.ts
index f9cfd4428..498882b92 100644
--- a/tests/e2e/specs/cover-letter-library.spec.ts
+++ b/tests/e2e/specs/cover-letter-library.spec.ts
@@ -1,7 +1,7 @@
import { randomUUID } from "node:crypto";
import { readFile } from "node:fs/promises";
import { Pool } from "pg";
-import { createSampleResumeFromDashboard, openSidebarSection } from "../fixtures/resume";
+import { createSampleResumeFromDashboard } from "../fixtures/resume";
import { expect, test } from "../fixtures/test";
test("imports a library letter into the builder as an independent copy", async ({ authPage: page }, testInfo) => {
@@ -45,7 +45,7 @@ test("imports a library letter into the builder as an independent copy", async (
await editor.getByRole("button", { name: "Close", exact: true }).click();
await page.goto(builderUrl);
- await openSidebarSection(page, "Custom Sections");
+ await page.getByRole("button", { name: "Cover Letter", exact: true }).click();
await page.getByRole("button", { name: "Add a new item", exact: true }).last().click();
const createItem = page.getByRole("dialog", { name: "Create a new cover letter", exact: true });
await createItem.getByLabel("Import from library", { exact: true }).click();