From d15c63198ca665d82a502f129d04c8ec4208b944 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 27 Oct 2023 11:50:51 -0600 Subject: [PATCH] Docs: Get the ETemplate2 webComponent widets working on doc site Sort of. This breaks shoelace images due to them not being imported / copied, and not using the CDN --- api/js/etemplate/Et2Widget/Et2Widget.ts | 2 +- api/js/etemplate/Styles/shoelace.ts | 21 ++++++++++++--------- api/js/jquery/jquery.noconflict.js | 1 + doc/etemplate2/_includes/default.njk | 3 ++- doc/etemplate2/eleventy.config.cjs | 18 ++++++++++++++++-- doc/scripts/build.mjs | 18 +++++++++--------- 6 files changed, 41 insertions(+), 22 deletions(-) diff --git a/api/js/etemplate/Et2Widget/Et2Widget.ts b/api/js/etemplate/Et2Widget/Et2Widget.ts index 9802f80f03..96eec296b3 100644 --- a/api/js/etemplate/Et2Widget/Et2Widget.ts +++ b/api/js/etemplate/Et2Widget/Et2Widget.ts @@ -1706,7 +1706,7 @@ function transformAttributes(widget, mgr : et2_arrayMgr, attributes) */ export function cssImage(image_name : string, app_name? : string) { - let url = egw?.image(image_name, app_name); + let url = egw?.image && egw?.image(image_name, app_name); if(url) { return css`url(${unsafeCSS(url)})`; diff --git a/api/js/etemplate/Styles/shoelace.ts b/api/js/etemplate/Styles/shoelace.ts index ccc8c4ce37..272279c25c 100644 --- a/api/js/etemplate/Styles/shoelace.ts +++ b/api/js/etemplate/Styles/shoelace.ts @@ -15,7 +15,7 @@ import {egw} from "../../jsapi/egw_global"; registerIconLibrary('default', { resolver: name => { - return typeof egw !== "undefined" ? `${egw.webserverUrl}/node_modules/@shoelace-style/shoelace/dist/assets/icons/${name}.svg` : '' + return typeof egw !== "undefined" ? `${egw.webserverUrl || ""}/node_modules/@shoelace-style/shoelace/dist/assets/icons/${name}.svg` : '' }, }); @@ -24,12 +24,15 @@ registerIconLibrary('default', { * @example * @example */ -registerIconLibrary('egw', { - resolver: name => - { - return typeof egw !== "undefined" ? (egw.image(name) || '') : '' - }, -}); +if(typeof egw !== "undefined" && typeof egw.image == "function") +{ + registerIconLibrary('egw', { + resolver: name => + { + return (egw.image(name) || ''); + }, + }); +} /** * Customise shoelace styles to match our stuff @@ -39,10 +42,10 @@ export default [sl_css, css` :root, :host, .sl-theme-light { - --sl-font-size-medium: ${typeof egw != "undefined" && egw.preference('textsize', 'common') != '12' ? parseInt(egw.preference('textsize', 'common')) : 12}px; + --sl-font-size-medium: ${typeof egw != "undefined" && egw.preference && egw.preference('textsize', 'common') != '12' ? parseInt(egw.preference('textsize', 'common')) : 12}px; --sl-input-height-small: 24px; --sl-input-height-medium: 32px; - --sl-button-font-size-medium: ${typeof egw != "undefined" && egw.preference('textsize', 'common') != '12' ? parseInt(egw.preference('textsize', 'common')) : 12}px; + --sl-button-font-size-medium: ${typeof egw != "undefined" && egw.preference && egw.preference('textsize', 'common') != '12' ? parseInt(egw.preference('textsize', 'common')) : 12}px; --sl-input-help-text-font-size-medium: var(--sl-font-size-medium); --sl-spacing-small: 0.1rem; --sl-spacing-medium: 0.5rem; diff --git a/api/js/jquery/jquery.noconflict.js b/api/js/jquery/jquery.noconflict.js index e13c091795..a63129e50e 100644 --- a/api/js/jquery/jquery.noconflict.js +++ b/api/js/jquery/jquery.noconflict.js @@ -7,5 +7,6 @@ * @subpackage ajax * @author Ralf Becker */ +import "../../../vendor/bower-asset/jquery/dist/jquery.min.js"; jQuery.noConflict(); \ No newline at end of file diff --git a/doc/etemplate2/_includes/default.njk b/doc/etemplate2/_includes/default.njk index dba2943b75..1201ca1fe4 100644 --- a/doc/etemplate2/_includes/default.njk +++ b/doc/etemplate2/_includes/default.njk @@ -35,10 +35,11 @@ {# Shoelace #} + {# EGroupware #} - + {# Set the initial theme and menu states here to prevent flashing #}