Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/app/components/Resume/ResumePDF/ResumePDFProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ResumePDFLink,
ResumePDFSection,
ResumePDFText,
addSoftBreaksToLongUnbrokenText,
} from "components/Resume/ResumePDF/common";
import type { ResumeProfile } from "lib/redux/types";

Expand Down Expand Up @@ -85,12 +86,17 @@ export const ResumePDFProfile = ({
...styles.flexRow,
alignItems: "center",
gap: spacing["1"],
maxWidth: "100%",
}}
>
<ResumePDFIcon type={iconType} isPDF={isPDF} />
<Wrapper>
<ResumePDFText>{value}</ResumePDFText>
</Wrapper>
<View style={{ flexGrow: 1, flexBasis: 0, maxWidth: "100%" }}>
<Wrapper>
<ResumePDFText>
{addSoftBreaksToLongUnbrokenText(value)}
</ResumePDFText>
</Wrapper>
</View>
</View>
);
})}
Expand Down
20 changes: 19 additions & 1 deletion src/app/components/Resume/ResumePDF/common/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ import { styles, spacing } from "components/Resume/ResumePDF/styles";
import { DEBUG_RESUME_PDF_FLAG } from "lib/constants";
import { DEFAULT_FONT_COLOR } from "lib/redux/settingsSlice";

const SOFT_BREAK_CHARACTER = "\u200B";
const LONG_UNBROKEN_TEXT_LENGTH = 20;
const SOFT_BREAK_INTERVAL = 8;

export const addSoftBreaksToLongUnbrokenText = (text: string) => {
return text
.split(/(\s+)/)
.map((segment) => {
if (segment.length < LONG_UNBROKEN_TEXT_LENGTH || /\s+/.test(segment)) {
return segment;
}

const chunks = segment.match(new RegExp(`.{1,${SOFT_BREAK_INTERVAL}}`, "g"));
return chunks ? chunks.join(SOFT_BREAK_CHARACTER) : segment;
})
.join("");
};

export const ResumePDFSection = ({
themeColor,
heading,
Expand Down Expand Up @@ -104,7 +122,7 @@ export const ResumePDFBulletList = ({
<ResumePDFText
style={{ lineHeight: "1.3", flexGrow: 1, flexBasis: 0 }}
>
{item}
{addSoftBreaksToLongUnbrokenText(item)}
</ResumePDFText>
</View>
))}
Expand Down