From 016622323167186d2da7d8da321a70b5e4dc68d4 Mon Sep 17 00:00:00 2001 From: Benjamin Vier Date: Fri, 20 Sep 2024 08:07:01 +0200 Subject: [PATCH] Timebased Trigger --- templates/landingpage/design.js | 6 ++- templates/landingpage/modules/main.js | 4 +- templates/landingpage/preview.twig | 2 +- .../timebased-trigger/index.js | 13 +++++++ .../timebased-trigger/template.twig | 4 ++ .../timebased-trigger/timebasedTrigger.js | 13 +++++++ templates/shared/modules/index.js | 1 + templates/website/design.js | 6 ++- webpack.config.js | 38 +++++++++---------- 9 files changed, 62 insertions(+), 25 deletions(-) create mode 100644 templates/shared/content-elements/timebased-trigger/index.js create mode 100644 templates/shared/content-elements/timebased-trigger/template.twig create mode 100644 templates/shared/content-elements/timebased-trigger/timebasedTrigger.js create mode 100644 templates/shared/modules/index.js diff --git a/templates/landingpage/design.js b/templates/landingpage/design.js index e50af30..271f767 100644 --- a/templates/landingpage/design.js +++ b/templates/landingpage/design.js @@ -39,7 +39,7 @@ module.exports = cx.design /*.withLabel('Content')*/ .withLabel('Inhalt') .withContentElements( - require('@bsi-cx/design-standard-library-web/content-elements/base/text').editor(require('../shared/configs/editor/formatted-text-editor')), + require('@bsi-cx/design-standard-library-web/content-elements/base/text'), require('@bsi-cx/design-standard-library-web/content-elements/base/figure'), require('@bsi-cx/design-standard-library-web/content-elements/base/banner'), require('@bsi-cx/design-standard-library-web/content-elements/base/button'), @@ -53,7 +53,9 @@ module.exports = cx.design require('@bsi-cx/design-standard-library-web/content-elements/advanced/webcam-image-upload'), require('@bsi-cx/design-standard-library-web/content-elements/base/slot-finder'), require('@bsi-cx/design-standard-library-web/content-elements/base/chart'), - require('@bsi-cx/design-standard-library-web/content-elements/base/html')), + require('@bsi-cx/design-standard-library-web/content-elements/base/html'), + require('../shared/content-elements/timebased-trigger'), + ), cx.contentElementGroup .withGroupId('forms-NjbmnQ') /*.withLabel('Forms')*/ diff --git a/templates/landingpage/modules/main.js b/templates/landingpage/modules/main.js index 93b7341..c08bb70 100644 --- a/templates/landingpage/modules/main.js +++ b/templates/landingpage/modules/main.js @@ -1 +1,3 @@ -import '@bsi-cx/design-standard-library-web/core/main/index'; \ No newline at end of file +import '../../shared/modules'; + +import '@bsi-cx/design-standard-library-web/core/main/index'; diff --git a/templates/landingpage/preview.twig b/templates/landingpage/preview.twig index d25cfa7..c2fb19a 100644 --- a/templates/landingpage/preview.twig +++ b/templates/landingpage/preview.twig @@ -9,7 +9,7 @@ {% block content %} {% include '@bsi-cx/design-standard-library-web/content-elements/advanced/webcam-image-upload/template.twig' %} - + {% include "../shared/content-elements/timebased-trigger/template.twig" %} {% embed '@bsi-cx/design-standard-library-web/content-elements/layout/col-two/template.twig' %} {% block col_two_dropzone_1 %} diff --git a/templates/shared/content-elements/timebased-trigger/index.js b/templates/shared/content-elements/timebased-trigger/index.js new file mode 100644 index 0000000..07033bb --- /dev/null +++ b/templates/shared/content-elements/timebased-trigger/index.js @@ -0,0 +1,13 @@ +const { cx, Icon } = require("@bsi-cx/design-build"); + +module.exports = cx.contentElement + .withFile(require("./template.twig")) + .withElementId("timebased-trigger-mO9Z1B") + .withLabel("Zeitgesteuerter Link") + .withIcon(Icon.ASTERISK) + .withParts( + cx.part.plainText + .withId("delay-wnR8CR") + .withLabel("Ausführung nach (in ms)"), + cx.part.link.withId("link-NOxBEU").withLabel("Link") + ); diff --git a/templates/shared/content-elements/timebased-trigger/template.twig b/templates/shared/content-elements/timebased-trigger/template.twig new file mode 100644 index 0000000..8d0258f --- /dev/null +++ b/templates/shared/content-elements/timebased-trigger/template.twig @@ -0,0 +1,4 @@ +
+
3000
+ +
diff --git a/templates/shared/content-elements/timebased-trigger/timebasedTrigger.js b/templates/shared/content-elements/timebased-trigger/timebasedTrigger.js new file mode 100644 index 0000000..4026fbc --- /dev/null +++ b/templates/shared/content-elements/timebased-trigger/timebasedTrigger.js @@ -0,0 +1,13 @@ +import Alpine from "@alpinejs/csp"; + +Alpine.data("timebasedTrigger", () => ({ + init() { + var delay = Number(this.$root.querySelector(".delay").innerText); + var linkElement = this.$root.querySelector("a"); + if (delay && linkElement) { + setTimeout(() => { + linkElement.click(); + }, delay); + } + }, +})); diff --git a/templates/shared/modules/index.js b/templates/shared/modules/index.js new file mode 100644 index 0000000..906de40 --- /dev/null +++ b/templates/shared/modules/index.js @@ -0,0 +1 @@ +import '../content-elements/timebased-trigger/timebasedTrigger'; diff --git a/templates/website/design.js b/templates/website/design.js index ec73235..7cbd2fe 100644 --- a/templates/website/design.js +++ b/templates/website/design.js @@ -39,7 +39,7 @@ module.exports = cx.design /*.withLabel('Content')*/ .withLabel('Inhalt') .withContentElements( - require('@bsi-cx/design-standard-library-web/content-elements/base/text').editor(require('../shared/configs/editor/formatted-text-editor')), + require('@bsi-cx/design-standard-library-web/content-elements/base/text'), require('@bsi-cx/design-standard-library-web/content-elements/base/figure'), require('@bsi-cx/design-standard-library-web/content-elements/base/banner'), require('@bsi-cx/design-standard-library-web/content-elements/base/button'), @@ -53,7 +53,9 @@ module.exports = cx.design require('@bsi-cx/design-standard-library-web/content-elements/advanced/webcam-image-upload'), require('@bsi-cx/design-standard-library-web/content-elements/base/slot-finder'), require('@bsi-cx/design-standard-library-web/content-elements/base/chart'), - require('@bsi-cx/design-standard-library-web/content-elements/base/html')), + require('@bsi-cx/design-standard-library-web/content-elements/base/html'), + require('../shared/content-elements/timebased-trigger'), + ), cx.contentElementGroup .withGroupId('forms-NjbmnQ') /*.withLabel('Forms')*/ diff --git a/webpack.config.js b/webpack.config.js index fe27693..c3a1780 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -4,7 +4,7 @@ const package = require('./package.json'); const {BuildConfig, WebpackConfigBuilder, Version, DesignType, ModuleConfig} = require('@bsi-cx/design-build'); const landingpageBuildConfig = new BuildConfig() - .withName('master-template-cx-22.0-landingpage') + .withName('bsi-elements-cx-22.0-landingpage') .withVersion(package.version) .withDesignType(DesignType.LANDINGPAGE) .withTargetVersion(Version.CX_22_0) @@ -23,7 +23,7 @@ const landingpageBuildConfig = new BuildConfig() const websiteBuildConfig = new BuildConfig() - .withName('master-template-cx-22.0-website') + .withName('bsi-elements-cx-22.0-website') .withVersion(package.version) .withDesignType(DesignType.WEBSITE) .withTargetVersion(Version.CX_22_0) @@ -41,28 +41,28 @@ const websiteBuildConfig = new BuildConfig() }); module.exports = WebpackConfigBuilder.fromConfigs( + // websiteBuildConfig.clone() + // .withName('bsi-elements-cx-1.3-website') + // .withTargetVersion(Version.CX_1_3) + // .withPropertiesFilePath(path.resolve(__dirname, 'properties-de.js')), + // websiteBuildConfig.clone() + // .withName('bsi-elements-cx-22.0-website') + // .withPropertiesFilePath(path.resolve(__dirname, 'properties-de.js')), websiteBuildConfig.clone() - .withName('master-template-cx-1.3-website') - .withTargetVersion(Version.CX_1_3) - .withPropertiesFilePath(path.resolve(__dirname, 'properties-de.js')), - websiteBuildConfig.clone() - .withName('master-template-cx-22.0-website') - .withPropertiesFilePath(path.resolve(__dirname, 'properties-de.js')), - websiteBuildConfig.clone() - .withName('master-template-cx-23.2-website') + .withName('bsi-elements-cx-23.2-website') .withTargetVersion(Version.CX_23_2) .withPropertiesFilePath(path.resolve(__dirname, 'properties-de.js')), + // landingpageBuildConfig.clone() + // .withName('bsi-elements-cx-1.3-landingpage-de') + // .withTargetVersion(Version.CX_1_3) + // .withPropertiesFilePath(path.resolve(__dirname, 'properties-de.js')), + // landingpageBuildConfig.clone() + // .withName('bsi-elements-cx-22.0-landingpage-de') + // .withPropertiesFilePath(path.resolve(__dirname, 'properties-de.js')), landingpageBuildConfig.clone() - .withName('master-template-cx-1.3-landingpage-de') - .withTargetVersion(Version.CX_1_3) - .withPropertiesFilePath(path.resolve(__dirname, 'properties-de.js')), - landingpageBuildConfig.clone() - .withName('master-template-cx-22.0-landingpage-de') - .withPropertiesFilePath(path.resolve(__dirname, 'properties-de.js')), - landingpageBuildConfig.clone() - .withName('master-template-cx-23.2-landingpage-de') + .withName('bsi-elements-cx-23.2-landingpage-de') .withTargetVersion(Version.CX_23_2) .withPropertiesFilePath(path.resolve(__dirname, 'properties-de.js')) /*landingpageBuildConfig.clone() - .withName('master-template-cx-22.0-landingpage-en') + .withName('bsi-elements-cx-22.0-landingpage-en') .withPropertiesFilePath(path.resolve(__dirname, 'properties-en.js'))*/); \ No newline at end of file