mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-08-21 14:01:42 +10:00
b932711f08
* feat: add section heading icons to PDF templates Add customizable Phosphor icons before section titles in PDF output. Users can toggle visibility globally via a new "Hide section heading icons" switch (independent of item-level icons) and customize individual section icons through the builder sidebar icon picker. - Add `icon` field to `baseSectionSchema` and `summarySchema` - Add `hideSectionIcons` to `pageSchema` (defaults to true for backward compat) - Implement `SectionHeadingIcon` component with heading font-size scaling - Support "none" sentinel for per-section icon hiding - Fallback to sensible defaults (briefcase, graduation-cap, etc.) for legacy data - Add icon picker to builder sidebar sections and custom section dialogs Closes #2632 * test: add unit tests for section heading icons - Add tests for getResumeSectionIcon() covering built-in sections, summary, custom sections, "none" sentinel, and default fallbacks - Add schema tests for baseSectionSchema icon field, summarySchema icon, and pageSchema hideSectionIcons default behavior * refactor: minor updates to icon display * Update apps/web/locales/es-ES.po Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --------- Co-authored-by: Amruth Pillai <im.amruth@gmail.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
import type { ResumeData, SectionType } from "@reactive-resume/schema/resume/data";
|
|
import { getDefaultSectionIconName } from "@reactive-resume/schema/resume/section-icons";
|
|
|
|
type RenderData = ResumeData & {
|
|
resolveSectionTitle?: unknown;
|
|
};
|
|
|
|
export const getResumeSectionIcon = (data: RenderData, sectionId: string): string => {
|
|
if (sectionId === "summary") {
|
|
const icon = data.summary.icon;
|
|
if (icon === "none") return "";
|
|
return icon || getDefaultSectionIconName("summary");
|
|
}
|
|
|
|
if (sectionId in data.sections) {
|
|
const sectionType = sectionId as SectionType;
|
|
const icon = data.sections[sectionType].icon;
|
|
if (icon === "none") return "";
|
|
return icon || getDefaultSectionIconName(sectionType);
|
|
}
|
|
|
|
const customSection = data.customSections.find((section) => section.id === sectionId);
|
|
if (!customSection) return "";
|
|
|
|
const icon = customSection.icon;
|
|
if (icon === "none") return "";
|
|
// For custom sections, fall back to the default icon of their base type
|
|
return icon || getDefaultSectionIconName(customSection.type);
|
|
};
|