Skip to content

Commit

Permalink
running template on an old version of rollup package
Browse files Browse the repository at this point in the history
  • Loading branch information
atherdon committed Mar 14, 2023
1 parent 754f7e8 commit ec8cf72
Show file tree
Hide file tree
Showing 29 changed files with 543 additions and 19 deletions.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions 1.4/___src/components/bodyComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// add preview stuff
// we need to find footer component
const EmailTemplateBodyComponent = (params) => {
const { footer, logoTop, logoBottom, content } = params;

if (!footer) {
throw new Error('no footer was passed');
}
if (!logoTop || !logoBottom) {
throw new Error('invalid logo');
}

return `<Body>${content}</Body>`;
};

export default EmailTemplateBodyComponent;
5 changes: 5 additions & 0 deletions 1.4/___src/components/footerComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const footerComponent = (children) => {
return `<Footer>${children}</Footer>`;
};

export default footerComponent;
11 changes: 11 additions & 0 deletions 1.4/___src/components/headComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const headComponent = (params) => {
const { title, headStyles, fonts } = params;

if (!title) throw new Error('no title was passed');
if (!headStyles) throw new Error('invalid headStyles');
if (!fonts) throw new Error('invalid fonts');

return `<Head title=${title} styles=${headStyles} fonts=${fonts} />`;
};

export default headComponent;
33 changes: 33 additions & 0 deletions 1.4/___src/components/mainComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function mainComponent(params) {
if (!params) {
throw new Error('no Params was passed');
}

const { head, body } = params;

if (!head) {
throw new Error('no headComponent was passed'); // todo change it later
}

if (!body) {
throw new Error('bodyComponent');
}

return `
import React from "react";
const Content = () => {
return (
<Template>
${head}
${body}
</Template>
);
};
export default Content;
`;
}

export default mainComponent;
7 changes: 7 additions & 0 deletions 1.4/___src/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const config = {
contact: 'https://sponsor.hackernoon.com/newsletter?ref=noonifications.tech',
mailingAddress: 'PO Box 2206, Edwards CO, 81632, U.S.A.',
unsubscribe: '#',
};

export default config;
42 changes: 42 additions & 0 deletions 1.4/___src/display/displayBody.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { displayFactoryTwo } from 'email-template-object';

import EmailTemplateBodyComponent from '../components/bodyComponent';
import footerString from '../display/displayFooter';

// const ERROR_BODY = '`bodyContent` is a required option for `renderTemplate`';

import {
logoTopComponent,
logoBottomComponent,
} from 'atherdon-newsletter-react-layouts-innercomponents';

const checkingBodyContent = (bodyContent) => {
if (!bodyContent) {
throw new Error('`bodyContent` is a required option for `renderTemplate`');
}
};

// const ContentData = '';

let addon1 = {
footer: footerString,

logoTop: logoTopComponent(),
logoBottom: logoBottomComponent(),

content: '[[THIS IS PLACE FOR A CONTENT INSIDE]',

// previewText: previewTextComponent('[AMA PREVIEW TEXT]')
};

//variant one
const settings = {
component: EmailTemplateBodyComponent,
// params: { footerComponent, logoTop, logoBottom, content },
params: addon1,
// subcomponents: { }
};

const BodyFactory = new displayFactoryTwo();
// console.log(BodyFactory.create(settings))
export default BodyFactory.create(settings);
26 changes: 26 additions & 0 deletions 1.4/___src/display/displayFooter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import misc from 'atherdon-newsletter-react-layouts-miscellaneous';

import { displayFactoryTwo } from 'email-template-object';

import footerComponent from '../components/footerComponent';

let mailingAddress = 'PO Box 2206, Edwards CO, 81632, U.S.A.';
let contact =
'https://sponsor.hackernoon.com/newsletter?ref=noonifications.tech';

const {} = misc;

const addon1 = {
children: '',
// sponsor: ''
};

const settings = {
component: footerComponent,
params: addon1,
};

const FooterFactory = new displayFactoryTwo();
// console.log(FooterFactory.create(settings));

export default FooterFactory.create(settings);
46 changes: 46 additions & 0 deletions 1.4/___src/display/displayHead.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// import factory from './factory';
import { displayFactoryTwo } from 'email-template-object';

// partials
import Miscellaneous from 'atherdon-newsletter-react-layouts-miscellaneous';
import headComponent from '../components/headComponent';

const { fontsComponent, headStylesComponent } = Miscellaneous;
const title = `The Secrets of High-Performing DevOps teams`;

