Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#266 cv monochrome force create header section #278

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ describe('Testing profile-section.mapper.ts', () => {
fullname: ' ',
emails: [] as string[],
relevantLinks: [] as RelevantLinkVm[],
avatarUrl: '',
city: '',
country: '',
};

// Act
Expand All @@ -101,6 +104,9 @@ describe('Testing profile-section.mapper.ts', () => {
fullname: ' ',
emails: [] as string[],
relevantLinks: [] as RelevantLinkVm[],
avatarUrl: '',
city: '',
country: '',
};

// Act
Expand Down Expand Up @@ -132,6 +138,9 @@ describe('Testing profile-section.mapper.ts', () => {
fullname: ' ',
emails: [] as string[],
relevantLinks: [] as RelevantLinkVm[],
avatarUrl: '',
city: '',
country: '',
};

// Act
Expand Down Expand Up @@ -163,6 +172,9 @@ describe('Testing profile-section.mapper.ts', () => {
fullname: ' ',
emails: [] as string[],
relevantLinks: [] as RelevantLinkVm[],
avatarUrl: '',
city: '',
country: '',
};

// Act
Expand Down Expand Up @@ -203,6 +215,9 @@ describe('Testing profile-section.mapper.ts', () => {
fullname: ' ',
emails: [] as string[],
relevantLinks: [] as RelevantLinkVm[],
avatarUrl: '',
city: '',
country: '',
};

// Act
Expand Down Expand Up @@ -244,6 +259,9 @@ describe('Testing profile-section.mapper.ts', () => {
fullname: ' ',
emails: [] as string[],
relevantLinks: [] as RelevantLinkVm[],
avatarUrl: '',
city: '',
country: '',
};

// Act
Expand All @@ -270,9 +288,9 @@ describe('Testing profile-section.mapper.ts', () => {
title: 'Computer Science Bachelor',
description: 'Frontend developer',
birthday: '30/03/1990',
avatar: undefined,
avatar: { link: 'http://manfredexport.com' },
contact: theContact,
location: undefined,
location: { municipality: 'Madrid', country: 'Spain' },
};

const cv: ManfredAwesomicCV = {
Expand All @@ -295,6 +313,9 @@ describe('Testing profile-section.mapper.ts', () => {
fullname: 'John Doe',
emails: ['[email protected]', '[email protected]'] as string[],
relevantLinks: [theLink] as RelevantLinkVm[],
avatarUrl: 'http://manfredexport.com',
city: 'Madrid',
country: 'Spain',
};

// Act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export const mapFromMacCvToProfileSectionVm = (cv: ManfredAwesomicCV): ProfileSe
const description = cv?.aboutMe?.profile?.description ?? '';
const fullname = `${name ?? ''} ${surnames ?? ''}`;
const emails = (cv?.aboutMe?.profile?.contact?.contactMails as string[]) ?? [];

const avatarUrl = (cv?.aboutMe?.profile?.avatar?.link as string) ?? '';

const city = cv?.aboutMe?.profile?.location?.municipality ?? '';
const country = cv?.aboutMe?.profile?.location?.country ?? '';

const relevantLinks = cv?.aboutMe?.relevantLinks
? mapRelevantLinksToVm(cv.aboutMe.relevantLinks as ManfredRelevantLink[])
: [];
Expand All @@ -39,5 +45,8 @@ export const mapFromMacCvToProfileSectionVm = (cv: ManfredAwesomicCV): ProfileSe
fullname,
emails,
relevantLinks,
avatarUrl,
city,
country,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ export interface ProfileSectionVm {
fullname: string;
emails: string[];
relevantLinks: RelevantLinkVm[];
avatarUrl: string;
city: string;
country: string;
}

export interface RelevantLinkVm {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
</header>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import ejs from 'ejs';
import headerElementEndTemplate from './header-element-end.ejs?raw';

export const generateHeaderElementEnd = (): string => ejs.render(headerElementEndTemplate);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './header-element-end.part';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<div class="background"></div>
<header class="container header">
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import ejs from 'ejs';
import headerElementStartTemplate from './header-element-start.ejs?raw';

export const generateHeaderElementStart = (): string => ejs.render(headerElementStartTemplate);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './header-element-start.part';
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script>
<script>
// Selecciona un elemento del DOM
const elementInDOM = selector => document.querySelector(selector);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
.header__image {
width: 100%;
height: 100%;
background-image: url('https://media-asgard.s3.eu-west-1.amazonaws.com/22/11/22/46a1d99e-54b1-4d4f-b887-bd32b97684d8_david_squared_2018.jpg');
background-image: url('<%= avatarUrl -%>');
background-size: cover;
filter: saturate(25%);
background-repeat: no-repeat;
Expand Down Expand Up @@ -711,5 +711,4 @@
}
</style>
</head>
<body>
<h1 class="title">Probando</h1>
<body>
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import ejs from 'ejs';
import { HexColor } from '@/model';
import { ManfredAwesomicCV } from '@lemoncode/manfred-common/model';
import htmlDocumentStartTemplate from './html-document-start.ejs?raw';
import { mapFromMacCvToProfileSectionVm } from '@lemoncode/manfred-common/profile-section';

export const generateHtmlDocumentStart = (color: HexColor): string => ejs.render(htmlDocumentStartTemplate, { color });
export const generateHtmlDocumentStart = (cv: ManfredAwesomicCV, color: HexColor): string => {
const profileSectionVm = mapFromMacCvToProfileSectionVm(cv);
const avatarUrl = profileSectionVm.avatarUrl;

return ejs.render(htmlDocumentStartTemplate, { color, avatarUrl });
};
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export * from './html-document-start';
export * from './html-document-end';
export * from './header-element-start';
export * from './header-element-end';
export * from './profile-section';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './profile-section';
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<%_ if (profile && profile !=='undefined' ) { -%>
juanpms2 marked this conversation as resolved.
Show resolved Hide resolved
<div class="header__text">
<h1 class="header__title">
<%= profile?.name %><br />
<span><%= profile?.surnames %></span>
</h1>
<p class="header__subtitle">
<%= profile?.title %>
</p>
</div>
<%_ if (profile.avatarUrl && profile.avatarUrl !=='undefined' ) { -%>
juanpms2 marked this conversation as resolved.
Show resolved Hide resolved
<div class="header__avatar">
<div class="header__image"></div>
<div class="header__filter"></div>
</div>
<%_ } -%>
<%_ } -%>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import ejs from 'ejs';
import { ProfileSectionVm, mapFromMacCvToProfileSectionVm } from '@lemoncode/manfred-common/profile-section';
import { ManfredAwesomicCV } from '@lemoncode/manfred-common/model';

import profileSectionTemplate from './profile-section.ejs?raw';

export const generateProfileSection = (cv: ManfredAwesomicCV): string => {
const profileSectionVm = mapFromMacCvToProfileSectionVm(cv);

return generateProfileSectionInner(profileSectionVm);
};

const generateProfileSectionInner = (profileSectionVm: ProfileSectionVm): string => {
const rootObject = {
profile: profileSectionVm,
};

return ejs.render(profileSectionTemplate, rootObject);
};
16 changes: 14 additions & 2 deletions packages/manfred2html/src/engine/cv-monochrome-force/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
import { ManfredAwesomicCV, Settings } from '@/model';
import { generateHtmlDocumentStart, generateHtmlDocumentEnd } from './html-parts';
import {
generateHtmlDocumentStart,
generateHtmlDocumentEnd,
generateHeaderElementStart,
generateHeaderElementEnd,
generateProfileSection,
} from './html-parts';

export const exportManfredJSonToCVMonochromeForceHTML = (
manfredJsonContent: ManfredAwesomicCV,
settings: Settings
): string => {
const htmlDocumentStart = generateHtmlDocumentStart(settings.colorTheme);
const htmlDocumentStart = generateHtmlDocumentStart(manfredJsonContent, settings.colorTheme);
const htmlDocumentEnd = generateHtmlDocumentEnd();
const headerElementStart = generateHeaderElementStart();
const headerElementEnd = generateHeaderElementEnd();
const profileSection = generateProfileSection(manfredJsonContent);

return `
${htmlDocumentStart}
${headerElementStart}
${profileSection}
${headerElementEnd}
${htmlDocumentEnd}
`;
};
Loading