From c408b4f91670666aa548fc8103de8db4f7f3435c Mon Sep 17 00:00:00 2001 From: Elanor Krause Date: Fri, 2 Feb 2024 14:22:27 +0100 Subject: [PATCH] added features block --- dist/__chunks__/unsafe-html.tmuruS4o.js | 10 ++++++ dist/__chunks__/unsafe-html.tmuruS4o.js.map | 1 + dist/banner/banner.js | 10 +----- dist/banner/banner.js.map | 2 +- dist/features/features.js | 2 ++ dist/features/features.js.map | 1 + src/blocks/features/features.ts | 37 +++++++++++++++++++++ types/blocks/features/features.d.ts | 1 + vite.config.ts | 29 ++++++++-------- 9 files changed, 69 insertions(+), 24 deletions(-) create mode 100644 dist/__chunks__/unsafe-html.tmuruS4o.js create mode 100644 dist/__chunks__/unsafe-html.tmuruS4o.js.map create mode 100644 dist/features/features.js create mode 100644 dist/features/features.js.map create mode 100644 src/blocks/features/features.ts create mode 100644 types/blocks/features/features.d.ts diff --git a/dist/__chunks__/unsafe-html.tmuruS4o.js b/dist/__chunks__/unsafe-html.tmuruS4o.js new file mode 100644 index 00000000..fc5a89d2 --- /dev/null +++ b/dist/__chunks__/unsafe-html.tmuruS4o.js @@ -0,0 +1,10 @@ +import{T as s,w as o}from"./lit-element.XkUWx5ik.js";/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const u={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},c=e=>(...t)=>({_$litDirective$:e,values:t});class h{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,n){this._$Ct=t,this._$AM=i,this._$Ci=n}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}}/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */class r extends h{constructor(t){if(super(t),this.it=s,t.type!==u.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===s||t==null)return this._t=void 0,this.it=t;if(t===o)return t;if(typeof t!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const i=[t];return i.raw=i,this._t={_$litType$:this.constructor.resultType,strings:i,values:[]}}}r.directiveName="unsafeHTML",r.resultType=1;const l=c(r);export{l as o}; +//# sourceMappingURL=unsafe-html.tmuruS4o.js.map diff --git a/dist/__chunks__/unsafe-html.tmuruS4o.js.map b/dist/__chunks__/unsafe-html.tmuruS4o.js.map new file mode 100644 index 00000000..79c2b159 --- /dev/null +++ b/dist/__chunks__/unsafe-html.tmuruS4o.js.map @@ -0,0 +1 @@ +{"version":3,"file":"unsafe-html.tmuruS4o.js","sources":["../../node_modules/lit-html/directive.js","../../node_modules/lit-html/directives/unsafe-html.js"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}export{i as Directive,t as PartType,e as directive};\n//# sourceMappingURL=directive.js.map\n","import{nothing as t,noChange as i}from\"../lit-html.js\";import{Directive as r,PartType as s,directive as n}from\"../directive.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */class e extends r{constructor(i){if(super(i),this.it=t,i.type!==s.CHILD)throw Error(this.constructor.directiveName+\"() can only be used in child bindings\")}render(r){if(r===t||null==r)return this._t=void 0,this.it=r;if(r===i)return r;if(\"string\"!=typeof r)throw Error(this.constructor.directiveName+\"() called with a non-string value\");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName=\"unsafeHTML\",e.resultType=1;const o=n(e);export{e as UnsafeHTMLDirective,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aAAaA,EAAE,WAAW,EAAO,MAACI,EAAEC,EAAEL,CAAC","x_google_ignoreList":[0,1]} \ No newline at end of file diff --git a/dist/banner/banner.js b/dist/banner/banner.js index 94c446cf..885c5273 100644 --- a/dist/banner/banner.js +++ b/dist/banner/banner.js @@ -1,10 +1,2 @@ -import{T as d,w as p,j as $,x as c}from"../__chunks__/lit-element.XkUWx5ik.js";/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */const T={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},y=r=>(...e)=>({_$litDirective$:r,values:e});class _{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */class l extends _{constructor(e){if(super(e),this.it=d,e.type!==T.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===d||e==null)return this._t=void 0,this.it=e;if(e===p)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}l.directiveName="unsafeHTML",l.resultType=1;const v=y(l),A=({headline:r,subline:e,texts:t,buttons:i,picture:s})=>c``;function m(r){var u,h;const e=r.querySelector("div"),t=r.children[1],i=(u=e==null?void 0:e.querySelector("h1"))==null?void 0:u.innerText,s=(h=e==null?void 0:e.querySelector("h3"))==null?void 0:h.innerText,n=e?[...e.querySelectorAll("p")]:[],a=[...t==null?void 0:t.querySelectorAll("a")],o=(e==null?void 0:e.querySelector("picture"))||void 0;console.log({headline:i,subline:s,texts:n,buttons:a,picture:o}),r.innerHTML="",r.style.removeProperty("display"),$(A({headline:i,subline:s,texts:n,buttons:a,picture:o}),r)}export{m as default}; +import{j as d,x as i}from"../__chunks__/lit-element.XkUWx5ik.js";import{o as h}from"../__chunks__/unsafe-html.tmuruS4o.js";const u=({headline:n,subline:e,texts:r,buttons:a,picture:c})=>i``;function $(n){var p,s;const e=n.querySelector("div"),r=n.children[1],a=(p=e==null?void 0:e.querySelector("h1"))==null?void 0:p.innerText,c=(s=e==null?void 0:e.querySelector("h3"))==null?void 0:s.innerText,l=e?[...e.querySelectorAll("p")]:[],o=[...r==null?void 0:r.querySelectorAll("a")],t=(e==null?void 0:e.querySelector("picture"))||void 0;console.log({headline:a,subline:c,texts:l,buttons:o,picture:t}),n.innerHTML="",n.style.removeProperty("display"),d(u({headline:a,subline:c,texts:l,buttons:o,picture:t}),n)}export{$ as default}; //# sourceMappingURL=banner.js.map diff --git a/dist/banner/banner.js.map b/dist/banner/banner.js.map index 1bd51c18..66dbb8f3 100644 --- a/dist/banner/banner.js.map +++ b/dist/banner/banner.js.map @@ -1 +1 @@ -{"version":3,"file":"banner.js","sources":["../../node_modules/lit-html/directive.js","../../node_modules/lit-html/directives/unsafe-html.js","../../src/blocks/banner/banner.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nconst t={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},e=t=>(...e)=>({_$litDirective$:t,values:e});class i{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}export{i as Directive,t as PartType,e as directive};\n//# sourceMappingURL=directive.js.map\n","import{nothing as t,noChange as i}from\"../lit-html.js\";import{Directive as r,PartType as s,directive as n}from\"../directive.js\";\n/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */class e extends r{constructor(i){if(super(i),this.it=t,i.type!==s.CHILD)throw Error(this.constructor.directiveName+\"() can only be used in child bindings\")}render(r){if(r===t||null==r)return this._t=void 0,this.it=r;if(r===i)return r;if(\"string\"!=typeof r)throw Error(this.constructor.directiveName+\"() called with a non-string value\");if(r===this.it)return this._t;this.it=r;const s=[r];return s.raw=s,this._t={_$litType$:this.constructor.resultType,strings:s,values:[]}}}e.directiveName=\"unsafeHTML\",e.resultType=1;const o=n(e);export{e as UnsafeHTMLDirective,o as unsafeHTML};\n//# sourceMappingURL=unsafe-html.js.map\n","import { html, render } from 'lit';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\n\ninterface TemplateArgs {\n headline?: string;\n subline?: string;\n picture?: HTMLPictureElement;\n texts?: HTMLParagraphElement[];\n buttons?: HTMLAnchorElement[];\n}\n\nconst template = ({ headline, subline, texts, buttons, picture }: TemplateArgs) => {\n return html`\n
\n
\n
\n

${headline}

\n

${subline}

\n
\n ${texts?.map((text) => html`

${text.innerText}

`)}\n \n
\n ${picture ?? unsafeHTML(picture)} \n
\n `;\n};\n\nexport default function (block: HTMLElement) {\n const firstRow = block.querySelector('div');\n const secondRow = block.children[1];\n const headline = firstRow?.querySelector('h1')?.innerText;\n const subline = firstRow?.querySelector('h3')?.innerText;\n const texts = firstRow ? [...firstRow.querySelectorAll('p')] : [];\n const buttons = [...secondRow?.querySelectorAll('a')];\n const picture = firstRow?.querySelector('picture') || undefined;\n\n console.log({ headline, subline, texts, buttons, picture });\n\n block.innerHTML = '';\n\n block.style.removeProperty('display');\n render(template({ headline, subline, texts, buttons, picture }), block);\n}\n"],"names":["t","e","i","r","s","o","n","template","headline","subline","texts","buttons","picture","html","text","button","unsafeHTML","banner","block","firstRow","secondRow","_a","_b","render"],"mappings":"+EAAA;AAAA;AAAA;AAAA;AAAA,GAKA,MAAMA,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAEC,EAAED,GAAG,IAAI,KAAK,CAAC,gBAAgBA,EAAE,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,YAAAA,EAAS,IACRI,GACCF,iBACaE,EAAO,IAAI,wBAAwBA,EAAO,SAAS,YAEnE,yCAGyBH,GAAWI,EAAWJ,CAAO,CAAC,oBAKlE,SAAAK,EAAyBC,EAAoB,SACrC,MAAAC,EAAWD,EAAM,cAAc,KAAK,EACpCE,EAAYF,EAAM,SAAS,CAAC,EAC5BV,GAAWa,EAAAF,GAAA,YAAAA,EAAU,cAAc,QAAxB,YAAAE,EAA+B,UAC1CZ,GAAUa,EAAAH,GAAA,YAAAA,EAAU,cAAc,QAAxB,YAAAG,EAA+B,UACzCZ,EAAQS,EAAW,CAAC,GAAGA,EAAS,iBAAiB,GAAG,CAAC,EAAI,GACzDR,EAAU,CAAC,GAAGS,GAAA,YAAAA,EAAW,iBAAiB,IAAI,EAC9CR,GAAUO,GAAA,YAAAA,EAAU,cAAc,aAAc,OAEtD,QAAQ,IAAI,CAAE,SAAAX,EAAU,QAAAC,EAAS,MAAAC,EAAO,QAAAC,EAAS,QAAAC,EAAS,EAE1DM,EAAM,UAAY,GAEZA,EAAA,MAAM,eAAe,SAAS,EAC7BK,EAAAhB,EAAS,CAAE,SAAAC,EAAU,QAAAC,EAAS,MAAAC,EAAO,QAAAC,EAAS,QAAAC,CAAA,CAAS,EAAGM,CAAK,CACxE","x_google_ignoreList":[0,1]} \ No newline at end of file +{"version":3,"file":"banner.js","sources":["../../src/blocks/banner/banner.ts"],"sourcesContent":["import { html, render } from 'lit';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\n\ninterface TemplateArgs {\n headline?: string;\n subline?: string;\n picture?: HTMLPictureElement;\n texts?: HTMLParagraphElement[];\n buttons?: HTMLAnchorElement[];\n}\n\nconst template = ({ headline, subline, texts, buttons, picture }: TemplateArgs) => {\n return html`\n
\n
\n
\n

${headline}

\n

${subline}

\n
\n ${texts?.map((text) => html`

${text.innerText}

`)}\n \n
\n ${picture ?? unsafeHTML(picture)} \n
\n `;\n};\n\nexport default function (block: HTMLElement) {\n const firstRow = block.querySelector('div');\n const secondRow = block.children[1];\n const headline = firstRow?.querySelector('h1')?.innerText;\n const subline = firstRow?.querySelector('h3')?.innerText;\n const texts = firstRow ? [...firstRow.querySelectorAll('p')] : [];\n const buttons = [...secondRow?.querySelectorAll('a')];\n const picture = firstRow?.querySelector('picture') || undefined;\n\n console.log({ headline, subline, texts, buttons, picture });\n\n block.innerHTML = '';\n\n block.style.removeProperty('display');\n render(template({ headline, subline, texts, buttons, picture }), block);\n}\n"],"names":["template","headline","subline","texts","buttons","picture","html","text","button","unsafeHTML","banner","block","firstRow","secondRow","_a","_b","render"],"mappings":"2HAWA,MAAMA,EAAW,CAAC,CAAE,SAAAC,EAAU,QAAAC,EAAS,MAAAC,EAAO,QAAAC,EAAS,QAAAC,KAC9CC,0DAIOL,CAAQ,WACTC,CAAO,gBAEZC,GAAA,YAAAA,EAAO,IAAKI,GAASD,OAAUC,EAAK,SAAS,OAAO,uBAElDH,GAAA,YAAAA,EAAS,IACRI,GACCF,iBACaE,EAAO,IAAI,wBAAwBA,EAAO,SAAS,YAEnE,yCAGyBH,GAAWI,EAAWJ,CAAO,CAAC,oBAKlE,SAAAK,EAAyBC,EAAoB,SACrC,MAAAC,EAAWD,EAAM,cAAc,KAAK,EACpCE,EAAYF,EAAM,SAAS,CAAC,EAC5BV,GAAWa,EAAAF,GAAA,YAAAA,EAAU,cAAc,QAAxB,YAAAE,EAA+B,UAC1CZ,GAAUa,EAAAH,GAAA,YAAAA,EAAU,cAAc,QAAxB,YAAAG,EAA+B,UACzCZ,EAAQS,EAAW,CAAC,GAAGA,EAAS,iBAAiB,GAAG,CAAC,EAAI,GACzDR,EAAU,CAAC,GAAGS,GAAA,YAAAA,EAAW,iBAAiB,IAAI,EAC9CR,GAAUO,GAAA,YAAAA,EAAU,cAAc,aAAc,OAEtD,QAAQ,IAAI,CAAE,SAAAX,EAAU,QAAAC,EAAS,MAAAC,EAAO,QAAAC,EAAS,QAAAC,EAAS,EAE1DM,EAAM,UAAY,GAEZA,EAAA,MAAM,eAAe,SAAS,EAC7BK,EAAAhB,EAAS,CAAE,SAAAC,EAAU,QAAAC,EAAS,MAAAC,EAAO,QAAAC,EAAS,QAAAC,CAAA,CAAS,EAAGM,CAAK,CACxE"} \ No newline at end of file diff --git a/dist/features/features.js b/dist/features/features.js new file mode 100644 index 00000000..c2945af2 --- /dev/null +++ b/dist/features/features.js @@ -0,0 +1,2 @@ +import{j as i,x as o}from"../__chunks__/lit-element.XkUWx5ik.js";import{o as a}from"../__chunks__/unsafe-html.tmuruS4o.js";const l=e=>o`${e.map(t=>o`
${t.icon}
${a(t.textBlock)}
`)}`;function d(e){const t=e.querySelectorAll(":scope > div");let n=[];[...t].forEach(r=>{const s=r.children[0].innerHTML,c=r.children[1].innerHTML;n.push({icon:s,textBlock:c})}),e.innerHTML="",e.style.removeProperty("display"),i(l(n),e)}export{d as default}; +//# sourceMappingURL=features.js.map diff --git a/dist/features/features.js.map b/dist/features/features.js.map new file mode 100644 index 00000000..7aefac92 --- /dev/null +++ b/dist/features/features.js.map @@ -0,0 +1 @@ +{"version":3,"file":"features.js","sources":["../../src/blocks/features/features.ts"],"sourcesContent":["import { html, render } from 'lit';\nimport { unsafeHTML } from 'lit-html/directives/unsafe-html.js';\n\ninterface Feature {\n icon: string;\n textBlock: string;\n}\n\ntype TemplateArgs = Feature[];\n\nconst template = (features: TemplateArgs) => {\n return html`\n ${features.map(\n (feature) => html`\n
\n ${feature.icon}\n
${unsafeHTML(feature.textBlock)}
\n
\n `\n )}\n `;\n};\n\nexport default function (block: HTMLElement) {\n const rows = block.querySelectorAll(':scope > div');\n let features: Feature[] = [];\n [...rows].forEach((row) => {\n const icon = row.children[0].innerHTML;\n const textBlock = row.children[1].innerHTML;\n features.push({ icon, textBlock });\n });\n\n block.innerHTML = '';\n\n block.style.removeProperty('display');\n render(template(features), block);\n}\n"],"names":["template","features","html","feature","unsafeHTML","block","rows","row","icon","textBlock","render"],"mappings":"2HAUA,MAAMA,EAAYC,GACTC,IACHD,EAAS,IACRE,GAAYD,uCAEmBC,EAAQ,IAAI,+BACjBC,EAAWD,EAAQ,SAAS,CAAC,kBAGzD,CAAA,GAIL,SAAAF,EAAyBI,EAAoB,CACrC,MAAAC,EAAOD,EAAM,iBAAiB,cAAc,EAClD,IAAIJ,EAAsB,CAAA,EAC1B,CAAC,GAAGK,CAAI,EAAE,QAASC,GAAQ,CACzB,MAAMC,EAAOD,EAAI,SAAS,CAAC,EAAE,UACvBE,EAAYF,EAAI,SAAS,CAAC,EAAE,UAClCN,EAAS,KAAK,CAAE,KAAAO,EAAM,UAAAC,CAAW,CAAA,CAAA,CAClC,EAEDJ,EAAM,UAAY,GAEZA,EAAA,MAAM,eAAe,SAAS,EAC7BK,EAAAV,EAASC,CAAQ,EAAGI,CAAK,CAClC"} \ No newline at end of file diff --git a/src/blocks/features/features.ts b/src/blocks/features/features.ts new file mode 100644 index 00000000..6d72100a --- /dev/null +++ b/src/blocks/features/features.ts @@ -0,0 +1,37 @@ +import { html, render } from 'lit'; +import { unsafeHTML } from 'lit-html/directives/unsafe-html.js'; + +interface Feature { + icon: string; + textBlock: string; +} + +type TemplateArgs = Feature[]; + +const template = (features: TemplateArgs) => { + return html` + ${features.map( + (feature) => html` +
+ ${feature.icon} +
${unsafeHTML(feature.textBlock)}
+
+ ` + )} + `; +}; + +export default function (block: HTMLElement) { + const rows = block.querySelectorAll(':scope > div'); + let features: Feature[] = []; + [...rows].forEach((row) => { + const icon = row.children[0].innerHTML; + const textBlock = row.children[1].innerHTML; + features.push({ icon, textBlock }); + }); + + block.innerHTML = ''; + + block.style.removeProperty('display'); + render(template(features), block); +} diff --git a/types/blocks/features/features.d.ts b/types/blocks/features/features.d.ts new file mode 100644 index 00000000..95509577 --- /dev/null +++ b/types/blocks/features/features.d.ts @@ -0,0 +1 @@ +export default function (block: HTMLElement): void; diff --git a/vite.config.ts b/vite.config.ts index 558d1d71..4bf880d9 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,9 +1,9 @@ -import { defineConfig } from "vite"; -import minifyHTML from "rollup-plugin-minify-html-literals"; +import { defineConfig } from 'vite'; +import minifyHTML from 'rollup-plugin-minify-html-literals'; -const { resolve } = require("path"); +const { resolve } = require('path'); -const isProd = process.env.NODE_ENV === "production"; +const isProd = process.env.NODE_ENV === 'production'; export default defineConfig(({ command, mode }) => { return { @@ -15,25 +15,26 @@ export default defineConfig(({ command, mode }) => { minify: true, cssMinify: true, commonjsOptions: { - include: ["node_modules/**"], + include: ['node_modules/**'], }, emptyOutDir: true, rollupOptions: { cache: false, - preserveEntrySignatures: "strict", + preserveEntrySignatures: 'strict', input: { - styles: resolve(__dirname, "src/styles/sass/main.scss"), - main: resolve(__dirname, "src/main.ts"), - counter: resolve(__dirname, "src/blocks/counter/counter.ts"), - banner: resolve(__dirname, "src/blocks/banner/banner.ts"), + styles: resolve(__dirname, 'src/styles/sass/main.scss'), + main: resolve(__dirname, 'src/main.ts'), + counter: resolve(__dirname, 'src/blocks/counter/counter.ts'), + banner: resolve(__dirname, 'src/blocks/banner/banner.ts'), + features: resolve(__dirname, 'src/blocks/features/features.ts'), }, output: { - dir: "dist", + dir: 'dist', assetFileNames: () => { - return "[name]/[name][extname]"; + return '[name]/[name][extname]'; }, - chunkFileNames: "__chunks__/[name].[hash].js", - entryFileNames: "[name]/[name].js", + chunkFileNames: '__chunks__/[name].[hash].js', + entryFileNames: '[name]/[name].js', }, plugins: [isProd && minifyHTML()], },