// ----
// const ERROR_TITLE = '`title` is a required option for `renderTemplate`'

const checkingTitle = (title) => {
if (!title) {
throw new Error('`title` is a required option for `renderTemplate`');
}
};
// ---

// fonts, headStyles

let addon1 = {
title,
headStyles: headStylesComponent(),
fonts: fontsComponent(),

// logoTop:logoTopComponent(),
// logoBottom: logoBottomComponent(),

// content:'[[THIS IS PLACE FOR A CONTENT INSIDE]',
// previewText:previewTextComponent('[AMA PREVIEW TEXT]')
};

//variant one
const settings = {
component: headComponent,
params: addon1,
};

// console.log(addon1)
// console.log(settings)

const Factory = new displayFactoryTwo();
// console.log(Factory.create(settings));
export default Factory.create(settings);
33 changes: 33 additions & 0 deletions 1.4/___src/display/displayMain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { displayFactoryTwo } from 'email-template-object';

import MainComponent from '../components/mainComponent';

import HeadString from './displayHead';

// TODO we need to be able to pass content variable from this
// file and
import BodyString from './displayBody';

// import EmailTemplateBodyComponent from '../components/bodyComponent';

// const title = `The Secrets of High-Performing DevOps teams`;
const content = '[THIS IS PLACE FOR A CONTENT INSIDE]';
// const content2 = ContentComponent;

let addon1 = {
head: HeadString,
body: BodyString,
// body: EmailTemplateBodyComponent()
parsedContent: content,
};

//variant one
const settings = {
component: MainComponent,

params: addon1,
};

const Factory = new displayFactoryTwo();

export default Factory.create(settings);
14 changes: 14 additions & 0 deletions 1.4/___src/display/fullTemplate2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { headComponent } from '../components/head';

import { EmailTemplateBodyComponent } from '../components/body';

import mainComponent from '../components/mainComponent';

let addon1 = {
footer: footerString,

logoTop: logoTopComponent(),
logoBottom: logoBottomComponent(),
content: '[[THIS IS PLACE FOR A CONTENT INSIDE]',
previewText: previewTextComponent('[AMA PREVIEW TEXT]'),
};
20 changes: 20 additions & 0 deletions 1.4/___src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import EmailTemplateBodyComponent from './components/bodyComponent';
import headComponent from './components/headComponent';
import mainComponent from './components/mainComponent';

import footerComponent from './components/footerComponent';

// import misc from "./misc/";

// import typography from "./typography/";

// import { reactFullTemplate } from "./reactFullTemplate";

// const layout = {
// body,
// misc,
// typography,
// reactFullTemplate,
// };

// export default layout;
27 changes: 27 additions & 0 deletions 1.4/___src/methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import HeadString from './display/displayHead';

import BodyString from './display/displayBody';

import FooterString from './display/displayFooter';

import MainString from './display/displayMain';

console.log(MainString);

const printHead = () => {
return HeadString;
};

const printMain = () => {
return MainString;
};

const printFooter = () => {
return FooterString;
};

const printBody = () => {
return BodyString;
};

export { printMain, printBody, printFooter, printHead };
80 changes: 80 additions & 0 deletions 1.4/___tests/methods.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { printMain, printFooter, printBody, printHead } from '../src/methods'

import { writingFile } from 'markup-generator';
// console.log(printMain())
// console.log(printHead())



// var generateEmptyTemplateComponent = require('../src/t/emptyTemplate');

// var generateTemplateComponent = require('../src/t/generateTemplate');



describe('test helpers', () => {


test('rendering head component', () => {

const string1 = printHead();

writingFile(string1, 'lit-empty');

// // console.log(string);
expect(printHead()).toBeDefined();


});


test('rendering Footer Component', () => {

const string2 = printFooter();

writingFile(string2, 'lit-empty');

// console.log(string);
expect(printFooter()).toBeDefined();

// writingFile(string2);

});

test('rendering Body Component', () => {

const string3 = printBody();

// console.log(string);
expect(printBody()).toBeDefined();

// writingFile(string3);
writingFile(string3, 'lit-empty');
});



// test('rendering Empty Template', () => {

// const string = generateEmptyTemplateComponent();
// console.log(string);
// });


test('rendering Main Component', () => {


const string4 = printMain();

// // console.log(string);

expect(printMain()).toBeDefined();

// writingFile(string4);
writingFile(string4, 'lit-empty');
expect(typeof string4).toBe('string');

});


});
Loading

0 comments on commit ec8cf72

Please sign in to comment.