@jsonresume/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +689 -0
- package/dist/resume-print.css +425 -0
- package/dist/tokens.css +139 -0
- package/package.json +66 -0
- package/src/badges/BadgeRowOutline.jsx +118 -0
- package/src/badges/BadgeRowOutline.stories.tsx +160 -0
- package/src/badges/index.jsx +5 -0
- package/src/callouts/Callout.jsx +80 -0
- package/src/callouts/Callout.stories.tsx +27 -0
- package/src/callouts/HighlightCard.jsx +114 -0
- package/src/callouts/HighlightCard.stories.tsx +27 -0
- package/src/callouts/InfoBox.jsx +82 -0
- package/src/callouts/InfoBox.stories.tsx +26 -0
- package/src/callouts/index.jsx +4 -0
- package/src/certifications/AwardCard.jsx +83 -0
- package/src/certifications/AwardCard.stories.tsx +32 -0
- package/src/certifications/CertificationBadge.jsx +85 -0
- package/src/certifications/CertificationBadge.stories.tsx +29 -0
- package/src/certifications/CertificationRow.jsx +150 -0
- package/src/certifications/CertificationRow.stories.tsx +64 -0
- package/src/certifications/HonorsList.jsx +87 -0
- package/src/certifications/HonorsList.stories.tsx +36 -0
- package/src/certifications/index.jsx +5 -0
- package/src/containers/AccentCalloutPanel.jsx +176 -0
- package/src/containers/AccentCalloutPanel.stories.tsx +105 -0
- package/src/containers/MutedPanel.jsx +125 -0
- package/src/containers/MutedPanel.stories.tsx +113 -0
- package/src/containers/RoleBlockFramed.jsx +191 -0
- package/src/containers/RoleBlockFramed.stories.tsx +230 -0
- package/src/containers/SoftCardOutline.jsx +161 -0
- package/src/containers/SoftCardOutline.stories.tsx +174 -0
- package/src/containers/index.jsx +9 -0
- package/src/data/KPIChipLine.jsx +158 -0
- package/src/data/KPIChipLine.stories.tsx +99 -0
- package/src/data/KeyValueInline.jsx +150 -0
- package/src/data/KeyValueInline.stories.tsx +136 -0
- package/src/data/MetricBar.jsx +93 -0
- package/src/data/MetricBar.stories.tsx +31 -0
- package/src/data/MetricBullet.jsx +129 -0
- package/src/data/MetricBullet.stories.tsx +99 -0
- package/src/data/MetricInline.jsx +60 -0
- package/src/data/MetricInline.stories.tsx +53 -0
- package/src/data/ProgressCircle.jsx +81 -0
- package/src/data/ProgressCircle.stories.tsx +102 -0
- package/src/data/StatCard.jsx +65 -0
- package/src/data/StatCard.stories.tsx +29 -0
- package/src/data/index.jsx +12 -0
- package/src/dates/DateBadge.jsx +73 -0
- package/src/dates/DateBadge.stories.tsx +30 -0
- package/src/dates/RelativeDate.jsx +121 -0
- package/src/dates/RelativeDate.stories.tsx +29 -0
- package/src/dates/index.jsx +3 -0
- package/src/experience/ExperienceCard.jsx +82 -0
- package/src/experience/ExperienceCard.stories.tsx +36 -0
- package/src/experience/ExperienceCompact.jsx +72 -0
- package/src/experience/ExperienceCompact.stories.tsx +53 -0
- package/src/experience/ExperienceGrid.jsx +65 -0
- package/src/experience/ExperienceGrid.stories.tsx +63 -0
- package/src/experience/ExperienceTimeline.jsx +24 -0
- package/src/experience/ExperienceTimeline.stories.tsx +63 -0
- package/src/experience/RoleHeaderCompact.jsx +99 -0
- package/src/experience/index.jsx +9 -0
- package/src/header/ContactRowLine.jsx +125 -0
- package/src/header/ContactRowLine.stories.tsx +65 -0
- package/src/header/CornerInitials.jsx +178 -0
- package/src/header/CornerInitials.stories.tsx +129 -0
- package/src/header/Footer.jsx +50 -0
- package/src/header/Footer.stories.tsx +25 -0
- package/src/header/HeaderCentered.jsx +51 -0
- package/src/header/HeaderCentered.stories.tsx +30 -0
- package/src/header/HeaderMinimal.jsx +50 -0
- package/src/header/HeaderMinimal.stories.tsx +29 -0
- package/src/header/HeaderSplit.jsx +65 -0
- package/src/header/HeaderSplit.stories.tsx +29 -0
- package/src/header/HeroNameBlock.jsx +71 -0
- package/src/header/HeroNameBlock.stories.tsx +37 -0
- package/src/header/NameStackElegant.jsx +104 -0
- package/src/header/NameStackElegant.stories.tsx +60 -0
- package/src/header/PageBreak.jsx +25 -0
- package/src/header/PageBreak.stories.tsx +22 -0
- package/src/header/SectionFlagTitle.jsx +87 -0
- package/src/header/SectionFlagTitle.stories.tsx +53 -0
- package/src/header/SectionRuleTitle.jsx +84 -0
- package/src/header/SectionRuleTitle.stories.tsx +52 -0
- package/src/header/index.jsx +18 -0
- package/src/helpers/calculations.js +428 -0
- package/src/index.js +253 -0
- package/src/languages/LanguageBar.jsx +90 -0
- package/src/languages/LanguageBar.stories.tsx +28 -0
- package/src/languages/LanguageGrid.jsx +118 -0
- package/src/languages/LanguageGrid.stories.tsx +33 -0
- package/src/languages/LanguageLevelBarLite.jsx +147 -0
- package/src/languages/LanguageLevelBarLite.stories.tsx +74 -0
- package/src/languages/ProficiencyScale.jsx +107 -0
- package/src/languages/ProficiencyScale.stories.tsx +30 -0
- package/src/languages/index.jsx +5 -0
- package/src/layouts/CardLayout.jsx +46 -0
- package/src/layouts/CardLayout.stories.tsx +272 -0
- package/src/layouts/FlexLayout.jsx +53 -0
- package/src/layouts/FlexLayout.stories.tsx +270 -0
- package/src/layouts/GridLayout.jsx +38 -0
- package/src/layouts/GridLayout.stories.tsx +183 -0
- package/src/layouts/SidebarLayout.jsx +63 -0
- package/src/layouts/SidebarLayout.stories.tsx +162 -0
- package/src/layouts/StackLayout.jsx +26 -0
- package/src/layouts/StackLayout.stories.tsx +192 -0
- package/src/layouts/TwoColumnMicroGrid.jsx +87 -0
- package/src/layouts/TwoColumnMicroGrid.stories.tsx +96 -0
- package/src/layouts/index.jsx +11 -0
- package/src/lists/AchievementListSpacious.jsx +81 -0
- package/src/lists/AchievementListSpacious.stories.tsx +49 -0
- package/src/lists/AchievementListTight.jsx +80 -0
- package/src/lists/AchievementListTight.stories.tsx +49 -0
- package/src/lists/BulletList.jsx +66 -0
- package/src/lists/BulletList.stories.tsx +38 -0
- package/src/lists/CheckList.jsx +94 -0
- package/src/lists/CheckList.stories.tsx +38 -0
- package/src/lists/CompactList.jsx +90 -0
- package/src/lists/CompactList.stories.tsx +34 -0
- package/src/lists/DefinitionKeyline.jsx +114 -0
- package/src/lists/DefinitionKeyline.stories.tsx +90 -0
- package/src/lists/HangingBulletList.jsx +82 -0
- package/src/lists/HangingBulletList.stories.tsx +50 -0
- package/src/lists/IconList.jsx +89 -0
- package/src/lists/IconList.stories.tsx +36 -0
- package/src/lists/ListDashCompact.jsx +69 -0
- package/src/lists/ListDashCompact.stories.tsx +60 -0
- package/src/lists/MiniDotLeaderList.jsx +69 -0
- package/src/lists/MiniDotLeaderList.stories.tsx +73 -0
- package/src/lists/NumberedList.jsx +74 -0
- package/src/lists/NumberedList.stories.tsx +39 -0
- package/src/lists/index.jsx +12 -0
- package/src/metadata/GreyLabelCaps.jsx +66 -0
- package/src/metadata/GreyLabelCaps.stories.tsx +40 -0
- package/src/metadata/InlineKicker.jsx +61 -0
- package/src/metadata/InlineKicker.stories.tsx +35 -0
- package/src/metadata/MetaRow.jsx +96 -0
- package/src/metadata/MetaRow.stories.tsx +38 -0
- package/src/metadata/SmallCapsHeading.jsx +75 -0
- package/src/metadata/SmallCapsHeading.stories.tsx +54 -0
- package/src/metadata/SubsectionLabel.jsx +92 -0
- package/src/metadata/SubsectionLabel.stories.tsx +40 -0
- package/src/metadata/index.jsx +10 -0
- package/src/primitives/AccentSidebarStripe.stories.tsx +65 -0
- package/src/primitives/AccentSidebarStripe.tsx +95 -0
- package/src/primitives/AccentTopRule.stories.tsx +102 -0
- package/src/primitives/AccentTopRule.tsx +103 -0
- package/src/primitives/Badge.jsx +125 -0
- package/src/primitives/Badge.stories.tsx +27 -0
- package/src/primitives/ContactInfo.jsx +133 -0
- package/src/primitives/ContactInfo.stories.tsx +30 -0
- package/src/primitives/DIVIDERS.md +333 -0
- package/src/primitives/DateRange.jsx +178 -0
- package/src/primitives/DateRange.stories.tsx +28 -0
- package/src/primitives/DottedDivider.stories.tsx +54 -0
- package/src/primitives/DottedDivider.tsx +102 -0
- package/src/primitives/InlineSeparatorPipe.jsx +64 -0
- package/src/primitives/InlineSeparatorPipe.stories.tsx +96 -0
- package/src/primitives/KeylineDivider.stories.tsx +48 -0
- package/src/primitives/KeylineDivider.tsx +80 -0
- package/src/primitives/Link.jsx +59 -0
- package/src/primitives/Link.stories.tsx +29 -0
- package/src/primitives/ListItem.jsx +127 -0
- package/src/primitives/ListItem.stories.tsx +27 -0
- package/src/primitives/RulesetStack.stories.tsx +85 -0
- package/src/primitives/RulesetStack.tsx +117 -0
- package/src/primitives/Section.jsx +37 -0
- package/src/primitives/Section.stories.tsx +28 -0
- package/src/primitives/SectionTitle.jsx +62 -0
- package/src/primitives/SectionTitle.stories.tsx +27 -0
- package/src/primitives/index.jsx +36 -0
- package/src/print/ColumnBreak.jsx +44 -0
- package/src/print/ColumnBreak.stories.tsx +22 -0
- package/src/print/KeepTogether.jsx +24 -0
- package/src/print/KeepTogether.stories.tsx +26 -0
- package/src/print/LetterheadBar.jsx +100 -0
- package/src/print/LetterheadBar.stories.tsx +141 -0
- package/src/print/PageFooterLine.jsx +93 -0
- package/src/print/PageFooterLine.stories.tsx +121 -0
- package/src/print/PageHeaderLine.jsx +59 -0
- package/src/print/PageHeaderLine.stories.tsx +108 -0
- package/src/print/PrintOnly.jsx +49 -0
- package/src/print/PrintOnly.stories.tsx +26 -0
- package/src/print/SoftShadowEmulation.jsx +88 -0
- package/src/print/SoftShadowEmulation.stories.tsx +214 -0
- package/src/print/index.jsx +8 -0
- package/src/profile/Avatar.jsx +66 -0
- package/src/profile/Avatar.stories.tsx +84 -0
- package/src/profile/ContactGrid.jsx +63 -0
- package/src/profile/ContactGrid.stories.tsx +33 -0
- package/src/profile/ProfileCard.jsx +73 -0
- package/src/profile/ProfileCard.stories.tsx +35 -0
- package/src/profile/SocialLinks.jsx +61 -0
- package/src/profile/SocialLinks.stories.tsx +33 -0
- package/src/profile/index.jsx +9 -0
- package/src/providers/ThemeProvider.jsx +56 -0
- package/src/providers/ThemeProvider.stories.tsx +149 -0
- package/src/publications/PortfolioGrid.jsx +122 -0
- package/src/publications/PortfolioGrid.stories.tsx +62 -0
- package/src/publications/ProjectCard.jsx +151 -0
- package/src/publications/ProjectCard.stories.tsx +36 -0
- package/src/publications/PublicationEntryPlain.jsx +127 -0
- package/src/publications/PublicationEntryPlain.stories.tsx +58 -0
- package/src/publications/PublicationItem.jsx +120 -0
- package/src/publications/PublicationItem.stories.tsx +32 -0
- package/src/publications/index.jsx +5 -0
- package/src/quotes/BlockQuote.jsx +55 -0
- package/src/quotes/BlockQuote.stories.tsx +33 -0
- package/src/quotes/PullQuote.jsx +70 -0
- package/src/quotes/PullQuote.stories.tsx +32 -0
- package/src/quotes/Testimonial.jsx +99 -0
- package/src/quotes/Testimonial.stories.tsx +36 -0
- package/src/quotes/index.jsx +4 -0
- package/src/skills/SkillBar.jsx +66 -0
- package/src/skills/SkillBar.stories.tsx +112 -0
- package/src/skills/SkillCategory.jsx +71 -0
- package/src/skills/SkillCategory.stories.tsx +197 -0
- package/src/skills/SkillCloud.jsx +53 -0
- package/src/skills/SkillCloud.stories.tsx +132 -0
- package/src/skills/SkillGroup.jsx +56 -0
- package/src/skills/SkillGroup.stories.tsx +162 -0
- package/src/skills/SkillPill.jsx +56 -0
- package/src/skills/SkillPill.stories.tsx +157 -0
- package/src/skills/SkillRating.jsx +60 -0
- package/src/skills/SkillRating.stories.tsx +115 -0
- package/src/skills/index.jsx +11 -0
- package/src/styles/tokens.css +139 -0
- package/src/tables/ComparisonTable.jsx +128 -0
- package/src/tables/ComparisonTable.stories.tsx +41 -0
- package/src/tables/DataTable.jsx +149 -0
- package/src/tables/DataTable.stories.tsx +64 -0
- package/src/tables/SkillMatrix.jsx +139 -0
- package/src/tables/SkillMatrix.stories.tsx +90 -0
- package/src/tables/index.jsx +4 -0
- package/src/tags/ToolTagRibbon.jsx +106 -0
- package/src/tags/ToolTagRibbon.stories.tsx +121 -0
- package/src/tags/index.jsx +5 -0
- package/src/timeline/TimelineInline.stories.tsx +83 -0
- package/src/timeline/TimelineInline.tsx +202 -0
- package/src/timeline/TimelineItem.jsx +106 -0
- package/src/timeline/TimelineItem.stories.tsx +64 -0
- package/src/timeline/TimelineRuleMinimal.stories.tsx +68 -0
- package/src/timeline/TimelineRuleMinimal.tsx +165 -0
- package/src/timeline/TimelineSection.jsx +21 -0
- package/src/timeline/TimelineSection.stories.tsx +44 -0
- package/src/timeline/index.jsx +9 -0
- package/src/tokens/index.js +164 -0
- package/src/typography/Heading.jsx +48 -0
- package/src/typography/Heading.stories.tsx +46 -0
- package/src/typography/HyphenationSafeParagraph.jsx +98 -0
- package/src/typography/HyphenationSafeParagraph.stories.tsx +151 -0
- package/src/typography/Label.jsx +38 -0
- package/src/typography/Label.stories.tsx +27 -0
- package/src/typography/QuoteStripe.jsx +78 -0
- package/src/typography/QuoteStripe.stories.tsx +63 -0
- package/src/typography/SectionIntroParagraph.jsx +62 -0
- package/src/typography/SectionIntroParagraph.stories.tsx +57 -0
- package/src/typography/Text.jsx +42 -0
- package/src/typography/Text.stories.tsx +35 -0
- package/src/typography/index.jsx +11 -0
- package/src/utils/Divider.jsx +32 -0
- package/src/utils/Divider.stories.tsx +24 -0
- package/src/utils/Flex.jsx +6 -0
- package/src/utils/Flex.stories.tsx +28 -0
- package/src/utils/Grid.jsx +6 -0
- package/src/utils/Grid.stories.tsx +28 -0
- package/src/utils/Spacer.jsx +18 -0
- package/src/utils/Spacer.stories.tsx +26 -0
- package/src/utils/index.jsx +9 -0
- package/src/utils/security.js +155 -0
- package/src/visuals/BackgroundPattern.jsx +65 -0
- package/src/visuals/BackgroundPattern.stories.tsx +27 -0
- package/src/visuals/BorderAccent.jsx +147 -0
- package/src/visuals/BorderAccent.stories.tsx +27 -0
- package/src/visuals/ColorBlock.jsx +60 -0
- package/src/visuals/ColorBlock.stories.tsx +27 -0
- package/src/visuals/DividerVariants.jsx +120 -0
- package/src/visuals/DividerVariants.stories.tsx +27 -0
- package/src/visuals/index.jsx +5 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resume Data Calculation Helpers
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for computing metrics and insights from JSON Resume data.
|
|
5
|
+
* Use these helpers in themes to display calculated metrics, statistics, and insights.
|
|
6
|
+
*
|
|
7
|
+
* @module @resume/core/helpers/calculations
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Calculate total years of professional experience from work history
|
|
12
|
+
* @param {Array} work - Array of work experience objects with startDate and endDate
|
|
13
|
+
* @returns {number} Total years of experience (rounded to nearest year)
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const years = calculateTotalExperience(resume.work);
|
|
17
|
+
* // => 8 (years)
|
|
18
|
+
*/
|
|
19
|
+
export function calculateTotalExperience(work = []) {
|
|
20
|
+
if (!Array.isArray(work) || work.length === 0) return 0;
|
|
21
|
+
|
|
22
|
+
const totalYears = work.reduce((acc, job) => {
|
|
23
|
+
if (!job.startDate) return acc;
|
|
24
|
+
|
|
25
|
+
const start = new Date(job.startDate);
|
|
26
|
+
const end = job.endDate ? new Date(job.endDate) : new Date();
|
|
27
|
+
const years = (end - start) / (1000 * 60 * 60 * 24 * 365.25); // Use 365.25 for leap years
|
|
28
|
+
|
|
29
|
+
return acc + years;
|
|
30
|
+
}, 0);
|
|
31
|
+
|
|
32
|
+
return Math.round(totalYears);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Calculate years of experience for the current/most recent role
|
|
37
|
+
* @param {Array} work - Array of work experience objects
|
|
38
|
+
* @returns {number} Years in current role (rounded to 1 decimal)
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* const currentYears = calculateCurrentRoleExperience(resume.work);
|
|
42
|
+
* // => 2.5 (years)
|
|
43
|
+
*/
|
|
44
|
+
export function calculateCurrentRoleExperience(work = []) {
|
|
45
|
+
if (!Array.isArray(work) || work.length === 0) return 0;
|
|
46
|
+
|
|
47
|
+
// Assume first item is most recent (no endDate or latest endDate)
|
|
48
|
+
const currentRole = work.find((job) => !job.endDate) || work[0];
|
|
49
|
+
if (!currentRole || !currentRole.startDate) return 0;
|
|
50
|
+
|
|
51
|
+
const start = new Date(currentRole.startDate);
|
|
52
|
+
const end = currentRole.endDate ? new Date(currentRole.endDate) : new Date();
|
|
53
|
+
const years = (end - start) / (1000 * 60 * 60 * 24 * 365.25);
|
|
54
|
+
|
|
55
|
+
return Math.round(years * 10) / 10; // Round to 1 decimal
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Count total number of companies worked at
|
|
60
|
+
* @param {Array} work - Array of work experience objects
|
|
61
|
+
* @returns {number} Number of unique companies
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* const companies = countCompanies(resume.work);
|
|
65
|
+
* // => 5
|
|
66
|
+
*/
|
|
67
|
+
export function countCompanies(work = []) {
|
|
68
|
+
if (!Array.isArray(work) || work.length === 0) return 0;
|
|
69
|
+
|
|
70
|
+
const uniqueCompanies = new Set(work.map((job) => job.name).filter(Boolean));
|
|
71
|
+
|
|
72
|
+
return uniqueCompanies.size;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Count total number of projects
|
|
77
|
+
* @param {Array} projects - Array of project objects
|
|
78
|
+
* @returns {number} Number of projects
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* const projectCount = countProjects(resume.projects);
|
|
82
|
+
* // => 12
|
|
83
|
+
*/
|
|
84
|
+
export function countProjects(projects = []) {
|
|
85
|
+
return Array.isArray(projects) ? projects.length : 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Count total number of publications
|
|
90
|
+
* @param {Array} publications - Array of publication objects
|
|
91
|
+
* @returns {number} Number of publications
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const pubCount = countPublications(resume.publications);
|
|
95
|
+
* // => 8
|
|
96
|
+
*/
|
|
97
|
+
export function countPublications(publications = []) {
|
|
98
|
+
return Array.isArray(publications) ? publications.length : 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Count total number of awards received
|
|
103
|
+
* @param {Array} awards - Array of award objects
|
|
104
|
+
* @returns {number} Number of awards
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const awardCount = countAwards(resume.awards);
|
|
108
|
+
* // => 3
|
|
109
|
+
*/
|
|
110
|
+
export function countAwards(awards = []) {
|
|
111
|
+
return Array.isArray(awards) ? awards.length : 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Count total skills across all skill categories
|
|
116
|
+
* @param {Array} skills - Array of skill objects with keywords
|
|
117
|
+
* @returns {number} Total number of skill keywords
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* const skillCount = countTotalSkills(resume.skills);
|
|
121
|
+
* // => 42
|
|
122
|
+
*/
|
|
123
|
+
export function countTotalSkills(skills = []) {
|
|
124
|
+
if (!Array.isArray(skills) || skills.length === 0) return 0;
|
|
125
|
+
|
|
126
|
+
return skills.reduce((total, skill) => {
|
|
127
|
+
const keywords = skill.keywords || [];
|
|
128
|
+
return total + keywords.length;
|
|
129
|
+
}, 0);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Count skill categories
|
|
134
|
+
* @param {Array} skills - Array of skill objects
|
|
135
|
+
* @returns {number} Number of skill categories
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* const categories = countSkillCategories(resume.skills);
|
|
139
|
+
* // => 6
|
|
140
|
+
*/
|
|
141
|
+
export function countSkillCategories(skills = []) {
|
|
142
|
+
return Array.isArray(skills) ? skills.length : 0;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Count languages spoken
|
|
147
|
+
* @param {Array} languages - Array of language objects
|
|
148
|
+
* @returns {number} Number of languages
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* const langCount = countLanguages(resume.languages);
|
|
152
|
+
* // => 3
|
|
153
|
+
*/
|
|
154
|
+
export function countLanguages(languages = []) {
|
|
155
|
+
return Array.isArray(languages) ? languages.length : 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Calculate total volunteer hours (if duration data is available)
|
|
160
|
+
* @param {Array} volunteer - Array of volunteer objects with startDate and endDate
|
|
161
|
+
* @returns {number} Total volunteer years
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* const volunteerYears = calculateVolunteerYears(resume.volunteer);
|
|
165
|
+
* // => 4
|
|
166
|
+
*/
|
|
167
|
+
export function calculateVolunteerYears(volunteer = []) {
|
|
168
|
+
if (!Array.isArray(volunteer) || volunteer.length === 0) return 0;
|
|
169
|
+
|
|
170
|
+
const totalYears = volunteer.reduce((acc, vol) => {
|
|
171
|
+
if (!vol.startDate) return acc;
|
|
172
|
+
|
|
173
|
+
const start = new Date(vol.startDate);
|
|
174
|
+
const end = vol.endDate ? new Date(vol.endDate) : new Date();
|
|
175
|
+
const years = (end - start) / (1000 * 60 * 60 * 24 * 365.25);
|
|
176
|
+
|
|
177
|
+
return acc + years;
|
|
178
|
+
}, 0);
|
|
179
|
+
|
|
180
|
+
return Math.round(totalYears);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Calculate total education years
|
|
185
|
+
* @param {Array} education - Array of education objects with startDate and endDate
|
|
186
|
+
* @returns {number} Total years of education
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* const eduYears = calculateEducationYears(resume.education);
|
|
190
|
+
* // => 6
|
|
191
|
+
*/
|
|
192
|
+
export function calculateEducationYears(education = []) {
|
|
193
|
+
if (!Array.isArray(education) || education.length === 0) return 0;
|
|
194
|
+
|
|
195
|
+
const totalYears = education.reduce((acc, edu) => {
|
|
196
|
+
if (!edu.startDate) return acc;
|
|
197
|
+
|
|
198
|
+
const start = new Date(edu.startDate);
|
|
199
|
+
const end = edu.endDate ? new Date(edu.endDate) : new Date();
|
|
200
|
+
const years = (end - start) / ((1000 * 60 * 60 * 24) / 365.25);
|
|
201
|
+
|
|
202
|
+
return acc + years;
|
|
203
|
+
}, 0);
|
|
204
|
+
|
|
205
|
+
return Math.round(totalYears);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Get highest education level
|
|
210
|
+
* @param {Array} education - Array of education objects with studyType
|
|
211
|
+
* @returns {string} Highest degree (PhD, Master's, Bachelor's, etc.)
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* const degree = getHighestDegree(resume.education);
|
|
215
|
+
* // => "PhD"
|
|
216
|
+
*/
|
|
217
|
+
export function getHighestDegree(education = []) {
|
|
218
|
+
if (!Array.isArray(education) || education.length === 0) return '';
|
|
219
|
+
|
|
220
|
+
const degreeRanking = {
|
|
221
|
+
phd: 5,
|
|
222
|
+
doctorate: 5,
|
|
223
|
+
doctoral: 5,
|
|
224
|
+
master: 4,
|
|
225
|
+
mba: 4,
|
|
226
|
+
bachelor: 3,
|
|
227
|
+
associate: 2,
|
|
228
|
+
diploma: 1,
|
|
229
|
+
certificate: 1,
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
let highest = { level: 0, studyType: '' };
|
|
233
|
+
|
|
234
|
+
education.forEach((edu) => {
|
|
235
|
+
if (!edu.studyType) return;
|
|
236
|
+
|
|
237
|
+
const studyTypeLower = edu.studyType.toLowerCase();
|
|
238
|
+
for (const [key, level] of Object.entries(degreeRanking)) {
|
|
239
|
+
if (studyTypeLower.includes(key) && level > highest.level) {
|
|
240
|
+
highest = { level, studyType: edu.studyType };
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
return highest.studyType;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Calculate career trajectory (promotions/role changes)
|
|
250
|
+
* @param {Array} work - Array of work experience objects with position
|
|
251
|
+
* @returns {number} Number of distinct positions held
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* const positions = countCareerPositions(resume.work);
|
|
255
|
+
* // => 7
|
|
256
|
+
*/
|
|
257
|
+
export function countCareerPositions(work = []) {
|
|
258
|
+
if (!Array.isArray(work) || work.length === 0) return 0;
|
|
259
|
+
|
|
260
|
+
const uniquePositions = new Set(
|
|
261
|
+
work.map((job) => job.position).filter(Boolean)
|
|
262
|
+
);
|
|
263
|
+
|
|
264
|
+
return uniquePositions.size;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Get career progression rate (positions per year)
|
|
269
|
+
* @param {Array} work - Array of work experience objects
|
|
270
|
+
* @returns {number} Average years per position
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* const rate = getCareerProgressionRate(resume.work);
|
|
274
|
+
* // => 2.3 (years per position)
|
|
275
|
+
*/
|
|
276
|
+
export function getCareerProgressionRate(work = []) {
|
|
277
|
+
const totalYears = calculateTotalExperience(work);
|
|
278
|
+
const positions = countCareerPositions(work);
|
|
279
|
+
|
|
280
|
+
if (totalYears === 0 || positions === 0) return 0;
|
|
281
|
+
|
|
282
|
+
return Math.round((totalYears / positions) * 10) / 10;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Calculate total highlights/achievements across work experience
|
|
287
|
+
* @param {Array} work - Array of work experience objects with highlights
|
|
288
|
+
* @returns {number} Total number of highlights
|
|
289
|
+
*
|
|
290
|
+
* @example
|
|
291
|
+
* const achievements = countTotalHighlights(resume.work);
|
|
292
|
+
* // => 28
|
|
293
|
+
*/
|
|
294
|
+
export function countTotalHighlights(work = []) {
|
|
295
|
+
if (!Array.isArray(work) || work.length === 0) return 0;
|
|
296
|
+
|
|
297
|
+
return work.reduce((total, job) => {
|
|
298
|
+
const highlights = job.highlights || [];
|
|
299
|
+
return total + highlights.length;
|
|
300
|
+
}, 0);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Get all unique industries from work experience
|
|
305
|
+
* @param {Array} work - Array of work experience objects with industry field
|
|
306
|
+
* @returns {Array<string>} Array of unique industries
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* const industries = getUniqueIndustries(resume.work);
|
|
310
|
+
* // => ["Technology", "Finance", "Healthcare"]
|
|
311
|
+
*/
|
|
312
|
+
export function getUniqueIndustries(work = []) {
|
|
313
|
+
if (!Array.isArray(work) || work.length === 0) return [];
|
|
314
|
+
|
|
315
|
+
const industries = new Set(work.map((job) => job.industry).filter(Boolean));
|
|
316
|
+
|
|
317
|
+
return Array.from(industries);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Get most recent/current employer
|
|
322
|
+
* @param {Array} work - Array of work experience objects
|
|
323
|
+
* @returns {Object|null} Most recent work object
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* const current = getCurrentEmployer(resume.work);
|
|
327
|
+
* // => { name: "Google", position: "Senior Engineer", ... }
|
|
328
|
+
*/
|
|
329
|
+
export function getCurrentEmployer(work = []) {
|
|
330
|
+
if (!Array.isArray(work) || work.length === 0) return null;
|
|
331
|
+
|
|
332
|
+
// Find first job without endDate (current), or first in array
|
|
333
|
+
return work.find((job) => !job.endDate) || work[0];
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Check if currently employed
|
|
338
|
+
* @param {Array} work - Array of work experience objects
|
|
339
|
+
* @returns {boolean} True if currently employed
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* const employed = isCurrentlyEmployed(resume.work);
|
|
343
|
+
* // => true
|
|
344
|
+
*/
|
|
345
|
+
export function isCurrentlyEmployed(work = []) {
|
|
346
|
+
if (!Array.isArray(work) || work.length === 0) return false;
|
|
347
|
+
return work.some((job) => !job.endDate);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Calculate comprehensive Key Metrics object for dashboard displays
|
|
352
|
+
* @param {Object} resume - Complete JSON Resume object
|
|
353
|
+
* @returns {Array<Object>} Array of metric objects with label and value
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* const metrics = calculateKeyMetrics(resume);
|
|
357
|
+
* // => [
|
|
358
|
+
* // { label: 'Years Experience', value: 8 },
|
|
359
|
+
* // { label: 'Companies', value: 5 },
|
|
360
|
+
* // { label: 'Projects', value: 12 },
|
|
361
|
+
* // { label: 'Core Skills', value: 42 }
|
|
362
|
+
* // ]
|
|
363
|
+
*/
|
|
364
|
+
export function calculateKeyMetrics(resume) {
|
|
365
|
+
const metrics = [];
|
|
366
|
+
|
|
367
|
+
const {
|
|
368
|
+
work = [],
|
|
369
|
+
projects = [],
|
|
370
|
+
skills = [],
|
|
371
|
+
publications = [],
|
|
372
|
+
awards = [],
|
|
373
|
+
education = [],
|
|
374
|
+
volunteer = [],
|
|
375
|
+
languages = [],
|
|
376
|
+
} = resume;
|
|
377
|
+
|
|
378
|
+
// Experience
|
|
379
|
+
const experience = calculateTotalExperience(work);
|
|
380
|
+
if (experience > 0) {
|
|
381
|
+
metrics.push({ label: 'Years Experience', value: experience });
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// Companies
|
|
385
|
+
const companies = countCompanies(work);
|
|
386
|
+
if (companies > 0) {
|
|
387
|
+
metrics.push({ label: 'Companies', value: companies });
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Projects
|
|
391
|
+
const projectCount = countProjects(projects);
|
|
392
|
+
if (projectCount > 0) {
|
|
393
|
+
metrics.push({ label: 'Projects', value: projectCount });
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Skills
|
|
397
|
+
const skillCount = countTotalSkills(skills);
|
|
398
|
+
if (skillCount > 0) {
|
|
399
|
+
metrics.push({ label: 'Core Skills', value: skillCount });
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// Publications
|
|
403
|
+
const pubCount = countPublications(publications);
|
|
404
|
+
if (pubCount > 0) {
|
|
405
|
+
metrics.push({ label: 'Publications', value: pubCount });
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Awards
|
|
409
|
+
const awardCount = countAwards(awards);
|
|
410
|
+
if (awardCount > 0) {
|
|
411
|
+
metrics.push({ label: 'Awards', value: awardCount });
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Education
|
|
415
|
+
const degree = getHighestDegree(education);
|
|
416
|
+
if (degree) {
|
|
417
|
+
metrics.push({ label: 'Education', value: degree });
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Languages
|
|
421
|
+
const langCount = countLanguages(languages);
|
|
422
|
+
if (langCount > 1) {
|
|
423
|
+
// Only show if multilingual
|
|
424
|
+
metrics.push({ label: 'Languages', value: langCount });
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return metrics;
|
|
428
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @resume/core
|
|
3
|
+
* React component library for building ATS-friendly resume themes
|
|
4
|
+
* Design tokens, primitives, and utilities with JSX
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Export theme provider
|
|
8
|
+
export { ThemeProvider, useTheme } from './providers/ThemeProvider.jsx';
|
|
9
|
+
|
|
10
|
+
// Export all React primitives
|
|
11
|
+
export {
|
|
12
|
+
Section,
|
|
13
|
+
SectionTitle,
|
|
14
|
+
ListItem,
|
|
15
|
+
DateRange,
|
|
16
|
+
formatDateRange,
|
|
17
|
+
Badge,
|
|
18
|
+
BadgeList,
|
|
19
|
+
ContactInfo,
|
|
20
|
+
Link,
|
|
21
|
+
InlineSeparatorPipe,
|
|
22
|
+
KeylineDivider,
|
|
23
|
+
DottedDivider,
|
|
24
|
+
AccentSidebarStripe,
|
|
25
|
+
AccentTopRule,
|
|
26
|
+
RulesetStack,
|
|
27
|
+
} from './primitives/index.jsx';
|
|
28
|
+
|
|
29
|
+
// Export design tokens
|
|
30
|
+
export {
|
|
31
|
+
default as tokens,
|
|
32
|
+
typography,
|
|
33
|
+
colors,
|
|
34
|
+
spacing,
|
|
35
|
+
layout,
|
|
36
|
+
radius,
|
|
37
|
+
shadows,
|
|
38
|
+
rawTokens,
|
|
39
|
+
} from './tokens/index.js';
|
|
40
|
+
|
|
41
|
+
// Export security utilities
|
|
42
|
+
export {
|
|
43
|
+
safeUrl,
|
|
44
|
+
getLinkRel,
|
|
45
|
+
sanitizeHtml,
|
|
46
|
+
isExternalUrl,
|
|
47
|
+
} from './utils/security.js';
|
|
48
|
+
|
|
49
|
+
// Export calculation helpers
|
|
50
|
+
export {
|
|
51
|
+
calculateTotalExperience,
|
|
52
|
+
calculateCurrentRoleExperience,
|
|
53
|
+
countCompanies,
|
|
54
|
+
countProjects,
|
|
55
|
+
countPublications,
|
|
56
|
+
countAwards,
|
|
57
|
+
countTotalSkills,
|
|
58
|
+
countSkillCategories,
|
|
59
|
+
countLanguages,
|
|
60
|
+
calculateVolunteerYears,
|
|
61
|
+
calculateEducationYears,
|
|
62
|
+
getHighestDegree,
|
|
63
|
+
countCareerPositions,
|
|
64
|
+
getCareerProgressionRate,
|
|
65
|
+
countTotalHighlights,
|
|
66
|
+
getUniqueIndustries,
|
|
67
|
+
getCurrentEmployer,
|
|
68
|
+
isCurrentlyEmployed,
|
|
69
|
+
calculateKeyMetrics,
|
|
70
|
+
} from './helpers/calculations.js';
|
|
71
|
+
|
|
72
|
+
// Export layouts
|
|
73
|
+
export {
|
|
74
|
+
GridLayout,
|
|
75
|
+
SidebarLayout,
|
|
76
|
+
StackLayout,
|
|
77
|
+
CardLayout,
|
|
78
|
+
FlexLayout,
|
|
79
|
+
TwoColumnMicroGrid,
|
|
80
|
+
} from './layouts/index.jsx';
|
|
81
|
+
|
|
82
|
+
// Export skills components
|
|
83
|
+
export {
|
|
84
|
+
SkillBar,
|
|
85
|
+
SkillPill,
|
|
86
|
+
SkillRating,
|
|
87
|
+
SkillGroup,
|
|
88
|
+
SkillCloud,
|
|
89
|
+
SkillCategory,
|
|
90
|
+
} from './skills/index.jsx';
|
|
91
|
+
|
|
92
|
+
// Export timeline components
|
|
93
|
+
export {
|
|
94
|
+
TimelineSection,
|
|
95
|
+
TimelineItem,
|
|
96
|
+
TimelineRuleMinimal,
|
|
97
|
+
TimelineInline,
|
|
98
|
+
} from './timeline/index.jsx';
|
|
99
|
+
|
|
100
|
+
// Export profile components
|
|
101
|
+
export {
|
|
102
|
+
Avatar,
|
|
103
|
+
ProfileCard,
|
|
104
|
+
ContactGrid,
|
|
105
|
+
SocialLinks,
|
|
106
|
+
} from './profile/index.jsx';
|
|
107
|
+
|
|
108
|
+
// Export typography components
|
|
109
|
+
export {
|
|
110
|
+
Heading,
|
|
111
|
+
Text,
|
|
112
|
+
Label,
|
|
113
|
+
SectionIntroParagraph,
|
|
114
|
+
QuoteStripe,
|
|
115
|
+
HyphenationSafeParagraph,
|
|
116
|
+
} from './typography/index.jsx';
|
|
117
|
+
|
|
118
|
+
// Export data display components
|
|
119
|
+
export {
|
|
120
|
+
ProgressCircle,
|
|
121
|
+
StatCard,
|
|
122
|
+
MetricBar,
|
|
123
|
+
MetricInline,
|
|
124
|
+
MetricBullet,
|
|
125
|
+
MetricBulletList,
|
|
126
|
+
KPIChipLine,
|
|
127
|
+
KPIChip,
|
|
128
|
+
KeyValueInline,
|
|
129
|
+
KeyValue,
|
|
130
|
+
} from './data/index.jsx';
|
|
131
|
+
|
|
132
|
+
// Export utilities
|
|
133
|
+
export { Divider, Spacer, Flex, Grid } from './utils/index.jsx';
|
|
134
|
+
|
|
135
|
+
// Export experience components
|
|
136
|
+
export {
|
|
137
|
+
ExperienceCard,
|
|
138
|
+
ExperienceTimeline,
|
|
139
|
+
ExperienceGrid,
|
|
140
|
+
ExperienceCompact,
|
|
141
|
+
} from './experience/index.jsx';
|
|
142
|
+
|
|
143
|
+
// Export header/footer components
|
|
144
|
+
export {
|
|
145
|
+
HeaderCentered,
|
|
146
|
+
HeaderSplit,
|
|
147
|
+
HeaderMinimal,
|
|
148
|
+
CornerInitials,
|
|
149
|
+
Footer,
|
|
150
|
+
PageBreak,
|
|
151
|
+
HeroNameBlock,
|
|
152
|
+
ContactRowLine,
|
|
153
|
+
SectionRuleTitle,
|
|
154
|
+
SectionFlagTitle,
|
|
155
|
+
NameStackElegant,
|
|
156
|
+
} from './header/index.jsx';
|
|
157
|
+
|
|
158
|
+
// Export quote/testimonial components
|
|
159
|
+
export { PullQuote, Testimonial, BlockQuote } from './quotes/index.jsx';
|
|
160
|
+
|
|
161
|
+
// Export certification/award components
|
|
162
|
+
export {
|
|
163
|
+
CertificationBadge,
|
|
164
|
+
CertificationRow,
|
|
165
|
+
AwardCard,
|
|
166
|
+
HonorsList,
|
|
167
|
+
} from './certifications/index.jsx';
|
|
168
|
+
|
|
169
|
+
// Export language/proficiency components
|
|
170
|
+
export {
|
|
171
|
+
LanguageBar,
|
|
172
|
+
LanguageLevelBarLite,
|
|
173
|
+
LanguageGrid,
|
|
174
|
+
ProficiencyScale,
|
|
175
|
+
} from './languages/index.jsx';
|
|
176
|
+
|
|
177
|
+
// Export publication/portfolio components
|
|
178
|
+
export {
|
|
179
|
+
PublicationItem,
|
|
180
|
+
PublicationEntryPlain,
|
|
181
|
+
PortfolioGrid,
|
|
182
|
+
ProjectCard,
|
|
183
|
+
} from './publications/index.jsx';
|
|
184
|
+
|
|
185
|
+
// Export table components
|
|
186
|
+
export { SkillMatrix, ComparisonTable, DataTable } from './tables/index.jsx';
|
|
187
|
+
|
|
188
|
+
// Export callout/highlight components
|
|
189
|
+
export { Callout, InfoBox, HighlightCard } from './callouts/index.jsx';
|
|
190
|
+
|
|
191
|
+
// Export list components
|
|
192
|
+
export {
|
|
193
|
+
CheckList,
|
|
194
|
+
IconList,
|
|
195
|
+
NumberedList,
|
|
196
|
+
BulletList,
|
|
197
|
+
CompactList,
|
|
198
|
+
AchievementListTight,
|
|
199
|
+
AchievementListSpacious,
|
|
200
|
+
HangingBulletList,
|
|
201
|
+
ListDashCompact,
|
|
202
|
+
MiniDotLeaderList,
|
|
203
|
+
DefinitionKeyline,
|
|
204
|
+
} from './lists/index.jsx';
|
|
205
|
+
|
|
206
|
+
// Export date components
|
|
207
|
+
export { DateBadge, RelativeDate } from './dates/index.jsx';
|
|
208
|
+
|
|
209
|
+
// Export visual components
|
|
210
|
+
export {
|
|
211
|
+
BackgroundPattern,
|
|
212
|
+
ColorBlock,
|
|
213
|
+
DividerVariants,
|
|
214
|
+
BorderAccent,
|
|
215
|
+
} from './visuals/index.jsx';
|
|
216
|
+
|
|
217
|
+
// Export print utilities
|
|
218
|
+
export {
|
|
219
|
+
KeepTogether,
|
|
220
|
+
ColumnBreak,
|
|
221
|
+
PrintOnly,
|
|
222
|
+
ScreenOnly,
|
|
223
|
+
PageHeaderLine,
|
|
224
|
+
PageFooterLine,
|
|
225
|
+
LetterheadBar,
|
|
226
|
+
SoftShadowEmulation,
|
|
227
|
+
} from './print/index.jsx';
|
|
228
|
+
|
|
229
|
+
// Export metadata components
|
|
230
|
+
export {
|
|
231
|
+
InlineKicker,
|
|
232
|
+
MetaRow,
|
|
233
|
+
SubsectionLabel,
|
|
234
|
+
GreyLabelCaps,
|
|
235
|
+
SmallCapsHeading,
|
|
236
|
+
} from './metadata/index.jsx';
|
|
237
|
+
|
|
238
|
+
// Export container components
|
|
239
|
+
export {
|
|
240
|
+
MutedPanel,
|
|
241
|
+
AccentCalloutPanel,
|
|
242
|
+
SoftCardOutline,
|
|
243
|
+
RoleBlockFramed,
|
|
244
|
+
} from './containers/index.jsx';
|
|
245
|
+
|
|
246
|
+
// Export tag components
|
|
247
|
+
export { ToolTagRibbon } from './tags/index.jsx';
|
|
248
|
+
|
|
249
|
+
// Export badge components
|
|
250
|
+
export { BadgeRowOutline } from './badges/index.jsx';
|
|
251
|
+
|
|
252
|
+
// Package metadata
|
|
253
|
+
export const version = '0.2.0';
|