-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ard-skill-section Updated hard skills section
- Loading branch information
Showing
4 changed files
with
69 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/manfred2word/src/engine/doc-parts/hard-skill-section/hard-skill-section.helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { IParagraphOptions, IRunOptions, Paragraph, Table, TableCell, TableRow, TextRun, XmlComponent } from 'docx'; | ||
import { TableStyles } from '../doc-parts.vm'; | ||
|
||
export const renderTable = (rows: TableRow[], styles?: TableStyles): XmlComponent => | ||
new Table({ | ||
...styles, | ||
rows: [...rows], | ||
}); | ||
|
||
export const renderTableRow = (cells: TableCell[], styles?: TableStyles): TableRow => | ||
new TableRow({ | ||
...styles, | ||
children: [...cells], | ||
}); | ||
|
||
export const renderTableCell = (children: XmlComponent[], styles?: TableStyles): TableCell => | ||
new TableCell({ | ||
...styles, | ||
children: [...children], | ||
}); | ||
|
||
export const renderParagraph = (children: XmlComponent[], opcions?: IParagraphOptions): XmlComponent => | ||
new Paragraph({ | ||
...opcions, | ||
children: [...children], | ||
}); | ||
|
||
export const renderTextRun = (text: string, options?: IRunOptions): XmlComponent => new TextRun({ ...options, text }); |
71 changes: 39 additions & 32 deletions
71
packages/manfred2word/src/engine/doc-parts/hard-skill-section/hard-skill-section.part.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,47 @@ | ||
import { TableCell, TableRow, Table } from 'docx'; | ||
import { TableRow, Table, XmlComponent, HeadingLevel } from 'docx'; | ||
import { ManfredAwesomicCV } from '@/model'; | ||
import { HardSkillVM } from './hard-skill-section.vm'; | ||
import { mapFromCvToHardSkillVm } from './hard-skill-section.mapper'; | ||
import { | ||
renderTable, | ||
renderTableRow, | ||
renderTableCell, | ||
renderParagraph, | ||
renderTextRun, | ||
} from './hard-skill-section.helpers'; | ||
import { sectionTitle } from './hard-skill-constants'; | ||
import { styles } from './hard-skill-section.styles'; | ||
import { renderSectionHardSkillSection, renderTitleHardSkillSection } from './sections-hard-skill-section.parts'; | ||
|
||
export const generateHardSkillSection = (cv: ManfredAwesomicCV): Table => { | ||
const hardSkillVmArray = mapFromCvToHardSkillVm(cv); | ||
const getSkillNameList = (skillList: HardSkillVM[]): string[] => | ||
skillList.map(item => (item.skill?.name ? item.skill?.name : '')); | ||
|
||
const createSkillListWithSeparator = (skillList: string[]): XmlComponent[] => | ||
skillList.map((item, index) => (index === skillList.length - 1 ? renderTextRun(item) : renderTextRun(`${item} / `))); | ||
|
||
const createSkillsTableRow = (skillList: HardSkillVM[]): TableRow => { | ||
const list = getSkillNameList(skillList); | ||
const skillListWithSeparator = createSkillListWithSeparator(list); | ||
const paragraph = renderParagraph(skillListWithSeparator, { spacing: { before: 200 } }); | ||
const cell = renderTableCell([paragraph]); | ||
const row = renderTableRow([cell]); | ||
|
||
return generateHardSkillSectionInner(hardSkillVmArray); | ||
return row; | ||
}; | ||
|
||
const generateHardSkillSectionInner = (hardSkillVmArray: HardSkillVM[]): Table => | ||
new Table({ | ||
...styles.table, | ||
rows: [generateTitleHardSkill(), ...generateSectionFromVmToRows(hardSkillVmArray)], | ||
}); | ||
|
||
const generateTitleHardSkill = (): TableRow => | ||
new TableRow({ | ||
children: [ | ||
new TableCell({ | ||
children: [renderTitleHardSkillSection()], | ||
}), | ||
], | ||
}); | ||
|
||
const generateSectionFromVmToRows = (hardSkillSectionVm: HardSkillVM[]): TableRow[] => | ||
Boolean(hardSkillSectionVm) ? hardSkillSectionVm.map(softSkillVm => hardSkillsSection(softSkillVm)) : []; | ||
|
||
const hardSkillsSection = (sectionSoftSkillVm: HardSkillVM): TableRow => | ||
new TableRow({ | ||
children: [ | ||
new TableCell({ | ||
...styles.table, | ||
children: renderSectionHardSkillSection(sectionSoftSkillVm), | ||
}), | ||
], | ||
}); | ||
const createTitleTableRow = (text: string): TableRow => { | ||
const title = renderTextRun(text, { size: '18pt', bold: true }); | ||
const paragraph = renderParagraph([title], { spacing: { before: 200 } }); | ||
const cell = renderTableCell([paragraph]); | ||
const row = renderTableRow([cell]); | ||
|
||
return row; | ||
}; | ||
|
||
export const generateHardSkillSection = (cv: ManfredAwesomicCV): Table => { | ||
const hardSkillList = mapFromCvToHardSkillVm(cv); | ||
const title = createTitleTableRow(sectionTitle); | ||
const hardSkillItems = createSkillsTableRow(hardSkillList); | ||
const table = renderTable([title, hardSkillItems], styles.table); | ||
|
||
return table; | ||
}; |
56 changes: 0 additions & 56 deletions
56
...manfred2word/src/engine/doc-parts/hard-skill-section/sections-hard-skill-section.parts.ts
This file was deleted.
Oops, something went wrong.