diff --git a/dist/bundle.js b/dist/bundle.js index 5b1ba6e..ec3ca4b 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -1 +1 @@ -(()=>{"use strict";var e,n,t,r={756:(e,n,t)=>{t.d(n,{Z:()=>i});var r=t(645),o=t.n(r)()((function(e){return e[1]}));o.push([e.id,"#app {\n position: relative;\n}\n\n.content {\n position: absolute;\n top: 0;\n right: 0;\n left: 200px;\n}\n\n.sidebar {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n width: 200px;\n z-index: 100;\n padding: 10px;\n box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.1);\n overflow-y: auto;\n}\n",""]);const i=o},645:e=>{e.exports=function(e){var n=[];return n.toString=function(){return this.map((function(n){var t=e(n);return n[2]?"@media ".concat(n[2]," {").concat(t,"}"):t})).join("")},n.i=function(e,t,r){"string"==typeof e&&(e=[[null,e,""]]);var o={};if(r)for(var i=0;i{var r,o=function(){var e={};return function(n){if(void 0===e[n]){var t=document.querySelector(n);if(window.HTMLIFrameElement&&t instanceof window.HTMLIFrameElement)try{t=t.contentDocument.head}catch(e){t=null}e[n]=t}return e[n]}}(),i=[];function a(e){for(var n=-1,t=0;t{var n=e&&e.__esModule?()=>e.default:()=>e;return i.d(n,{a:n}),n},i.d=(e,n)=>{for(var t in n)i.o(n,t)&&!i.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:n[t]})},i.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),e=i(379),n=i.n(e),t=i(756),n()(t.Z,{insert:"head",singleton:!1}),t.Z.locals})(); \ No newline at end of file +(()=>{"use strict";var e,t,n,r={756:(e,t,n)=>{n.d(t,{Z:()=>i});var r=n(645),o=n.n(r)()((function(e){return e[1]}));o.push([e.id,"#app {\n position: relative;\n}\n\n.content {\n position: absolute;\n top: 0;\n right: 0;\n left: 200px;\n}\n\n.sidebar {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n width: 200px;\n z-index: 100;\n padding: 10px;\n box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.1);\n overflow-y: auto;\n}\n",""]);const i=o},645:e=>{e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=e(t);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")},t.i=function(e,n,r){"string"==typeof e&&(e=[[null,e,""]]);var o={};if(r)for(var i=0;i{var r,o=function(){var e={};return function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(e){n=null}e[t]=n}return e[t]}}(),i=[];function a(e){for(var t=-1,n=0;n{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e=i(379),t=i.n(e),n=i(756),t()(n.Z,{insert:"head",singleton:!1}),n.Z.locals,console.log([{type:"title",value:"Test title",options:{}},{type:"text",value:"Lorem ipsum dolor sit, amet consectetur adipisicing elit.",options:{}},{type:"textColumns",value:["text 1","text 2","text 3"],options:{}}])})(); \ No newline at end of file diff --git a/src/index.html b/src/index.html index b7a3b1e..39c1e58 100644 --- a/src/index.html +++ b/src/index.html @@ -16,54 +16,7 @@ -
-
-
-

Title

-
-
-
-
-

- Lorem ipsum dolor sit, amet consectetur adipisicing elit. Incidunt - consectetur reprehenderit ex blanditiis assumenda quaerat ea atque - fugit eaque asperiores eligendi accusantium ratione exercitationem - delectus eveniet unde rerum, possimus voluptate! -

-
-
- -
-
-

- Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Incidunt consectetur reprehenderit ex blanditiis assumenda - quaerat ea atque fugit eaque asperiores eligendi accusantium - ratione exercitationem delectus eveniet unde rerum, possimus - voluptate! -

-
-
-

- Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Incidunt consectetur reprehenderit ex blanditiis assumenda - quaerat ea atque fugit eaque asperiores eligendi accusantium - ratione exercitationem delectus eveniet unde rerum, possimus - voluptate! -

-
-
-

- Lorem ipsum dolor sit, amet consectetur adipisicing elit. - Incidunt consectetur reprehenderit ex blanditiis assumenda - quaerat ea atque fugit eaque asperiores eligendi accusantium - ratione exercitationem delectus eveniet unde rerum, possimus - voluptate! -

-
-
-
- +
diff --git a/src/index.js b/src/index.js index 20396d7..feae848 100644 --- a/src/index.js +++ b/src/index.js @@ -1 +1,68 @@ import './styles/main.css' +import { model } from './model.js' + +console.log(model) + +let generateHTML = (model) => { + let htmlBlock + return model + .map((block) => { + switch (block.type) { + case 'title': + htmlBlock = convertModelToTitle(block.value) + break + case 'text': + htmlBlock = convertModelToText(block.value) + break + case 'textColumns': + htmlBlock = convertModelToColumns(block.value) + break + default: + htmlBlock = `
` + break + } + return htmlBlock + }) + .join('') +} + +let convertModelToTitle = (value) => { + return ` +
+
+

${value}

+
+
` +} + +let convertModelToText = (value) => { + return ` +
+
+

+ ${value} +

+
+
` +} + +let convertModelToColumns = (value) => { + let columns = value + .map((item) => { + return ` +
+

+ ${item} +

+
` + }) + .join('') + return ` +
+ ${columns} +
` +} + +document + .querySelector('#site') + .insertAdjacentHTML('beforeend', generateHTML(model)) diff --git a/src/model.js b/src/model.js new file mode 100644 index 0000000..9d54bf3 --- /dev/null +++ b/src/model.js @@ -0,0 +1,30 @@ +export const model = [ + { + type: 'title', + value: 'Test title', + options: {} + }, + { + type: 'text', + value: 'Lorem ipsum dolor sit, amet consectetur adipisicing elit.', + options: {} + }, + { + type: 'textColumns', + value: [ + `Lorem ipsum dolor sit, amet consectetur adipisicing elit. Incidunt + consectetur reprehenderit ex blanditiis assumenda quaerat ea atque + fugit eaque asperiores eligendi accusantium ratione exercitationem + delectus eveniet unde rerum, possimus voluptate!`, + `Lorem ipsum dolor sit, amet consectetur adipisicing elit. Incidunt + consectetur reprehenderit ex blanditiis assumenda quaerat ea atque + fugit eaque asperiores eligendi accusantium ratione exercitationem + delectus eveniet unde rerum, possimus voluptate!`, + `Lorem ipsum dolor sit, amet consectetur adipisicing elit. Incidunt + consectetur reprehenderit ex blanditiis assumenda quaerat ea atque + fugit eaque asperiores eligendi accusantium ratione exercitationem + delectus eveniet unde rerum, possimus voluptate!` + ], + options: {} + } +] diff --git a/src/styles/main.css b/src/styles/main.css index 39edf69..6c4a502 100644 --- a/src/styles/main.css +++ b/src/styles/main.css @@ -20,3 +20,7 @@ box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.1); overflow-y: auto; } + +div { + padding: 10px; +}